Skip to contentSkip to conversation

hwmon: (lm95245) Make temp2_crit_hyst read-only

PATCH In review Guenter Roeck 2 participants 3 messages Feb 22, 2014 – Feb 23, 2014 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH v2 4/4 hwmon: (lm95245) Make temp2_crit_hyst read-only

The hysteresis register is shared among both temperature sensors. This means changing one also affects the other. To avoid confusion, established way to express this is to make only the first instance writable and keep all other instances as read-only. Otherwise users may be confused that changing the second writable value also affects the first, while it is more obvious that a writable value may affect a different read-only value.

---
v2: Additional patch

 drivers/hwmon/lm95245.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwmon/lm95245.c +1 -2
index 310e145..1f6a18f 100644
@@ -396,8 +396,7 @@ static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL,
 static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, 2);
 static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_limit,
 		set_limit, 7);
-static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_crit_hyst,
-		set_crit_hyst, 7);
+static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_crit_hyst, NULL, 7);
 static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL,
 		STATUS1_RTCRIT);
 static SENSOR_DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type,
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Reviewed-by on v2 4/4
#1 lore raw

Hi Guenter,

Quoted 20 lines · Guenter Roeck

The hysteresis register is shared among both temperature sensors. This means changing one also affects the other. To avoid confusion, established way to express this is to make only the first instance writable and keep all other instances as read-only. Otherwise users may be confused that changing the second writable value also affects the first, while it is more obvious that a writable value may affect a different read-only value.

---
v2: Additional patch

 drivers/hwmon/lm95245.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwmon/lm95245.c +0 -0
index 310e145..1f6a18f 100644

drivers/hwmon/lm95245.c static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, · line 402

Quoted 9 lines
drivers/hwmon/lm95245.c +1 -2
@@ -396,8 +396,7 @@ static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL,
 static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, 2);
 static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_limit,
 		set_limit, 7);
-static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_crit_hyst,
-		set_crit_hyst, 7);
+static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_crit_hyst, NULL, 7);
 static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL,
 		STATUS1_RTCRIT);
 static SENSOR_DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type,

Maybe you can mention the limitation in the driver documentation file. The lm90 documentation says this:

Each sensor has its own high and low limits, plus a critical limit. Additionally, there is a relative hysteresis value common to both critical values. To make life easier to user-space applications, two absolute values are exported, one for each channel, but these values are of course linked. Only the local hysteresis can be set from user-space, and the same delta applies to the remote hysteresis.

Thanks,

Signature · 7 lines
Jean Delvare
Suse L3 Support

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author maintainer
#2 lore raw
In reply to Guenter Roeck
Quoted 38 lines · Jean Delvare

Hi Guenter,

Quoted 20 lines · Guenter Roeck

The hysteresis register is shared among both temperature sensors. This means changing one also affects the other. To avoid confusion, established way to express this is to make only the first instance writable and keep all other instances as read-only. Otherwise users may be confused that changing the second writable value also affects the first, while it is more obvious that a writable value may affect a different read-only value.

---
v2: Additional patch

  drivers/hwmon/lm95245.c |    3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwmon/lm95245.c +0 -0
index 310e145..1f6a18f 100644

drivers/hwmon/lm95245.c static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, · line 402

Quoted 9 lines
drivers/hwmon/lm95245.c +1 -2
@@ -396,8 +396,7 @@ static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL,
  static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, 2);
  static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_limit,
  		set_limit, 7);
-static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_crit_hyst,
-		set_crit_hyst, 7);
+static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_crit_hyst, NULL, 7);
  static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL,
  		STATUS1_RTCRIT);
  static SENSOR_DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type,

Maybe you can mention the limitation in the driver documentation file. The lm90 documentation says this:

Quoted 7 lines

Each sensor has its own high and low limits, plus a critical limit. Additionally, there is a relative hysteresis value common to both critical values. To make life easier to user-space applications, two absolute values are exported, one for each channel, but these values are of course linked. Only the local hysteresis can be set from user-space, and the same delta applies to the remote hysteresis.

Good idea. I'll add the relevant text.

Thanks a lot for the review!

Guenter

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