From patchwork Tue May 16 07:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 682770 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 1D168C7EE2C for ; Tue, 16 May 2023 07:12:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230519AbjEPHMe (ORCPT ); Tue, 16 May 2023 03:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbjEPHMd (ORCPT ); Tue, 16 May 2023 03:12:33 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE1D935AD; Tue, 16 May 2023 00:12:28 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4f1fe1208a4so12906237e87.2; Tue, 16 May 2023 00:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684221147; x=1686813147; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=nIQsLaHssKkl6pMh4izl/5JY75K4E7vPiAyWjhDInUQ=; b=kVyZEfq6Q5jbhZ2IenNtfFHWP9ROgSqyZjUzcQyz17v9aApeHKzTAiCKMRPPt8Cz+U sO1aikJBvml29mD0dna23tcxwWy8iHg0X56CibVfXurzDAHBQtvy3SPRBkQD9BUmzSRK UWGib1T+IESAZ5lTgswFoUp48FFp3s7chTAeep0cf2bZw5QodQ3QQVMiATwuiLdfSeqx 8bvDST1CyN0vGgJFpxQNPn9RUEOeyQGRQBxtrynZzueM9HkG9B5sPKXdhwlOqikCnhmx j3hmIizOF/ix81U+k34v3TwnOPw5iu3mcbo/QwSHusrF9rI9a7AGDinMrTOB9bxl6DxC yjfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684221147; x=1686813147; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nIQsLaHssKkl6pMh4izl/5JY75K4E7vPiAyWjhDInUQ=; b=VqqZT1yZgoVMCjRDxsTnz/cs0Us6ZIyk3E728W8wr0Q93hrTZwVmYndt1WKwmNpM0Z x60bjYm3kDUla42gGLoFqogqR1VRi+I66X4JUpHgJlS5Jxe3r1phbs/lBPkvvWsqCyb/ +lYiqRE/XGxFdEQrb2NfmvgLi7GiyiTd2BSavBB/uUNLAiSPSOtgKaUy4JK8kzSSyh+2 q8pbGnTTVK6YF/TL4//LpcxgZS42f3dZQctbuAxb5SEFckhED2w04DputPYd59ZfB5xX SVSuLvvvi2X1KdrZh9fDp6qq7cb8H6nt+KMoc9Uy6iETbitbztcsI2X1Et7MASTz/6N/ RyMg== X-Gm-Message-State: AC+VfDysQ7KlMsmFR/Y0grRkGP/UWVU0NdiI6BMHLDxcuQMzMJJSwZRQ Dk9MOzWOGY03VwbhahS3hjU= X-Google-Smtp-Source: ACHHUZ6JEHZtYC7O57uCCGGCuU8NkL8W8zXPnQeRN4Mi+ogX1rDd1FtJEtvrACaEgE9PUk2Ib2pPaQ== X-Received: by 2002:ac2:48a1:0:b0:4f3:8823:ebe9 with SMTP id u1-20020ac248a1000000b004f38823ebe9mr715145lfg.22.1684221146822; Tue, 16 May 2023 00:12:26 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id g14-20020a19ee0e000000b004f25c29f64esm2700143lfb.176.2023.05.16.00.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 00:12:26 -0700 (PDT) Date: Tue, 16 May 2023 10:12:21 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Andreas Klinger , Marcin Wojtas , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan =?iso-8859-1?q?Neusch=E4fer?= , Linus Walleij , Paul Cercueil , Wolfram Sang , Akhil R , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-gpio@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH v4 1/7] drivers: fwnode: fix fwnode_irq_get[_byname]() Message-ID: <339cc23ccae4580d5551cc2b6b9b4afdde48f25e.1684220962.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The fwnode_irq_get() and the fwnode_irq_get_byname() return 0 upon device-tree IRQ mapping failure. This is contradicting the fwnode_irq_get_byname() function documentation and can potentially be a source of errors like: int probe(...) { ... irq = fwnode_irq_get_byname(); if (irq <= 0) return irq; ... } Here we do correctly check the return value from fwnode_irq_get_byname() but the driver probe will now return success. (There was already one such user in-tree). Change the fwnode_irq_get_byname() to work as documented and make also the fwnode_irq_get() follow same common convention returning a negative errno upon failure. Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname") Suggested-by: Sakari Ailus Suggested-by: Jonathan Cameron Signed-off-by: Matti Vaittinen --- I dropped the existing reviewed-by tags because change to fwnode_irq_get() was added. Revision history: v3 => v4: - Change also the fwnode_irq_get() --- drivers/base/property.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index f6117ec9805c..8c40abed7852 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -987,12 +987,18 @@ EXPORT_SYMBOL(fwnode_iomap); * @fwnode: Pointer to the firmware node * @index: Zero-based index of the IRQ * - * Return: Linux IRQ number on success. Other values are determined - * according to acpi_irq_get() or of_irq_get() operation. + * Return: Linux IRQ number on success. Negative errno on failure. */ int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) { - return fwnode_call_int_op(fwnode, irq_get, index); + int ret; + + ret = fwnode_call_int_op(fwnode, irq_get, index); + /* We treat mapping errors as invalid case */ + if (ret == 0) + return -EINVAL; + + return ret; } EXPORT_SYMBOL(fwnode_irq_get); From patchwork Tue May 16 07:13:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 682769 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 B35B3C77B7A for ; Tue, 16 May 2023 07:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbjEPHNo (ORCPT ); Tue, 16 May 2023 03:13:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231175AbjEPHNh (ORCPT ); Tue, 16 May 2023 03:13:37 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464601BE1; Tue, 16 May 2023 00:13:21 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ac836f4447so140644821fa.2; Tue, 16 May 2023 00:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684221199; x=1686813199; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=5yQG+L+sWAMbAKI7nwRV3Mk7EmEihKSJv4LlESWu6Rc=; b=EJMubyT2VJWX1+LZ4bUsldilZtFa74Xup//IE1hI4TlZKIQfXllceGaKcK0QLVkBIL Y7qxewfxN44AeMrltk4wayz71pVgLc0+e753neV4npsln1uMXL38S0AZT+kDtTYj9qP8 5PIpqb7293xJpKlAEN0Ew/fWXEj94qECrNBK0QKsA8QGmPCJ/4G5PwFk+gvK1duKSHZO mz/+dVg0Zlm0a1ZWDbbEl+EximPAP3Op3iQOYImkKl3PWIyKPc5QrRfsjPdiG0hRQWmN ip2mV35sPoJTj9/NFRK99pq5bV4QfIgMM3Wj7+0fEe86D20GRLqSaVuheN4VpW3lgFvQ 5mDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684221199; x=1686813199; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5yQG+L+sWAMbAKI7nwRV3Mk7EmEihKSJv4LlESWu6Rc=; b=BvHLQLPnqyqZIOGR7pK9374MFWsVktmiWgsXbSHUP9Xn1VjfDa6gHzecgVqSlAkuPW /uOlktWAIqDSI3JBNAvaq8yT8dsMYVWTFcqXkM/MRESk/J9Q/SUqPxp8ginTDbUC7xcE sIAOMqJMFF/6CAnM1LhVMXomqYVaAPnh/137mFdWtTe42orQECsqocdYbTfx3c5djZ5l 2xw2loxGVD/u2fIQLamSrLE7mN3svP5l6DSt65oXGKo8+h49AHMIfDYAOV1PqrUPdUnQ QlxcX8wHYIoG1Pub/61geXAfaQMMPl/OC8vEQGwK1QXkOHaMk+UXr0sDj/3dHg0ksxMy 5Waw== X-Gm-Message-State: AC+VfDwy9WMSStC55tASEC5kKP1p5xo42RYcuMO4bGpYGONI2r4krMOK LYXQG3pH9WGyOhCx5RMaO5U= X-Google-Smtp-Source: ACHHUZ5TiNy3bPlF9s9syDX3x/nLlKnam1O4n3XDWwbGWRbrFC9CpZ/d33KhANYPsXPIuMpFPrSOVA== X-Received: by 2002:a2e:3511:0:b0:2ad:661b:ac44 with SMTP id z17-20020a2e3511000000b002ad661bac44mr7934095ljz.39.1684221199254; Tue, 16 May 2023 00:13:19 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id w9-20020ac25989000000b004db3900da02sm2881066lfn.73.2023.05.16.00.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 00:13:18 -0700 (PDT) Date: Tue, 16 May 2023 10:13:14 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Andreas Klinger , Marcin Wojtas , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan =?iso-8859-1?q?Neusch=E4fer?= , Linus Walleij , Paul Cercueil , Wolfram Sang , Akhil R , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-gpio@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get Message-ID: <2d89de999a1d142efbd5eb10ff31cca12309e66d.1684220962.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org fwnode_irq_get[_byname]() were changed to not return 0 anymore. The special error case where device-tree based IRQ mapping fails can't no longer be reliably detected from this return value. This yields a functional change in the driver where the mapping failure is treated as an error. The mapping failure can occur for example when the device-tree IRQ information translation call-back(s) (xlate) fail, IRQ domain is not found, IRQ type conflicts, etc. In most cases this indicates an error in the device-tree and special handling is not really required. One more thing to note is that ACPI APIs do not return zero for any failures so this special handling did only apply on device-tree based systems. Drop the special (no error, just skip the IRQ) handling for DT mapping failures as these can no longer be separated from other errors at driver side. Signed-off-by: Matti Vaittinen --- The special handling in this driver was added when fixing a problem where returning zero from fwnode_irq_get[_byname]() was treated as succes yielding zero being used as a valid IRQ by the driver. f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check") The commit message does not mention if choosing not to abort the probe on device-tree mapping failure (as is done on other errors) was chosen because: a) Abort would have broken some existing setup. b) Because skipping an IRQ on failure is "the right thing to do", or c) because it sounded like a way to minimize risk of breaking something. If the reason is a) - then I'd appreciate receiving some more information and a suggestion how to proceed (if possible). If the reason is b), then it might be best to just skip the IRQ instead of aborting the probe for all errors on IRQ getting. Finally, in case of c), well, by acking this change you will now accept the risk :) The first patch of the series changes the fwnode_irq_get() so this depends on the first patch of the series and should not be applied alone. --- drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c index 2d1c1652cfd9..f9326210b5eb 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c @@ -1106,8 +1106,6 @@ static int wpcm450_gpio_register(struct platform_device *pdev, irq = fwnode_irq_get(child, i); if (irq < 0) break; - if (!irq) - continue; girq->parents[i] = irq; girq->num_parents++; From patchwork Tue May 16 07:13:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 682768 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 65B77C77B7A for ; Tue, 16 May 2023 07:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbjEPHOb (ORCPT ); Tue, 16 May 2023 03:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjEPHOP (ORCPT ); Tue, 16 May 2023 03:14:15 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC4E744AB; Tue, 16 May 2023 00:13:57 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4f1fe1208a4so12907697e87.2; Tue, 16 May 2023 00:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684221236; x=1686813236; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=x7iB2tT1FxzgZOFKdB6YdWc9HUsfJ2gQmhK2D8CH7ls=; b=F2Ois8vAySQr2U0tMK8uXNP/3vsb8HWxhd6w6T0u9tyJsJpG2pIF8ViQo9DfDpnfH+ ud43j7l2z7rT6LClB56VEbDxtWMpj0tcryVQkZ5bW3jPDZ9XtjLm2zMJKzgSRXehqADn ZnEgO9Z+BM4QphonC175O9hzG6X7T9769/kCCc/a3/EKDaSroyAYfT7VEsbgljBN/bf7 hbxb8Gn+FzJlB1r/Zc34QqxR4IKfKRwlZguJ6CWaoCayKTOhwxDHOIWrNuukamJVUny3 D3GG72MhfJvJV0OCp3SKi4vMdk1qI3SqJ9EiF8vNLYStQoXy8OtLLBqv2lH9MpU1wRVD U7HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684221236; x=1686813236; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x7iB2tT1FxzgZOFKdB6YdWc9HUsfJ2gQmhK2D8CH7ls=; b=fAlhPHwhRZHoo0Fjtxqhg4G5CR4+1F9vyR2x4PU6KVQez7B0lIrpZ129YKDjtrGAHm 5UMV6sx5wX+tMB9vpltvR+lCghWApvC0xhrTYJh51wUUIlAmVlDNxzvWWlqBUCDBXNv5 8QnycWiIR3y3hEUciCuZyn4FCSXYs8QSzV8ALOrOQ33d+Q+qlrTWCWSlkJsqkFETuKyl GcSPu7+LzmEUBxjWvPYBxAqqr3agZ6ShJM3RmInOdr+HAUliuR2Vo3e0+j34yxM+KznM OAg8sLYJpDHdkwv/L83QczksgpN28cleDTNoM2VamfAG9oQpI8AJRPnAr/DWhsLAi1C2 3bSg== X-Gm-Message-State: AC+VfDzY3njR/aQYBtt8IweGEXbCy587EkFWd3mw+kNH9DNlbOnXngOz qWnk4BWdoX249kKKkIHsBJE= X-Google-Smtp-Source: ACHHUZ7mcAh05jssI9gTt04ul3aPVER3NAMZdK2vv5y3BfBFTtQFfWIVyeOwl11u37jMcbM3dX4Rrw== X-Received: by 2002:a05:6512:20e:b0:4f2:7b65:baf1 with SMTP id a14-20020a056512020e00b004f27b65baf1mr3635981lfo.23.1684221235879; Tue, 16 May 2023 00:13:55 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id c17-20020ac244b1000000b004f13eff5375sm2847608lfm.45.2023.05.16.00.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 00:13:55 -0700 (PDT) Date: Tue, 16 May 2023 10:13:50 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Andreas Klinger , Marcin Wojtas , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan =?iso-8859-1?q?Neusch=E4fer?= , Linus Walleij , Paul Cercueil , Wolfram Sang , Akhil R , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-gpio@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH v4 6/7] pinctrl: pistachio: relax return value check for IRQ get Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org fwnode_irq_get[_byname]() were changed to not return 0 anymore. Drop check for return value 0. Signed-off-by: Matti Vaittinen --- The first patch of the series changes the fwnode_irq_get() so this depends on the first patch of the series and should not be applied alone. --- drivers/pinctrl/pinctrl-pistachio.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c index 53408344927a..8c50e0091b32 100644 --- a/drivers/pinctrl/pinctrl-pistachio.c +++ b/drivers/pinctrl/pinctrl-pistachio.c @@ -1393,12 +1393,6 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl) dev_err(pctl->dev, "Failed to retrieve IRQ for bank %u\n", i); goto err; } - if (!ret) { - fwnode_handle_put(child); - dev_err(pctl->dev, "No IRQ for bank %u\n", i); - ret = -EINVAL; - goto err; - } irq = ret; bank = &pctl->gpio_banks[i];