hwmon (occ): Add sensor attributes and register hwmon device
Setup the sensor attributes for every OCC sensor found by the first poll
response. Register the attributes with hwmon.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h
index a363462..9d01973 100644
--- a/drivers/hwmon/occ/common.h
+++ b/drivers/hwmon/occ/common.h
@@ -3,7 +3,9 @@
#ifndef OCC_COMMON_H
#define OCC_COMMON_H
+#include <linux/hwmon-sysfs.h>
#include <linux/mutex.h>
+#include <linux/sysfs.h>
struct device;
@@ -76,6 +78,15 @@ struct occ_sensors {
struct occ_sensor extended;
};
+/*
+ * Use our own attribute struct so we can dynamically allocate space for the
+ * name.
+ */
+struct occ_attribute {
+ char name[32];
+ struct sensor_device_attribute_2 sensor;
+};
+
struct occ {
struct device *bus_dev;
@@ -88,6 +99,11 @@ struct occ {
unsigned long last_update;
struct mutex lock; /* lock OCC access */
+
+ struct device *hwmon;
+ struct occ_attribute *attrs;
+ struct attribute_group group;
+ const struct attribute_group *groups[2];
};
int occ_setup(struct occ *occ, const char *name);