Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2012634rwd; Thu, 25 May 2023 23:47:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Dgn603gsNrzjFPyYvAOKMFbwJJgYJ0WlODm1srWLvw21IFo8iUmfv1/JdOrAvNNIP3rUB X-Received: by 2002:a05:6a00:2191:b0:64a:5cde:3a7d with SMTP id h17-20020a056a00219100b0064a5cde3a7dmr1892501pfi.27.1685083669580; Thu, 25 May 2023 23:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685083669; cv=none; d=google.com; s=arc-20160816; b=ItuOst7hLhviH4r5urZkG6MAaVDxHb4lxs7UJEIEhzIZdt4zos/8Eezp0fKuYE+izo MBk1Np8t+3UrzBgoyQY4m1zp5CNHsFCD2O6sfp4NwbbiH40CBjnPCAIe8IeOTL9Gu7oQ U9qE698IhW+99ohKV3rKJlWPnL6JsI88rrB8aj8QEYj2GgqLu08BtL7DsuGOjIfs/FDG wo7iMtf+2887bGQpzaEizHYSQ0apJxyjAcOPUN0nlv2KmbC7+OK2SN6KpmpnmepoX5jK PppHrcOSrwahu7+ruuNTPp9uCBlYQYJroWB59bIQ4/rAkebbQXeR50A8Syb4j5gU1KkY 7yNw== 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=cAIWAVxuFetjJrrCyLkzZqPv0PDDDlU03pSzLI8bStI=; b=Gj0W1a8UShD2pYag3BnTkudt39MMDy/JoNNlr2vb1hWxt2iWkyQt/gXkvMRMQMhnb2 59CaMM6eXQeGnw+0IAB4R9Po86mdTogpejcdwW4nNwtzvB10xJ9TYNxtW08OPcfTh/dm 1LHlSHbUiftdJ6cTDwrZl3HJdi6mhYPm9PZIYpGKZCq4rxtaQ7jVetGWvP+MBKF+gsYM pOk4POBxFoUfVc9c1QTNEbTU0s2zdY2MIMIDpTZMynimvG0sfw0GL64+QruGC+NiUedK qU+jrazqfR9DIbTvNeDoEwsV4veZVFHn3luLPrdKPlyjAGtvHKPXmA8T3TNzSE73XWOQ tuZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KxLR7Hhk; 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 x21-20020aa78f15000000b00642ea71f6d9si3371168pfr.336.2023.05.25.23.47.35; Thu, 25 May 2023 23:47:49 -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=KxLR7Hhk; 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 S233317AbjEZGft (ORCPT + 99 others); Fri, 26 May 2023 02:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbjEZGfr (ORCPT ); Fri, 26 May 2023 02:35:47 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1A5C12E; Thu, 25 May 2023 23:35:44 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f4b256a0c9so330023e87.2; Thu, 25 May 2023 23:35:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685082943; x=1687674943; 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=cAIWAVxuFetjJrrCyLkzZqPv0PDDDlU03pSzLI8bStI=; b=KxLR7HhkToIa5w9ZUoeLebvrRtTscYrXQvjH51a6aqQQIv/U4/P/ll2ivg3KNhai0X se9u67YaW86IKQJnDnLFmqGwaErx/BTEjJdo88RyFnFrws85sWUGzqqG0lm5eBFSrULu PZEHZOYKQu4dPje9vjVBNo+aR8lbnwt2U71aH/rFRctXC3u0zt4JEaE9+wVoHCfzhc3R zFC/dAeGjOHnGLibwG86PXjg3zNRphwdezIN4fe/OZ0hQE3pByDjoVEGsKl4DgysA3Z4 tPoXiylXe5c9da0pAGLohe3ay/eOY9nMk+0mOqDoApeHeHqJ0eiJfhuI5dydZkTHCMqO aQAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685082943; x=1687674943; 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=cAIWAVxuFetjJrrCyLkzZqPv0PDDDlU03pSzLI8bStI=; b=hyMTh8sKnRICOqOQSk8Kpwqwtng9/OfkhwyekkExD7et646IXveReRwzXUqBbHx4Ox OCTABG03Rvm9ZzNcja7OSdB3lsNbToM5nYiRtITHIE2ObXtEC8I8WPqHhebGpflN1Qp5 2Sa1HxGQwC0iU5Qz2tnlQiuHL3tp8LBdMmAGQpzT915xnnxCas7bh4Xyr2XGxrVgFinJ i8gRv+1ldOQ7eS4gx5mRUJen7WdpmB/giGuGbRWMtbfJkYeg+fNuQyNozEvWqTiBEJkp BP8gsL58r66UNwat2gFPdF+f47Ap15gogsgcgGtz0HAGqpoYOjjj8axW1QR8Q6MXawGU FBwQ== X-Gm-Message-State: AC+VfDzYPz176MrwutALXBHpAVQoKW01P1nqIi1KGjWaEYswhHbfplRb DcAAmiaF73zt+t8c4nBV0/4= X-Received: by 2002:ac2:46e5:0:b0:4f3:8143:765 with SMTP id q5-20020ac246e5000000b004f381430765mr240488lfo.27.1685082942778; Thu, 25 May 2023 23:35:42 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id w17-20020ac254b1000000b004f4b2aa6f66sm487671lfk.295.2023.05.25.23.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 23:35:42 -0700 (PDT) Date: Fri, 26 May 2023 09:35:30 +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 v6 1/8] drivers: fwnode: fix fwnode_irq_get[_byname]() Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MpNVpml8SzZtmtjR" 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 --MpNVpml8SzZtmtjR 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 --- I dropped the existing reviewed-by tags because change to fwnode_irq_get() was added. 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 --MpNVpml8SzZtmtjR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmRwUzIACgkQeFA3/03a ocWl3Qf8CNu2jLOOzjzDhnSm2xnKHRAK7eRA54Otr1t/U8jJnk2gvcCavb7O8t7C YnkPPeyB2ZbSfZF5rHXHVRT9rF6gPMaO1oCGUYOnio3ORsFQWmj8veEdR0H9yGsr Enhdoe3n6ovgylnyoAfFezf/w46tUhYTlWbppxSkqaMjkpbVWfpIbxQvnkqBrIR+ 9E+Nzjrx22zR6+uDNY1nq6LDy/0fNe2UTNPwrQSPrlDnh/8CToauRF5CsbQVK8jE LEfRPOhSQm77o2ZSY7wFNJ0anULJWpZu28oqyy5Oy3YCtPPxcsXqbmuAN9GnQktj 1BlOfxKCVtxUKiGEOgcEkwFmzznJwQ== =+cis -----END PGP SIGNATURE----- --MpNVpml8SzZtmtjR--