Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp882911pxf; Wed, 7 Apr 2021 14:04:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJhc01W3pPUIcDdUj9slBKfxb3f6PwsaoKCBwYqz8rPuQMzITfLQHkRR0PaXzGSykkVDGO X-Received: by 2002:a6b:b251:: with SMTP id b78mr3948424iof.95.1617829499193; Wed, 07 Apr 2021 14:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617829499; cv=none; d=google.com; s=arc-20160816; b=MA1mZ0hONGHV+vC9rjVlgW4wVr6vgXx8wwPiQdRcNx8V4gFpNQ/ybN8Iz6kSo61wgR foJxarmIswEGTNLSfCaKFx4lBduz2wjOuTLX85nuWYTwHSsxzObgojnE68AnAJY3/dzz YcpnJDW8kNItcAhnS9Oos0fUmdqx2Z9fmhlyzgdylIvzLODcjHGThyrs+KUzwJ0U2G4/ 4p8dmYVQZA2nJahaNLDKESDVcftjLj13Ew91K9+FKkO3VR5B/HeK/z8zUjNtcVZdH2zR opQJCAdlZhUzydGL7j8jLagkkT7OIo2gxqfBKi3z0W42sPZH9Mq3Uu9bGcl5z5n23kYS o83w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ROsQVEIrefaOCQ2KOHJsWbwIz6cyD7bG4pr9XdjN3xE=; b=IIR00cVlfL+jB05Aae+aKA+HZYyctGdqgv3OYaWSVWly1d+Jx/jR0BpeCtt37mkxyh d4wYs6AY/aq2TXQJIW0h0uKaREqVPdfx+4Mh2G8b8z7TdON4WFU4RVaSx3rlui8UODGL gdH94bLsG1d+m/Q2Qux/MPIVm0d7qbl3mjrzyiWOUAKwgXmmvET3kU1oOaM055YhdqNm M+9UdtzmdLxWKM5MLEUj2pFySDqqsdlFHAQ37n8vcIe0dur5b4fF30ve6KeAK+N/zL7a Trtq73C/E8SlHj9W7+znjOb1bfz/JI2D2OjkeeytT2MVP5CfT9VcwSQyo3Yc7+dBZ49X SFYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 15si24091747ilt.42.2021.04.07.14.04.47; Wed, 07 Apr 2021 14:04:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352988AbhDGOeR (ORCPT + 99 others); Wed, 7 Apr 2021 10:34:17 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:42118 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352977AbhDGOeD (ORCPT ); Wed, 7 Apr 2021 10:34:03 -0400 Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 2.0.3) id ebc5461653ed92d7; Wed, 7 Apr 2021 16:33:53 +0200 Received: from kreacher.localnet (89-64-81-116.dynamic.chello.pl [89.64.81.116]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 69565669203; Wed, 7 Apr 2021 16:33:52 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Hans de Goede Subject: [PATCH v1 5/5] ACPI: scan: Call acpi_get_object_info() from acpi_set_pnp_ids() Date: Wed, 07 Apr 2021 16:33:38 +0200 Message-ID: <2137295.iZASKD2KPV@kreacher> In-Reply-To: <2192169.ElGaqSPkdT@kreacher> References: <2192169.ElGaqSPkdT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.64.81.116 X-CLIENT-HOSTNAME: 89-64-81-116.dynamic.chello.pl X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrudejjedgjeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepkeelrdeigedrkedurdduudeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepkeelrdeigedrkedurdduudeipdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohephhguvghgohgvuggvsehrvgguhhgrthdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Notice that it is not necessary to call acpi_get_object_info() from acpi_add_single_object() in order to pass the pointer returned by it to acpi_init_device_object() and from there to acpi_set_pnp_ids(). It is more straightforward to call acpi_get_object_info() from acpi_set_pnp_ids() and avoid unnecessary pointer passing, so change the code accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/internal.h | 2 +- drivers/acpi/power.c | 2 +- drivers/acpi/scan.c | 21 +++++++++------------ 3 files changed, 11 insertions(+), 14 deletions(-) Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -1307,8 +1307,9 @@ static bool acpi_object_is_system_bus(ac } static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, - int device_type, struct acpi_device_info *info) + int device_type) { + struct acpi_device_info *info = NULL; struct acpi_pnp_device_id_list *cid_list; int i; @@ -1319,6 +1320,7 @@ static void acpi_set_pnp_ids(acpi_handle break; } + acpi_get_object_info(handle, &info); if (!info) { pr_err(PREFIX "%s: Error reading device info\n", __func__); @@ -1344,6 +1346,8 @@ static void acpi_set_pnp_ids(acpi_handle if (info->valid & ACPI_VALID_CLS) acpi_add_id(pnp, info->class_code.string); + kfree(info); + /* * Some devices don't reliably have _HIDs & _CIDs, so add * synthetic HIDs to make sure drivers can find them. @@ -1649,7 +1653,7 @@ static bool acpi_device_enumeration_by_p } void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, - int type, struct acpi_device_info *info) + int type) { INIT_LIST_HEAD(&device->pnp.ids); device->device_type = type; @@ -1658,7 +1662,7 @@ void acpi_init_device_object(struct acpi fwnode_init(&device->fwnode, &acpi_device_fwnode_ops); acpi_set_device_status(device, ACPI_STA_DEFAULT); acpi_device_get_busid(device); - acpi_set_pnp_ids(handle, &device->pnp, type, info); + acpi_set_pnp_ids(handle, &device->pnp, type); acpi_init_properties(device); acpi_bus_get_flags(device); device->flags.match_driver = false; @@ -1688,21 +1692,14 @@ static void acpi_scan_init_status(struct static int acpi_add_single_object(struct acpi_device **child, acpi_handle handle, int type) { - struct acpi_device_info *info = NULL; struct acpi_device *device; int result; - if (type == ACPI_BUS_TYPE_DEVICE && handle != ACPI_ROOT_OBJECT) - acpi_get_object_info(handle, &info); - device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL); - if (!device) { - kfree(info); + if (!device) return -ENOMEM; - } - acpi_init_device_object(device, handle, type, info); - kfree(info); + acpi_init_device_object(device, handle, type); /* * Getting the status is delayed till here so that we can call * acpi_bus_get_status() and use its quirk handling. Note that Index: linux-pm/drivers/acpi/internal.h =================================================================== --- linux-pm.orig/drivers/acpi/internal.h +++ linux-pm/drivers/acpi/internal.h @@ -109,7 +109,7 @@ struct acpi_device_bus_id { int acpi_device_add(struct acpi_device *device, void (*release)(struct device *)); void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, - int type, struct acpi_device_info *info); + int type); int acpi_device_setup_files(struct acpi_device *dev); void acpi_device_remove_files(struct acpi_device *dev); void acpi_device_add_finalize(struct acpi_device *device); Index: linux-pm/drivers/acpi/power.c =================================================================== --- linux-pm.orig/drivers/acpi/power.c +++ linux-pm/drivers/acpi/power.c @@ -925,7 +925,7 @@ int acpi_add_power_resource(acpi_handle return -ENOMEM; device = &resource->device; - acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, NULL); + acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER); mutex_init(&resource->resource_lock); INIT_LIST_HEAD(&resource->list_node); INIT_LIST_HEAD(&resource->dependents);