aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-02-22 11:56:45 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-03-18 21:27:44 -0400
commit07404aab52f5106ec436692474cf8f40978f5dac (patch)
treeaa0bdba57bd71b2d3af25a0fb30f612de2c0e577 /drivers/hwmon
parentf352df652ff37c434ed32bc5b7eb7ce430b73abc (diff)
hwmon: (lineage-pem) Convert to use devm_kzalloc
Marginally less code and eliminate the possibility of memory leaks. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lineage-pem.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/hwmon/lineage-pem.c b/drivers/hwmon/lineage-pem.c
index 5b8c9aeed3d6..d264937c7f5e 100644
--- a/drivers/hwmon/lineage-pem.c
+++ b/drivers/hwmon/lineage-pem.c
@@ -448,7 +448,7 @@ static int pem_probe(struct i2c_client *client,
448 | I2C_FUNC_SMBUS_WRITE_BYTE)) 448 | I2C_FUNC_SMBUS_WRITE_BYTE))
449 return -ENODEV; 449 return -ENODEV;
450 450
451 data = kzalloc(sizeof(*data), GFP_KERNEL); 451 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
452 if (!data) 452 if (!data)
453 return -ENOMEM; 453 return -ENOMEM;
454 454
@@ -462,11 +462,11 @@ static int pem_probe(struct i2c_client *client,
462 ret = pem_read_block(client, PEM_READ_FIRMWARE_REV, 462 ret = pem_read_block(client, PEM_READ_FIRMWARE_REV,
463 data->firmware_rev, sizeof(data->firmware_rev)); 463 data->firmware_rev, sizeof(data->firmware_rev));
464 if (ret < 0) 464 if (ret < 0)
465 goto out_kfree; 465 return ret;
466 466
467 ret = i2c_smbus_write_byte(client, PEM_CLEAR_INFO_FLAGS); 467 ret = i2c_smbus_write_byte(client, PEM_CLEAR_INFO_FLAGS);
468 if (ret < 0) 468 if (ret < 0)
469 goto out_kfree; 469 return ret;
470 470
471 dev_info(&client->dev, "Firmware revision %d.%d.%d\n", 471 dev_info(&client->dev, "Firmware revision %d.%d.%d\n",
472 data->firmware_rev[0], data->firmware_rev[1], 472 data->firmware_rev[0], data->firmware_rev[1],
@@ -475,7 +475,7 @@ static int pem_probe(struct i2c_client *client,
475 /* Register sysfs hooks */ 475 /* Register sysfs hooks */
476 ret = sysfs_create_group(&client->dev.kobj, &pem_group); 476 ret = sysfs_create_group(&client->dev.kobj, &pem_group);
477 if (ret) 477 if (ret)
478 goto out_kfree; 478 return ret;
479 479
480 /* 480 /*
481 * Check if input readings are supported. 481 * Check if input readings are supported.
@@ -534,8 +534,6 @@ out_remove_groups:
534 sysfs_remove_group(&client->dev.kobj, &pem_input_group); 534 sysfs_remove_group(&client->dev.kobj, &pem_input_group);
535 sysfs_remove_group(&client->dev.kobj, &pem_fan_group); 535 sysfs_remove_group(&client->dev.kobj, &pem_fan_group);
536 sysfs_remove_group(&client->dev.kobj, &pem_group); 536 sysfs_remove_group(&client->dev.kobj, &pem_group);
537out_kfree:
538 kfree(data);
539 return ret; 537 return ret;
540} 538}
541 539
@@ -549,7 +547,6 @@ static int pem_remove(struct i2c_client *client)
549 sysfs_remove_group(&client->dev.kobj, &pem_fan_group); 547 sysfs_remove_group(&client->dev.kobj, &pem_fan_group);
550 sysfs_remove_group(&client->dev.kobj, &pem_group); 548 sysfs_remove_group(&client->dev.kobj, &pem_group);
551 549
552 kfree(data);
553 return 0; 550 return 0;
554} 551}
555 552