Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1655842rwe; Fri, 2 Sep 2022 01:10:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR6pSzBdlj9vxINXuIhJfiy8Srq4RceULWRPHPUU+mXX4TEKKmIc7O5PgJGWOiR5iDPEQq6V X-Received: by 2002:a17:907:7b95:b0:731:113a:d7a2 with SMTP id ne21-20020a1709077b9500b00731113ad7a2mr25532881ejc.377.1662106248708; Fri, 02 Sep 2022 01:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662106248; cv=none; d=google.com; s=arc-20160816; b=LorKqD6GtXX3WuRmgFxNuwGHMgCSS3/HTnqrP/OkNmQVq+Yw8UKawEwpq2gKk1gJJT bxGNgT54YO0qnLurxlQx9YBMHcOoDGcznpdtBwI7CpDFU++SjQWY8vltfeGAs54vSpPU NQu+JrCWEaVe3sXmvyZiZ9Pl/mIkLwVG279MgAI77jr6gZXJ9x+lft2rgazqNwKXkrOT W+6qKJNLLDzbO4Rdqk9Lo5hl8HD19mUqJLyup7e4AZeg+2OBsi+MPOaX7Wa2BPdUPpCa 7pmAtodtlv82/y1KUZLG08j4rXLvyCqOLiHwbF7vigt6Idu+5M6fz9hU9W8dsIh9Cl2z Bytg== 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=7FWgID/U2dfvdGb/TU11/jfPeyjb0PNg1jowGcu9h+8=; b=B6SaEyQ7loDpWDx1O4lyvZ1F0HM4QEHG55nZfwgywJqujMP/QZOy1NuZRy+bFm3DGs 50Lll8DOE3B4ANx4IDFu8Ij/j+T4cVswW777Wpljc6WwXLA8oXirIKw/JxkCqKqU7uha 2ZsNMwXpmJKn3C0zT9uMezBssqMBigAAz6agMFVSXHu7YeVIXTLJlRl7IurZJaru2aaG 4YCi7WlwIWfAxnf+NQllXlUsUwpcGnv5jb2vwRppKuviN5+Tj06JDFu0aHcV9iEB814L o+GGXXhpQbH2uolkN5ljWcHffQ85itaN7va7isCqSJwXnQ5+MisPfDi0oy8qYuibw8lW dRMw== 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 qa15-20020a170907868f00b00730a20dd838si1466967ejc.84.2022.09.02.01.10.23; Fri, 02 Sep 2022 01:10:48 -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 S235325AbiIBHy3 (ORCPT + 99 others); Fri, 2 Sep 2022 03:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235508AbiIBHyS (ORCPT ); Fri, 2 Sep 2022 03:54:18 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42013BB693 for ; Fri, 2 Sep 2022 00:54:15 -0700 (PDT) Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MJqsr24rJz67wrR; Fri, 2 Sep 2022 15:53:36 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Fri, 2 Sep 2022 09:54:12 +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; Fri, 2 Sep 2022 08:54:10 +0100 From: John Garry To: CC: , , , , , , John Garry Subject: [PATCH v2 5/5] bus: hisi_lpc: Use platform_device_register_full() Date: Fri, 2 Sep 2022 15:47:21 +0800 Message-ID: <1662104841-55360-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1662104841-55360-1-git-send-email-john.garry@huawei.com> References: <1662104841-55360-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: dggems702-chm.china.huawei.com (10.3.19.179) 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 | 64 ++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c index 74f4448bff9d..3555a6857214 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,45 @@ 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 +555,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