Skip to contentSkip to conversation

hwmon: Replace update_rate sysfs attribute with update_interval

PATCH Applied Guenter Roeck 4 participants 14 messages Sep 16, 2010

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover hwmon: Replace update_rate sysfs attribute with update_interval

Two sysfs attributes are currently used to reflect sensor reading update
intervals: update_rate and rate. In all uses, the attribute reflects an interval, not a rate.

To reflect this, replace the sysfs ABI attribute update_rate with update_interval, and modify affected drivers to use update_interval.

#1 lore raw

PATCH 1/2 hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

The attribute reflects an interval, not a rate.

---
 Documentation/hwmon/sysfs-interface |   12 +++++-----
 drivers/hwmon/adm1031.c             |   43 +++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)
Documentation/hwmon/sysfs-interface +6 -6
index ff45d1f..df0cdd2 100644
@@ -91,13 +91,13 @@ name		The chip name.
 		I2C devices get this attribute created automatically.
 		RO
 
-update_rate	The rate at which the chip will update readings.
-		Unit: millisecond
+update_interval	The interval at which the chip or driver will update readings.
+		Unit: milliseconds
 		RW
-		Some devices have a variable update rate. This attribute
-		can be used to change the update rate to the desired
-		frequency.
-
+		Some devices have a variable update rate or interval.
+		Some drivers may want to make the update interval configurable
+		instead of using a hardcoded value. This attribute can be used
+		to change the update interval to the desired value.
 
 ************
 * Voltages *
drivers/hwmon/adm1031.c +24 -19

101 lines not on this page · raw message

Signature · 1 line
1.7.0.87.g0901d
#2 lore raw

Re: [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

Quoted 13 lines · Guenter Roeck

The attribute reflects an interval, not a rate.

---
 Documentation/hwmon/sysfs-interface |   12 +++++-----
 drivers/hwmon/adm1031.c             |   43 +++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)
Documentation/hwmon/sysfs-interface +0 -0
index ff45d1f..df0cdd2 100644

Documentation/hwmon/sysfs-interface name The chip name. · line 94

Quoted 6 lines
Documentation/hwmon/sysfs-interface +1 -2
@@ -91,13 +91,13 @@ name		The chip name.
 		I2C devices get this attribute created automatically.
 		RO
 
-update_rate	The rate at which the chip will update readings.
-		Unit: millisecond
+update_interval	The interval at which the chip or driver will update readings.

I think I prefer the original wording. The attribute is really about setting the register refresh rate at the hardware level. The fact that register cache lifetime in the driver can be adjusted accordingly is an optional implementation detail IMHO.

Documentation/hwmon/sysfs-interface name The chip name. · line 95

Quoted 1 line
Documentation/hwmon/sysfs-interface +1 -0
+		Unit: milliseconds

Why change? All other units are singular in the file.

Documentation/hwmon/sysfs-interface name The chip name. · line 100

Quoted 5 lines
Documentation/hwmon/sysfs-interface +0 -4
 		RW
-		Some devices have a variable update rate. This attribute
-		can be used to change the update rate to the desired
-		frequency.
-

Killing an innocent blank line ;)

Documentation/hwmon/sysfs-interface name The chip name. · line 103

Quoted 7 lines
Documentation/hwmon/sysfs-interface +4 -0
+		Some devices have a variable update rate or interval.
+		Some drivers may want to make the update interval configurable
+		instead of using a hardcoded value. This attribute can be used
+		to change the update interval to the desired value.
 
 ************
 * Voltages *

I'm fine with all the rest.

Signature · 6 lines
Jean Delvare

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

Re: [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

Quoted 17 lines · Jean Delvare
Quoted 16 lines · Guenter Roeck

The attribute reflects an interval, not a rate.

---
 Documentation/hwmon/sysfs-interface |   12 +++++-----
 drivers/hwmon/adm1031.c             |   43 +++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)
Documentation/hwmon/sysfs-interface +0 -0
index ff45d1f..df0cdd2 100644
@@ -91,13 +91,13 @@ name		The chip name.
 		I2C devices get this attribute created automatically.
 		RO
 
Quoted 9 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 94

Quoted 3 lines
Documentation/hwmon/sysfs-interface +1 -2
-update_rate	The rate at which the chip will update readings.
-		Unit: millisecond
+update_interval	The interval at which the chip or driver will update readings.

I think I prefer the original wording. The attribute is really about setting the register refresh rate at the hardware level. The fact that register cache lifetime in the driver can be adjusted accordingly is an optional implementation detail IMHO.

Ok, no problem.

Quoted 4 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 95

Quoted 1 line
Documentation/hwmon/sysfs-interface +1 -0
+		Unit: milliseconds

Why change? All other units are singular in the file.

Correct for anything but "milliseconds".

I changed it to milliseconds because all other attributes specify "milliseconds". No other reason. Am I missing something ?

Quoted 8 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 100

Quoted 5 lines
Documentation/hwmon/sysfs-interface +0 -4
 		RW
-		Some devices have a variable update rate. This attribute
-		can be used to change the update rate to the desired
-		frequency.
-

Killing an innocent blank line ;)

Just trying to sneak it through. Got me there.

Quoted 5 lines
Quoted 5 lines
Documentation/hwmon/sysfs-interface +4 -0
+		Some devices have a variable update rate or interval.
+		Some drivers may want to make the update interval configurable
+		instead of using a hardcoded value. This attribute can be used
+		to change the update interval to the desired value.
 
Quoted 8 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 103

Quoted 3 lines
Documentation/hwmon/sysfs-interface +1 -0
+           instead of using a hardcoded value." 
 ************
 * Voltages *

I'm fine with all the rest.

Signature · 1 line
Jean Delvare

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

#4 lore raw

Re: [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

Quoted 29 lines · Guenter Roeck
Quoted 17 lines · Jean Delvare
Quoted 16 lines · Guenter Roeck

The attribute reflects an interval, not a rate.

---
 Documentation/hwmon/sysfs-interface |   12 +++++-----
 drivers/hwmon/adm1031.c             |   43 +++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)
Documentation/hwmon/sysfs-interface +0 -0
index ff45d1f..df0cdd2 100644
@@ -91,13 +91,13 @@ name		The chip name.
 		I2C devices get this attribute created automatically.
 		RO
 
Quoted 9 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 94

Quoted 3 lines
Documentation/hwmon/sysfs-interface +1 -2
-update_rate	The rate at which the chip will update readings.
-		Unit: millisecond
+update_interval	The interval at which the chip or driver will update readings.

I think I prefer the original wording. The attribute is really about setting the register refresh rate at the hardware level. The fact that register cache lifetime in the driver can be adjusted accordingly is an optional implementation detail IMHO.

Ok, no problem.

Quoted 8 lines
Quoted 4 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 95

Quoted 1 line
Documentation/hwmon/sysfs-interface +1 -0
+		Unit: milliseconds

Why change? All other units are singular in the file.

Correct for anything but "milliseconds".

I changed it to milliseconds because all other attributes specify "milliseconds". No other reason. Am I missing something ?

I'd rather change all these to "millisecond", so that the document consistently uses singular for all units.

I also see that the indentation isn't consistent, with power and energy having 4 tabs where the rest has only 2. Bah.

Signature · 6 lines
Jean Delvare

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

Re: [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

Quoted 36 lines · Jean Delvare
Quoted 35 lines · Guenter Roeck
Quoted 17 lines · Jean Delvare
Quoted 16 lines · Guenter Roeck

The attribute reflects an interval, not a rate.

---
 Documentation/hwmon/sysfs-interface |   12 +++++-----
 drivers/hwmon/adm1031.c             |   43 +++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)
Documentation/hwmon/sysfs-interface +0 -0
index ff45d1f..df0cdd2 100644
@@ -91,13 +91,13 @@ name		The chip name.
 		I2C devices get this attribute created automatically.
 		RO
 
Quoted 9 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 94

Quoted 3 lines
Documentation/hwmon/sysfs-interface +1 -2
-update_rate	The rate at which the chip will update readings.
-		Unit: millisecond
+update_interval	The interval at which the chip or driver will update readings.

I think I prefer the original wording. The attribute is really about setting the register refresh rate at the hardware level. The fact that register cache lifetime in the driver can be adjusted accordingly is an optional implementation detail IMHO.

Ok, no problem.

Quoted 4 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 95

Quoted 1 line
Documentation/hwmon/sysfs-interface +1 -0
+		Unit: milliseconds

Why change? All other units are singular in the file.

Correct for anything but "milliseconds".

Quoted 9 lines
Quoted 2 lines

I changed it to milliseconds because all other attributes specify "milliseconds". No other reason. Am I missing something ?

I'd rather change all these to "millisecond", so that the document consistently uses singular for all units.

I also see that the indentation isn't consistent, with power and energy having 4 tabs where the rest has only 2. Bah.

To get beyond this ... how about you apply my rev2, and I make the other changes (formatting and milliseconds --> millisecond) in a subsequent patch ?

Guenter

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

#6 lore raw

