Commit 4678a2d3 authored by John Garry's avatar John Garry Committed by Wei Xu

bus: hisi_lpc: Use platform_device_register_full()

The code to create the child platform device is essentially the same as
what platform_device_register_full() does, so change over to use
that same function to reduce duplication.
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Suggested-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarWei Xu <xuwei5@hisilicon.com>
parent e8cd6506
...@@ -472,9 +472,7 @@ static int hisi_lpc_acpi_clear_enumerated(struct acpi_device *adev, void *not_us ...@@ -472,9 +472,7 @@ static int hisi_lpc_acpi_clear_enumerated(struct acpi_device *adev, void *not_us
struct hisi_lpc_acpi_cell { struct hisi_lpc_acpi_cell {
const char *hid; const char *hid;
const char *name; const struct platform_device_info *pdevinfo;
void *pdata;
size_t pdata_size;
}; };
static void hisi_lpc_acpi_remove(struct device *hostdev) static void hisi_lpc_acpi_remove(struct device *hostdev)
...@@ -505,28 +503,45 @@ static int hisi_lpc_acpi_add_child(struct acpi_device *child, void *data) ...@@ -505,28 +503,45 @@ static int hisi_lpc_acpi_add_child(struct acpi_device *child, void *data)
/* ipmi */ /* ipmi */
{ {
.hid = "IPI0001", .hid = "IPI0001",
.name = "hisi-lpc-ipmi", .pdevinfo = (struct platform_device_info []) {
{
.parent = hostdev,
.fwnode = acpi_fwnode_handle(child),
.name = "hisi-lpc-ipmi",
.id = PLATFORM_DEVID_AUTO,
.res = res,
.num_res = num_res,
},
},
}, },
/* 8250-compatible uart */ /* 8250-compatible uart */
{ {
.hid = "HISI1031", .hid = "HISI1031",
.name = "serial8250", .pdevinfo = (struct platform_device_info []) {
.pdata = (struct plat_serial8250_port []) {
{ {
.iobase = res->start, .parent = hostdev,
.uartclk = 1843200, .fwnode = acpi_fwnode_handle(child),
.iotype = UPIO_PORT, .name = "serial8250",
.flags = UPF_BOOT_AUTOCONF, .id = PLATFORM_DEVID_AUTO,
.res = res,
.num_res = num_res,
.data = (struct plat_serial8250_port []) {
{
.iobase = res->start,
.uartclk = 1843200,
.iotype = UPIO_PORT,
.flags = UPF_BOOT_AUTOCONF,
},
{}
},
.size_data = 2 * sizeof(struct plat_serial8250_port),
}, },
{}
}, },
.pdata_size = 2 *
sizeof(struct plat_serial8250_port),
}, },
{} {}
}; };
for (; cell && cell->name; cell++) { for (; cell && cell->hid; cell++) {
if (!strcmp(cell->hid, hid)) { if (!strcmp(cell->hid, hid)) {
found = true; found = true;
break; break;
...@@ -540,31 +555,12 @@ static int hisi_lpc_acpi_add_child(struct acpi_device *child, void *data) ...@@ -540,31 +555,12 @@ static int hisi_lpc_acpi_add_child(struct acpi_device *child, void *data)
return 0; return 0;
} }
pdev = platform_device_alloc(cell->name, PLATFORM_DEVID_AUTO); pdev = platform_device_register_full(cell->pdevinfo);
if (!pdev) if (IS_ERR(pdev))
return -ENOMEM; return PTR_ERR(pdev);
pdev->dev.parent = hostdev;
ACPI_COMPANION_SET(&pdev->dev, child);
ret = platform_device_add_resources(pdev, res, num_res);
if (ret)
goto fail;
ret = platform_device_add_data(pdev, cell->pdata, cell->pdata_size);
if (ret)
goto fail;
ret = platform_device_add(pdev);
if (ret)
goto fail;
acpi_device_set_enumerated(child); acpi_device_set_enumerated(child);
return 0; return 0;
fail:
platform_device_put(pdev);
return ret;
} }
/* /*
......
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