diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-05 15:55:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-05 15:55:36 -0700 |
commit | 161d2e0a195292a8a67b0f5c48e12a9984f75dac (patch) | |
tree | 4f3c516ab41737b1e51a58ca3d5f8cca421ae949 /drivers/hwmon/ds620.c | |
parent | c489d98c8c81a898cfed6bec193cca2006f956aa (diff) | |
parent | fce9626cd93abaf1ef21b361f8a0fa493cc855b2 (diff) |
Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck:
"Notable changes:
- Heiko Schocher provided a driver for TI TMP103.
- Kamil Debski provided a driver for pwm-controlled fans.
- Neelesh Gupta provided a driver for power, fan rpm, voltage and
temperature reporting on powerpc/powernv systems.
- Scott Kanowitz provided a driver supporting Lattice's POWR1220
power manager IC.
- Richard Zhu provided a pmbus front-end driver for TPS40422.
- Frans Klaver added support for TMP112 to the lm75 driver.
- Johannes Pointner added support for EPCOS B57330V2103 to the
ntc_thermistor driver.
- Guenter Roeck added support for TMP441 and TMP442 to the tmp421
driver.
- Axel Lin converted several drivers to the new hwmon API (36 of
them, if I counted correctly), and cleaned up many of the drivers
along the way.
There are also a number of patches fixing bugs discovered while
testing Axel's changes"
* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (88 commits)
hwmon: (g762) Use of_property_read_u32 at appropriate place
hwmon: (sis5595) Prevent overflow problem when writing large limits
hwmon: (gpio-fan) Prevent overflow problem when writing large limits
hwmon: (ibmpowernv) Use of_property_read_u32 at appropriate place
hwmon: (lm85) Convert to devm_hwmon_device_register_with_groups
hwmon: (lm85) Avoid forward declaration
hwmon: (lm78) Convert to devm_hwmon_device_register_with_groups
hwmon: (max6697) Use of_property_read_bool at appropriate places
hwmon: (pwm-fan) Make SENSORS_PWM_FAN depend on OF
hwmon: (pwm-fan) Remove duplicate dev_set_drvdata call
hwmon: (nct6775) Remove num_attr_groups from struct nct6775_data
hwmon: (nct6775) Update module description and Kconfig for NCT6106D and NCT6791D
hwmon: (adt7411) Convert to devm_hwmon_device_register_with_groups
hwmon: (g762) Convert to hwmon_device_register_with_groups
hwmon: (emc2103) Convert to devm_hwmon_device_register_with_groups
hwmon: (smsc47m1) Avoid forward declaration
hwmon: (smsc47m192) Convert to devm_hwmon_device_register_with_groups
hwmon: (smsc47m192) Avoid forward declaration
hwmon: (max1668) Make max1668_addr_list array const
hwmon: (max6639) Make normal_i2c array const
...
Diffstat (limited to 'drivers/hwmon/ds620.c')
-rw-r--r-- | drivers/hwmon/ds620.c | 60 |
1 files changed, 17 insertions, 43 deletions
diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c index 0918b9136588..edf550fc4eef 100644 --- a/drivers/hwmon/ds620.c +++ b/drivers/hwmon/ds620.c @@ -67,7 +67,7 @@ static const u8 DS620_REG_TEMP[3] = { /* Each client has this additional data */ struct ds620_data { - struct device *hwmon_dev; + struct i2c_client *client; struct mutex update_lock; char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -106,8 +106,8 @@ static void ds620_init_client(struct i2c_client *client) static struct ds620_data *ds620_update_client(struct device *dev) { - struct i2c_client *client = to_i2c_client(dev); - struct ds620_data *data = i2c_get_clientdata(client); + struct ds620_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; struct ds620_data *ret = data; mutex_lock(&data->update_lock); @@ -158,8 +158,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, long val; struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct ds620_data *data = i2c_get_clientdata(client); + struct ds620_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; res = kstrtol(buf, 10, &val); @@ -181,13 +181,15 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da, { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct ds620_data *data = ds620_update_client(dev); - struct i2c_client *client = to_i2c_client(dev); + struct i2c_client *client; u16 conf, new_conf; int res; if (IS_ERR(data)) return PTR_ERR(data); + client = data->client; + /* reset alarms if necessary */ res = i2c_smbus_read_word_swapped(client, DS620_REG_CONF); if (res < 0) @@ -213,7 +215,7 @@ static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, DS620_REG_CONFIG_THF); -static struct attribute *ds620_attributes[] = { +static struct attribute *ds620_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_min.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr, @@ -222,55 +224,28 @@ static struct attribute *ds620_attributes[] = { NULL }; -static const struct attribute_group ds620_group = { - .attrs = ds620_attributes, -}; +ATTRIBUTE_GROUPS(ds620); static int ds620_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct device *dev = &client->dev; + struct device *hwmon_dev; struct ds620_data *data; - int err; - data = devm_kzalloc(&client->dev, sizeof(struct ds620_data), - GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(struct ds620_data), GFP_KERNEL); if (!data) return -ENOMEM; - i2c_set_clientdata(client, data); + data->client = client; mutex_init(&data->update_lock); /* Initialize the DS620 chip */ ds620_init_client(client); - /* Register sysfs hooks */ - err = sysfs_create_group(&client->dev.kobj, &ds620_group); - if (err) - return err; - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - err = PTR_ERR(data->hwmon_dev); - goto exit_remove_files; - } - - dev_info(&client->dev, "temperature sensor found\n"); - - return 0; - -exit_remove_files: - sysfs_remove_group(&client->dev.kobj, &ds620_group); - return err; -} - -static int ds620_remove(struct i2c_client *client) -{ - struct ds620_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &ds620_group); - - return 0; + hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, + data, ds620_groups); + return PTR_ERR_OR_ZERO(hwmon_dev); } static const struct i2c_device_id ds620_id[] = { @@ -287,7 +262,6 @@ static struct i2c_driver ds620_driver = { .name = "ds620", }, .probe = ds620_probe, - .remove = ds620_remove, .id_table = ds620_id, }; |