aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lineage-pem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lineage-pem.c')
-rw-r--r--drivers/hwmon/lineage-pem.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/drivers/hwmon/lineage-pem.c b/drivers/hwmon/lineage-pem.c
index 58eded27f385..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
@@ -568,19 +565,8 @@ static struct i2c_driver pem_driver = {
568 .id_table = pem_id, 565 .id_table = pem_id,
569}; 566};
570 567
571static int __init pem_init(void) 568module_i2c_driver(pem_driver);
572{
573 return i2c_add_driver(&pem_driver);
574}
575
576static void __exit pem_exit(void)
577{
578 i2c_del_driver(&pem_driver);
579}
580 569
581MODULE_AUTHOR("Guenter Roeck <guenter.roeck@ericsson.com>"); 570MODULE_AUTHOR("Guenter Roeck <guenter.roeck@ericsson.com>");
582MODULE_DESCRIPTION("Lineage CPL PEM hardware monitoring driver"); 571MODULE_DESCRIPTION("Lineage CPL PEM hardware monitoring driver");
583MODULE_LICENSE("GPL"); 572MODULE_LICENSE("GPL");
584
585module_init(pem_init);
586module_exit(pem_exit);