Re: [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

Quoted 10 lines · Guenter Roeck
Quoted 6 lines · Jean Delvare

I'd rather change all these to "millisecond", so that the document consistently uses singular for all units.

I also see that the indentation isn't consistent, with power and energy having 4 tabs where the rest has only 2. Bah.

To get beyond this ... how about you apply my rev2, and I make the other changes (formatting and milliseconds --> millisecond) in a subsequent patch ?

I'll do the milliseconds --> millisecond myself, no need to resend. Further changes would indeed belong to one or two separate patches, if you have time for that. This is definitely low priority though.

Signature · 6 lines
Jean Delvare

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

Re: [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

Quoted 8 lines · Jean Delvare
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Jean Delvare

I'd rather change all these to "millisecond", so that the document consistently uses singular for all units.

I also see that the indentation isn't consistent, with power and energy having 4 tabs where the rest has only 2. Bah.

Quoted 8 lines
Quoted 3 lines

To get beyond this ... how about you apply my rev2, and I make the other changes (formatting and milliseconds --> millisecond) in a subsequent patch ?

I'll do the milliseconds --> millisecond myself, no need to resend. Further changes would indeed belong to one or two separate patches, if you have time for that. This is definitely low priority though.

Ok, thanks

Guenter

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

#8 lore raw

Re: [lm-sensors] [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

In reply to Jean Delvare
Quoted 17 lines · Jean Delvare
Quoted 16 lines · Guenter Roeck

The attribute reflects an interval, not a rate.

---
 Documentation/hwmon/sysfs-interface |   12 +++++-----
 drivers/hwmon/adm1031.c             |   43 +++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)
Documentation/hwmon/sysfs-interface +0 -0
index ff45d1f..df0cdd2 100644
@@ -91,13 +91,13 @@ name		The chip name.
 		I2C devices get this attribute created automatically.
 		RO
 
Quoted 6 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 94

Quoted 3 lines
Documentation/hwmon/sysfs-interface +1 -2
-update_rate	The rate at which the chip will update readings.
-		Unit: millisecond
+update_interval	The interval at which the chip or driver will update readings.

I think I prefer the original wording. The attribute is really about setting the register refresh rate at the hardware level. The fact that

Only, it doesn't set any rates in the hardware. It sets the period (interval).

If the unit of update_rate is changed to Hz, and the driver does hardware_timer_milliseconds = 1000/update_rate_Hz, THEN it will be correct to call it a rate...

I'd rather have it in Hz, actually. I consider that more user-friendly. But that's just personal preference.

Signature · 9 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

Re: [lm-sensors] [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

Quoted 25 lines · Henrique de Moraes Holschuh
Quoted 17 lines · Jean Delvare
Quoted 16 lines · Guenter Roeck

The attribute reflects an interval, not a rate.

---
 Documentation/hwmon/sysfs-interface |   12 +++++-----
 drivers/hwmon/adm1031.c             |   43 +++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)
Documentation/hwmon/sysfs-interface +0 -0
index ff45d1f..df0cdd2 100644
@@ -91,13 +91,13 @@ name		The chip name.
 		I2C devices get this attribute created automatically.
 		RO
 
Quoted 6 lines

Documentation/hwmon/sysfs-interface name The chip name. · line 94

Quoted 3 lines
Documentation/hwmon/sysfs-interface +1 -2
-update_rate	The rate at which the chip will update readings.
-		Unit: millisecond
+update_interval	The interval at which the chip or driver will update readings.

I think I prefer the original wording. The attribute is really about setting the register refresh rate at the hardware level. The fact that

Quoted 6 lines

Only, it doesn't set any rates in the hardware. It sets the period (interval).

If the unit of update_rate is changed to Hz, and the driver does hardware_timer_milliseconds = 1000/update_rate_Hz, THEN it will be correct to call it a rate...

I agree. My point was really only about "chip or driver" vs. "chip".

Quoted 2 lines

I'd rather have it in Hz, actually. I consider that more user-friendly. But that's just personal preference.

The problem with Hz is that we need to be able to handle values lower than 1, and mHz as a unit isn't exactly friendly. I would be very fine with Hz (especially as we use it for pwmN_freq already) if we didn't have to support frequencies below 1 Hz. For such low frequencies, period (or interval) is clearer than frequency IMHO.

Signature · 6 lines
Jean Delvare

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

Re: [lm-sensors] [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

Quoted 8 lines · Jean Delvare
Quoted 2 lines

I'd rather have it in Hz, actually. I consider that more user-friendly. But that's just personal preference.

The problem with Hz is that we need to be able to handle values lower than 1, and mHz as a unit isn't exactly friendly. I would be very fine with Hz (especially as we use it for pwmN_freq already) if we didn't have to support frequencies below 1 Hz. For such low frequencies, period (or interval) is clearer than frequency IMHO.

We can always use fixed point math... ;-)

I am kidding, I am perfectly aware it is not worth the trouble.

And I agree with you, mHz would be horrible as far as usability goes. And prone to be confused with MHz, too.

Signature · 9 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v1 1/2
#11 lore raw

Re: [lm-sensors] [PATCH 1/2] hwmon: (adm1031) Replace update_rate sysfs attribute with update_interval

In reply to Guenter Roeck
Quoted 8 lines · Guenter Roeck

The attribute reflects an interval, not a rate.

---
 Documentation/hwmon/sysfs-interface |   12 +++++-----
 drivers/hwmon/adm1031.c             |   43 +++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)

I'm the original author of both the update_rate text in sysfs-interface and the adm1031 support. Your change looks good to me. Thanks for doing the work.

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

#12 lore raw

PATCH 2/2 hwmon: (lm95241) Replace rate sysfs attribute with update_interval

In reply to Guenter Roeck

update_interval is the matching attribute defined in the hwmon sysfs ABI. Use it.

---
 drivers/hwmon/lm95241.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
drivers/hwmon/lm95241.c +11 -10
index 94741d4..464340f 100644
@@ -91,7 +91,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev);
 struct lm95241_data {
 	struct device *hwmon_dev;
 	struct mutex update_lock;
-	unsigned long last_updated, rate; /* in jiffies */
+	unsigned long last_updated, interval; /* in jiffies */
 	char valid; /* zero until following fields are valid */
 	/* registers values */
 	u8 local_h, local_l; /* local */
@@ -114,23 +114,23 @@ show_temp(local);
 show_temp(remote1);
 show_temp(remote2);
 
-static ssize_t show_rate(struct device *dev, struct device_attribute *attr,
+static ssize_t show_interval(struct device *dev, struct device_attribute *attr,
 			 char *buf)
 {
 	struct lm95241_data *data = lm95241_update_device(dev);
 
-	snprintf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->rate / HZ);
+	snprintf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->interval / HZ);
 	return strlen(buf);
 }
 
