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>
This commit is contained in:
Eddie James
2018-11-08 15:05:28 -06:00
committed by Guenter Roeck
parent c10e753d43
commit 54076cb3b5
2 changed files with 353 additions and 0 deletions

View File

@@ -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);