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

Configure Feed

Select the types of activity you want to include in your feed.

mfd: kempld: Simplify device registration

Use platform_device_register_full() instead of open coding this
function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240223195113.880121-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Andy Shevchenko and committed by
Lee Jones
f0336cc4 b5036277

+13 -20
+13 -20
drivers/mfd/kempld-core.c
··· 6 6 * Author: Michael Brunner <michael.brunner@kontron.com> 7 7 */ 8 8 9 + #include <linux/err.h> 9 10 #include <linux/platform_device.h> 10 11 #include <linux/mfd/core.h> 11 12 #include <linux/mfd/kempld.h> ··· 132 131 static int kempld_create_platform_device(const struct dmi_system_id *id) 133 132 { 134 133 const struct kempld_platform_data *pdata = id->driver_data; 135 - int ret; 134 + const struct platform_device_info pdevinfo = { 135 + .name = "kempld", 136 + .id = PLATFORM_DEVID_NONE, 137 + .res = pdata->ioresource, 138 + .num_res = 1, 139 + .data = pdata, 140 + .size_data = sizeof(*pdata), 141 + }; 136 142 137 - kempld_pdev = platform_device_alloc("kempld", -1); 138 - if (!kempld_pdev) 139 - return -ENOMEM; 140 - 141 - ret = platform_device_add_data(kempld_pdev, pdata, sizeof(*pdata)); 142 - if (ret) 143 - goto err; 144 - 145 - ret = platform_device_add_resources(kempld_pdev, pdata->ioresource, 1); 146 - if (ret) 147 - goto err; 148 - 149 - ret = platform_device_add(kempld_pdev); 150 - if (ret) 151 - goto err; 143 + kempld_pdev = platform_device_register_full(&pdevinfo); 144 + if (IS_ERR(kempld_pdev)) 145 + return PTR_ERR(kempld_pdev); 152 146 153 147 return 0; 154 - err: 155 - platform_device_put(kempld_pdev); 156 - return ret; 157 148 } 158 149 159 150 /** ··· 417 424 struct resource *ioport; 418 425 int ret; 419 426 420 - if (kempld_pdev == NULL) { 427 + if (IS_ERR_OR_NULL(kempld_pdev)) { 421 428 /* 422 429 * No kempld_pdev device has been registered in kempld_init, 423 430 * so we seem to be probing an ACPI platform device.