Jelajahi Sumber

hwmon: Only call vid_which_vrm() when needed

Some hardware monitoring drivers create the VID/VRM interface files
conditionally depending on the chip model or configuration. We should
only call vid_which_vrm() when we are actually going to create the
files. Not only it is more logical and efficient that way, but it also
prevents printing unnecessary warnings such as the one reported here:
http://lists.lm-sensors.org/pipermail/lm-sensors/2007-February/018954.html

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Jean Delvare 18 tahun lalu
induk
melakukan
8a665a0552
2 mengubah file dengan 6 tambahan dan 5 penghapusan
  1. 1 1
      drivers/hwmon/lm87.c
  2. 5 4
      drivers/hwmon/w83627hf.c

+ 1 - 1
drivers/hwmon/lm87.c

@@ -747,6 +747,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
 	}
 	}
 
 
 	if (!(data->channel & CHAN_NO_VID)) {
 	if (!(data->channel & CHAN_NO_VID)) {
+		data->vrm = vid_which_vrm();
 		if ((err = device_create_file(&new_client->dev,
 		if ((err = device_create_file(&new_client->dev,
 					&dev_attr_cpu0_vid))
 					&dev_attr_cpu0_vid))
 		 || (err = device_create_file(&new_client->dev,
 		 || (err = device_create_file(&new_client->dev,
@@ -779,7 +780,6 @@ static void lm87_init_client(struct i2c_client *client)
 	u8 config;
 	u8 config;
 
 
 	data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
 	data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
-	data->vrm = vid_which_vrm();
 
 
 	config = lm87_read_value(client, LM87_REG_CONFIG);
 	config = lm87_read_value(client, LM87_REG_CONFIG);
 	if (!(config & 0x01)) {
 	if (!(config & 0x01)) {

+ 5 - 4
drivers/hwmon/w83627hf.c

@@ -1181,12 +1181,16 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
 					&dev_attr_temp3_type)))
 					&dev_attr_temp3_type)))
 			goto ERROR4;
 			goto ERROR4;
 
 
-	if (kind != w83697hf && data->vid != 0xff)
+	if (kind != w83697hf && data->vid != 0xff) {
+		/* Convert VID to voltage based on VRM */
+		data->vrm = vid_which_vrm();
+
 		if ((err = device_create_file(&new_client->dev,
 		if ((err = device_create_file(&new_client->dev,
 					&dev_attr_cpu0_vid))
 					&dev_attr_cpu0_vid))
 		 || (err = device_create_file(&new_client->dev,
 		 || (err = device_create_file(&new_client->dev,
 					&dev_attr_vrm)))
 					&dev_attr_vrm)))
 			goto ERROR4;
 			goto ERROR4;
+	}
 
 
 	if (kind == w83627thf || kind == w83637hf || kind == w83687thf)
 	if (kind == w83627thf || kind == w83637hf || kind == w83687thf)
 		if ((err = device_create_file(&new_client->dev,
 		if ((err = device_create_file(&new_client->dev,
@@ -1420,9 +1424,6 @@ static void w83627hf_init_client(struct i2c_client *client)
 			w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);
 			w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);
 	}
 	}
 
 
-	/* Convert VID to voltage based on VRM */
-	data->vrm = vid_which_vrm();
-
 	tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
 	tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
 	for (i = 1; i <= 3; i++) {
 	for (i = 1; i <= 3; i++) {
 		if (!(tmp & BIT_SCFG1[i - 1])) {
 		if (!(tmp & BIT_SCFG1[i - 1])) {