Skip to contentSkip to conversation

Bugfix for ds620.c (sign error)

PATCH Applied Roland Stigge 2 participants 4 messages Sep 21, 2011 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bugfix for ds620.c (sign error)

Bugfix for ds620.c: Signed temperatures were not handled appropriately

drivers/hwmon/ds620.c +3 -2
index 257957c..92e39fa 100644
@@ -72,7 +72,7 @@ struct ds620_data {
 	char valid;		/* !=0 if following fields are valid */
 	unsigned long last_updated;	/* In jiffies */
 
-	u16 temp[3];		/* Register values, word */
+	s16 temp[3];		/* Register values, word */
 };
 
 /*
@@ -169,7 +169,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
-	return sprintf(buf, "%d\n", ((data->temp[attr->index] / 8) * 625) / 10);
+	return sprintf(buf, "%d\n",
+			(((int)data->temp[attr->index] / 8) * 625) / 10);
 }
 
 static ssize_t set_temp(struct device *dev, struct device_attribute *da,

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

#1 lore raw

Hi Roland,

Quoted 19 lines · Roland Stigge

Bugfix for ds620.c: Signed temperatures were not handled appropriately

drivers/hwmon/ds620.c +1 -1
index 257957c..92e39fa 100644
@@ -72,7 +72,7 @@ struct ds620_data {
 	char valid;		/* !=0 if following fields are valid */
 	unsigned long last_updated;	/* In jiffies */
 
-	u16 temp[3];		/* Register values, word */
+	s16 temp[3];		/* Register values, word */
 };
 
 /*

drivers/hwmon/ds620.c static ssize_t show_temp(struct device *dev, struct device_attribute *da, · line 173

Quoted 6 lines
drivers/hwmon/ds620.c +2 -1
@@ -169,7 +169,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
-	return sprintf(buf, "%d\n", ((data->temp[attr->index] / 8) * 625) / 10);
+	return sprintf(buf, "%d\n",
+			(((int)data->temp[attr->index] / 8) * 625) / 10);

since data->temp is now already signed, you do not need the typecast to int here (conversion from s16 to int is automatic).

Thanks,
Guenter

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

#2 lore raw

PATCH 1/1 Bugfix for ds620.c (sign error)

In reply to Roland Stigge

Bugfix for ds620.c: Signed temperatures were not handled appropriately

drivers/hwmon/ds620.c +1 -1
index 257957c..4f7c3fc 100644
@@ -72,7 +72,7 @@ struct ds620_data {
 	char valid;		/* !=0 if following fields are valid */
 	unsigned long last_updated;	/* In jiffies */
 
-	u16 temp[3];		/* Register values, word */
+	s16 temp[3];		/* Register values, word */
 };
 
 /*

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

#3 lore raw
In reply to Roland Stigge
Quoted 10 lines · Roland Stigge

Bugfix for ds620.c: Signed temperatures were not handled appropriately

drivers/hwmon/ds620.c +0 -0
index 257957c..4f7c3fc 100644

drivers/hwmon/ds620.c struct ds620_data { · line 77

Quoted 7 lines
drivers/hwmon/ds620.c +1 -1
@@ -72,7 +72,7 @@ struct ds620_data {
 	char valid;		/* !=0 if following fields are valid */
 	unsigned long last_updated;	/* In jiffies */
 
-	u16 temp[3];		/* Register values, word */
+	s16 temp[3];		/* Register values, word */
 };
 

Applied.

Thanks,
Guenter

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