Skip to contentSkip to conversation

hwmon: (f75375s) Fix bit shifting in f75375_write16

PATCH Applied Nikolaus Schulz 2 participants 2 messages Feb 8, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/4 hwmon: (f75375s) Fix bit shifting in f75375_write16

From: Nikolaus Schulz <[email protected]>

In order to extract the high byte of the 16-bit word, shift the word to the right, not to the left.

---
 drivers/hwmon/f75375s.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hwmon/f75375s.c +1 -1
index b3eef44..0aabaaf 100644
@@ -172,7 +172,7 @@ static inline void f75375_write8(struct i2c_client *client, u8 reg,
 static inline void f75375_write16(struct i2c_client *client, u8 reg,
 		u16 value)
 {
-	int err = i2c_smbus_write_byte_data(client, reg, (value << 8));
+	int err = i2c_smbus_write_byte_data(client, reg, (value >> 8));
 	if (err)
 		return;
 	i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF));
Signature · 7 lines
1.7.9


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 16 lines · Nikolaus Schulz

From: Nikolaus Schulz <[email protected]>

In order to extract the high byte of the 16-bit word, shift the word to the right, not to the left.

---
 drivers/hwmon/f75375s.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hwmon/f75375s.c +0 -0
index b3eef44..0aabaaf 100644

drivers/hwmon/f75375s.c static inline void f75375_write8(struct i2c_client *client, u8 reg, · line 178

Quoted 8 lines
drivers/hwmon/f75375s.c +1 -1
@@ -172,7 +172,7 @@ static inline void f75375_write8(struct i2c_client *client, u8 reg,
 static inline void f75375_write16(struct i2c_client *client, u8 reg,
 		u16 value)
 {
-	int err = i2c_smbus_write_byte_data(client, reg, (value << 8));
+	int err = i2c_smbus_write_byte_data(client, reg, (value >> 8));
 	if (err)
 		return;
 	i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF));

Again, nice catch. A bit puzzling, though, that this wasn't caught earlier.

Thanks, applied.

Guenter

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