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 37542C433F5 for ; Mon, 10 Jan 2022 20:11:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245703AbiAJULq (ORCPT ); Mon, 10 Jan 2022 15:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245676AbiAJULp (ORCPT ); Mon, 10 Jan 2022 15:11:45 -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 D6B5CC061748 for ; Mon, 10 Jan 2022 12:11:44 -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 1n70zq-0000Jr-8q; Mon, 10 Jan 2022 21:10:26 +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 1n70zg-009aNt-0Y; Mon, 10 Jan 2022 21:10:15 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1n70ze-0007V8-8f; Mon, 10 Jan 2022 21:10:14 +0100 Date: Mon, 10 Jan 2022 21:10:14 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Sergey Shtylyov Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , Jiri Slaby , Liam Girdwood , linux-iio@vger.kernel.org, Linus Walleij , Amit Kucheria , alsa-devel@alsa-project.org, Andy Shevchenko , Sebastian Reichel , linux-phy@lists.infradead.org, Thierry Reding , linux-mtd@lists.infradead.org, linux-i2c@vger.kernel.org, linux-gpio@vger.kernel.org, Miquel Raynal , Guenter Roeck , Lee Jones , openipmi-developer@lists.sourceforge.net, Saravanan Sekar , Khuong Dinh , Florian Fainelli , Matthias Schiffer , kvm@vger.kernel.org, Kamal Dasu , Richard Weinberger , Bartosz Golaszewski , Daniel Lezcano , Kishon Vijay Abraham I , bcm-kernel-feedback-list@broadcom.com, linux-serial@vger.kernel.org, Jakub Kicinski , Zhang Rui , Jaroslav Kysela , platform-driver-x86@vger.kernel.org, linux-pwm@vger.kernel.org, John Garry , Robert Richter , Zha Qipeng , Corey Minyard , linux-pm@vger.kernel.org, Peter Korsgaard , William Breathitt Gray , Mark Gross , Hans de Goede , Alex Williamson , Mark Brown , Borislav Petkov , Matthias Brugger , Takashi Iwai , Mauro Carvalho Chehab , Benson Leung , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, Tony Luck , Mun Yew Tham , Eric Auger , netdev@vger.kernel.org, Yoshihiro Shimoda , Cornelia Huck , linux-mmc@vger.kernel.org, Joakim Zhang , linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Vinod Koul , James Morse , Pengutronix Kernel Team , Niklas =?utf-8?Q?S=C3=B6derlund?= , linux-mediatek@lists.infradead.org, Brian Norris , "David S. Miller" Subject: Re: [PATCH 1/2] platform: make platform_get_irq_optional() optional Message-ID: <20220110201014.mtajyrfcfznfhyqm@pengutronix.de> References: <20220110195449.12448-1-s.shtylyov@omp.ru> <20220110195449.12448-2-s.shtylyov@omp.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="brvee3afuyivhyph" Content-Disposition: inline In-Reply-To: <20220110195449.12448-2-s.shtylyov@omp.ru> 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 --brvee3afuyivhyph Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, On Mon, Jan 10, 2022 at 10:54:48PM +0300, Sergey Shtylyov wrote: > This patch is based on the former Andy Shevchenko's patch: >=20 > https://lore.kernel.org/lkml/20210331144526.19439-1-andriy.shevchenko@lin= ux.intel.com/ >=20 > Currently platform_get_irq_optional() returns an error code even if IRQ > resource simply has not been found. It prevents the callers from being > error code agnostic in their error handling: >=20 > ret =3D platform_get_irq_optional(...); > if (ret < 0 && ret !=3D -ENXIO) > return ret; // respect deferred probe > if (ret > 0) > ...we get an IRQ... >=20 > All other *_optional() APIs seem to return 0 or NULL in case an optional > resource is not available. Let's follow this good example, so that the > callers would look like: >=20 > 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 that 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. In my eyes the problem with platform_get_irq() and platform_get_irq_optional() is that someone considered it was a good idea that a global function emits an error message. The problem is, that's only true most of the time. (Sometimes the caller can handle an error (here: the absence of an irq) just fine, sometimes the generic error message just isn't as good as a message by the caller could be. (here: The caller could emit "TX irq not found" which is a much nicer message than "IRQ index 5 not found".) My suggestion would be to keep the return value of platform_get_irq_optional() as is, but rename it to platform_get_irq_silent() to get rid of the expectation invoked by the naming similarity that motivated you to change platform_get_irq_optional(). Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --brvee3afuyivhyph Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmHckpoACgkQwfwUeK3K 7AmPEAf/e1sLmVHBLqGY9M4YYn2aUPQflQncGGvDAcCOcOjWhjj61Z53oAw8B/Eb 3J5RoNwe8DIoUyLHQa6DtxFAk+dFhxCCt/6oJngstFQmZYKw3pdpADTY7EDtYA8+ mYdn6pcScMhpA6OBtI9ybuLy2WaUubn5rCr+NsldDY9GS9GaUvCNWcayugGDQSH1 uHWNiupkgORajRdaD+ENzFqUohu0HSr6CPy0mid1+4h/9xcykRE38sjcmQ1n+7qs /Rpe0taiRj94Ut9mV/MW8nEARhxt+bRH/oI91P369tNKqaWP2IdMcyB04zJvNeLc YLmkZv+MpI9lIZU3TrRVSk9UVwA0BQ== =/ril -----END PGP SIGNATURE----- --brvee3afuyivhyph--