Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2053253pxb; Sun, 16 Jan 2022 08:23:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8W0zTTx0Mawuy0A0BrWKfDYlIxr8wXH4W/SRoc/lMQXX+OAP3qKjOXvKJsw9FhEoM/NMX X-Received: by 2002:a63:90c7:: with SMTP id a190mr5985114pge.438.1642350188247; Sun, 16 Jan 2022 08:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642350188; cv=none; d=google.com; s=arc-20160816; b=yno6vOyTlWuHpt9sIck9xRbgyNCVn3Vtd/EK7iDuTtE6fxUaOCAXK+YEeXGyenwraB ovYduWWYlBDOhwT1OcZIEuPfL7PgK/XwBzJjsBM/dZyMo9fsY+3zgyQ/RA0v+Gbv5X0C vXzMp9YeekHFiEDoF+zGOvinzxavQOLOzubtLwBT9P1FZH1et4VM2uxwC1bk5LY3Ttyp 8tR5I6YcX5xZnG4QpQXrnl4HulP8hm0fZrF82UFNmtLKw9yI8OGqUAyqVXdF7TWraxC7 A5aoW5ZVJsiRyA/EQkgmqIpcJXJsDSvdITXdsr2nMUcdm7oXTmXQFEMEExk7Bcwck/cl I4Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-filter; bh=XQJIsCoDA9XWHlT1hubSOl14qZzTpQ1P+L30BlKw4JI=; b=ZrDeXE7kchS/23Z0T40pTObMNGGHVdLVeFZ29JKlfoTkGEDWpBIzX8xbgwHRqRUbbd YgTYFpWf7F+grAt3tCNDHFf7tNXn/oYYWhyhLlSjlQO/kHcUTaNZQiueiZXJ+XEY26FX yFwF0XJvnWpfMTv0SG3PL2dWzxjEJT6674l1AEEr934JFknX04jpbM5PoL6Vk7v6yU0z gWN9sdOVe5TWGxTgJsWxdjJUI0BaNa6OGZWc7lL4MjY5I3UMa9OjL8q9BM/LM8CcmBCz LIAsmWclixk9kUK6/cBmg03CejfKlHSZSl6FPqbhBwR2qB0pdawak2EgfbdUys+pYc1+ 6rQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si12489486plf.81.2022.01.16.08.22.56; Sun, 16 Jan 2022 08:23:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233733AbiAOVGN (ORCPT + 99 others); Sat, 15 Jan 2022 16:06:13 -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-kernel@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