From: Guenter Roeck Date: Sat, 2 Jun 2012 16:58:00 +0000 (-0700) Subject: hwmon: (ads1015) Convert to use devm_ functions X-Git-Tag: next-20120823~74^2~33 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=69ef887f1cf28db0d3fcdcfa7a51d3d96b06781f;p=karo-tx-linux.git hwmon: (ads1015) Convert to use devm_ functions Convert to use devm_ functions to reduce code size and simplify the code. Cc: Dirk Eibach Signed-off-by: Guenter Roeck --- diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c index 1958f03efd7a..2798246ad814 100644 --- a/drivers/hwmon/ads1015.c +++ b/drivers/hwmon/ads1015.c @@ -156,7 +156,6 @@ static int ads1015_remove(struct i2c_client *client) hwmon_device_unregister(data->hwmon_dev); for (k = 0; k < ADS1015_CHANNELS; ++k) device_remove_file(&client->dev, &ads1015_in[k].dev_attr); - kfree(data); return 0; } @@ -254,11 +253,10 @@ static int ads1015_probe(struct i2c_client *client, int err; unsigned int k; - data = kzalloc(sizeof(struct ads1015_data), GFP_KERNEL); - if (!data) { - err = -ENOMEM; - goto exit; - } + data = devm_kzalloc(&client->dev, sizeof(struct ads1015_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; i2c_set_clientdata(client, data); mutex_init(&data->update_lock); @@ -284,8 +282,6 @@ static int ads1015_probe(struct i2c_client *client, exit_remove: for (k = 0; k < ADS1015_CHANNELS; ++k) device_remove_file(&client->dev, &ads1015_in[k].dev_attr); - kfree(data); -exit: return err; }