diff options
Diffstat (limited to 'inahwmon.c')
| -rw-r--r-- | inahwmon.c | 50 |
1 files changed, 40 insertions, 10 deletions
@@ -4,21 +4,41 @@ #include "linux/i2c.h" -static const struct hwmon_channel_info power = { - .type = hwmon_power, - .config = HWMON_P_INPUT -}; +static int ina260_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + return 0; +} +static int ina260_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) +{ + return 0; +} -static const struct hwmon_channel_info * const ina260_info[] = { - &power, +static umode_t ina260_is_visible(const void *drvdata, + enum hwmon_sensor_types type, + u32 attr, int channel){ + return 0444; + } + +#define HWMON_CHANNEL_INFO(stype, ...) \ + (&(struct hwmon_channel_info) { \ + .type = hwmon_##stype, \ + .config = (u32 []) { \ + __VA_ARGS__, 0 \ + } \ + }) + +static const struct hwmon_channel_info * ina260_info[] = { + HWMON_CHANNEL_INFO(power,HWMON_P_INPUT), NULL }; static const struct hwmon_ops ina260_hwmon_ops = { - //.is_visible = ina238_is_visible, - .read = NULL, - .write = NULL, + .is_visible = ina260_is_visible, + .read = ina260_read, + .write = ina260_write, }; static const struct hwmon_chip_info ina260_chip_info = { @@ -26,10 +46,19 @@ static const struct hwmon_chip_info ina260_chip_info = { .info = ina260_info, }; + +/*const struct attribute_group *extra_groups[] = { + NULL +};*/ + static int ina260_probe_new(struct i2c_client *client){ + struct device *hwmon_dev; - hwmon_device_register_with_info(&client->dev,client->name,NULL, + hwmon_dev=hwmon_device_register_with_info(&client->dev,client->name,NULL, &ina260_chip_info,NULL); + if (IS_ERR(hwmon_dev)) + return PTR_ERR(hwmon_dev); + return 0; } static int ina260_remove(struct i2c_client *client){ @@ -46,6 +75,7 @@ static const struct i2c_device_id ina260_ids[] = { MODULE_DEVICE_TABLE(i2c,ina260_ids); static struct i2c_driver ina260_driver = { + .class = I2C_CLASS_HWMON, .driver = { .name = "ina260HWMON" }, |
