Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2318954rwd; Fri, 19 May 2023 04:16:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59Z5BDRm4wabz7Eu35au3zrAntk0JPu1kBigh/hX2tz7YkvaC+ZH/mPfRlymDbaWHnkpeK X-Received: by 2002:a17:902:b78b:b0:1ac:85e9:3cab with SMTP id e11-20020a170902b78b00b001ac85e93cabmr2305877pls.56.1684494963085; Fri, 19 May 2023 04:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684494963; cv=none; d=google.com; s=arc-20160816; b=AcTxkptz5VkHzN12RcSQoLeuBF/Z23y5u9iPiPtgkkP0R/DdTH2/cwp/OhdEflFsQ1 M8oYh7VTwcJPvafr8Pmf11vRZdHXBCq9y2Ahhb8zZOewIhxChOq7u6pwn2ecAV4HiQ3W zcqhvSzbXek3cWQC9cF7MBRG099ODobd5oe6mbjfEHwoGoOBGioL+o7QfcoTv8O3ra+A 5oWvkyxgc96v2hwVMrl1QAqVsjBtMTiOrkb55wUOTKsFznadGpW96NmpOCijkElpuL0q y+jR33DWiskdNdnaG9gOwtkhV3llwfYzT/4t0bZlxJthDvOntI1rnYGpN0+93ELxpKXB gsIg== 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=oY1HYSQizqf++ddJ9pIAfIcp1VHkJcel6jxA5ixO9Ds=; b=m1mK8oetBASG1SmCn9jZcxz0fq9dokH2Vx4jgK402yxCIOfSDJ6l68Z1qhNpbJgdGc Q+6L8gcWfq21rWas3c68TAKkoTwQncfuLbynzSCbnzRI7hzvZeZ1Sut2r029bwsoFmmP wL/3bUUMSfnDCkh8EF2LfjVkrV2tC3VU716BOr8oBKOXuKLrwZOxR1PGDViCtamGjkvy w9crHZXyvt+t7buUYy1PKjQwlT/LZxi3ZkwQOrQRkPX4UJowOYUn26/0KptdSscObqfp +HWScgx7E2YxaoQT7uahyLS2wsyENP/sakR99WbPjbaMXt6qdsGHjaDqPJ0AV5h7Xqo5 k5Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=IDpkDXNP; 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 lg13-20020a170902fb8d00b001a980a2b405si3066698plb.471.2023.05.19.04.15.47; Fri, 19 May 2023 04:16:03 -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=IDpkDXNP; 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 S231797AbjESLBr (ORCPT + 99 others); Fri, 19 May 2023 07:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbjESLBp (ORCPT ); Fri, 19 May 2023 07:01:45 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3616D1BE2; Fri, 19 May 2023 04:01:12 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2ad9f2926adso34391261fa.1; Fri, 19 May 2023 04:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684494060; x=1687086060; 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=oY1HYSQizqf++ddJ9pIAfIcp1VHkJcel6jxA5ixO9Ds=; b=IDpkDXNP+kZGUOjDbquAIu8yEdEqWAlhJ7BycF2yRZK0PX+d1qr9Z/GhnVwsxqGoVb nT4fuXwMGtQLMGkczH4zGgyQHbw4t0ABMJR9gLLF9DaHv9j9huaLkHkE3Ha2oIMY/KIv 4RqFwJ1cDMjVv6uppJLKmCOn8XaCzufgu64VGOlW5j8UM1niBuZ6oHk9JCuCOXOS/vrE BtA0u7mgRzltM8XiVpvFbg+dOZCAjVDrtQ/XEgVKII8GYwW01/PfkmjCNWBZxAUHQCyi u9vKF5eIUHdVu5K5nvKmNpoNpHT7C8ub4tWDFbSD/xWQDdoLP7swIolp4H6h9tPYFb92 PDsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684494060; x=1687086060; 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=oY1HYSQizqf++ddJ9pIAfIcp1VHkJcel6jxA5ixO9Ds=; b=CedA2cBco53eUQNfVhQlLA0lhJT2eszU5wQZsF9M2TZIDBN/18WTgmykbiUvdPqzaE CXf9ts5z3W9sCYIqVr1kZMBMzQTy7Dj4hurQT70PebRN20q6ZOx/KFF9OOPUB3Na3MDD O6wTDvgE1r/EZCldcS8QC5IkR8RgZCiRUsuEaDUeZHW6b8R8qZRspILNRh7mkN7lHbUi Ut1vOdlcuSylRYj3MQhxWfpL5oaBQxogXhiiYCaPyfayeTXP8N8i9lFDJNR4UYggKd7Y 6pxLQialGCGpwR241aBOHMLnUsunxzfK+7Iy3egj1CLAFgMz8oy06iyT+EzSxfAWHhRU uGXQ== X-Gm-Message-State: AC+VfDyryOtf1tWLooEG/+VrTQtQHbiqjc5uSE8ngn36/v1eKyFZ7qIQ b6FMq5t30mkI0vwPd3OLaWY/nIN0iVo= X-Received: by 2002:ac2:547c:0:b0:4f0:1e7d:f897 with SMTP id e28-20020ac2547c000000b004f01e7df897mr768560lfn.17.1684494060124; Fri, 19 May 2023 04:01:00 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id o6-20020ac24346000000b004f251cf3d31sm558454lfl.153.2023.05.19.04.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 04:00:59 -0700 (PDT) Date: Fri, 19 May 2023 14:00:54 +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 v5 1/8] drivers: fwnode: fix fwnode_irq_get[_byname]() Message-ID: <339cc23ccae4580d5551cc2b6b9b4afdde48f25e.1684493615.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tU6wD8GYZKI8Boni" 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 --tU6wD8GYZKI8Boni 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 --- I dropped the existing reviewed-by tags because change to fwnode_irq_get() was added. Revision history: 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 --tU6wD8GYZKI8Boni Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmRnVuUACgkQeFA3/03a ocV6bQgAkFMOjbtyS4zrLbCiAlRh+q00AnzwI0kFgMmRl9l6W/Ms88Tcyl11kXZ+ ZyBzt9f2l2InccBaq76yul41ha3XIpAxz3vArpvRqEI5MxFDYoVz/2wwvs7eSltk xNTVEsxhm+1+tY7MtITToS/rGCieMvwWRTSp/reRDtgI0m7/zYrpd5cWGtN7saDb ELRlcfoeZQmxQSW9i7xpVcgDgeQEyD24DLKMSMhpZuYI32hrOrTsfxqZEg6cYJxm Pw+5Pq+lQrGGbvqABzvmGA8GPwR8cciSiHT1gOmpzWCr1HDDa0Nv0Vb7lEt1s9DY mmGcznUSTBxJXb/2UHzgLie14q3Qzw== =mfwf -----END PGP SIGNATURE----- --tU6wD8GYZKI8Boni--