From patchwork Mon Jul 3 12:18:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 699634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DD54EB64DD for ; Mon, 3 Jul 2023 12:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230035AbjGCMSu (ORCPT ); Mon, 3 Jul 2023 08:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbjGCMSt (ORCPT ); Mon, 3 Jul 2023 08:18:49 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBA3410E; Mon, 3 Jul 2023 05:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688386728; x=1719922728; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f5cSMS9Hc/IEGZhdqhDLhD3xAE26SJ8iHGtEWOKDz/4=; b=GUqLaMmnCfAMT1FkTY3g/JBFtHgAbOAk4wIzHmyYLFv68uwpkhpBbGfx 1QzTVRFGjDX8eBKhKSo+Znc4JBeweHOUuRkXDZYucw2I/0HyuX//Q21Vj 7czSzPjc6X4jRrzZ3KVp+6jiBILbhC9UdY2N+fmL0ZvT7MzN+ttb0gERz Q6Eut9fYtPJD8Gvgt/ZQ5xUIClNyKUHx7RKYISmcbF1Pfau19ZROuVkzf EeFJWKOpn/J4QFs0Xy/NIQv8H1YeBxPRIge3CpFmUC4LV6Mr9ly+Se7PI vlkVqqsBS7/Jc81Xfz2cyIgMVWxdlhrUeICi6BO32nE45x9zEyUpoto5c g==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="449242344" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="449242344" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 05:18:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="863065885" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="863065885" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 03 Jul 2023 05:18:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 22F6113C; Mon, 3 Jul 2023 15:18:42 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Benjamin Tissoires Subject: [PATCH v1 1/3] gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*() Date: Mon, 3 Jul 2023 15:18:36 +0300 Message-Id: <20230703121838.70898-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703121838.70898-1-andriy.shevchenko@linux.intel.com> References: <20230703121838.70898-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org GPIO library should rely only on the GPIO device's fwnode. Hence, replace GPIO chip fwnode usage by respective OF node from GPIO device. JFYI, this is partial revert of 8afe82550240 ("gpiolib: of: Prepare of_gpiochip_add() / of_gpiochip_remove() for fwnode"). Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-of.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 1436cdb5fa26..5fde5a3f5118 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -1078,16 +1078,16 @@ int of_gpiochip_add(struct gpio_chip *chip) if (ret) return ret; - fwnode_handle_get(chip->fwnode); + of_node_get(np); ret = of_gpiochip_scan_gpios(chip); if (ret) - fwnode_handle_put(chip->fwnode); + of_node_put(np); return ret; } void of_gpiochip_remove(struct gpio_chip *chip) { - fwnode_handle_put(chip->fwnode); + of_node_put(dev_of_node(&chip->gpiodev->dev)); } From patchwork Mon Jul 3 12:18:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 698742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43E3BEB64DC for ; Mon, 3 Jul 2023 12:19:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231162AbjGCMTG (ORCPT ); Mon, 3 Jul 2023 08:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbjGCMSz (ORCPT ); Mon, 3 Jul 2023 08:18:55 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F5B198; Mon, 3 Jul 2023 05:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688386734; x=1719922734; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WIw/lYPfjECKbt13n6a0kFhIAeRW5JIxgsAB/IJQ1rk=; b=NR7pOi/Du+1ITsJMKe0RoIJO3/1xVABhTDx1bF8B3Ja9FxqBiFCfkn9w NYj3LV3OuqZwTL0sKQa1IcgYdNPH3mdljLFZ+8pAchd/K8PHdDN22TnCZ QvigVOzxxjLOXlcHwxa8AYpIn2ZrgQk2xzVpPSWJ8sD6FNbXXWOqhTHEs Nf9QZ8gMykawZ5PJ/8RXFW4dfSNaf8ONKVfgXMy1zjYb1l3a5nrEHUW7o hYvMzD2agldkLZh1Kmfn5tgwvN9zgvlGL7L5GkP1RaSlO7DQ2X4j7NKhC C3qNuxU1JttvpuIOzQiqh0b868QE2vEUIYklN4whoAJD9mnbhbs7VCZHe Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="343200935" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="343200935" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 05:18:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="831811640" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="831811640" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2023 05:18:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 288F9177; Mon, 3 Jul 2023 15:18:42 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Benjamin Tissoires Subject: [PATCH v1 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find() Date: Mon, 3 Jul 2023 15:18:37 +0300 Message-Id: <20230703121838.70898-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703121838.70898-1-andriy.shevchenko@linux.intel.com> References: <20230703121838.70898-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org GPIO library should rely only on the GPIO device's fwnode. Hence, replace GPIO chip fwnode usage by respective fwnode from GPIO device. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 97496c0f9133..cafbf9597ead 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -128,7 +128,7 @@ static bool acpi_gpio_deferred_req_irqs_done; static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) { - return ACPI_HANDLE_FWNODE(gc->fwnode) == data; + return ACPI_HANDLE(&gc->gpiodev->dev) == data; } /** From patchwork Mon Jul 3 12:18:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 698743 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED970C001B0 for ; Mon, 3 Jul 2023 12:18:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbjGCMSt (ORCPT ); Mon, 3 Jul 2023 08:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbjGCMSs (ORCPT ); Mon, 3 Jul 2023 08:18:48 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1195A109; Mon, 3 Jul 2023 05:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688386728; x=1719922728; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iKjfzmoGgKnWfJYiwCW1KqBhCHm32seAtWfANjROfaY=; b=NlmUCFI5JKFFsAeEoLj1uo0WdMQyTwXWEBDhPcoDAJkWtxoByrvCHO2E UsNHbRiKGdJOO/qgAaVtD2yMjsCAn82URxivD2cBy1zFTwEL4hwcoVOTB uVtOt8HElUrwo40onnheSdUW61jhnyPce8p1qsDEW/pOMeO6v2loetP9I aQOAssOUbn+vmbgwhxDxKb1xBt4BA9DArnR83Bh8mYpTRzhLiKp8cZxhO dqGGCfSyYvJQJ4ohu1z0J8HEtJR6mNklcsA/GjRGhShHY58UE4DdTnBb5 XOn7r6Fntae+Gz9I88y8uxBJlmyLKFoh1PXCJCZvEQKYsqe5f3zZVyFkr w==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="449242335" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="449242335" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 05:18:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="863065884" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="863065884" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 03 Jul 2023 05:18:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 372D617C; Mon, 3 Jul 2023 15:18:42 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Benjamin Tissoires Subject: [PATCH v1 3/3] gpiolib: Do not alter GPIO chip fwnode member Date: Mon, 3 Jul 2023 15:18:38 +0300 Message-Id: <20230703121838.70898-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703121838.70898-1-andriy.shevchenko@linux.intel.com> References: <20230703121838.70898-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Ideally we should not touch data in the given GPIO chip structure. Let's become closer to it by avoid altering fwnode member. The GPIO library must use fwnode from GPIO device and the drivers might use one from GPIO chip in case they initialized it. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bc8b9d6afe0e..8b7032300039 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -708,13 +708,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, int base = 0; int ret = 0; - /* - * If the calling driver did not initialize firmware node, do it here - * using the parent device, if any. - */ - if (!gc->fwnode && gc->parent) - gc->fwnode = dev_fwnode(gc->parent); - /* * First: allocate and populate the internal stat container, and * set up the struct device. @@ -729,7 +722,14 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, gc->gpiodev = gdev; gpiochip_set_data(gc, data); - device_set_node(&gdev->dev, gc->fwnode); + /* + * If the calling driver did not initialize firmware node, + * do it here using the parent device, if any. + */ + if (gc->fwnode) + device_set_node(&gdev->dev, gc->fwnode); + else if (gc->parent) + device_set_node(&gdev->dev, dev_fwnode(gc->parent)); gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); if (gdev->id < 0) {