Skip to content

Commit

Permalink
hwmon: (ads1015) Convert to use devm_ functions
Browse files Browse the repository at this point in the history
Convert to use devm_ functions to reduce code size and simplify the code.

Cc: Dirk Eibach <eibach@gdsys.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Guenter Roeck committed Sep 24, 2012
1 parent 08940b8 commit 57457e3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/hwmon/ads1015.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down

0 comments on commit 57457e3

Please sign in to comment.