Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2237567pxb; Mon, 18 Jan 2021 11:57:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxB0mIqhdm8PaBwFPPrP5kXclbvYpXGGyvzyw1NG/kkFv8yNGvHyWULUXKcDMVvh/T9vyKJ X-Received: by 2002:a05:6402:b07:: with SMTP id bm7mr853459edb.104.1610999855062; Mon, 18 Jan 2021 11:57:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610999855; cv=none; d=google.com; s=arc-20160816; b=d9TR6cnCExcbJ6vV+T1u+Hy22tAEmS/GGElsWvZ+x8Vgu0rZJfM5HqXgCir+vafkEr CCEAszTX2hYh/cdYpXFGlDA6Y3vAYRZMMudGiNl5qwRKL2e0tqgNzBiqC70gIp1JHKLE sYax0CCqrb0sDoRvsPiIyYVUTdPO7aOlaeLqKT5e/rK6qn6hnJE7TUq7qLjYSvcohKty WtRUpM4va3gBQjV3pnu1A8Tcsq32bayNAjvt/pWfNObkRzzvnj9wuqYiPdrYjo0TPuJb R+V5tuSediy4P8QM5raFzFKWEAQDMTH4RJqtk+2rjIue5IZBGkobUrr+sLYTt3Tq00Vn l9Dg== 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 :message-id:date:subject:cc:to:from; bh=V8HqEI1+fselTGUAMdHW9NexUKLP7kBez38DcYSn+t8=; b=TcMkwx2YZ48oBJjca6w/mWKiUrefxhK/OXn/PSseyv34PqZVmy/M2wpiYfqnzTb9f9 499HvYxrtXYSn2Gw9JXS1K+FYdTrXEGX6ZEjDqP8Vfkbb86SGbT+xo93NnW5k80oKD6B 3ARsV2Yz5cRbu38Q3kJRjs6vmOZOk345146mVOcws49DHihb2mvkUDcBHRXHMzQ5dGUi I8xxA4q7ZalUOc0Ltx2e0DP8HTp2QwMlcrkYiqcS302Tx59RoedShRgAu97zDiQEi683 NSkg75TkjO1LZEPtT4sRMSpnpWCDlJbRIVRt9goQRbyz0auesmIfoSNaXgi+uRu3HT+g xrSw== 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 e8si4621647ejj.540.2021.01.18.11.57.11; Mon, 18 Jan 2021 11:57:35 -0800 (PST) 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 S2437381AbhARTxW (ORCPT + 99 others); Mon, 18 Jan 2021 14:53:22 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:47536 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393965AbhART0e (ORCPT ); Mon, 18 Jan 2021 14:26:34 -0500 Received: from 89-64-82-41.dynamic.chello.pl (89.64.82.41) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.537) id 29d09316bb40c20e; Mon, 18 Jan 2021 20:25:37 +0100 From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Hans de Goede Subject: [PATCH] ACPI: scan: Rearrange code related to acpi_get_device_data() Date: Mon, 18 Jan 2021 20:25:37 +0100 Message-ID: <3445520.6OZ3MRzmT7@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki There are two callers of acpi_get_device_data(), acpi_bus_get_device() and acpi_bus_get_acpi_device(), but only one of them takes the int return value into account. Moreover, the latter knows that it passes a valid return pointer to acpi_get_device_data() and it properly clears that pointer upfront, so it doesn't need acpi_get_device_data() to do that. For this reason, rearrange acpi_get_device_data() to return a strct acpi_device pointer instead of an int and adapt its callers to that. While at it, rename acpi_get_device_data() to handle_to_device(), because the old name does not really reflect the functionality provided by that function. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- On top of https://patchwork.kernel.org/project/linux-acpi/patch/20210115215752.389656-1-hdegoede@redhat.com/ --- drivers/acpi/scan.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -578,29 +578,31 @@ static void acpi_scan_drop_device(acpi_h mutex_unlock(&acpi_device_del_lock); } -static int acpi_get_device_data(acpi_handle handle, struct acpi_device **device, - void (*callback)(void *)) +static struct acpi_device *handle_to_device(acpi_handle handle, + void (*callback)(void *)) { + struct acpi_device *adev = NULL; acpi_status status; - if (!device) - return -EINVAL; - - *device = NULL; - status = acpi_get_data_full(handle, acpi_scan_drop_device, - (void **)device, callback); - if (ACPI_FAILURE(status) || !*device) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", - handle)); - return -ENODEV; + (void **)&adev, callback); + if (ACPI_FAILURE(status) || !adev) { + acpi_handle_debug(handle, "No context!\n"); + return NULL; } - return 0; + return adev; } int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) { - return acpi_get_device_data(handle, device, NULL); + if (!device) + return -EINVAL; + + *device = handle_to_device(handle, NULL); + if (!*device) + return -ENODEV; + + return 0; } EXPORT_SYMBOL(acpi_bus_get_device); @@ -612,10 +614,7 @@ static void get_acpi_device(void *dev) struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle) { - struct acpi_device *adev = NULL; - - acpi_get_device_data(handle, &adev, get_acpi_device); - return adev; + return handle_to_device(handle, get_acpi_device); } void acpi_bus_put_acpi_device(struct acpi_device *adev)