Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (sch56xx-common) Simplify sch56xx_device_add

Use platform_device_register_simple() instead of
manually calling platform_device_alloc()/platform_device_add().

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210508131457.12780-5-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Armin Wolf and committed by
Guenter Roeck
5c1c78e0 989c9c67

+4 -23
+4 -23
drivers/hwmon/sch56xx-common.c
··· 504 504 struct resource res = { 505 505 .start = address, 506 506 .end = address + REGION_LENGTH - 1, 507 + .name = name, 507 508 .flags = IORESOURCE_IO, 508 509 }; 509 510 int err; 510 511 511 - sch56xx_pdev = platform_device_alloc(name, address); 512 - if (!sch56xx_pdev) 513 - return -ENOMEM; 514 - 515 - res.name = sch56xx_pdev->name; 516 512 err = acpi_check_resource_conflict(&res); 517 513 if (err) 518 - goto exit_device_put; 514 + return err; 519 515 520 - err = platform_device_add_resources(sch56xx_pdev, &res, 1); 521 - if (err) { 522 - pr_err("Device resource addition failed\n"); 523 - goto exit_device_put; 524 - } 516 + sch56xx_pdev = platform_device_register_simple(name, -1, &res, 1); 525 517 526 - err = platform_device_add(sch56xx_pdev); 527 - if (err) { 528 - pr_err("Device addition failed\n"); 529 - goto exit_device_put; 530 - } 531 - 532 - return 0; 533 - 534 - exit_device_put: 535 - platform_device_put(sch56xx_pdev); 536 - 537 - return err; 518 + return PTR_ERR_OR_ZERO(sch56xx_pdev); 538 519 } 539 520 540 521 static int __init sch56xx_init(void)