Skip to contentSkip to conversation

hwmon: (ds1621) Save an I2C write at

PATCH New Jean Delvare 1 participant 1 message Jan 16, 2009 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 hwmon: (ds1621) Save an I2C write at

Don't write back the configuration register if not needed. This is important because on every write there's a delay before we can write to the chip again.

---
 drivers/hwmon/ds1621.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hwmon/ds1621.c +4 -3
@@ -147,10 +147,10 @@ static int ds1621_write_value(struct i2c
 static void ds1621_init_client(struct i2c_client *client)
 {
 	struct ds1621_data *data = i2c_get_clientdata(client);
-	int reg;
+	int old_reg, reg;
 
 	data->last_written = jiffies;
-	reg = ds1621_read_value(client, DS1621_REG_CONF);
+	old_reg = reg = ds1621_read_value(client, DS1621_REG_CONF);
 	/* switch to continuous conversion mode */
 	reg &= ~ DS1621_REG_CONFIG_1SHOT;
 
@@ -160,7 +160,8 @@ static void ds1621_init_client(struct i2
 	else if (polarity = 1)
 		reg |= DS1621_REG_CONFIG_POLARITY;
 	
-	ds1621_write_value(client, DS1621_REG_CONF, reg);
+	if (reg != old_reg)
+		ds1621_write_value(client, DS1621_REG_CONF, reg);
 	
 	/* start conversion */
 	i2c_smbus_write_byte(client, DS1621_COM_START);
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors