From nobody Mon Apr 6 21:32:20 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FA98ECAAA1 for ; Mon, 5 Sep 2022 08:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237395AbiIEIbv (ORCPT ); Mon, 5 Sep 2022 04:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236849AbiIEIbJ (ORCPT ); Mon, 5 Sep 2022 04:31:09 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E407413E07 for ; Mon, 5 Sep 2022 01:29:38 -0700 (PDT) Received: from fraeml734-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MLhWC4KbTz6889W; Mon, 5 Sep 2022 16:28:55 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml734-chm.china.huawei.com (10.206.15.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 5 Sep 2022 10:29:36 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 5 Sep 2022 09:29:34 +0100 From: John Garry To: CC: , , , , , , John Garry Subject: [PATCH v3 5/5] bus: hisi_lpc: Use platform_device_register_full() Date: Mon, 5 Sep 2022 16:23:06 +0800 Message-ID: <1662366186-233933-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1662366186-233933-1-git-send-email-john.garry@huawei.com> References: <1662366186-233933-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: John Garry Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko --- drivers/bus/hisi_lpc.c | 68 ++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c index 74f4448bff9d..5b65a48f17e7 100644 --- a/drivers/bus/hisi_lpc.c +++ b/drivers/bus/hisi_lpc.c @@ -472,9 +472,7 @@ static int hisi_lpc_acpi_clear_enumerated(struct acpi_d= evice *adev, void *not_us =20 struct hisi_lpc_acpi_cell { const char *hid; - const char *name; - void *pdata; - size_t pdata_size; + const struct platform_device_info *pdevinfo; }; =20 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) /* ipmi */ { .hid =3D "IPI0001", - .name =3D "hisi-lpc-ipmi", + .pdevinfo =3D (struct platform_device_info []) { + { + .parent =3D hostdev, + .fwnode =3D acpi_fwnode_handle(child), + .name =3D "hisi-lpc-ipmi", + .id =3D PLATFORM_DEVID_AUTO, + .res =3D res, + .num_res =3D num_res, + }, + }, }, /* 8250-compatible uart */ { .hid =3D "HISI1031", - .name =3D "serial8250", - .pdata =3D (struct plat_serial8250_port []) { + .pdevinfo =3D (struct platform_device_info []) { { - .iobase =3D res->start, - .uartclk =3D 1843200, - .iotype =3D UPIO_PORT, - .flags =3D UPF_BOOT_AUTOCONF, + .parent =3D hostdev, + .fwnode =3D acpi_fwnode_handle(child), + .name =3D "serial8250", + .id =3D PLATFORM_DEVID_AUTO, + .res =3D res, + .num_res =3D num_res, + .data =3D (struct plat_serial8250_port []) { + { + .iobase =3D res->start, + .uartclk =3D 1843200, + .iotype =3D UPIO_PORT, + .flags =3D UPF_BOOT_AUTOCONF, + }, + {} + }, + .size_data =3D 2 * sizeof(struct plat_serial8250_port), }, - {} }, - .pdata_size =3D 2 * - sizeof(struct plat_serial8250_port), }, {} }; =20 - for (; cell && cell->name; cell++) { + for (; cell && cell->hid; cell++) { if (!strcmp(cell->hid, hid)) { found =3D true; break; @@ -540,31 +555,12 @@ static int hisi_lpc_acpi_add_child(struct acpi_device= *child, void *data) return 0; } =20 - pdev =3D platform_device_alloc(cell->name, PLATFORM_DEVID_AUTO); - if (!pdev) - return -ENOMEM; - - pdev->dev.parent =3D hostdev; - ACPI_COMPANION_SET(&pdev->dev, child); - - ret =3D platform_device_add_resources(pdev, res, num_res); - if (ret) - goto fail; - - ret =3D platform_device_add_data(pdev, cell->pdata, cell->pdata_size); - if (ret) - goto fail; - - ret =3D platform_device_add(pdev); - if (ret) - goto fail; + pdev =3D platform_device_register_full(cell->pdevinfo); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); =20 acpi_device_set_enumerated(child); return 0; - -fail: - platform_device_put(pdev); - return ret; } =20 /* --=20 2.35.3