diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 11:35:52 -0700 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-21 21:48:42 -0700 |
commit | f511a21f4ea7d4410241e15db5cb05a287812582 (patch) | |
tree | 579fed57a571bc4cac6297afac503b64214bcf85 | |
parent | bd91d3bab8787f53c1b937ac817b0c59f8146b97 (diff) | |
download | linux-f511a21f4ea7d4410241e15db5cb05a287812582.tar.bz2 |
hwmon: (tmp102) 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>
Acked-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r-- | drivers/hwmon/tmp102.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c index 0d466b9d8908..4e1ff82c63e0 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c @@ -159,17 +159,16 @@ static int __devinit tmp102_probe(struct i2c_client *client, return -ENODEV; } - tmp102 = kzalloc(sizeof(*tmp102), GFP_KERNEL); - if (!tmp102) { - dev_dbg(&client->dev, "kzalloc failed\n"); + tmp102 = devm_kzalloc(&client->dev, sizeof(*tmp102), GFP_KERNEL); + if (!tmp102) return -ENOMEM; - } + i2c_set_clientdata(client, tmp102); status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG); if (status < 0) { dev_err(&client->dev, "error reading config register\n"); - goto fail_free; + return status; } tmp102->config_orig = status; status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, @@ -213,9 +212,6 @@ fail_remove_sysfs: fail_restore_config: i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, tmp102->config_orig); -fail_free: - kfree(tmp102); - return status; } @@ -236,8 +232,6 @@ static int __devexit tmp102_remove(struct i2c_client *client) config | TMP102_CONF_SD); } - kfree(tmp102); - return 0; } |