Skip to content

Commit

Permalink
hwmon: (w83795) 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: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
  • Loading branch information
Guenter Roeck committed Jul 22, 2012
1 parent 20f426f commit 4cb14a3
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/hwmon/w83795.c
Original file line number Diff line number Diff line change
Expand Up @@ -2157,11 +2157,9 @@ static int w83795_probe(struct i2c_client *client,
struct w83795_data *data;
int err;

data = kzalloc(sizeof(struct w83795_data), GFP_KERNEL);
if (!data) {
err = -ENOMEM;
goto exit;
}
data = devm_kzalloc(dev, sizeof(struct w83795_data), GFP_KERNEL);
if (!data)
return -ENOMEM;

i2c_set_clientdata(client, data);
data->chip_type = id->driver_data;
Expand Down Expand Up @@ -2247,8 +2245,6 @@ static int w83795_probe(struct i2c_client *client,

exit_remove:
w83795_handle_files(dev, device_remove_file_wrapper);
kfree(data);
exit:
return err;
}

Expand All @@ -2258,7 +2254,6 @@ static int w83795_remove(struct i2c_client *client)

hwmon_device_unregister(data->hwmon_dev);
w83795_handle_files(&client->dev, device_remove_file_wrapper);
kfree(data);

return 0;
}
Expand Down

0 comments on commit 4cb14a3

Please sign in to comment.