Commit f0336cc4 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Lee Jones

mfd: kempld: Simplify device registration

Use platform_device_register_full() instead of open coding this
function.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240223195113.880121-4-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent b5036277
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* Author: Michael Brunner <michael.brunner@kontron.com> * Author: Michael Brunner <michael.brunner@kontron.com>
*/ */
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/kempld.h> #include <linux/mfd/kempld.h>
...@@ -131,28 +132,20 @@ static struct platform_device *kempld_pdev; ...@@ -131,28 +132,20 @@ static struct platform_device *kempld_pdev;
static int kempld_create_platform_device(const struct dmi_system_id *id) static int kempld_create_platform_device(const struct dmi_system_id *id)
{ {
const struct kempld_platform_data *pdata = id->driver_data; const struct kempld_platform_data *pdata = id->driver_data;
int ret; const struct platform_device_info pdevinfo = {
.name = "kempld",
kempld_pdev = platform_device_alloc("kempld", -1); .id = PLATFORM_DEVID_NONE,
if (!kempld_pdev) .res = pdata->ioresource,
return -ENOMEM; .num_res = 1,
.data = pdata,
ret = platform_device_add_data(kempld_pdev, pdata, sizeof(*pdata)); .size_data = sizeof(*pdata),
if (ret) };
goto err;
ret = platform_device_add_resources(kempld_pdev, pdata->ioresource, 1); kempld_pdev = platform_device_register_full(&pdevinfo);
if (ret) if (IS_ERR(kempld_pdev))
goto err; return PTR_ERR(kempld_pdev);
ret = platform_device_add(kempld_pdev);
if (ret)
goto err;
return 0; return 0;
err:
platform_device_put(kempld_pdev);
return ret;
} }
/** /**
...@@ -424,7 +417,7 @@ static int kempld_probe(struct platform_device *pdev) ...@@ -424,7 +417,7 @@ static int kempld_probe(struct platform_device *pdev)
struct resource *ioport; struct resource *ioport;
int ret; int ret;
if (kempld_pdev == NULL) { if (IS_ERR_OR_NULL(kempld_pdev)) {
/* /*
* No kempld_pdev device has been registered in kempld_init, * No kempld_pdev device has been registered in kempld_init,
* so we seem to be probing an ACPI platform device. * so we seem to be probing an ACPI platform device.
......
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