Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2744121rwd; Sun, 28 May 2023 23:31:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6iuU0Ch8LK1yOdBJUhoiOOZTH/4HJECJJL7mQzmveb1IDSCcR2t7RBMvbAVT3JHKC6/uKL X-Received: by 2002:a05:6a20:748b:b0:10b:7243:c212 with SMTP id p11-20020a056a20748b00b0010b7243c212mr9513905pzd.42.1685341907692; Sun, 28 May 2023 23:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685341907; cv=none; d=google.com; s=arc-20160816; b=ZlqSGI5VlcacnwSrexSKMfA5KcxrGr36zDJGvHlWk19OKUm0tjiQ2RENDMBtkwLEyX JXJ//xrHwEwegOpDpPVfZrUTBRECJA/y5VyB+Vzl+axxxwncyt7eHp+jjtDg3o+ypQPg Zs3764ipOIi/2NbI3b6/K9IrbAMujz1Nv/VQrNnzbnYHSL2SbH5oseVf226MrPcSWptM mm8qCGSP7HF8IyUWvsgqv05/FAsXwkDhlkGjZfxtGxNpkkXmULZiEvM070KvEX4V1WIj 6UJgAiPzmlrC21tq7+a1161YaE2uAiPqKa+OHPeEa+NqH6tLK7Tc3I1+2+NiSnT5O3Z9 DWtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JRZkhSfNi/CahwvYTKjgmeTw6RKVKTnQbqpayNzly3w=; b=TNf/JWjbTG/UNr2aju0aqQ+pKsnKxu1/WM8bBfMxVXI9RrFD3dYp//8aVQhksxo3D+ mum8aNlpFgWNLUpdIXswEq6V+4IHD+fib6adgd2jDWwpP8qoDyz3LoCEZso6uNc6Q4SC TUJ3aBcmK3b1I5IdoSHeXYmUzQOw3a3HCcWolqVIQIhXSmuIrfr5wKrdwO3NFy2vPpQF qwnTjMo9jaCIzU//pxYQm6J02ThsOa6+vIbfwKIv9uoWXv+ouQvSJB8DyWQlBDne638F X2ynHwqHJooS9LbjLpV+AbbKkao3X562w65NAYoEiI4Mtfrtk+b9upUy8qOSOJCUJcLO xpsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="NgR/fbJP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k24-20020aa79738000000b006455d53001fsi9261256pfg.40.2023.05.28.23.31.35; Sun, 28 May 2023 23:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="NgR/fbJP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbjE2GWo (ORCPT + 99 others); Mon, 29 May 2023 02:22:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjE2GWl (ORCPT ); Mon, 29 May 2023 02:22:41 -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 C5B10C2; Sun, 28 May 2023 23:22:39 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4f3b5881734so3268562e87.0; Sun, 28 May 2023 23:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685341358; x=1687933358; 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=JRZkhSfNi/CahwvYTKjgmeTw6RKVKTnQbqpayNzly3w=; b=NgR/fbJPAxlA6ez4qMq0Ef7YeLvwdGjfoAR11dyQrwOqRT3j5c5e3HOaCb7pOtnDWO xHoYdgZIg7kLKjsza+J0mrXKaFWuH74btl0Y/4OFE9xhyn6yppFKZtCO7WwDzLR9SWiq v+zK4NTRcstq4UOtSjQ5OyG/bsgXK11Eq20CMlIBJEhRSn3ROKcu3A0ijeUqmCWj4rq7 M+ScwPFEoLcV7G8Ylh3Z8HQsaXK82shh4Oj95VzQLO893tA/3VL/epny988lwT7cyTED U2TBpUQXCuBaISPLj7a0T++zoH2qn7WZfIotXwPNNYoJFEDPjzAB+y5CvdSp0xNe14bn gLIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685341358; x=1687933358; 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=JRZkhSfNi/CahwvYTKjgmeTw6RKVKTnQbqpayNzly3w=; b=CRguAAEK8C1khJO4d0uAJlQyn24mbUn50ejSgeritJ1m8brqAY9q/iODcdFY7sCpty /jhgL8YrKcZTw2ccReEIMqaEKpmArGyvVDLuaECZN5ONRLfIVUY7V7rg1/plNpzsLwIT 7PyJeJN5d7C5/Yxm6ewEMVzHgZ0AuTm4eYNe3fCDZaq0OM2gD+NEeNim7Xb1sMNRAGOq 5HELW01h6/Vc7R598nTql/wCYI8JoCO07HiqnzlvEJUfEew4bTSP0tWnA9AcnnKh3yg5 WbP44B5oM/nNxRBTbY5Lwp7aRXK9K4Q2AEzj+v/zrq9/CIyzoe9DOnFYVt1X00tPa4wr QxJw== X-Gm-Message-State: AC+VfDyvAJ6Yihnej3sauXvhDBAwsh7eVVVOSvnJcd52da/UWbYG9mkh rjbgjRdd3tkJEFu4rTFHTe4= X-Received: by 2002:ac2:5298:0:b0:4f1:5010:4b34 with SMTP id q24-20020ac25298000000b004f150104b34mr3954548lfm.18.1685341357703; Sun, 28 May 2023 23:22:37 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id z3-20020a19f703000000b004f11eb32f20sm1870130lfe.13.2023.05.28.23.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 May 2023 23:22:37 -0700 (PDT) Date: Mon, 29 May 2023 09:22:33 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Wolfram Sang , 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 , Akhil R , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@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 v7 1/9] drivers: fwnode: fix fwnode_irq_get[_byname]() Message-ID: <3e64fe592dc99e27ef9a0b247fc49fa26b6b8a58.1685340157.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="d0SdDmkUrqipDMDe" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --d0SdDmkUrqipDMDe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =3D fwnode_irq_get_byname(); if (irq <=3D 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 Reviewed-by: Andy Shevchenko Reviewed-by: Jonathan Cameron --- Revision history: v4 =3D>: - No Changes v3 =3D> 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 =3D fwnode_call_int_op(fwnode, irq_get, index); + /* We treat mapping errors as invalid case */ + if (ret =3D=3D 0) + return -EINVAL; + + return ret; } EXPORT_SYMBOL(fwnode_irq_get); =20 --=20 2.40.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --d0SdDmkUrqipDMDe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmR0RKkACgkQeFA3/03a ocW/sggAtiSReQyO+hEipTMoCjONOi3/T6FwbXBn6NUUakrhTIMT5IfrfgA1LXCH aYaMi5lPZVBGdIks7DuFqctgt9Ccnfk8dRFWZJlGm2aThQmB5pX0+BS0OOlWmlmp pV80t6WGKpEgyubqn7nOqYeXoKHBFKBTChf52E5HgppGKHm3lU3Gsg+ZvCcJ3jQh 53k8my/bwrKEjdcBfZ9KPYCwX1xN57iwELuO6ANTIZqIX2W0RqjNKGnc4R94pKvt EqUme6tQgscHvndmEiY+hq5i3clwxUuo4/PF7mH6SATxxFHD4X6EFDa3T4+3vvRO OkNUYblbeisq4XXpXnbh16wSk10gGA== =sM2l -----END PGP SIGNATURE----- --d0SdDmkUrqipDMDe--