Message ID | Y1dzCCMCDswQFVvO@dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp822857wru; Mon, 24 Oct 2022 22:40:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ui4SQQcflTWuyQ0SI6iEknzLqj7Nzox7VS3yR2euHdZV6VhBNVB9f5xAbCvM3NmXnXsmZ X-Received: by 2002:a17:906:ef8b:b0:79d:8a30:5616 with SMTP id ze11-20020a170906ef8b00b0079d8a305616mr15932362ejb.522.1666676413205; Mon, 24 Oct 2022 22:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666676413; cv=none; d=google.com; s=arc-20160816; b=dqAKyxpvgZRiz5S/7SL7GiCTgQ/6u24WCfdJv2R1HmmZkAMChf0FBa4BKW3bQEAM45 qw5fYxxxm2QYjNNyKHC8kG7ev1T3NnpPk6kAW0PcBu/rlgGwKgTaPKElqMNwQcRMOHYW ROeuIGsRnMjPJwRUSSk9t9e2KdYTMgxFQVHBiqr9Dv1RZgeub36eqDfN9kNspadRwRIA XZAE7PlaoUaig3K9wt+zd8N1+MWUbVoLZZAfapPdZ8Hx0fbfVykBDW7AMEkF2GheMJ2b OBkhCZX3z1+3JrhfzwiCkhZn9jN3l2AnN6kNPTT0kHHGZ+tegCWlPD4OlCDdmMBd29pZ WzGw== 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=TVytv0a4cjMk9lrwtG4w8hPvQBP8qabYQWD39/Mm8gU=; b=Q8KvABe3wh8O9ExijtiGBDcwXPVtk+ohwq6DOx2AVTcX+yCuZmw0lNdz168WFuL6Dh Q+dNkrUNLf0Be202v5Zayq64m6qCSG03PXJf22RvmjPtzJ5QLl2vqfdRrSr/DZmqg6I2 I+14QWn6P2cnUh6wTAGJKqEdL9jR9bDi+OjezY+Q74QR8NpovXE8VWBzZUj8sCpvf/zb trpYG9Sfa22Z4Er0vsgg4Ob/luZO2lXb7qmSvSan2/h8T6yOt/qge6ouYgpcWnITGccv T1RTamWJTxyJt2wVrU6Ni5x+f2rM9tClPJGBOpcPb0FgbpJUjOu98IJz0gNqNSUOQVW1 WTUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=buVpW2cC; 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 d24-20020a50fb18000000b0044f2eb2de9asi1612728edq.444.2022.10.24.22.39.49; Mon, 24 Oct 2022 22:40:13 -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=20210112 header.b=buVpW2cC; 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 S230372AbiJYFYu (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Tue, 25 Oct 2022 01:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230341AbiJYFYm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Oct 2022 01:24:42 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7BECBBE1D; Mon, 24 Oct 2022 22:24:41 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id bn35so6692985ljb.5; Mon, 24 Oct 2022 22:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=TVytv0a4cjMk9lrwtG4w8hPvQBP8qabYQWD39/Mm8gU=; b=buVpW2cCDje1OJjiB/F72+1QhTWqpAJHlcwOYdulAbgJHe/Df6qGapuhHuClK5l/vn b4BRbEPDic480X2guACkeF6Nqxr5ISnEqtVlTmQkLihU5eoM0XiCiIEWmdNoargre79j PzhGbcxQ0gOzSaBv0akKGH9UF3l9xyMoyBVS3Z57JHddqiZmJ7JIh0soWSUm0TuOBSkh C6ispySx5h4rsBcwJFBom6zNOtFgOvkjD7aAqftAV/7s5SO5jCa8m8JjXemIxclekSvF EKcWW8aZ56HAK6ckCAWBuXGnMoxogRTqsi1G6iH74jUyFpfsZ8zWmpPWRWTKiC6cS6Ph aLVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=TVytv0a4cjMk9lrwtG4w8hPvQBP8qabYQWD39/Mm8gU=; b=dAs96YkgtLp9KKiJfRBAhJuJZhTn8xORSt1OOMz3p9t+6s+JvBmVHbNEXx/CIrPANV uIH4Ees05hiigS7AcV1jckqW4H37TIK1VTNXlSwHEASD+LMswLncAqadWuYuQa7kIvA6 oe4PCbuUBl3G9TaSghUcM2qKTCxbr2AogdzFiMRHByr3GIgJCFAzTi60FRwy9vp520jy bfs3ei6cpGMexB/VDg+byplpvAmkh5330jdwDqIRSS8S3LB7PrqWIPX0COCgbJuP/eTM 3m1E7GQ4Hv9XuTt01lBW4suLgZ4IvIWs9uCUu8zG3Wk75S9ptHudzLES1rs+SrH8g/c2 fGvw== X-Gm-Message-State: ACrzQf30HTBJt0djlnO9oAxZrsuSgbEenNGXqSNrTVT2j8cO24lDCx+U d7NydBJklj2U2S5/yheyspA= X-Received: by 2002:a2e:6a03:0:b0:276:c5d2:be6c with SMTP id f3-20020a2e6a03000000b00276c5d2be6cmr6454740ljc.104.1666675479878; Mon, 24 Oct 2022 22:24:39 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::2]) by smtp.gmail.com with ESMTPSA id f7-20020a05651c02c700b0027718ee951dsm36222ljo.37.2022.10.24.22.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 22:24:39 -0700 (PDT) Date: Tue, 25 Oct 2022 08:24:24 +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>, Wolfram Sang <wsa@kernel.org>, Akhil R <akhilrajeev@nvidia.com>, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drivers: fwnode: fix fwnode_irq_get_byname() kerneldoc Message-ID: <Y1dzCCMCDswQFVvO@dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uc/Yl6o0ICkvldoT" 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 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?1747636886772030995?= X-GMAIL-MSGID: =?utf-8?q?1747636886772030995?= |
Series |
drivers: fwnode: fix fwnode_irq_get_byname() kerneldoc
|
|
Commit Message
Matti Vaittinen
Oct. 25, 2022, 5:24 a.m. UTC
The fwnode_irq_get_byname() may return zero on device-tree mapping
error. Fix documentation to reflect this as current documentation
suggests check:
if (ret < 0)
is enough to detect the errors. This is not the case.
Add zero as a return value indicating error.
Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname")
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
drivers/base/property.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Moi, On Tue, Oct 25, 2022 at 08:24:24AM +0300, Matti Vaittinen wrote: > The fwnode_irq_get_byname() may return zero on device-tree mapping > error. Fix documentation to reflect this as current documentation > suggests check: > > if (ret < 0) > is enough to detect the errors. This is not the case. > > Add zero as a return value indicating error. > > Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname") > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> > --- > drivers/base/property.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/base/property.c b/drivers/base/property.c > index 4d6278a84868..df437d10aa08 100644 > --- a/drivers/base/property.c > +++ b/drivers/base/property.c > @@ -960,7 +960,7 @@ EXPORT_SYMBOL(fwnode_irq_get); > * string. > * > * Return: > - * Linux IRQ number on success, or negative errno otherwise. > + * Linux IRQ number on success, zero or negative errno otherwise. I wonder if it would be possible instead to always return a negative error code on error. Returning zero on error is really unconventional and can be expected to be a source of bugs. We have code already that takes the error code zero into account in e.g. static int smbalert_probe(struct i2c_client *ara, const struct i2c_device_id *id) { ... irq = fwnode_irq_get_byname(dev_fwnode(adapter->dev.parent), "smbus_alert"); if (irq <= 0) return irq; And zero turns into successful probe! > */ > int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name) > {
Hi Sakari, On 10/25/22 09:48, Sakari Ailus wrote: > Moi, > > On Tue, Oct 25, 2022 at 08:24:24AM +0300, Matti Vaittinen wrote: >> The fwnode_irq_get_byname() may return zero on device-tree mapping >> error. Fix documentation to reflect this as current documentation >> suggests check: >> >> if (ret < 0) >> is enough to detect the errors. This is not the case. >> >> Add zero as a return value indicating error. >> >> Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname") >> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> >> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> >> --- >> drivers/base/property.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/base/property.c b/drivers/base/property.c >> index 4d6278a84868..df437d10aa08 100644 >> --- a/drivers/base/property.c >> +++ b/drivers/base/property.c >> @@ -960,7 +960,7 @@ EXPORT_SYMBOL(fwnode_irq_get); >> * string. >> * >> * Return: >> - * Linux IRQ number on success, or negative errno otherwise. >> + * Linux IRQ number on success, zero or negative errno otherwise. > > I wonder if it would be possible instead to always return a negative error > code on error. Returning zero on error is really unconventional and can be > expected to be a source of bugs. Agree, and I did also consider just adding: if (!ret) return -EINVAL; (or another feasible errno) return ret; at the end of the fwnode_irq_get_byname(). However, such a functional change would require auditing the existing callers which I have no time right now. if (someone is up to the task) be my guest :) else please fix the doc ;) Yours -- Matti
ti 25. lokak. 2022 klo 10.06 Matti Vaittinen (mazziesaccount@gmail.com) kirjoitti: > > Hi Sakari, > > On 10/25/22 09:48, Sakari Ailus wrote: > > Moi, > > > > On Tue, Oct 25, 2022 at 08:24:24AM +0300, Matti Vaittinen wrote: > >> The fwnode_irq_get_byname() may return zero on device-tree mapping > >> error. Fix documentation to reflect this as current documentation > >> suggests check: > >> > >> if (ret < 0) > >> is enough to detect the errors. This is not the case. > >> > >> Add zero as a return value indicating error. > >> > >> Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname") > >> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > >> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> > >> --- > >> drivers/base/property.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/base/property.c b/drivers/base/property.c > >> index 4d6278a84868..df437d10aa08 100644 > >> --- a/drivers/base/property.c > >> +++ b/drivers/base/property.c > >> @@ -960,7 +960,7 @@ EXPORT_SYMBOL(fwnode_irq_get); > >> * string. > >> * > >> * Return: > >> - * Linux IRQ number on success, or negative errno otherwise. > >> + * Linux IRQ number on success, zero or negative errno otherwise. > > > > I wonder if it would be possible instead to always return a negative error > > code on error. Returning zero on error is really unconventional and can be > > expected to be a source of bugs. > > Agree, and I did also consider just adding: > > if (!ret) > return -EINVAL; (or another feasible errno) > > return ret; > > at the end of the fwnode_irq_get_byname(). > > However, such a functional change would require auditing the existing > callers which I have no time right now. Oh. I just did grep the callers. It seems to me that there are only a handful of callers in 6.1-rc2. Auditing those does not seem like a big task after all. So I guess I can check them if changing the return value is preferred. Yours, --Matti
On Tue, Oct 25, 2022 at 10:17:21AM +0300, Matti Vaittinen wrote: > ti 25. lokak. 2022 klo 10.06 Matti Vaittinen > (mazziesaccount@gmail.com) kirjoitti: > > > > Hi Sakari, > > > > On 10/25/22 09:48, Sakari Ailus wrote: > > > Moi, > > > > > > On Tue, Oct 25, 2022 at 08:24:24AM +0300, Matti Vaittinen wrote: > > >> The fwnode_irq_get_byname() may return zero on device-tree mapping > > >> error. Fix documentation to reflect this as current documentation > > >> suggests check: > > >> > > >> if (ret < 0) > > >> is enough to detect the errors. This is not the case. > > >> > > >> Add zero as a return value indicating error. > > >> > > >> Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname") > > >> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > >> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> > > >> --- > > >> drivers/base/property.c | 2 +- > > >> 1 file changed, 1 insertion(+), 1 deletion(-) > > >> > > >> diff --git a/drivers/base/property.c b/drivers/base/property.c > > >> index 4d6278a84868..df437d10aa08 100644 > > >> --- a/drivers/base/property.c > > >> +++ b/drivers/base/property.c > > >> @@ -960,7 +960,7 @@ EXPORT_SYMBOL(fwnode_irq_get); > > >> * string. > > >> * > > >> * Return: > > >> - * Linux IRQ number on success, or negative errno otherwise. > > >> + * Linux IRQ number on success, zero or negative errno otherwise. > > > > > > I wonder if it would be possible instead to always return a negative error > > > code on error. Returning zero on error is really unconventional and can be > > > expected to be a source of bugs. > > > > Agree, and I did also consider just adding: > > > > if (!ret) > > return -EINVAL; (or another feasible errno) > > > > return ret; > > > > at the end of the fwnode_irq_get_byname(). > > > > However, such a functional change would require auditing the existing > > callers which I have no time right now. > > Oh. I just did grep the callers. It seems to me that there are only a > handful of callers in 6.1-rc2. Auditing those does not seem like a big > task after all. So I guess I can check them if changing the return > value is preferred. Yes, please do so. thanks, greg k-h
diff --git a/drivers/base/property.c b/drivers/base/property.c index 4d6278a84868..df437d10aa08 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -960,7 +960,7 @@ EXPORT_SYMBOL(fwnode_irq_get); * string. * * Return: - * Linux IRQ number on success, or negative errno otherwise. + * Linux IRQ number on success, zero or negative errno otherwise. */ int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name) {