diff options
author | Jaghathiswari Rankappagounder Natarajan <jaghu@google.com> | 2017-08-30 19:34:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-08-31 12:50:14 -0400 |
commit | 2eb7954809bf26de27bc3a2fea4eef606bbf4482 (patch) | |
tree | 7558e99f62aaedec768c2bf4138c08bbe01df78f /drivers | |
parent | db15d73e5f0ea8e9b2c2be31dea45205257eb5fd (diff) |
drivers: w1: add hwmon support structures
This patch has changes to w1.h/w1.c generic files to add (optional) hwmon
support structures.
Signed-off-by: Jaghathiswari Rankappagounder Natarajan <jaghu@google.com>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/w1/w1.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 3c76e1ca4b83..0c2a5a8327bd 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/kthread.h> | 26 | #include <linux/kthread.h> |
27 | #include <linux/freezer.h> | 27 | #include <linux/freezer.h> |
28 | #include <linux/hwmon.h> | ||
28 | 29 | ||
29 | #include <linux/atomic.h> | 30 | #include <linux/atomic.h> |
30 | 31 | ||
@@ -649,9 +650,24 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl) | |||
649 | return err; | 650 | return err; |
650 | } | 651 | } |
651 | } | 652 | } |
652 | 653 | if (IS_REACHABLE(CONFIG_HWMON) && fops->chip_info) { | |
654 | struct device *hwmon | ||
655 | = hwmon_device_register_with_info(&sl->dev, | ||
656 | "w1_slave_temp", sl, | ||
657 | fops->chip_info, | ||
658 | NULL); | ||
659 | if (IS_ERR(hwmon)) { | ||
660 | dev_warn(&sl->dev, | ||
661 | "could not create hwmon device\n"); | ||
662 | } else { | ||
663 | sl->hwmon = hwmon; | ||
664 | } | ||
665 | } | ||
653 | break; | 666 | break; |
654 | case BUS_NOTIFY_DEL_DEVICE: | 667 | case BUS_NOTIFY_DEL_DEVICE: |
668 | if (IS_REACHABLE(CONFIG_HWMON) && fops->chip_info && | ||
669 | sl->hwmon) | ||
670 | hwmon_device_unregister(sl->hwmon); | ||
655 | if (fops->remove_slave) | 671 | if (fops->remove_slave) |
656 | sl->family->fops->remove_slave(sl); | 672 | sl->family->fops->remove_slave(sl); |
657 | if (fops->groups) | 673 | if (fops->groups) |