Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1241694pxb; Fri, 21 Jan 2022 13:09:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZw/+N9QoRkqHzlgRLPRXLK3ESXJL0V8jhgRSKhnkFYufxdCnPshv21x0bs5fPML3gRV7Y X-Received: by 2002:a05:6a00:10d5:b0:4bc:a0eb:c6a0 with SMTP id d21-20020a056a0010d500b004bca0ebc6a0mr5367153pfu.70.1642799355207; Fri, 21 Jan 2022 13:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799355; cv=none; d=google.com; s=arc-20160816; b=deY90zM45SjYFnbJKkULgwnKGtYk8IweYrZIKl0Y+8TE6Sln+mM8TzqDTlT8/VYc81 /3p9fUI/IYfZrf1wcbbUWgHw2W0C3QwqkN27DdYh1XEk1a/rJNbOeViJxHyFNM1tAYfL NsEsRP9q+PwsZ/cMdwbK2zEkX0ekejL8nDUnS5xvy2uZZkxWLfJly+9mAWu2Kg73JsoU 9KJuV+KcPUJ4cOrnHY1roCxYnuIzjjoDqU/G4jYRBbNhJikDICanS50OBOC2q5Ybmw5t cICIZOd/ksKlXk4hp68KevdKYDrg2gC1idhtkAr0ZaLB4ke/iqpNKV+T7XMlUTFSv5W2 TAdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=SiFRhEFAle14KmEgr0WcA6pdolhotxhbY/6D0GleGu4=; b=deV3vTsAPc4ciPnxJBp6KN6hAn8U/KdMZwMYIlR6GmhGMncRqPX7/FcGG1hWeAcMNN V+pCkvQ8D1KaKhwNkQYabP1s9UbnIeHQZQcv+EnH38jILmfGVeVaQKkMvtr480KQqjZb 7RuOoYlJjeHadUJFEphP6S8ONO6r2yMW6cqUzXLmJuI7cuiCTyQORDXVRcu4RHsHWYfk 5Er9CVWKV5eNNUk/wBNOmB2Q045btvLE+jrryNqTMsornCJ5eN4UMTZ66/slKq0xSjOX GOCpcxfyKMlSpYWjh1T+3YEpvatW84m8ERtjeJ6C7BLLk8UeQ2geey0sB++s4fNA7LXu qa4g== 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 l12si8279783pls.599.2022.01.21.13.09.03; Fri, 21 Jan 2022 13:09:15 -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 S1357523AbiATH6m (ORCPT + 99 others); Thu, 20 Jan 2022 02:58:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344508AbiATH6h (ORCPT ); Thu, 20 Jan 2022 02:58:37 -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 CAE9FC061574 for ; Wed, 19 Jan 2022 23:58:36 -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 1nASK7-0002RI-3O; Thu, 20 Jan 2022 08:57:35 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1nASJu-00BJom-IA; Thu, 20 Jan 2022 08:57:21 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nASJt-000Bvo-3V; Thu, 20 Jan 2022 08:57:21 +0100 Date: Thu, 20 Jan 2022 08:57:18 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Andy Shevchenko 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 , Jaroslav Kysela , Guenter Roeck , Thierry Reding , MTD Maling List , Linux I2C , Miquel Raynal , linux-phy@lists.infradead.org, Jiri Slaby , openipmi-developer@lists.sourceforge.net, Khuong Dinh , Florian Fainelli , Matthias Schiffer , Joakim Zhang , Kamal Dasu , Greg Kroah-Hartman , Lee Jones , Bartosz Golaszewski , Daniel Lezcano , Kishon Vijay Abraham I , Geert Uytterhoeven , "open list:SERIAL DRIVERS" , bcm-kernel-feedback-list , 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 , Jakub Kicinski , Matthias Brugger , Takashi Iwai , platform-driver-x86@vger.kernel.org, Benson Leung , Linux ARM , linux-edac@vger.kernel.org, Tony Luck , Mun Yew Tham , Hans de Goede , netdev@vger.kernel.org, Yoshihiro Shimoda , Cornelia Huck , Linux MMC List , Liam Girdwood , linux-spi , Linux-Renesas , Sergey Shtylyov , Vinod Koul , James Morse , Zha Qipeng , Pengutronix Kernel Team , Richard Weinberger , Niklas =?utf-8?Q?S=C3=B6derlund?= , linux-mediatek@lists.infradead.org, Brian Norris , "David S. Miller" Subject: Re: [PATCH] driver core: platform: Rename platform_get_irq_optional() to platform_get_irq_silent() Message-ID: <20220120075718.5qtrpc543kkykaow@pengutronix.de> References: <20220112085009.dbasceh3obfok5dc@pengutronix.de> <20220112213121.5ruae5mxwj6t3qiy@pengutronix.de> <20220113110831.wvwbm75hbfysbn2d@pengutronix.de> <20220113194358.xnnbhsoyetihterb@pengutronix.de> <20220115154539.j3tsz5ioqexq2yuu@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vtmtr3soi3npiqhl" Content-Disposition: inline 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-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --vtmtr3soi3npiqhl Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 19, 2022 at 08:51:29PM +0200, Andy Shevchenko wrote: > On Sat, Jan 15, 2022 at 04:45:39PM +0100, Uwe Kleine-K=F6nig wrote: > > On Fri, Jan 14, 2022 at 03:04:38PM +0200, Andy Shevchenko wrote: > > > On Thu, Jan 13, 2022 at 08:43:58PM +0100, Uwe Kleine-K=F6nig wrote: > > > > > It'd certainly be good to name anything that doesn't correspond t= o one > > > > > of the existing semantics for the API (!) something different rat= her > > > > > than adding yet another potentially overloaded meaning. > > > >=20 > > > > It seems we're (at least) three who agree about this. Here is a pat= ch > > > > fixing the name. > > >=20 > > > And similar number of people are on the other side. > >=20 > > If someone already opposed to the renaming (and not only the name) I > > must have missed that. > >=20 > > So you think it's a good idea to keep the name > > platform_get_irq_optional() despite the "not found" value returned by it > > isn't usable as if it were a normal irq number? >=20 > I meant that on the other side people who are in favour of Sergey's patch. > Since that I commented already that I opposed the renaming being a standa= lone > change. >=20 > Do you agree that we have several issues with platform_get_irq*() APIs? >=20 > 1. The unfortunate naming unfortunate naming for the currently implemented semantic, yes. > 2. The vIRQ0 handling: a) WARN() followed by b) returned value 0 I'm happy with the vIRQ0 handling. Today platform_get_irq() and it's silent variant returns either a valid and usuable irq number or a negative error value. That's totally fine. > 3. The specific cookie for "IRQ not found, while no error happened" case Not sure what you mean here. I have no problem that a situation I can cope with is called an error for the query function. I just do error handling and continue happily. So the part "while no error happened" is irrelevant to me. Additionally I see the problems: 4. The semantic as implemented in Sergey's patch isn't better than the current one. platform_get_irq*() is still considerably different from (clk|gpiod)_get* because the not-found value for the _optional variant isn't usuable for the irq case. For clk and gpio I get rid of a whole if branch, for irq I only change the if-condition. (And if that change is considered good or bad seems to be subjective.) For the idea to add a warning to platform_get_irq_optional for all but -ENXIO (and -EPROBE_DEFER), I see the problem: 5. platform_get_irq*() issuing an error message is only correct most of the time and given proper error handling in the caller (which might be able to handle not only -ENXIO but maybe also -EINVAL[1]) the error message is irritating. Today platform_get_irq() emits an error message for all but -EPROBE_DEFER. As soon as we find a driver that handles -EINVAL we need a function platform_get_irq_variant1 to be silent for -EINVAL, -EPROBE_DEFER and -ENXIO (or platform_get_irq_variant2 that is only silent for -EINVAL and -EPROBE_DEFER?) IMHO a query function should always be silent and let the caller do the error handling. And if it's only because mydev: IRQ index 0 not found is worse than mydev: neither TX irq not a muxed RX/TX irq found =2E Also "index 0" is irritating for devices that are expected to have only a single irq (i.e. the majority of all devices). Yes, I admit, we can safe some code by pushing the error message in a query function. But that doesn't only have advantages. Best regards Uwe [1] Looking through the source I wonder: What are the errors that can happen in platform_get_irq*()? (calling everything but a valid irq number an error) Looking at many callers, they only seem to expect "not found" and some "probe defer" (even platform_get_irq() interprets everything but -EPROBE_DEFER as "IRQ index %u not found\n".) IMHO before we should consider to introduce a platform_get_irq*() variant with improved semantics, some cleanup in the internals of the irq lookup are necessary. --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --vtmtr3soi3npiqhl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmHpFdoACgkQwfwUeK3K 7AlpCwf8CIVWD1ztALs4saPfU+hCAXGdHPMYsVb4ZTfj+uT0g5uOPF3Vn08Dfosw tyqmKEnwGKIMZpavCJ+pScDwmT2FfANDq+R3xZzWj1hEcEvhjMFWB/IDU+s33/IB 9pbnCAE8Oa/2PGjM3+FGf5OA6q8vCcuO8XHluolGQqPqvajsCulKZytLIFnnTc9t UXm+5HxATeIlvcxF5NHMcNFRt2ADkTGVGj0zrEOxinsiT3edhaWLDR5/vSnbXySV NKWnnkWO/T3Huohcr85IS2dVfqbqxuMmfU6RyQKdMat7ZUzOqtffi2I6KdXRRjog OHR+PLT7KSOdf6ODGMs+9P8AMEotwg== =El6G -----END PGP SIGNATURE----- --vtmtr3soi3npiqhl--