Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp587555rwe; Thu, 1 Sep 2022 04:54:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR42/EtcJZbTxcmKriNXdBx3WjM77WDS2C2DehhOln17FYsRrYtDmXCykhOFPvn5MD61Vy25 X-Received: by 2002:a17:90b:4ac3:b0:1fd:ded0:ea80 with SMTP id mh3-20020a17090b4ac300b001fdded0ea80mr8035524pjb.142.1662033247297; Thu, 01 Sep 2022 04:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662033247; cv=none; d=google.com; s=arc-20160816; b=D/MfCmJ9CbA2TvPu9bkdU882Hu4S9bbZrBd1q+fmw12sw32HBRwRfc4yCQDFE0tENH zf1s+u96PdNC8Xzckg9mnEuhEZAdbklS+7QNSWdKkYWO81Yf/hxHOSnAHNgxA0Yw1kaW BtP4RXPE5UGnL2TzAIr/uqen8snIgik2Q2D3/JF2A1nG06ln+dHV1sZyape9Ik66b0oZ vowpD/fIye9QNv7s9LMMgDtJTY/JFJ47/RtokSG5zRw2YwSE4BPmsPsEpAcGUVBRBFdc 1OY8ZP6O0M3Z5D0WLMhjRopxmVaUBCpKV3FYOnhoVf9++x0zPq265fuzsMEUCORC7TeG dUbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=M5iDx6QD/jNV2htyymQrLh9oFs47JxzJiildk0tkLu8=; b=jOhclpWpVikzjOc+LH3XtqvwmcW4ZXPWJjUQOCDxifeF421HmKaiHTtqSwy0fMJYaz iWCqFWHkqniis3uDTW8CDuUolUXyLCw8leh1rak3MS52k0JDucbaiPGr37KtxABU6wsQ 48NXRv81/34Ph+ao1ZUktGC48wdlDI2av8reNzz2JNngpojZ9Sz/RK2flPPYLJeF0Cpq 4zLFsqCYjjCTwB9y89GnzZFgQBrkqdBYRgYJE9Kri/HKmLGndO3ZeuMHSVurCSu7Mp3M os9Nb9dxuRd/XXIL70u0gbwope1JJnlvZbWBtVZSBZnZ2JVl54d2kz7i+e9JhVeoAv+W BsQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a056a000c8400b0053815aa4c51si13463741pfv.195.2022.09.01.04.53.56; Thu, 01 Sep 2022 04:54:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234462AbiIALV2 (ORCPT + 99 others); Thu, 1 Sep 2022 07:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234279AbiIALVO (ORCPT ); Thu, 1 Sep 2022 07:21:14 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18FCE125B90 for ; Thu, 1 Sep 2022 04:21:13 -0700 (PDT) Received: from fraeml709-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MJJW81QP1z682sP; Thu, 1 Sep 2022 19:20:36 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml709-chm.china.huawei.com (10.206.15.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 1 Sep 2022 13:21:11 +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.24; Thu, 1 Sep 2022 12:21:09 +0100 From: John Garry To: CC: , , , , , , John Garry Subject: [PATCH 5/5] bus: hisi_lpc: Use platform_device_register_full() Date: Thu, 1 Sep 2022 19:14:31 +0800 Message-ID: <1662030871-182688-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1662030871-182688-1-git-send-email-john.garry@huawei.com> References: <1662030871-182688-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/bus/hisi_lpc.c | 70 ++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c index 74f4448bff9d..2203ee57eaaf 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_device *adev, void *not_us struct hisi_lpc_acpi_cell { const char *hid; - const char *name; - void *pdata; - size_t pdata_size; + const struct platform_device_info *pdevinfo; }; static void hisi_lpc_acpi_remove(struct device *hostdev) @@ -505,28 +503,51 @@ static int hisi_lpc_acpi_add_child(struct acpi_device *child, void *data) /* ipmi */ { .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 */ { .hid = "HISI1031", - .name = "serial8250", - .pdata = (struct plat_serial8250_port []) { + .pdevinfo = (struct platform_device_info []) { { - .iobase = res->start, - .uartclk = 1843200, - .iotype = UPIO_PORT, - .flags = UPF_BOOT_AUTOCONF, + .parent = hostdev, + .fwnode = acpi_fwnode_handle(child), + + .name = "serial8250", + .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)) { found = true; break; @@ -540,31 +561,12 @@ static int hisi_lpc_acpi_add_child(struct acpi_device *child, void *data) return 0; } - pdev = platform_device_alloc(cell->name, PLATFORM_DEVID_AUTO); + pdev = platform_device_register_full(cell->pdevinfo); if (!pdev) return -ENOMEM; - 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); return 0; - -fail: - platform_device_put(pdev); - return ret; } /* -- 2.35.3