Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A88FCC4332F for ; Wed, 12 Jan 2022 08:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351769AbiALIyF (ORCPT ); Wed, 12 Jan 2022 03:54:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351768AbiALIyD (ORCPT ); Wed, 12 Jan 2022 03:54:03 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1202C06173F for ; Wed, 12 Jan 2022 00:54:02 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7ZLN-0005mh-UE; Wed, 12 Jan 2022 09:50:57 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n7ZL6-009rFV-QA; Wed, 12 Jan 2022 09:50:40 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1n7ZL5-00061g-Dl; Wed, 12 Jan 2022 09:50:39 +0100 Date: Wed, 12 Jan 2022 09:50:09 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Geert Uytterhoeven Cc: Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , kvm@vger.kernel.org, "Rafael J. Wysocki" , linux-iio@vger.kernel.org, Linus Walleij , Amit Kucheria , ALSA Development Mailing List , Liam Girdwood , Guenter Roeck , Thierry Reding , linux-mtd@lists.infradead.org, linux-i2c@vger.kernel.org, Miquel Raynal , linux-phy@lists.infradead.org, Jiri Slaby , "David S. Miller" , Khuong Dinh , Florian Fainelli , Matthias Schiffer , Joakim Zhang , Kamal Dasu , Lee Jones , Bartosz Golaszewski , Daniel Lezcano , Tony Luck , Kishon Vijay Abraham I , bcm-kernel-feedback-list@broadcom.com, linux-serial@vger.kernel.org, Jakub Kicinski , Zhang Rui , Matthias Brugger , platform-driver-x86@vger.kernel.org, linux-pwm@vger.kernel.org, Robert Richter , Saravanan Sekar , Corey Minyard , linux-pm@vger.kernel.org, Mauro Carvalho Chehab , John Garry , Peter Korsgaard , William Breathitt Gray , Mark Gross , linux-gpio@vger.kernel.org, Alex Williamson , Mark Brown , Borislav Petkov , Eric Auger , Takashi Iwai , Jaroslav Kysela , openipmi-developer@lists.sourceforge.net, Andy Shevchenko , Benson Leung , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, Sergey Shtylyov , Richard Weinberger , Mun Yew Tham , Hans de Goede , Greg Kroah-Hartman , Yoshihiro Shimoda , Cornelia Huck , linux-mmc@vger.kernel.org, Linux Kernel Mailing List , linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Vinod Koul , James Morse , Zha Qipeng , Sebastian Reichel , Niklas =?utf-8?Q?S=C3=B6derlund?= , linux-mediatek@lists.infradead.org, Brian Norris , netdev@vger.kernel.org Subject: Re: [PATCH 1/2] platform: make platform_get_irq_optional() optional Message-ID: <20220112085009.dbasceh3obfok5dc@pengutronix.de> References: <20220110195449.12448-1-s.shtylyov@omp.ru> <20220110195449.12448-2-s.shtylyov@omp.ru> <20220110201014.mtajyrfcfznfhyqm@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xmww6gsp5dtrk3ed" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --xmww6gsp5dtrk3ed Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 12, 2022 at 09:33:48AM +0100, Geert Uytterhoeven wrote: > Hi Andrew, >=20 > On Mon, Jan 10, 2022 at 10:20 PM Andrew Lunn wrote: > > On Mon, Jan 10, 2022 at 09:10:14PM +0100, Uwe Kleine-K=F6nig wrote: > > > On Mon, Jan 10, 2022 at 10:54:48PM +0300, Sergey Shtylyov wrote: > > > > This patch is based on the former Andy Shevchenko's patch: > > > > > > > > https://lore.kernel.org/lkml/20210331144526.19439-1-andriy.shevchen= ko@linux.intel.com/ > > > > > > > > Currently platform_get_irq_optional() returns an error code even if= IRQ > > > > resource simply has not been found. It prevents the callers from be= ing > > > > error code agnostic in their error handling: > > > > > > > > ret =3D platform_get_irq_optional(...); > > > > if (ret < 0 && ret !=3D -ENXIO) > > > > return ret; // respect deferred probe > > > > if (ret > 0) > > > > ...we get an IRQ... > > > > > > > > All other *_optional() APIs seem to return 0 or NULL in case an opt= ional > > > > resource is not available. Let's follow this good example, so that = the > > > > callers would look like: > > > > > > > > ret =3D platform_get_irq_optional(...); > > > > if (ret < 0) > > > > return ret; > > > > if (ret > 0) > > > > ...we get an IRQ... > > > > > > The difference to gpiod_get_optional (and most other *_optional) is t= hat > > > you can use the NULL value as if it were a valid GPIO. > > > > > > As this isn't given with for irqs, I don't think changing the return > > > value has much sense. > > > > We actually want platform_get_irq_optional() to look different to all > > the other _optional() methods because it is not equivalent. If it > > looks the same, developers will assume it is the same, and get > > themselves into trouble. >=20 > Developers already assume it is the same, and thus forget they have > to check against -ENXIO instead of zero. Is this an ack for renaming platform_get_irq_optional() to platform_get_irq_silent()? And then a coccinelle or sparse or ... hook that catches people testing the return value against 0 would be great. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --xmww6gsp5dtrk3ed Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmHeljYACgkQwfwUeK3K 7AljMgf/RPunUgCLZTRo6HVoWGaeXoeKF+2cGlwuAsz4Z00TAkiSHfoaeZtHOlTi q5shu1KHHU618Mhtt6XvXodObLXVJs41ty1v6SytKsW7BJQt5naWkyRnggT5tFWu ggmVGMBXOmKX/wp2DCDa7dah1/SOrnFqP53whp6ZTB6oejvTyXmM97J3490sqGq5 MsUAM2Z9/yyDuSZevN858NdTs3OZGSfWvvhFoG4EurYBcNo4znZgjQ6JgBbg3L5J /m2yKP4XrG0hiM86Q5XlzUdX3r5ERS4K78HS9ywkjsC/gmXD3i3XQGIjcG5VMN7F HGppnegV30H+5MPW7Ws6xs2xopwryw== =d8xy -----END PGP SIGNATURE----- --xmww6gsp5dtrk3ed--