hwmon: Fix the code examples in documentation
Fix a bug in the code examples, make them comply with CodingStyle, and indent them for a better redability. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Hans de Goede <j.w.r.degoede@hhs.nl> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
This commit is contained in:
parent
2ed4263308
commit
5fbea518da
|
@ -450,22 +450,20 @@ continuous like for example a tempX_type, then when an invalid value is
|
||||||
written, -EINVAL should be returned.
|
written, -EINVAL should be returned.
|
||||||
|
|
||||||
Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees):
|
Example1, temp1_max, register is a signed 8 bit value (-128 - 127 degrees):
|
||||||
--- begin code ---
|
|
||||||
long v = simple_strtol(buf, NULL, 10) / 1000;
|
long v = simple_strtol(buf, NULL, 10) / 1000;
|
||||||
SENSORS_LIMIT(v, -128, 127);
|
v = SENSORS_LIMIT(v, -128, 127);
|
||||||
/* write v to register */
|
/* write v to register */
|
||||||
--- end code ---
|
|
||||||
|
|
||||||
Example2, fan divider setting, valid values 2, 4 and 8:
|
Example2, fan divider setting, valid values 2, 4 and 8:
|
||||||
--- begin code ---
|
|
||||||
unsigned long v = simple_strtoul(buf, NULL, 10);
|
|
||||||
|
|
||||||
switch (v) {
|
unsigned long v = simple_strtoul(buf, NULL, 10);
|
||||||
case 2: v = 1; break;
|
|
||||||
case 4: v = 2; break;
|
switch (v) {
|
||||||
case 8: v = 3; break;
|
case 2: v = 1; break;
|
||||||
default:
|
case 4: v = 2; break;
|
||||||
return -EINVAL;
|
case 8: v = 3; break;
|
||||||
}
|
default:
|
||||||
/* write v to register */
|
return -EINVAL;
|
||||||
--- end code ---
|
}
|
||||||
|
/* write v to register */
|
||||||
|
|
Loading…
Reference in a new issue