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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D377C433F5 for ; Wed, 12 Jan 2022 08:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ORyFAoPBO4AxwxzxO9/ytP4ouDDewmtN9rDce8wQBv4=; b=jfPZYf2MDf4qwciSGpdxHKovLU DfBtkBrWSzFwfHupepzCJA45/SLVP2j+Yhr9FKI8aVLHbnwomnn2wXKPSRPdBWRChaSO3mOtpXxNv vItnNAzZqrQxj3g+M9Skzte1dK/HFrljDIRAMjXXBUbOzarsbNEJZ/qDSJw441hSO4I/7YsYRPuor o/05rXGTB2gEL6MB2OWvFEE/kie1GCeD7augnAIZsRxHCYMakCp+V7sWmUYOZV3opMt3J9lQg2+46 vQgZyI/fDd25ZH5NVL/AXiMddzIH3IPDfJ+GzajStJt0Nf07GXyd2z0mvVHR5XDe8hwK/9qCGp1Jo Ykqkdncg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7ZOA-001dRA-It; Wed, 12 Jan 2022 08:53:50 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7ZNw-001dLF-0U for linux-phy@lists.infradead.org; Wed, 12 Jan 2022 08:53:37 +0000 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 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-phy@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220112_005336_065402_46DD8F89 X-CRM114-Status: GOOD ( 34.93 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1299439570321777102==" Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org --===============1299439570321777102== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xmww6gsp5dtrk3ed" Content-Disposition: inline --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-- --===============1299439570321777102== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy --===============1299439570321777102==--