Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350546
b: refs/heads/master
c: c25fb81
h: refs/heads/master
v: v3
  • Loading branch information
Guenter Roeck committed Jan 26, 2013
1 parent 12e3415 commit 5245dd5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c73bad746cad97e438ccd148705907f20697288a
refs/heads/master: c25fb816298138a4b12c606f0aaa018bdd3cc09c
8 changes: 4 additions & 4 deletions trunk/Documentation/hwmon/sysfs-interface
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,14 @@ add/subtract if it has been divided before the add/subtract.
What to do if a value is found to be invalid, depends on the type of the
sysfs attribute that is being set. If it is a continuous setting like a
tempX_max or inX_max attribute, then the value should be clamped to its
limits using SENSORS_LIMIT(value, min_limit, max_limit). If it is not
continuous like for example a tempX_type, then when an invalid value is
written, -EINVAL should be returned.
limits using clamp_val(value, min_limit, max_limit). If it is not continuous
like for example a tempX_type, then when an invalid value is written,
-EINVAL should be returned.

Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees):

long v = simple_strtol(buf, NULL, 10) / 1000;
v = SENSORS_LIMIT(v, -128, 127);
v = clamp_val(v, -128, 127);
/* write v to register */

Example2, fan divider setting, valid values 2, 4 and 8:
Expand Down
12 changes: 0 additions & 12 deletions trunk/include/linux/hwmon.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,4 @@ struct device *hwmon_device_register(struct device *dev);

void hwmon_device_unregister(struct device *dev);

/* Scale user input to sensible values */
static inline int SENSORS_LIMIT(long value, long low, long high)
{
if (value < low)
return low;
else if (value > high)
return high;
else
return value;
}

#endif

0 comments on commit 5245dd5

Please sign in to comment.