aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus/lm25066.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/pmbus/lm25066.c')
-rw-r--r--drivers/hwmon/pmbus/lm25066.c46
1 files changed, 8 insertions, 38 deletions
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index 84a37f0c8db6..c299392716af 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -176,7 +176,6 @@ static int lm25066_probe(struct i2c_client *client,
176 const struct i2c_device_id *id) 176 const struct i2c_device_id *id)
177{ 177{
178 int config; 178 int config;
179 int ret;
180 struct lm25066_data *data; 179 struct lm25066_data *data;
181 struct pmbus_driver_info *info; 180 struct pmbus_driver_info *info;
182 181
@@ -184,15 +183,14 @@ static int lm25066_probe(struct i2c_client *client,
184 I2C_FUNC_SMBUS_READ_BYTE_DATA)) 183 I2C_FUNC_SMBUS_READ_BYTE_DATA))
185 return -ENODEV; 184 return -ENODEV;
186 185
187 data = kzalloc(sizeof(struct lm25066_data), GFP_KERNEL); 186 data = devm_kzalloc(&client->dev, sizeof(struct lm25066_data),
187 GFP_KERNEL);
188 if (!data) 188 if (!data)
189 return -ENOMEM; 189 return -ENOMEM;
190 190
191 config = i2c_smbus_read_byte_data(client, LM25066_DEVICE_SETUP); 191 config = i2c_smbus_read_byte_data(client, LM25066_DEVICE_SETUP);
192 if (config < 0) { 192 if (config < 0)
193 ret = config; 193 return config;
194 goto err_mem;
195 }
196 194
197 data->id = id->driver_data; 195 data->id = id->driver_data;
198 info = &data->info; 196 info = &data->info;
@@ -291,28 +289,10 @@ static int lm25066_probe(struct i2c_client *client,
291 } 289 }
292 break; 290 break;
293 default: 291 default:
294 ret = -ENODEV; 292 return -ENODEV;
295 goto err_mem;
296 } 293 }
297 294
298 ret = pmbus_do_probe(client, id, info); 295 return pmbus_do_probe(client, id, info);
299 if (ret)
300 goto err_mem;
301 return 0;
302
303err_mem:
304 kfree(data);
305 return ret;
306}
307
308static int lm25066_remove(struct i2c_client *client)
309{
310 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
311 const struct lm25066_data *data = to_lm25066_data(info);
312
313 pmbus_do_remove(client);
314 kfree(data);
315 return 0;
316} 296}
317 297
318static const struct i2c_device_id lm25066_id[] = { 298static const struct i2c_device_id lm25066_id[] = {
@@ -330,22 +310,12 @@ static struct i2c_driver lm25066_driver = {
330 .name = "lm25066", 310 .name = "lm25066",
331 }, 311 },
332 .probe = lm25066_probe, 312 .probe = lm25066_probe,
333 .remove = lm25066_remove, 313 .remove = pmbus_do_remove,
334 .id_table = lm25066_id, 314 .id_table = lm25066_id,
335}; 315};
336 316
337static int __init lm25066_init(void) 317module_i2c_driver(lm25066_driver);
338{
339 return i2c_add_driver(&lm25066_driver);
340}
341
342static void __exit lm25066_exit(void)
343{
344 i2c_del_driver(&lm25066_driver);
345}
346 318
347MODULE_AUTHOR("Guenter Roeck"); 319MODULE_AUTHOR("Guenter Roeck");
348MODULE_DESCRIPTION("PMBus driver for LM25066/LM5064/LM5066"); 320MODULE_DESCRIPTION("PMBus driver for LM25066/LM5064/LM5066");
349MODULE_LICENSE("GPL"); 321MODULE_LICENSE("GPL");
350module_init(lm25066_init);
351module_exit(lm25066_exit);