diff options
author | Armin Wolf <W_Armin@gmx.de> | 2021-05-08 16:14:57 +0300 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2021-06-17 14:21:44 +0300 |
commit | 5c1c78e0a0a2f37de0b05851878af8e02eeae02f (patch) | |
tree | a0962a64c1aa939d9cfaa1974fd3ea14dd07e3b1 /drivers/hwmon | |
parent | 989c9c675bbbf3264b42b05e8924a9930b500e6c (diff) | |
download | linux-5c1c78e0a0a2f37de0b05851878af8e02eeae02f.tar.xz |
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>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/sch56xx-common.c | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c index 04739bbff8f9..40cdadad35e5 100644 --- a/drivers/hwmon/sch56xx-common.c +++ b/drivers/hwmon/sch56xx-common.c @@ -504,37 +504,18 @@ static int __init sch56xx_device_add(int address, const char *name) struct resource res = { .start = address, .end = address + REGION_LENGTH - 1, + .name = name, .flags = IORESOURCE_IO, }; int err; - sch56xx_pdev = platform_device_alloc(name, address); - if (!sch56xx_pdev) - return -ENOMEM; - - res.name = sch56xx_pdev->name; err = acpi_check_resource_conflict(&res); if (err) - goto exit_device_put; - - err = platform_device_add_resources(sch56xx_pdev, &res, 1); - if (err) { - pr_err("Device resource addition failed\n"); - goto exit_device_put; - } - - err = platform_device_add(sch56xx_pdev); - if (err) { - pr_err("Device addition failed\n"); - goto exit_device_put; - } - - return 0; + return err; -exit_device_put: - platform_device_put(sch56xx_pdev); + sch56xx_pdev = platform_device_register_simple(name, -1, &res, 1); - return err; + return PTR_ERR_OR_ZERO(sch56xx_pdev); } static int __init sch56xx_init(void) |