hwmon: (pcf8591) Convert to use devm_ functions
Guenter Roeck
maintainerPATCH 68/95 hwmon: (pcf8591) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code.
Signed-off-by Guenter Roeck <[email protected]>
--- drivers/hwmon/pcf8591.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/hwmon/pcf8591.c +5 -10
@@ -200,11 +200,10 @@ static int pcf8591_probe(struct i2c_client *client,struct pcf8591_data *data;int err; - data =kzalloc (sizeof (struct pcf8591_data ),GFP_KERNEL ); -if (!data) { - err = -ENOMEM ; - goto exit; - } + data =devm_kzalloc (&client->dev,sizeof (struct pcf8591_data ), +GFP_KERNEL ); +if (!data) +return -ENOMEM ;i2c_set_clientdata (client, data);mutex_init (&data->update_lock);
@@ -215,7 +214,7 @@ static int pcf8591_probe(struct i2c_client *client,/* Register sysfs hooks */ err =sysfs_create_group (&client->dev.kobj, &pcf8591_attr_group);if (err) - goto exit_kfree; +return err;/* Register input2 if not in "two differential inputs" mode */ if (input_mode !=3 ) {
@@ -242,9 +241,6 @@ static int pcf8591_probe(struct i2c_client *client, exit_sysfs_remove:sysfs_remove_group (&client->dev.kobj, &pcf8591_attr_group_opt);sysfs_remove_group (&client->dev.kobj, &pcf8591_attr_group); -exit_kfree: -kfree (data); -exit:return err; }
@@ -255,7 +251,6 @@ static int pcf8591_remove(struct i2c_client *client)hwmon_device_unregister (data->hwmon_dev);sysfs_remove_group (&client->dev.kobj, &pcf8591_attr_group_opt);sysfs_remove_group (&client->dev.kobj, &pcf8591_attr_group); -kfree (i2c_get_clientdata (client));return 0 ; }
Signature · 7 lines
1.7.9.7 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 6 lines · Guenter Roeck
Convert to use
devm_functions to reduce code size and simplify the code.Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/pcf8591.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
Acked-by Jean Delvare <[email protected]>
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors