hwmon: Documentation: Add usage example for HWMON_CHANNEL_INFO
authorGuenter Roeck <linux@roeck-us.net>
Sun, 31 Mar 2019 17:22:24 +0000 (10:22 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 16 Apr 2019 00:19:53 +0000 (17:19 -0700)
The new HWMON_CHANNEL_INFO macro simplifies the code, reduces the
likelihood of errors, and makes the code easier to read. Add a usage
example to help driver writers to actually use it.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Documentation/hwmon/hwmon-kernel-api.txt

index 8bdefb4..f8e2ab5 100644 (file)
@@ -207,6 +207,19 @@ static const struct hwmon_channel_info *lm75_info[] = {
        NULL
 };
 
+The HWMON_CHANNEL_INFO() macro can and should be used when possible.
+With this macro, the above example can be simplified to
+
+static const struct hwmon_channel_info *lm75_info[] = {
+       HWMON_CHANNEL_INFO(chip,
+                          HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL),
+       HWMON_CHANNEL_INFO(temp,
+                          HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST),
+       NULL
+};
+
+The remaining declarations are as follows.
+
 static const struct hwmon_ops lm75_hwmon_ops = {
        .is_visible = lm75_is_visible,
        .read = lm75_read,