summaryrefslogtreecommitdiff
path: root/drivers/hwmon/ltc4215.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-01 13:51:48 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-01 13:51:48 -0700
commit26f31fb936042459d481557a83bda7a3f4d61906 (patch)
tree1d871ee1c82896355ad0aef6eea8dbd601d8169d /drivers/hwmon/ltc4215.c
parent0c8cfbade0e9bef5637907ed00c7b81bc86ad359 (diff)
parentf76992b00a4111fc4679b0b2d49fe75f05c2b04d (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: - New drivers for ADC128D818, LTC2945, LTC4260, and LTC4222 - Added support for LTM4676 to ltc2978 driver - Converted several drivers to use devm_hwmon_device_register_with_groups - Various cleanup in several drivers * tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (36 commits) hwmon: (pmbus/ltc2978) Add support for LTM4676 hwmon: (pmbus/ltc2978) Add new chip ID for LTC2974 hwmon: Do not accept invalid name attributes hwmon: (max6639) Use SIMPLE_DEV_PM_OPS macro hwmon: (lm95245) Make temp2_crit_hyst read-only hwmon: (lm95245) Convert to use devm_hwmon_device_register_with_groups hwmon: (lm95245) Drop useless debug message hwmon: (lm95245) Fix hysteresis temperatures hwmon: (max6639) Convert to use devm_hwmon_device_register_with_groups hwmon: (max6639) Introduce local dev variable, and reduce noisiness hwmon: (max6650) Introduce local 'dev' variable hwmon: (max6650) Drop error message after memory allocation failures hwmon: (max6650) Convert to use devm_hwmon_device_register_with_groups hwmon: (max6650) Rearrange code to no longer require forward declarations hwmon: (ltc4215) Convert to devm_hwmon_device_register_with_groups hwmon: (coretemp) Convert to use devm_hwmon_device_register_with_groups hwmon: (coretemp) Allocate platform data with devm_kzalloc hwmon: (coretemp) Use sysfs_create_group to create sysfs attributes hwmon: (ltc4245) Remove devicetree conditionals hwmon: (ltc4245) Drop debug messages ...
Diffstat (limited to 'drivers/hwmon/ltc4215.c')
-rw-r--r--drivers/hwmon/ltc4215.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/drivers/hwmon/ltc4215.c b/drivers/hwmon/ltc4215.c
index 8a142960d69e..c8a9bd9b050f 100644
--- a/drivers/hwmon/ltc4215.c
+++ b/drivers/hwmon/ltc4215.c
@@ -33,7 +33,7 @@ enum ltc4215_cmd {
};
struct ltc4215_data {
- struct device *hwmon_dev;
+ struct i2c_client *client;
struct mutex update_lock;
bool valid;
@@ -45,8 +45,8 @@ struct ltc4215_data {
static struct ltc4215_data *ltc4215_update_device(struct device *dev)
{
- struct i2c_client *client = to_i2c_client(dev);
- struct ltc4215_data *data = i2c_get_clientdata(client);
+ struct ltc4215_data *data = dev_get_drvdata(dev);
+ struct i2c_client *client = data->client;
s32 val;
int i;
@@ -214,7 +214,7 @@ static SENSOR_DEVICE_ATTR(in2_min_alarm, S_IRUGO, ltc4215_show_alarm, NULL,
* Finally, construct an array of pointers to members of the above objects,
* as required for sysfs_create_group()
*/
-static struct attribute *ltc4215_attributes[] = {
+static struct attribute *ltc4215_attrs[] = {
&sensor_dev_attr_curr1_input.dev_attr.attr,
&sensor_dev_attr_curr1_max_alarm.dev_attr.attr,
@@ -229,57 +229,33 @@ static struct attribute *ltc4215_attributes[] = {
NULL,
};
-
-static const struct attribute_group ltc4215_group = {
- .attrs = ltc4215_attributes,
-};
+ATTRIBUTE_GROUPS(ltc4215);
static int ltc4215_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = client->adapter;
+ struct device *dev = &client->dev;
struct ltc4215_data *data;
- int ret;
+ struct device *hwmon_dev;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
- data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
- i2c_set_clientdata(client, data);
+ data->client = client;
mutex_init(&data->update_lock);
/* Initialize the LTC4215 chip */
i2c_smbus_write_byte_data(client, LTC4215_FAULT, 0x00);
- /* Register sysfs hooks */
- ret = sysfs_create_group(&client->dev.kobj, &ltc4215_group);
- if (ret)
- return ret;
-
- data->hwmon_dev = hwmon_device_register(&client->dev);
- if (IS_ERR(data->hwmon_dev)) {
- ret = PTR_ERR(data->hwmon_dev);
- goto out_hwmon_device_register;
- }
-
- return 0;
-
-out_hwmon_device_register:
- sysfs_remove_group(&client->dev.kobj, &ltc4215_group);
- return ret;
-}
-
-static int ltc4215_remove(struct i2c_client *client)
-{
- struct ltc4215_data *data = i2c_get_clientdata(client);
-
- hwmon_device_unregister(data->hwmon_dev);
- sysfs_remove_group(&client->dev.kobj, &ltc4215_group);
-
- return 0;
+ hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
+ data,
+ ltc4215_groups);
+ return PTR_ERR_OR_ZERO(hwmon_dev);
}
static const struct i2c_device_id ltc4215_id[] = {
@@ -294,7 +270,6 @@ static struct i2c_driver ltc4215_driver = {
.name = "ltc4215",
},
.probe = ltc4215_probe,
- .remove = ltc4215_remove,
.id_table = ltc4215_id,
};