-static ssize_t set_rate(struct device *dev, struct device_attribute *attr,
+static ssize_t set_interval(struct device *dev, struct device_attribute *attr,
 			const char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm95241_data *data = i2c_get_clientdata(client);
 
-	strict_strtol(buf, 10, &data->rate);
-	data->rate = data->rate * HZ / 1000;
+	strict_strtol(buf, 10, &data->interval);
+	data->interval = data->interval * HZ / 1000;
 
 	return count;
 }
@@ -286,7 +286,8 @@ static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min1, set_min1);
 static DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min2, set_min2);
 static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max1, set_max1);
 static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max2, set_max2);
-static DEVICE_ATTR(rate, S_IWUSR | S_IRUGO, show_rate, set_rate);
+static DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO, show_interval,
+		   set_interval);
 
 static struct attribute *lm95241_attributes[] = {
 	&dev_attr_temp1_input.attr,
@@ -298,7 +299,7 @@ static struct attribute *lm95241_attributes[] = {
 	&dev_attr_temp3_min.attr,
 	&dev_attr_temp2_max.attr,
 	&dev_attr_temp3_max.attr,
-	&dev_attr_rate.attr,
+	&dev_attr_update_interval.attr,
 	NULL
 };
 
@@ -376,7 +377,7 @@ static void lm95241_init_client(struct i2c_client *client)
 {
 	struct lm95241_data *data = i2c_get_clientdata(client);
 
-	data->rate = HZ;    /* 1 sec default */
+	data->interval = HZ;    /* 1 sec default */
 	data->valid = 0;
 	data->config = CFG_CR0076;
 	data->model = 0;
@@ -410,7 +411,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev)
 
 	mutex_lock(&data->update_lock);
 
-	if (time_after(jiffies, data->last_updated + data->rate) ||
+	if (time_after(jiffies, data->last_updated + data->interval) ||
 	    !data->valid) {
 		dev_dbg(&client->dev, "Updating lm95241 data.\n");
 		data->local_h =
Signature · 1 line
1.7.0.87.g0901d
Applied
#13 lore raw

Re: [PATCH 2/2] hwmon: (lm95241) Replace rate sysfs attribute with update_interval

Quoted 4 lines · Guenter Roeck

update_interval is the matching attribute defined in the hwmon sysfs ABI. Use it.

Applied, thanks.

Signature · 6 lines
Jean Delvare

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