Commit 5c1c78e0 authored by Armin Wolf's avatar Armin Wolf Committed by Guenter Roeck

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: default avatarArmin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210508131457.12780-5-W_Armin@gmx.deReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 989c9c67
...@@ -504,37 +504,18 @@ static int __init sch56xx_device_add(int address, const char *name) ...@@ -504,37 +504,18 @@ static int __init sch56xx_device_add(int address, const char *name)
struct resource res = { struct resource res = {
.start = address, .start = address,
.end = address + REGION_LENGTH - 1, .end = address + REGION_LENGTH - 1,
.name = name,
.flags = IORESOURCE_IO, .flags = IORESOURCE_IO,
}; };
int err; 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); err = acpi_check_resource_conflict(&res);
if (err) if (err)
goto exit_device_put; return err;
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;
exit_device_put: sch56xx_pdev = platform_device_register_simple(name, -1, &res, 1);
platform_device_put(sch56xx_pdev);
return err; return PTR_ERR_OR_ZERO(sch56xx_pdev);
} }
static int __init sch56xx_init(void) static int __init sch56xx_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment