From mboxrd@z Thu Jan 1 00:00:00 1970 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 5130FC4321E for ; Sat, 15 Jan 2022 21:06:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233724AbiAOVGL (ORCPT ); Sat, 15 Jan 2022 16:06:11 -0500 Received: from mxout01.lancloud.ru ([45.84.86.81]:45150 "EHLO mxout01.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233684AbiAOVGK (ORCPT ); Sat, 15 Jan 2022 16:06:10 -0500 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout01.lancloud.ru 2176D209C7CC Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH] driver core: platform: Rename platform_get_irq_optional() to platform_get_irq_silent() To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , "Geert Uytterhoeven" CC: Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , KVM list , "Rafael J. Wysocki" , , "Linus Walleij" , Amit Kucheria , "ALSA Development Mailing List" , Andy Shevchenko , Jaroslav Kysela , Guenter Roeck , Thierry Reding , MTD Maling List , Linux I2C , Miquel Raynal , , Jiri Slaby , , "Khuong Dinh" , Florian Fainelli , Matthias Schiffer , Joakim Zhang , Kamal Dasu , Greg Kroah-Hartman , Lee Jones , "Bartosz Golaszewski" , Daniel Lezcano , "Tony Luck" , Kishon Vijay Abraham I , bcm-kernel-feedback-list , "open list:SERIAL DRIVERS" , Jakub Kicinski , Zhang Rui , Linux PWM List , Robert Richter , "Saravanan Sekar" , Corey Minyard , Linux PM list , Linux Kernel Mailing List , Mauro Carvalho Chehab , John Garry , Peter Korsgaard , William Breathitt Gray , Mark Gross , "open list:GPIO SUBSYSTEM" , Alex Williamson , Mark Brown , Borislav Petkov , "Sebastian Reichel" , Eric Auger , "Matthias Brugger" , Takashi Iwai , , Benson Leung , Linux ARM , , Mun Yew Tham , "Hans de Goede" , netdev , "Yoshihiro Shimoda" , Cornelia Huck , Linux MMC List , "Liam Girdwood" , linux-spi , 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: <20220112213121.5ruae5mxwj6t3qiy@pengutronix.de> <20220113110831.wvwbm75hbfysbn2d@pengutronix.de> <20220113194358.xnnbhsoyetihterb@pengutronix.de> <1df04d74-8aa2-11f1-54e9-34d0e8f4e58b@omp.ru> <20220113224319.akljsjtu7ps75vun@pengutronix.de> <20220115152102.m47snsdrw2elagak@pengutronix.de> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <77cea138-977a-1454-4808-bd16dd7d2734@omp.ru> Date: Sun, 16 Jan 2022 00:06:00 +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: <20220115152102.m47snsdrw2elagak@pengutronix.de> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On 1/15/22 6:21 PM, Uwe Kleine-König wrote: [...] >>>>>> The subsystems regulator, clk and gpio have the concept of a dummy >>>>>> resource. For regulator, clk and gpio there is a semantic difference >>>>>> between the regular _get() function and the _get_optional() variant. >>>>>> (One might return the dummy resource, the other won't. Unfortunately >>>>>> which one implements which isn't the same for these three.) The >>>>>> difference between platform_get_irq() and platform_get_irq_optional() is >>>>>> only that the former might emit an error message and the later won't. >>>> >>>> This is only a current difference but I'm still going to return 0 ISO >>>> -ENXIO from latform_get_irq_optional(), no way I'd leave that -ENXIO there >>>> alone... :-) >>> >>> This would address a bit of the critic in my commit log. But as 0 isn't >>> a dummy value like the dummy values that exist for clk, gpiod and >>> regulator I still think that the naming is a bad idea because it's not >>> in the spirit of the other *_get_optional functions. >>> >>> Seeing you say that -ENXIO is a bad return value for >>> platform_get_irq_optional() and 0 should be used instead, I wonder why >>> not changing platform_get_irq() to return 0 instead of -ENXIO, too. >>> This question is for now only about a sensible semantic. That actually >>> changing platform_get_irq() is probably harder than changing >>> platform_get_irq_optional() is a different story. >>> >>> If only platform_get_irq_optional() is changed and given that the >>> callers have to do something like: >>> >>> if (this_irq_exists()): >>> ... (e.g. request_irq) >>> else: >>> ... (e.g. setup polling) >>> >>> I really think it's a bad idea that this_irq_exists() has to be >>> different for platform_get_irq() vs. platform_get_irq_optional(). >> >> For platform_get_irq(), the IRQ being absent is an error condition, >> hence it should return an error code. >> For platform_get_irq_optional(), the IRQ being absent is not an error >> condition, hence it should not return an error code, and 0 is OK. > > Please show a few examples how this simplifies the code. If it's only As for platform_get_irq(), returning -ENXIO simplifies things a lot: you don't have to check for 0 at every freaking call site and have s/th like (every time!): irq = platform_get_irq(); if (irq <= 0) return irq ?: -ENXIO; // any error code you choose instead of just: irq = platform_get_irq(); if (irq < 0) return irq; This scales better in my book. > that a driver has to check for == 0 instead of == -ENXIO, than that's > not a good enough motivation to make platform_get_irq_optional() > different to platform_get_irq(). Again, it scales better... good motivation in my eyes. > Best regards > Uwe MBR, Sergey From mboxrd@z Thu Jan 1 00:00:00 1970 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 212A2C433EF for ; Sat, 15 Jan 2022 21:06:21 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:CC:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Mpohpa+rMbX2rM6cVNKgXJJgKbI2sqKYtgkgHZrQYwc=; b=3KgY9sxY2qXaHb5UNb0NJcWTff qRIv5UgQY+gAbWZzl548AszgwAOXeS9dMtjD4K8zGIsFlTbSYfSGK27Lo/DUq6SCOJezvVoQgyE0E t2J/ZjVuvnrWrvHq+caAXgYqyQTJ9sXKVvwQu5XmEmyvoy5uHhJqESTEWuV7jUDiHlmQV+DZ3E1jl E7ShEUYAuuxzE5xrYS6ZC9A8V/5fF+nsXvrdTNcgoFBVRoGahO22wIZlMmMO5sRLH6E7sQKjO96/X bO5Z9PL5z6Uc4lLGHuz1vXjopuxMUTsJq/B3BZjsrIC3TgIt0cc5WqI0nrgMaXP5+hJAZHm1Z37sG PpdJwj/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8qFZ-00BZI5-SV; Sat, 15 Jan 2022 21:06:13 +0000 Received: from mxout04.lancloud.ru ([45.84.86.114]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8qFV-00BZH5-16; Sat, 15 Jan 2022 21:06:11 +0000 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout04.lancloud.ru 21DDC20ADE46 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH] driver core: platform: Rename platform_get_irq_optional() to platform_get_irq_silent() To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , "Geert Uytterhoeven" CC: Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , KVM list , "Rafael J. Wysocki" , , "Linus Walleij" , Amit Kucheria , "ALSA Development Mailing List" , Andy Shevchenko , Jaroslav Kysela , Guenter Roeck , Thierry Reding , MTD Maling List , Linux I2C , Miquel Raynal , , Jiri Slaby , , "Khuong Dinh" , Florian Fainelli , Matthias Schiffer , Joakim Zhang , Kamal Dasu , Greg Kroah-Hartman , Lee Jones , "Bartosz Golaszewski" , Daniel Lezcano , "Tony Luck" , Kishon Vijay Abraham I , bcm-kernel-feedback-list , "open list:SERIAL DRIVERS" , Jakub Kicinski , Zhang Rui , Linux PWM List , Robert Richter , "Saravanan Sekar" , Corey Minyard , Linux PM list , Linux Kernel Mailing List , Mauro Carvalho Chehab , John Garry , Peter Korsgaard , William Breathitt Gray , Mark Gross , "open list:GPIO SUBSYSTEM" , Alex Williamson , Mark Brown , Borislav Petkov , "Sebastian Reichel" , Eric Auger , "Matthias Brugger" , Takashi Iwai , , Benson Leung , Linux ARM , , Mun Yew Tham , "Hans de Goede" , netdev , "Yoshihiro Shimoda" , Cornelia Huck , Linux MMC List , "Liam Girdwood" , linux-spi , 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: <20220112213121.5ruae5mxwj6t3qiy@pengutronix.de> <20220113110831.wvwbm75hbfysbn2d@pengutronix.de> <20220113194358.xnnbhsoyetihterb@pengutronix.de> <1df04d74-8aa2-11f1-54e9-34d0e8f4e58b@omp.ru> <20220113224319.akljsjtu7ps75vun@pengutronix.de> <20220115152102.m47snsdrw2elagak@pengutronix.de> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <77cea138-977a-1454-4808-bd16dd7d2734@omp.ru> Date: Sun, 16 Jan 2022 00:06:00 +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: <20220115152102.m47snsdrw2elagak@pengutronix.de> Content-Language: en-US X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220115_130609_472883_B0B8D2CB X-CRM114-Status: GOOD ( 24.82 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On 1/15/22 6:21 PM, Uwe Kleine-K=F6nig wrote: [...] >>>>>> The subsystems regulator, clk and gpio have the concept of a dummy >>>>>> resource. For regulator, clk and gpio there is a semantic difference >>>>>> between the regular _get() function and the _get_optional() variant. >>>>>> (One might return the dummy resource, the other won't. Unfortunately >>>>>> which one implements which isn't the same for these three.) The >>>>>> difference between platform_get_irq() and platform_get_irq_optional(= ) is >>>>>> only that the former might emit an error message and the later won't. >>>> >>>> This is only a current difference but I'm still going to return 0 I= SO >>>> -ENXIO from latform_get_irq_optional(), no way I'd leave that -ENXIO t= here >>>> alone... :-) >>> >>> This would address a bit of the critic in my commit log. But as 0 isn't >>> a dummy value like the dummy values that exist for clk, gpiod and >>> regulator I still think that the naming is a bad idea because it's not >>> in the spirit of the other *_get_optional functions. >>> >>> Seeing you say that -ENXIO is a bad return value for >>> platform_get_irq_optional() and 0 should be used instead, I wonder why >>> not changing platform_get_irq() to return 0 instead of -ENXIO, too. >>> This question is for now only about a sensible semantic. That actually >>> changing platform_get_irq() is probably harder than changing >>> platform_get_irq_optional() is a different story. >>> >>> If only platform_get_irq_optional() is changed and given that the >>> callers have to do something like: >>> >>> if (this_irq_exists()): >>> ... (e.g. request_irq) >>> else: >>> ... (e.g. setup polling) >>> >>> I really think it's a bad idea that this_irq_exists() has to be >>> different for platform_get_irq() vs. platform_get_irq_optional(). >> >> For platform_get_irq(), the IRQ being absent is an error condition, >> hence it should return an error code. >> For platform_get_irq_optional(), the IRQ being absent is not an error >> condition, hence it should not return an error code, and 0 is OK. > = > Please show a few examples how this simplifies the code. If it's only As for platform_get_irq(), returning -ENXIO simplifies things a lot: you= don't have to check for 0 at every freaking call site and have s/th like (every time!): irq =3D platform_get_irq(); if (irq <=3D 0) return irq ?: -ENXIO; // any error code you choose instead of just: irq =3D platform_get_irq(); if (irq < 0) return irq; This scales better in my book. > that a driver has to check for =3D=3D 0 instead of =3D=3D -ENXIO, than th= at's > not a good enough motivation to make platform_get_irq_optional() > different to platform_get_irq(). Again, it scales better... good motivation in my eyes. > Best regards > Uwe MBR, Sergey _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 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 E0663C433EF for ; Sat, 15 Jan 2022 21:06:27 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:CC:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/CcEli0s1rfeLmcjLr4IC5ZkQC9O1jMYn0HnuXtqr8A=; b=LyMMuVw5Qb/JYDLlqfZd0ChWRr Nakmifr++8zIuCp234J7ZWQMBlKkPLDCV40c7Fwp+K8AMjl13q6FBLTM8a/LzW0UlL5t9TuCLTbnI qWb8uptuS/iRLrjkAnBb5luFsoX53I7YAW/VCqCQU1YwExWm/MEn82d5Pxl5iBg7IXEpT5fuDM5w8 2VtoVME/RM5RX3EKZW/0oDdJYGC5VZ8DE7yzdqXie3vRR8HzT4cgL1cNJhDHhn/MjIzXqKv2U2HZL 6mjohKDZFhup8HfzvAAYpxAZF5+8OwIxA+l0dNyrjnY3KqXbjDLqhDw1DSMTKwI5culeOMqc9MdZT /OqU/AFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8qFn-00BZMN-C6; Sat, 15 Jan 2022 21:06:27 +0000 Received: from mxout04.lancloud.ru ([45.84.86.114]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8qFV-00BZH5-16; Sat, 15 Jan 2022 21:06:11 +0000 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout04.lancloud.ru 21DDC20ADE46 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH] driver core: platform: Rename platform_get_irq_optional() to platform_get_irq_silent() To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , "Geert Uytterhoeven" CC: Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , KVM list , "Rafael J. Wysocki" , , "Linus Walleij" , Amit Kucheria , "ALSA Development Mailing List" , Andy Shevchenko , Jaroslav Kysela , Guenter Roeck , Thierry Reding , MTD Maling List , Linux I2C , Miquel Raynal , , Jiri Slaby , , "Khuong Dinh" , Florian Fainelli , Matthias Schiffer , Joakim Zhang , Kamal Dasu , Greg Kroah-Hartman , Lee Jones , "Bartosz Golaszewski" , Daniel Lezcano , "Tony Luck" , Kishon Vijay Abraham I , bcm-kernel-feedback-list , "open list:SERIAL DRIVERS" , Jakub Kicinski , Zhang Rui , Linux PWM List , Robert Richter , "Saravanan Sekar" , Corey Minyard , Linux PM list , Linux Kernel Mailing List , Mauro Carvalho Chehab , John Garry , Peter Korsgaard , William Breathitt Gray , Mark Gross , "open list:GPIO SUBSYSTEM" , Alex Williamson , Mark Brown , Borislav Petkov , "Sebastian Reichel" , Eric Auger , "Matthias Brugger" , Takashi Iwai , , Benson Leung , Linux ARM , , Mun Yew Tham , "Hans de Goede" , netdev , "Yoshihiro Shimoda" , Cornelia Huck , Linux MMC List , "Liam Girdwood" , linux-spi , 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: <20220112213121.5ruae5mxwj6t3qiy@pengutronix.de> <20220113110831.wvwbm75hbfysbn2d@pengutronix.de> <20220113194358.xnnbhsoyetihterb@pengutronix.de> <1df04d74-8aa2-11f1-54e9-34d0e8f4e58b@omp.ru> <20220113224319.akljsjtu7ps75vun@pengutronix.de> <20220115152102.m47snsdrw2elagak@pengutronix.de> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <77cea138-977a-1454-4808-bd16dd7d2734@omp.ru> Date: Sun, 16 Jan 2022 00:06:00 +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: <20220115152102.m47snsdrw2elagak@pengutronix.de> Content-Language: en-US X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220115_130609_472883_B0B8D2CB X-CRM114-Status: GOOD ( 24.82 ) 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: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org On 1/15/22 6:21 PM, Uwe Kleine-K=F6nig wrote: [...] >>>>>> The subsystems regulator, clk and gpio have the concept of a dummy >>>>>> resource. For regulator, clk and gpio there is a semantic difference >>>>>> between the regular _get() function and the _get_optional() variant. >>>>>> (One might return the dummy resource, the other won't. Unfortunately >>>>>> which one implements which isn't the same for these three.) The >>>>>> difference between platform_get_irq() and platform_get_irq_optional(= ) is >>>>>> only that the former might emit an error message and the later won't. >>>> >>>> This is only a current difference but I'm still going to return 0 I= SO >>>> -ENXIO from latform_get_irq_optional(), no way I'd leave that -ENXIO t= here >>>> alone... :-) >>> >>> This would address a bit of the critic in my commit log. But as 0 isn't >>> a dummy value like the dummy values that exist for clk, gpiod and >>> regulator I still think that the naming is a bad idea because it's not >>> in the spirit of the other *_get_optional functions. >>> >>> Seeing you say that -ENXIO is a bad return value for >>> platform_get_irq_optional() and 0 should be used instead, I wonder why >>> not changing platform_get_irq() to return 0 instead of -ENXIO, too. >>> This question is for now only about a sensible semantic. That actually >>> changing platform_get_irq() is probably harder than changing >>> platform_get_irq_optional() is a different story. >>> >>> If only platform_get_irq_optional() is changed and given that the >>> callers have to do something like: >>> >>> if (this_irq_exists()): >>> ... (e.g. request_irq) >>> else: >>> ... (e.g. setup polling) >>> >>> I really think it's a bad idea that this_irq_exists() has to be >>> different for platform_get_irq() vs. platform_get_irq_optional(). >> >> For platform_get_irq(), the IRQ being absent is an error condition, >> hence it should return an error code. >> For platform_get_irq_optional(), the IRQ being absent is not an error >> condition, hence it should not return an error code, and 0 is OK. > = > Please show a few examples how this simplifies the code. If it's only As for platform_get_irq(), returning -ENXIO simplifies things a lot: you= don't have to check for 0 at every freaking call site and have s/th like (every time!): irq =3D platform_get_irq(); if (irq <=3D 0) return irq ?: -ENXIO; // any error code you choose instead of just: irq =3D platform_get_irq(); if (irq < 0) return irq; This scales better in my book. > that a driver has to check for =3D=3D 0 instead of =3D=3D -ENXIO, than th= at's > not a good enough motivation to make platform_get_irq_optional() > different to platform_get_irq(). Again, it scales better... good motivation in my eyes. > Best regards > Uwe MBR, Sergey -- = linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy From mboxrd@z Thu Jan 1 00:00:00 1970 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 54250C433EF for ; Sat, 15 Jan 2022 21:06:54 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:CC:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2yyHho3PCHCJpZSleQnw/qyDEQwNKpTA7Zc4Ed17CWk=; b=0eRB8wV2MUKrvstxH9RjTs62ql 33ctBGTY9XwU09G4A6JTLwTPUgxtdaEsdh23jwaGTh7YQyOtUpYpZdMhI5ZfKmHmLx2/ow5kc1v6N j3putqRXV+7Us6wUIve+c1APR3OSHnZjZo5xZsQAzueVQXSLjTFO7gQldXgp9kogJyXagRnlunMF1 pP3vg6KWqcE87hSpAHooPo6EjykNNGOc/7/TfquCidkanm4OO3rr6M4f/cHgN0/krajQJm4ClKJB1 VdKlWp7hmsDaKrocUFTTNIWZIc1qpvJyZ2I+0N6vqf2Pptjgrm3/53/5raIbCybJ5Crt/+yFxwCvs kX0K2/ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8qFa-00BZIK-UD; Sat, 15 Jan 2022 21:06:15 +0000 Received: from mxout04.lancloud.ru ([45.84.86.114]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8qFV-00BZH5-16; Sat, 15 Jan 2022 21:06:11 +0000 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout04.lancloud.ru 21DDC20ADE46 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH] driver core: platform: Rename platform_get_irq_optional() to platform_get_irq_silent() To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , "Geert Uytterhoeven" CC: Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , KVM list , "Rafael J. Wysocki" , , "Linus Walleij" , Amit Kucheria , "ALSA Development Mailing List" , Andy Shevchenko , Jaroslav Kysela , Guenter Roeck , Thierry Reding , MTD Maling List , Linux I2C , Miquel Raynal , , Jiri Slaby , , "Khuong Dinh" , Florian Fainelli , Matthias Schiffer , Joakim Zhang , Kamal Dasu , Greg Kroah-Hartman , Lee Jones , "Bartosz Golaszewski" , Daniel Lezcano , "Tony Luck" , Kishon Vijay Abraham I , bcm-kernel-feedback-list , "open list:SERIAL DRIVERS" , Jakub Kicinski , Zhang Rui , Linux PWM List , Robert Richter , "Saravanan Sekar" , Corey Minyard , Linux PM list , Linux Kernel Mailing List , Mauro Carvalho Chehab , John Garry , Peter Korsgaard , William Breathitt Gray , Mark Gross , "open list:GPIO SUBSYSTEM" , Alex Williamson , Mark Brown , Borislav Petkov , "Sebastian Reichel" , Eric Auger , "Matthias Brugger" , Takashi Iwai , , Benson Leung , Linux ARM , , Mun Yew Tham , "Hans de Goede" , netdev , "Yoshihiro Shimoda" , Cornelia Huck , Linux MMC List , "Liam Girdwood" , linux-spi , 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: <20220112213121.5ruae5mxwj6t3qiy@pengutronix.de> <20220113110831.wvwbm75hbfysbn2d@pengutronix.de> <20220113194358.xnnbhsoyetihterb@pengutronix.de> <1df04d74-8aa2-11f1-54e9-34d0e8f4e58b@omp.ru> <20220113224319.akljsjtu7ps75vun@pengutronix.de> <20220115152102.m47snsdrw2elagak@pengutronix.de> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <77cea138-977a-1454-4808-bd16dd7d2734@omp.ru> Date: Sun, 16 Jan 2022 00:06:00 +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: <20220115152102.m47snsdrw2elagak@pengutronix.de> Content-Language: en-US X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220115_130609_472883_B0B8D2CB X-CRM114-Status: GOOD ( 24.82 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On 1/15/22 6:21 PM, Uwe Kleine-K=F6nig wrote: [...] >>>>>> The subsystems regulator, clk and gpio have the concept of a dummy >>>>>> resource. For regulator, clk and gpio there is a semantic difference >>>>>> between the regular _get() function and the _get_optional() variant. >>>>>> (One might return the dummy resource, the other won't. Unfortunately >>>>>> which one implements which isn't the same for these three.) The >>>>>> difference between platform_get_irq() and platform_get_irq_optional(= ) is >>>>>> only that the former might emit an error message and the later won't. >>>> >>>> This is only a current difference but I'm still going to return 0 I= SO >>>> -ENXIO from latform_get_irq_optional(), no way I'd leave that -ENXIO t= here >>>> alone... :-) >>> >>> This would address a bit of the critic in my commit log. But as 0 isn't >>> a dummy value like the dummy values that exist for clk, gpiod and >>> regulator I still think that the naming is a bad idea because it's not >>> in the spirit of the other *_get_optional functions. >>> >>> Seeing you say that -ENXIO is a bad return value for >>> platform_get_irq_optional() and 0 should be used instead, I wonder why >>> not changing platform_get_irq() to return 0 instead of -ENXIO, too. >>> This question is for now only about a sensible semantic. That actually >>> changing platform_get_irq() is probably harder than changing >>> platform_get_irq_optional() is a different story. >>> >>> If only platform_get_irq_optional() is changed and given that the >>> callers have to do something like: >>> >>> if (this_irq_exists()): >>> ... (e.g. request_irq) >>> else: >>> ... (e.g. setup polling) >>> >>> I really think it's a bad idea that this_irq_exists() has to be >>> different for platform_get_irq() vs. platform_get_irq_optional(). >> >> For platform_get_irq(), the IRQ being absent is an error condition, >> hence it should return an error code. >> For platform_get_irq_optional(), the IRQ being absent is not an error >> condition, hence it should not return an error code, and 0 is OK. > = > Please show a few examples how this simplifies the code. If it's only As for platform_get_irq(), returning -ENXIO simplifies things a lot: you= don't have to check for 0 at every freaking call site and have s/th like (every time!): irq =3D platform_get_irq(); if (irq <=3D 0) return irq ?: -ENXIO; // any error code you choose instead of just: irq =3D platform_get_irq(); if (irq < 0) return irq; This scales better in my book. > that a driver has to check for =3D=3D 0 instead of =3D=3D -ENXIO, than th= at's > not a good enough motivation to make platform_get_irq_optional() > different to platform_get_irq(). Again, it scales better... good motivation in my eyes. > Best regards > Uwe MBR, Sergey ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ From mboxrd@z Thu Jan 1 00:00:00 1970 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 E63C8C433EF for ; Sun, 16 Jan 2022 08:53:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 39652185D; Sun, 16 Jan 2022 09:53:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 39652185D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642323236; bh=yaYV1g277um5HLPe6lEsLO6FgK87nDFflSFNYdAsGbU=; h=Subject:To:References:From:Date:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aHkgu2X4qCubdZyRaqA6VHrRKSExw2V2r7pn/8DrsmKt1yCpnNzm6cCeSRT+8XRFf iyjIU6nAmZG43h5VOmrD/DC5AqV5GBzONI0z56rIavueun8deubYjw8NOE6xDXLyZ+ 3fJa3P5UwhkV/AT0l9w23uDgKNX02VwQ9/V5WWHI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 120C4F80527; Sun, 16 Jan 2022 09:50:56 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 46168F800B0; Sat, 15 Jan 2022 22:06:21 +0100 (CET) Received: from mxout04.lancloud.ru (mxout04.lancloud.ru [45.84.86.114]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 63D67F800B0 for ; Sat, 15 Jan 2022 22:06:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 63D67F800B0 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout04.lancloud.ru 21DDC20ADE46 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH] driver core: platform: Rename platform_get_irq_optional() to platform_get_irq_silent() To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , "Geert Uytterhoeven" References: <20220112213121.5ruae5mxwj6t3qiy@pengutronix.de> <20220113110831.wvwbm75hbfysbn2d@pengutronix.de> <20220113194358.xnnbhsoyetihterb@pengutronix.de> <1df04d74-8aa2-11f1-54e9-34d0e8f4e58b@omp.ru> <20220113224319.akljsjtu7ps75vun@pengutronix.de> <20220115152102.m47snsdrw2elagak@pengutronix.de> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <77cea138-977a-1454-4808-bd16dd7d2734@omp.ru> Date: Sun, 16 Jan 2022 00:06:00 +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: <20220115152102.m47snsdrw2elagak@pengutronix.de> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT02.lancloud.ru (fd00:f066::142) To LFEX1907.lancloud.ru (fd00:f066::207) X-Mailman-Approved-At: Sun, 16 Jan 2022 09:50:50 +0100 Cc: Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , KVM list , "Rafael J. Wysocki" , linux-iio@vger.kernel.org, Linus Walleij , Amit Kucheria , ALSA Development Mailing List , Guenter Roeck , Thierry Reding , MTD Maling List , Linux I2C , Miquel Raynal , linux-phy@lists.infradead.org, linux-spi , Jiri Slaby , "David S. Miller" , 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 , platform-driver-x86@vger.kernel.org, Linux PWM List , Hans de Goede , Robert Richter , Saravanan Sekar , Corey Minyard , Linux PM list , Liam Girdwood , Mauro Carvalho Chehab , John Garry , Peter Korsgaard , William Breathitt Gray , Mark Gross , "open list:GPIO SUBSYSTEM" , Alex Williamson , Mark Brown , Borislav Petkov , Takashi Iwai , Matthias Brugger , openipmi-developer@lists.sourceforge.net, Andy Shevchenko , Benson Leung , Pengutronix Kernel Team , Linux ARM , linux-edac@vger.kernel.org, Tony Luck , Richard Weinberger , Mun Yew Tham , Eric Auger , Greg Kroah-Hartman , Yoshihiro Shimoda , Cornelia Huck , Linux MMC List , Joakim Zhang , Linux Kernel Mailing List , Linux-Renesas , Vinod Koul , James Morse , Zha Qipeng , Sebastian Reichel , =?UTF-8?Q?Niklas_S=c3=b6derlund?= , linux-mediatek@lists.infradead.org, Brian Norris , netdev X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On 1/15/22 6:21 PM, Uwe Kleine-König wrote: [...] >>>>>> The subsystems regulator, clk and gpio have the concept of a dummy >>>>>> resource. For regulator, clk and gpio there is a semantic difference >>>>>> between the regular _get() function and the _get_optional() variant. >>>>>> (One might return the dummy resource, the other won't. Unfortunately >>>>>> which one implements which isn't the same for these three.) The >>>>>> difference between platform_get_irq() and platform_get_irq_optional() is >>>>>> only that the former might emit an error message and the later won't. >>>> >>>> This is only a current difference but I'm still going to return 0 ISO >>>> -ENXIO from latform_get_irq_optional(), no way I'd leave that -ENXIO there >>>> alone... :-) >>> >>> This would address a bit of the critic in my commit log. But as 0 isn't >>> a dummy value like the dummy values that exist for clk, gpiod and >>> regulator I still think that the naming is a bad idea because it's not >>> in the spirit of the other *_get_optional functions. >>> >>> Seeing you say that -ENXIO is a bad return value for >>> platform_get_irq_optional() and 0 should be used instead, I wonder why >>> not changing platform_get_irq() to return 0 instead of -ENXIO, too. >>> This question is for now only about a sensible semantic. That actually >>> changing platform_get_irq() is probably harder than changing >>> platform_get_irq_optional() is a different story. >>> >>> If only platform_get_irq_optional() is changed and given that the >>> callers have to do something like: >>> >>> if (this_irq_exists()): >>> ... (e.g. request_irq) >>> else: >>> ... (e.g. setup polling) >>> >>> I really think it's a bad idea that this_irq_exists() has to be >>> different for platform_get_irq() vs. platform_get_irq_optional(). >> >> For platform_get_irq(), the IRQ being absent is an error condition, >> hence it should return an error code. >> For platform_get_irq_optional(), the IRQ being absent is not an error >> condition, hence it should not return an error code, and 0 is OK. > > Please show a few examples how this simplifies the code. If it's only As for platform_get_irq(), returning -ENXIO simplifies things a lot: you don't have to check for 0 at every freaking call site and have s/th like (every time!): irq = platform_get_irq(); if (irq <= 0) return irq ?: -ENXIO; // any error code you choose instead of just: irq = platform_get_irq(); if (irq < 0) return irq; This scales better in my book. > that a driver has to check for == 0 instead of == -ENXIO, than that's > not a good enough motivation to make platform_get_irq_optional() > different to platform_get_irq(). Again, it scales better... good motivation in my eyes. > Best regards > Uwe MBR, Sergey