Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1689555 > unrolled thread
| Started by | Jaghathiswari Rankappagounder Natarajan <jaghu@google.com> |
|---|---|
| First post | 2017-07-18 01:10 +0200 |
| Last post | 2017-07-18 01:10 +0200 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH linux v5 0/3] Export 1-wire thermal sensors as hwmon device Jaghathiswari Rankappagounder Natarajan <jaghu@google.com> - 2017-07-18 01:10 +0200
[PATCH linux v5 1/3] drivers: w1: add hwmon support structures Jaghathiswari Rankappagounder Natarajan <jaghu@google.com> - 2017-07-18 01:10 +0200
| From | Jaghathiswari Rankappagounder Natarajan <jaghu@google.com> |
|---|---|
| Date | 2017-07-18 01:10 +0200 |
| Subject | [PATCH linux v5 0/3] Export 1-wire thermal sensors as hwmon device |
| Message-ID | <u4njj-2ZX-3@gated-at.bofh.it> |
Hi Greg,
Please pull in this patchset into the tree. Thanks!
Summary of what this patchset does:
Our board has 4 DS18B20 1-wire temperature sensors. Each 1-wire bus and the
sensor under it is already configured against the Linux 1-wire driver
(called w1). They have a sysfs file(e.g.
/sys/bus/w1/devices/w1_bus_master1/28-000007704f4c/w1_slave) which, when read,
runs code to read the temperature. We'd like the temperatures to show up in
hwmon, so that the BMC IPMI sensor plumbing can forward those to host.
This patchset is based on linux mainline version v4.10.
Tested:
Yes; On a board with 4 DS18B20 1-wire temperature sensors:
root@zaius:/sys/class/hwmon# ls
hwmon0 hwmon1 hwmon2 hwmon3 hwmon4 hwmon5
root@zaius:/sys/class/hwmon# cd hwmon0
root@zaius:/sys/class/hwmon/hwmon0# ls
device name subsystem temp1_input uevent
root@zaius:/sys/class/hwmon/hwmon0# cat temp1_input
24500
root@zaius:/sys/class/hwmon/hwmon0# cd ..
root@zaius:/sys/class/hwmon# cd hwmon1
root@zaius:/sys/class/hwmon/hwmon1# cat temp1_input
26562
root@zaius:/sys/class/hwmon/hwmon1# cd ..
root@zaius:/sys/class/hwmon# cd hwmon2
root@zaius:/sys/class/hwmon/hwmon2# cat temp1_input
27250
root@zaius:/sys/class/hwmon/hwmon2# cd ..
root@zaius:/sys/class/hwmon# cd hwmon3
root@zaius:/sys/class/hwmon/hwmon3# cat temp1_input
22250
root@zaius:/sys/class/hwmon/hwmon3#
Jaghathiswari Rankappagounder Natarajan (3):
drivers: w1: add hwmon support structures
drivers: w1: refactor w1_slave_show to make the temp reading
functionality separate
drivers: w1: add hwmon temp support for w1_therm
drivers/w1/slaves/w1_therm.c | 164 +++++++++++++++++++++++++++++++++++--------
drivers/w1/w1.c | 18 ++++-
drivers/w1/w1.h | 2 +
drivers/w1/w1_family.h | 2 +
4 files changed, 156 insertions(+), 30 deletions(-)
--
2.13.2.932.g7449e964c-goog
[toc] | [next] | [standalone]
| From | Jaghathiswari Rankappagounder Natarajan <jaghu@google.com> |
|---|---|
| Date | 2017-07-18 01:10 +0200 |
| Subject | [PATCH linux v5 1/3] drivers: w1: add hwmon support structures |
| Message-ID | <u4njk-2ZX-43@gated-at.bofh.it> |
| In reply to | #1689555 |
This patch has changes to w1.h/w1.c/w1_family.h 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>
---
v2
- made changes to support hwmon_device_register_with_info mentioned by Guenter.
v3
- used IS_REACHABLE(CONFIG_HWMON).
- removed hwmon device first before removing slave.
v4
- moved && to be in the previous line.
drivers/w1/w1.c | 18 +++++++++++++++++-
drivers/w1/w1.h | 2 ++
drivers/w1/w1_family.h | 2 ++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index e213c678bbfe..6485603131e8 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -32,6 +32,7 @@
#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
+#include <linux/hwmon.h>
#include <linux/atomic.h>
@@ -659,9 +660,24 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl)
return err;
}
}
-
+ if (IS_REACHABLE(CONFIG_HWMON) && fops->chip_info) {
+ struct device *hwmon
+ = hwmon_device_register_with_info(&sl->dev,
+ "w1_slave_temp", sl,
+ fops->chip_info,
+ NULL);
+ if (IS_ERR(hwmon)) {
+ dev_warn(&sl->dev,
+ "could not create hwmon device\n");
+ } else {
+ sl->hwmon = hwmon;
+ }
+ }
break;
case BUS_NOTIFY_DEL_DEVICE:
+ if (IS_REACHABLE(CONFIG_HWMON) && fops->chip_info &&
+ sl->hwmon)
+ hwmon_device_unregister(sl->hwmon);
if (fops->remove_slave)
sl->family->fops->remove_slave(sl);
if (fops->groups)
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 129895f562b0..74ef1a543856 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -83,6 +83,7 @@ struct w1_reg_num
* @family: module for device family type
* @family_data: pointer for use by the family module
* @dev: kernel device identifier
+ * @hwmon: pointer to hwmon device
*
*/
struct w1_slave
@@ -99,6 +100,7 @@ struct w1_slave
struct w1_family *family;
void *family_data;
struct device dev;
+ struct device *hwmon;
};
typedef void (*w1_slave_found_callback)(struct w1_master *, u64);
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
index 10a7a0767187..9001851e1316 100644
--- a/drivers/w1/w1_family.h
+++ b/drivers/w1/w1_family.h
@@ -55,12 +55,14 @@ struct w1_slave;
* @add_slave: add_slave
* @remove_slave: remove_slave
* @groups: sysfs group
+ * @chip_info: pointer to struct hwmon_chip_info
*/
struct w1_family_ops
{
int (* add_slave)(struct w1_slave *);
void (* remove_slave)(struct w1_slave *);
const struct attribute_group **groups;
+ const struct hwmon_chip_info *chip_info;
};
/**
--
2.13.2.932.g7449e964c-goog
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web