Message ID | cover.1684220962.git.mazziesaccount@gmail.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp234672vqo; Tue, 16 May 2023 00:18:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7n3h/Mu7dZ+qqB/nspaYM7YHcY/2ztuZ7+wHKqe/qWYjTlAbvjbk9+fLzgMYqZywsXwvtS X-Received: by 2002:a05:6a00:24d1:b0:646:ec88:998c with SMTP id d17-20020a056a0024d100b00646ec88998cmr36791495pfv.15.1684221497671; Tue, 16 May 2023 00:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684221497; cv=none; d=google.com; s=arc-20160816; b=aA41cucqm50C6HZnQs83wsxlTnRWLAl4exsihgIzAaR2/1BRjkDP4cJFBdS9yZ93n+ QzsLpMfMiDeyH1AJdeC/xNXd98DLp9aoWGOPls/SnltLX4dhj2gunL6J1l5/ZKEyC3Nc TYQlouD0lyNfh/gN7VuLHFkcTWz85VDm8oMYbbZ9LEjNR34aBTD/cWFC8k5YYPmwJ39h 3pSvuThE//nZ5pysNHOYYr43poPDBOTzM0aZLkhhUprlecXZxuiN2i+vtZcB7qLaGvep 5X1jhPBEhEOfmo5FDu2PEg0sLuTpbVeCAcr7BWEKtXx33+ShyIPXsJIjwFS+zDQkzyGY 8ATg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=GPjYHqvh0wAbW7+EmboW//QApPov+nEWDCvpi+IrMFE=; b=OSR/TiCxPqOl6uvURmso/tSMt54CnkniYFmj5GnjpOsYKNfdgRcF5mUAMUSe7tQSHl 2rHi+r0ADa7pb4i9UZpi20n9xb0OXzecFfPuHBqnJVs6Q9/3ylQqC8zoKlc8WBbjcg31 65+LgKkg9LcZn10PY2rznCGybZCfVwm4TqqIfcFxAPGq+zi8nvuMnEP/OnufZ7uJV3rs +MHVZ5FPiD/e1xGvubcdWVNLypMHa0D6pnF1aHlSgwFcyWRs0VafVt+xqaF/OKow3aPP LoO4rApmk1DKKFax+Y53HIAjrWPT7fsLXMQZPCpNUAs/Dm4GxcnIs/SrQix6WQq7fWfC Jv4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="lvBWM/nK"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 7-20020a630007000000b0052c7c1eb769si18045072pga.856.2023.05.16.00.18.05; Tue, 16 May 2023 00:18:17 -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="lvBWM/nK"; 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 S230516AbjEPHMQ (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Tue, 16 May 2023 03:12:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbjEPHMO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 16 May 2023 03:12:14 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 212D41AE; Tue, 16 May 2023 00:12:13 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4f13bfe257aso15778066e87.3; Tue, 16 May 2023 00:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684221131; x=1686813131; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=GPjYHqvh0wAbW7+EmboW//QApPov+nEWDCvpi+IrMFE=; b=lvBWM/nKFobeJG+7xSVWzJCNApstZM0n0FmuI9OAwm5iB3uF/deR6kLocGUk3v+Roa g4Qsq6FgZ1ukQXoAbVUE98vR4OWxQbWdENeCPPiEUOTqbNUGrWJf72DRgh1Qcisn7GL+ 19ja10CoEgneWavU+4eXIYkAln2KsqBq7uD8PJHN7exfiiFncb/TvTMqQ+D30CkwQkCf Bn4dLQsdCKjrjIKaRBXcFwtUSvFBnlsa4w5MZkWxP6y+NbeIYm7W2t5MwitO5eVqGcV3 CQXKlCiQRWpt+7VK/hon+ocVc6ClOSG00MJe0gcCrsZVNMUC3Ng+d+0dZ8jpfQdkueNQ Vyeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684221131; x=1686813131; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GPjYHqvh0wAbW7+EmboW//QApPov+nEWDCvpi+IrMFE=; b=Ddz40gnLiDUZsgnAUZQWTZYcReRLzn/dXvtdiaVAQPecgK1Kb+q3jSrk+u940f+UqP kofB8cgs/nanQX8/iVU/WEjZm+A2q30jidKt3lv+phdY/75cK+etg5m19+NL/cz2VwGi sBqTHna8gVfR10t4Lh83dat9CimNjZ+Ye71b6PT8oUn8ltyRtipMlLmiTXmmMNYppqus AdMJ40ZmsYKiuMILYPJIYXi3QLBthXPRHUGm8k0R0m9XrpuyGeQUNPXHBi7cMeWaXk/F TzrKR1gJUtPrupomsSgLP2kcIhljGayDrsl6FRkHH6KofkS42HsIlVb0BJ/brTdQCaK6 TmAQ== X-Gm-Message-State: AC+VfDwX9sRS6GxH1Ru5LfrvSrkG5WRaQ34l6opl9M8L02hu4PqwXsW0 ungNqi11+jNMUccqfnVY8mM= X-Received: by 2002:ac2:4156:0:b0:4eb:1294:983d with SMTP id c22-20020ac24156000000b004eb1294983dmr6992358lfi.7.1684221131041; Tue, 16 May 2023 00:12:11 -0700 (PDT) Received: from fedora (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id o4-20020ac24944000000b004eeda2caa3fsm2863433lfi.55.2023.05.16.00.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 00:12:10 -0700 (PDT) Date: Tue, 16 May 2023 10:12:03 +0300 From: Matti Vaittinen <mazziesaccount@gmail.com> To: Matti Vaittinen <mazziesaccount@gmail.com>, Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Daniel Scally <djrscally@gmail.com>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Sakari Ailus <sakari.ailus@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J. Wysocki" <rafael@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Michael Hennerich <Michael.Hennerich@analog.com>, Jonathan Cameron <jic23@kernel.org>, Andreas Klinger <ak@it-klinger.de>, Marcin Wojtas <mw@semihalf.com>, Russell King <linux@armlinux.org.uk>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Jonathan =?iso-8859-1?q?Neusch=E4fer?= <j.neuschaefer@gmx.net>, Linus Walleij <linus.walleij@linaro.org>, Paul Cercueil <paul@crapouillou.net>, Wolfram Sang <wsa@kernel.org>, Akhil R <akhilrajeev@nvidia.com>, 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 0/7] fix fwnode_irq_get[_byname()] returnvalue Message-ID: <cover.1684220962.git.mazziesaccount@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WelOJ0Zn8BeyKL7K" Content-Disposition: inline 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766034241031725162?= X-GMAIL-MSGID: =?utf-8?q?1766034241031725162?= |
Series |
fix fwnode_irq_get[_byname()] returnvalue
|
|
Message
Matti Vaittinen
May 16, 2023, 7:12 a.m. UTC
The fwnode_irq_get() and the fwnode_irq_get_byname() may have returned zero if mapping the IRQ fails. This contradicts the fwnode_irq_get_byname() documentation. Furthermore, returning zero or errno on error is unepected and can easily lead to problems like: int probe(foo) { ... ret = fwnode_irq_get_byname(...); if (ret < 0) return ret; ... } or int probe(foo) { ... ret = fwnode_irq_get_byname(...); if (ret <= 0) return ret; ... } which are both likely to be wrong. First treats zero as successful call and misses the IRQ mapping failure. Second returns zero from probe even though it detects the IRQ mapping failure correvtly. Here we change the fwnode_irq_get() and the fwnode_irq_get_byname() to always return a negative errno upon failure. I have audited following callers (v6.4-rc2): fwnode_irq_get_byname(): drivers/i2c/i2c-smbus.c drivers/iio/accel/adxl355_core.c drivers/iio/accel/kionix-kx022a.c drivers/iio/adc/ad4130.c drivers/iio/adc/max11410.c drivers/iio/addac/ad74115.c drivers/iio/gyro/fxas21002c_core.c drivers/iio/imu/adis16480.c drivers/iio/imu/bmi160/bmi160_core.c drivers/iio/imu/bmi160/bmi160_core.c fwnode_irq_get(): drivers/gpio/gpio-dwapb.c drivers/iio/chemical/scd30_serial.c drivers/iio/proximity/mb1232.c drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c drivers/net/mdio/fwnode_mdio.c drivers/pinctrl/pinctrl-ingenic.c drivers/pinctrl/pinctrl-microchip-sgpio.c drivers/pinctrl/pinctrl-pistachio.c and it seems to me these calls will be Ok after the change. The i2c-smbus.c and kionix-kx022a.c will gain a functional change (bugfix?) as after this patch the probe will return -EINVAL should the IRQ mapping fail. The series will also adjust the return value check for zero to be omitted. NOTES: Changes are compile-tested only. drivers/pinctrl/nuvoton/pinctrl-wpcm450.c will also gain a functional change. The pinctrl-wpcm450.c change is easy to see - after this series the device-tree mapping failures will be handled as any other errors - probe will be aborted with -EINVAL. Other feasible option could be treating other errors in IRQ getting same way as the DT mapping failures - just silently skip the IRQ. Please see comment in the respective patch. drivers/iio/cdc/ad7150.c will gain functional change as well. Here the logic is less straightforward but boils down to the same question as with the pinctrl-wpcm450.c. Should all the IRQ getting errors jump to same 'no-IRQ' branch as the DT mapping error, or should the DT mapping error abort the probe with error same way as other IRQ getting failures do? Revision history: v3 => v4: - Change also the fwnode_irq_get() as was suggested by Jonathan. Changelog v2 => v3: - rebase/resend/add kx022a fix. Changelog v1 => v2: - minor styling --- Matti Vaittinen (7): drivers: fwnode: fix fwnode_irq_get[_byname]() iio: mb1232: relax return value check for IRQ get net-next: mb1232: relax return value check for IRQ get pinctrl: wpcm450: elax return value check for IRQ get pinctrl: ingenic: relax return value check for IRQ get pinctrl: pistachio: relax return value check for IRQ get iio: cdc: ad7150: Functional change drivers/base/property.c | 12 +++++++++--- drivers/iio/cdc/ad7150.c | 3 +-- drivers/iio/proximity/mb1232.c | 4 ++-- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 4 ++-- drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 -- drivers/pinctrl/pinctrl-ingenic.c | 2 -- drivers/pinctrl/pinctrl-pistachio.c | 6 ------ 7 files changed, 14 insertions(+), 19 deletions(-) base-commit: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
Comments
On Tue, May 16, 2023 at 9:12 AM Matti Vaittinen <mazziesaccount@gmail.com> wrote: > The fwnode_irq_get() and the fwnode_irq_get_byname() may have returned > zero if mapping the IRQ fails. This contradicts the > fwnode_irq_get_byname() documentation. Furthermore, returning zero or > errno on error is unepected and can easily lead to problems > like: Also, zero is not really a valid IRQ, it means NO_IRQ: https://lwn.net/Articles/470820/ I'll apply the pinctrl patches. Yours, Linus Walleij
On 5/17/23 15:43, Linus Walleij wrote: > On Tue, May 16, 2023 at 9:12 AM Matti Vaittinen > <mazziesaccount@gmail.com> wrote: > >> The fwnode_irq_get() and the fwnode_irq_get_byname() may have returned >> zero if mapping the IRQ fails. This contradicts the >> fwnode_irq_get_byname() documentation. Furthermore, returning zero or >> errno on error is unepected and can easily lead to problems >> like: > > Also, zero is not really a valid IRQ, it means NO_IRQ: > https://lwn.net/Articles/470820/ > > I'll apply the pinctrl patches. Thanks Linus. I guess you noticed but please wait until the patch 1/7 gets in as the pinctrl patches won't do "the right thing" without it. (Just ensuring we are on a same page ;) ) Yours, -- Matti