aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adt7462.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:01 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 00:08:30 -0400
commit0880830096ee314c953d4bd5d017e27589f0e830 (patch)
treeabb7de7a9d91bc91e8654ee5db702494c8686cb3 /drivers/hwmon/adt7462.c
parent65ec17b0d5a5351846e3503d5599e1630e57ffc4 (diff)
hwmon: (adt7462) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/adt7462.c')
-rw-r--r--drivers/hwmon/adt7462.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c
index 339269f76e57..baee482aedfc 100644
--- a/drivers/hwmon/adt7462.c
+++ b/drivers/hwmon/adt7462.c
@@ -1931,11 +1931,10 @@ static int adt7462_probe(struct i2c_client *client,
1931 struct adt7462_data *data; 1931 struct adt7462_data *data;
1932 int err; 1932 int err;
1933 1933
1934 data = kzalloc(sizeof(struct adt7462_data), GFP_KERNEL); 1934 data = devm_kzalloc(&client->dev, sizeof(struct adt7462_data),
1935 if (!data) { 1935 GFP_KERNEL);
1936 err = -ENOMEM; 1936 if (!data)
1937 goto exit; 1937 return -ENOMEM;
1938 }
1939 1938
1940 i2c_set_clientdata(client, data); 1939 i2c_set_clientdata(client, data);
1941 mutex_init(&data->lock); 1940 mutex_init(&data->lock);
@@ -1946,7 +1945,7 @@ static int adt7462_probe(struct i2c_client *client,
1946 data->attrs.attrs = adt7462_attr; 1945 data->attrs.attrs = adt7462_attr;
1947 err = sysfs_create_group(&client->dev.kobj, &data->attrs); 1946 err = sysfs_create_group(&client->dev.kobj, &data->attrs);
1948 if (err) 1947 if (err)
1949 goto exit_free; 1948 return err;
1950 1949
1951 data->hwmon_dev = hwmon_device_register(&client->dev); 1950 data->hwmon_dev = hwmon_device_register(&client->dev);
1952 if (IS_ERR(data->hwmon_dev)) { 1951 if (IS_ERR(data->hwmon_dev)) {
@@ -1958,9 +1957,6 @@ static int adt7462_probe(struct i2c_client *client,
1958 1957
1959exit_remove: 1958exit_remove:
1960 sysfs_remove_group(&client->dev.kobj, &data->attrs); 1959 sysfs_remove_group(&client->dev.kobj, &data->attrs);
1961exit_free:
1962 kfree(data);
1963exit:
1964 return err; 1960 return err;
1965} 1961}
1966 1962
@@ -1970,7 +1966,6 @@ static int adt7462_remove(struct i2c_client *client)
1970 1966
1971 hwmon_device_unregister(data->hwmon_dev); 1967 hwmon_device_unregister(data->hwmon_dev);
1972 sysfs_remove_group(&client->dev.kobj, &data->attrs); 1968 sysfs_remove_group(&client->dev.kobj, &data->attrs);
1973 kfree(data);
1974 return 0; 1969 return 0;
1975} 1970}
1976 1971