hwmon: (w83795) Only start monitoring if needed
authorJean Delvare <khali@linux-fr.org>
Thu, 28 Oct 2010 18:31:46 +0000 (20:31 +0200)
committerJean Delvare <khali@endymion.delvare>
Thu, 28 Oct 2010 18:31:46 +0000 (20:31 +0200)
This saves an SMBus write if monitoring was already enabled.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
drivers/hwmon/w83795.c

index b45416011c2a193a0b92c7f196bc895dd45a284c..62deffcc64a3d2bbf162fe27e85493042b269e0b 100644 (file)
@@ -55,6 +55,7 @@ MODULE_PARM_DESC(reset, "Set to 1 to reset chip, not recommended");
 #define W83795_REG_I2C_ADDR            0xfc
 #define W83795_REG_CONFIG              0x01
 #define W83795_REG_CONFIG_CONFIG48     0x04
+#define W83795_REG_CONFIG_START        0x01
 
 /* Multi-Function Pin Ctrl Registers */
 #define W83795_REG_VOLT_CTRL1          0x02
@@ -1664,12 +1665,18 @@ static const struct sensor_device_attribute_2 sda_single_files[] = {
 
 static void w83795_init_client(struct i2c_client *client)
 {
+       u8 config;
+
        if (reset)
                w83795_write(client, W83795_REG_CONFIG, 0x80);
 
-       /* Start monitoring */
-       w83795_write(client, W83795_REG_CONFIG,
-                    w83795_read(client, W83795_REG_CONFIG) | 0x01);
+       /* Start monitoring if needed */
+       config = w83795_read(client, W83795_REG_CONFIG);
+       if (!(config & W83795_REG_CONFIG_START)) {
+               dev_info(&client->dev, "Enabling monitoring operations\n");
+               w83795_write(client, W83795_REG_CONFIG,
+                            config | W83795_REG_CONFIG_START);
+       }
 }
 
 static int w83795_get_device_id(struct i2c_client *client)