diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 14:35:52 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:42 -0400 |
commit | f511a21f4ea7d4410241e15db5cb05a287812582 (patch) | |
tree | 579fed57a571bc4cac6297afac503b64214bcf85 /drivers/hwmon | |
parent | bd91d3bab8787f53c1b937ac817b0c59f8146b97 (diff) |
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>
Diffstat (limited to 'drivers/hwmon')
-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 0d466b9d890..4e1ff82c63e 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c | |||
@@ -159,17 +159,16 @@ static int __devinit tmp102_probe(struct i2c_client *client, | |||
159 | return -ENODEV; | 159 | return -ENODEV; |
160 | } | 160 | } |
161 | 161 | ||
162 | tmp102 = kzalloc(sizeof(*tmp102), GFP_KERNEL); | 162 | tmp102 = devm_kzalloc(&client->dev, sizeof(*tmp102), GFP_KERNEL); |
163 | if (!tmp102) { | 163 | if (!tmp102) |
164 | dev_dbg(&client->dev, "kzalloc failed\n"); | ||
165 | return -ENOMEM; | 164 | return -ENOMEM; |
166 | } | 165 | |
167 | i2c_set_clientdata(client, tmp102); | 166 | i2c_set_clientdata(client, tmp102); |
168 | 167 | ||
169 | status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG); | 168 | status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG); |
170 | if (status < 0) { | 169 | if (status < 0) { |
171 | dev_err(&client->dev, "error reading config register\n"); | 170 | dev_err(&client->dev, "error reading config register\n"); |
172 | goto fail_free; | 171 | return status; |
173 | } | 172 | } |
174 | tmp102->config_orig = status; | 173 | tmp102->config_orig = status; |
175 | status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, | 174 | status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, |
@@ -213,9 +212,6 @@ fail_remove_sysfs: | |||
213 | fail_restore_config: | 212 | fail_restore_config: |
214 | i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, | 213 | i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, |
215 | tmp102->config_orig); | 214 | tmp102->config_orig); |
216 | fail_free: | ||
217 | kfree(tmp102); | ||
218 | |||
219 | return status; | 215 | return status; |
220 | } | 216 | } |
221 | 217 | ||
@@ -236,8 +232,6 @@ static int __devexit tmp102_remove(struct i2c_client *client) | |||
236 | config | TMP102_CONF_SD); | 232 | config | TMP102_CONF_SD); |
237 | } | 233 | } |
238 | 234 | ||
239 | kfree(tmp102); | ||
240 | |||
241 | return 0; | 235 | return 0; |
242 | } | 236 | } |
243 | 237 | ||