aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/tmp102.c14
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:
213fail_restore_config: 212fail_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);
216fail_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