Skip to contentSkip to conversation

ADT746X: logical-bitwise & confusion

PATCH Mark M. Hoffman 2 participants 2 messages May 26, 2008 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

Hi again:

Quoted 35 lines · Mark M. Hoffman

Hi:

Quoted 32 lines · Andrew Morton

From: Roel Kluin <[email protected]>

logical-bitwise & confusion

Cc Mark M. Hoffman <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Segher Boessenkool <[email protected]>
Cc "Darrick J. Wong" <[email protected]>

---

 drivers/hwmon/adt7473.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff -puN drivers/hwmon/adt7473.c~adt746x-logical-bitwise-confusion-in-set_max_duty_at_crit drivers/hwmon/adt7473.c

drivers/hwmon/adt7473.c renamed from drivers/hwmon/adt7473.c~adt746x-logical-bitwise-confusion-in-set_max_duty_at_crit +3 -3
@@ -573,11 +573,11 @@ static ssize_t set_max_duty_at_crit(stru
 				    const char *buf,
 				    size_t count)
 {
-	u8 reg;
+	u8 reg, temp;
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7473_data *data = i2c_get_clientdata(client);
-	int temp = simple_strtol(buf, NULL, 10);
-	temp = temp && 0xFF;
+
+	temp = simple_strtol(buf, NULL, 10);
 
Quoted 5 lines
Quoted 3 lines
drivers/hwmon/adt7473.c renamed from drivers/hwmon/adt7473.c~adt746x-logical-bitwise-confusion-in-set_max_duty_at_crit +0 -0
 	mutex_lock(&data->lock);
 	data->max_duty_at_overheat = temp;

_

Applied to hwmon-2.6.git/testing, thanks.

Oops. Thank you Jean for pointing out that the above is no good. How about this one instead...

commit ad49ac743a01705a77318a06831bb82b7f44c5ec

Author: Mark M. Hoffman <[email protected]>
Date:   Mon May 26 15:09:36 2008 -0400

hwmon: (adt7473) clarify an awkward bit of code

drivers/hwmon/adt7473.c +1 -2
index 93dbf5e..24c2239 100644
@@ -572,10 +572,9 @@ static ssize_t set_max_duty_at_crit(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7473_data *data = i2c_get_clientdata(client);
 	int temp = simple_strtol(buf, NULL, 10);
-	temp = temp && 0xFF;
 
 	mutex_lock(&data->lock);
-	data->max_duty_at_overheat = temp;
+	data->max_duty_at_overheat = !!temp;
 	reg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG4);
 	if (temp)
 		reg |= ADT7473_CFG4_MAX_DUTY_AT_OVT;
Signature · 8 lines
Mark M. Hoffman
[email protected]


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by
#1 lore raw
Quoted 62 lines · Mark M. Hoffman

Hi again:

Quoted 35 lines · Mark M. Hoffman

Hi:

Quoted 32 lines · Andrew Morton

From: Roel Kluin <[email protected]>

logical-bitwise & confusion

Cc Mark M. Hoffman <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Segher Boessenkool <[email protected]>
Cc "Darrick J. Wong" <[email protected]>

---

 drivers/hwmon/adt7473.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff -puN drivers/hwmon/adt7473.c~adt746x-logical-bitwise-confusion-in-set_max_duty_at_crit drivers/hwmon/adt7473.c

drivers/hwmon/adt7473.c renamed from drivers/hwmon/adt7473.c~adt746x-logical-bitwise-confusion-in-set_max_duty_at_crit +3 -3
@@ -573,11 +573,11 @@ static ssize_t set_max_duty_at_crit(stru
 				    const char *buf,
 				    size_t count)
 {
-	u8 reg;
+	u8 reg, temp;
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7473_data *data = i2c_get_clientdata(client);
-	int temp = simple_strtol(buf, NULL, 10);
-	temp = temp && 0xFF;
+
+	temp = simple_strtol(buf, NULL, 10);
 
Quoted 5 lines
Quoted 3 lines
drivers/hwmon/adt7473.c renamed from drivers/hwmon/adt7473.c~adt746x-logical-bitwise-confusion-in-set_max_duty_at_crit +0 -0
 	mutex_lock(&data->lock);
 	data->max_duty_at_overheat = temp;

_

Applied to hwmon-2.6.git/testing, thanks.

Oops. Thank you Jean for pointing out that the above is no good. How about this one instead...

commit ad49ac743a01705a77318a06831bb82b7f44c5ec

Author: Mark M. Hoffman <[email protected]>
Date:   Mon May 26 15:09:36 2008 -0400

hwmon: (adt7473) clarify an awkward bit of code

drivers/hwmon/adt7473.c +0 -0
index 93dbf5e..24c2239 100644
@@ -572,10 +572,9 @@ static ssize_t set_max_duty_at_crit(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);

drivers/hwmon/adt7473.c static ssize_t set_max_duty_at_crit(struct device *dev, · line 580

Quoted 10 lines
drivers/hwmon/adt7473.c +1 -2
 	struct adt7473_data *data = i2c_get_clientdata(client);
 	int temp = simple_strtol(buf, NULL, 10);
-	temp = temp && 0xFF;
 
 	mutex_lock(&data->lock);
-	data->max_duty_at_overheat = temp;
+	data->max_duty_at_overheat = !!temp;
 	reg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG4);
 	if (temp)
 		reg |= ADT7473_CFG4_MAX_DUTY_AT_OVT;

Yep, much better.

Signature · 6 lines
Jean Delvare

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