From patchwork Wed Oct 6 17:31:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1537317 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4HPhMN0kStz9sRN for ; Thu, 7 Oct 2021 04:31:28 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238119AbhJFRdS (ORCPT ); Wed, 6 Oct 2021 13:33:18 -0400 Received: from mga14.intel.com ([192.55.52.115]:37987 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbhJFRdR (ORCPT ); Wed, 6 Oct 2021 13:33:17 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10129"; a="226368285" X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="226368285" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2021 10:31:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="484200637" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 06 Oct 2021 10:31:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5DEDD159; Wed, 6 Oct 2021 20:31:27 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Saravana Kannan , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org Cc: "Rafael J. Wysocki" , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Wolfram Sang Subject: [PATCH v2 1/3] driver core: Provide device_match_acpi_handle() helper Date: Wed, 6 Oct 2021 20:31:23 +0300 Message-Id: <20211006173125.84423-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org We have couple of users of this helper, make it available for them. Signed-off-by: Andy Shevchenko --- v2: fixed compilation error (Greg) drivers/base/core.c | 6 ++++++ include/linux/device/bus.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index c4a2c97a21a2..3a5623ea1369 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4840,6 +4840,12 @@ int device_match_acpi_dev(struct device *dev, const void *adev) } EXPORT_SYMBOL(device_match_acpi_dev); +int device_match_acpi_handle(struct device *dev, const void *handle) +{ + return ACPI_HANDLE(dev) == handle; +} +EXPORT_SYMBOL(device_match_acpi_handle); + int device_match_any(struct device *dev, const void *unused) { return 1; diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h index 062777a45a74..a039ab809753 100644 --- a/include/linux/device/bus.h +++ b/include/linux/device/bus.h @@ -143,6 +143,7 @@ int device_match_of_node(struct device *dev, const void *np); int device_match_fwnode(struct device *dev, const void *fwnode); int device_match_devt(struct device *dev, const void *pdevt); int device_match_acpi_dev(struct device *dev, const void *adev); +int device_match_acpi_handle(struct device *dev, const void *handle); int device_match_any(struct device *dev, const void *unused); /* iterator helpers for buses */ From patchwork Wed Oct 6 17:31:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1537314 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4HPhMM0tSDz9sRN for ; Thu, 7 Oct 2021 04:31:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231617AbhJFRdR (ORCPT ); Wed, 6 Oct 2021 13:33:17 -0400 Received: from mga05.intel.com ([192.55.52.43]:17584 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231175AbhJFRdQ (ORCPT ); Wed, 6 Oct 2021 13:33:16 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10129"; a="312263256" X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="312263256" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2021 10:31:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="589841439" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 06 Oct 2021 10:31:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6784056; Wed, 6 Oct 2021 20:31:27 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Saravana Kannan , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org Cc: "Rafael J. Wysocki" , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Wolfram Sang Subject: [PATCH v2 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Date: Wed, 6 Oct 2021 20:31:24 +0300 Message-Id: <20211006173125.84423-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211006173125.84423-1-andriy.shevchenko@linux.intel.com> References: <20211006173125.84423-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Since driver core provides a generic device_match_acpi_handle() we may replace the custom one with it. This unifies code to find an adapter with the similar one which finds a client. Signed-off-by: Andy Shevchenko --- v2: no changes drivers/i2c/i2c-core-acpi.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 7ea2ac712a57..0aea776cd4c9 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -398,24 +398,20 @@ u32 i2c_acpi_find_bus_speed(struct device *dev) } EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed); -static int i2c_acpi_find_match_adapter(struct device *dev, const void *data) -{ - struct i2c_adapter *adapter = i2c_verify_adapter(dev); - - if (!adapter) - return 0; - - return ACPI_HANDLE(dev) == (acpi_handle)data; -} - struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle) { + struct i2c_adapter *adapter; struct device *dev; - dev = bus_find_device(&i2c_bus_type, NULL, handle, - i2c_acpi_find_match_adapter); + dev = bus_find_device(&i2c_bus_type, NULL, handle, device_match_acpi_handle); + if (!dev) + return NULL; + + adapter = i2c_verify_adapter(dev); + if (!adapter) + put_device(dev); - return dev ? i2c_verify_adapter(dev) : NULL; + return adapter; } EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle); From patchwork Wed Oct 6 17:31:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1537316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4HPhMM58Nnz9sXS for ; Thu, 7 Oct 2021 04:31:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238554AbhJFRdR (ORCPT ); Wed, 6 Oct 2021 13:33:17 -0400 Received: from mga09.intel.com ([134.134.136.24]:57494 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238337AbhJFRdQ (ORCPT ); Wed, 6 Oct 2021 13:33:16 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10129"; a="225948671" X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="225948671" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2021 10:31:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="522311855" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 06 Oct 2021 10:31:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6F1DA170; Wed, 6 Oct 2021 20:31:27 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Saravana Kannan , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org Cc: "Rafael J. Wysocki" , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Wolfram Sang Subject: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle() Date: Wed, 6 Oct 2021 20:31:25 +0300 Message-Id: <20211006173125.84423-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211006173125.84423-1-andriy.shevchenko@linux.intel.com> References: <20211006173125.84423-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Since driver core provides a generic device_match_acpi_handle() we may replace the custom code with it. Signed-off-by: Andy Shevchenko --- v2: no changes drivers/gpio/gpiolib-acpi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 47712b6903b5..32f1f720b94b 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -95,10 +95,7 @@ static bool acpi_gpio_deferred_req_irqs_done; static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) { - if (!gc->parent) - return false; - - return ACPI_HANDLE(gc->parent) == data; + return gc->parent ? device_match_acpi_handle(gc->parent, data) : false; } /**