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 7DC83C433F5 for ; Thu, 13 Jan 2022 20:35:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234411AbiAMUfs (ORCPT ); Thu, 13 Jan 2022 15:35:48 -0500 Received: from mxout01.lancloud.ru ([45.84.86.81]:38800 "EHLO mxout01.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230515AbiAMUfn (ORCPT ); Thu, 13 Jan 2022 15:35:43 -0500 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout01.lancloud.ru 09BA62097191 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH 1/2] platform: make platform_get_irq_optional() optional To: Mark Brown , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= CC: Geert Uytterhoeven , Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , KVM list , "Rafael J. Wysocki" , , Linus Walleij , "Amit Kucheria" , ALSA Development Mailing List , Andy Shevchenko , Joakim Zhang , Guenter Roeck , Thierry Reding , MTD Maling List , Linux I2C , Miquel Raynal , , , linux-spi , Jiri Slaby , , "Khuong Dinh" , Florian Fainelli , Matthias Schiffer , Kamal Dasu , "Lee Jones" , Bartosz Golaszewski , "Daniel Lezcano" , Kishon Vijay Abraham I , bcm-kernel-feedback-list , "open list:SERIAL DRIVERS" , Jakub Kicinski , Zhang Rui , Jaroslav Kysela , Linux PWM List , Hans de Goede , Robert Richter , Saravanan Sekar , Corey Minyard , Linux PM list , Mauro Carvalho Chehab , "John Garry" , Peter Korsgaard , "William Breathitt Gray" , Mark Gross , "open list:GPIO SUBSYSTEM" , Alex Williamson , Borislav Petkov , "Sebastian Reichel" , Matthias Brugger , "Takashi Iwai" , , Benson Leung , Linux ARM , , Tony Luck , Mun Yew Tham , Eric Auger , "Greg Kroah-Hartman" , Yoshihiro Shimoda , Cornelia Huck , "Linux MMC List" , Liam Girdwood , Linux Kernel Mailing List , Linux-Renesas , Vinod Koul , "James Morse" , Zha Qipeng , "Pengutronix Kernel Team" , Richard Weinberger , =?UTF-8?Q?Niklas_S=c3=b6derlund?= , , Brian Norris , "David S. Miller" References: <20220110195449.12448-1-s.shtylyov@omp.ru> <20220110195449.12448-2-s.shtylyov@omp.ru> <20220110201014.mtajyrfcfznfhyqm@pengutronix.de> <20220112085009.dbasceh3obfok5dc@pengutronix.de> <20220112213121.5ruae5mxwj6t3qiy@pengutronix.de> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <29f0c65d-77f2-e5b2-f6cc-422add8a707d@omp.ru> Date: Thu, 13 Jan 2022 23:35:34 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/13/22 12:45 AM, Mark Brown wrote: [...] > (Do we really need *all* the CCs here?) Yeah, 25 files were changed and that resulted in 75 persons/lists addressed. I didn't expect such a wide audience myself... :-) >> That convinces me, that platform_get_irq_optional() is a bad name. The >> only difference to platform_get_irq is that it's silent. And returning >> a dummy irq value (which would make it aligned with the other _optional >> functions) isn't possible. > There is regulator_get_optional() which is I believe the earliest of > these APIs, it doesn't return a dummy either (and is silent too) - this Hm, I'm seeing it's rather noisy... :-) > is because regulator_get() does return a dummy since it's the vastly > common case that regulators must be physically present and them not > being found is due to there being an error in the system description. > It's unfortunate that we've ended up with these two different senses for > _optional(), people frequently get tripped up by it. > >>> To me it sounds much more logical for the driver to check if an >>> optional irq is non-zero (available) or zero (not available), than to >>> sprinkle around checks for -ENXIO. In addition, you have to remember >>> that this one returns -ENXIO, while other APIs use -ENOENT or -ENOSYS >>> (or some other error code) to indicate absence. I thought not having >>> to care about the actual error code was the main reason behind the >>> introduction of the *_optional() APIs. > >> No, the main benefit of gpiod_get_optional() (and clk_get_optional()) is >> that you can handle an absent GPIO (or clk) as if it were available. Hm, I've just looked at these and must note that they match 1:1 with platform_get_irq_optional(). Unfortunately, we can't however behave the same way in request_irq() -- because it has to support IRQ0 for the sake of i8253 drivers in arch/... > Similarly for the regulator API, kind of. MBR, Sergey