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 70CADC4332F for ; Mon, 10 Jan 2022 21:08:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343811AbiAJVIl (ORCPT ); Mon, 10 Jan 2022 16:08:41 -0500 Received: from mga04.intel.com ([192.55.52.120]:30171 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343788AbiAJVIj (ORCPT ); Mon, 10 Jan 2022 16:08:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641848919; x=1673384919; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=noXDmlMb/EBRvid+M0xTN4DJrqhApqmO9Jn6H9SNPpk=; b=lrwTqACLWTe81ZxqCH/BWfzQGN91+hs8RtoBMi1k7VTBjiNpTA/5x7ha d/8INGCxUD5A6e2YXt+QSceu40k/hxSwWoyqxyhEo04PQ2NAQ+vP1KjXl 2mNCg0Dsxu1XXtCMM4yTZEAtIrdIb8BaTD/uz2kPL7NO536uZDmpeY289 E3go6tZFo3D6y0blg0CWhbTxGjFUSM+qjQ1lr8c6pH6UwtgQFiB3tjd0L X1EVaDHXV3/vdfuYootLB1E1utULamPpyTKWfQ2uO1Rz5Ycj6kQNhDgKY UhIcZ6luhoLIm//3CNhMBAMS3P2O6qjM8mg8J8sZY789435IYjb5FUZwl w==; X-IronPort-AV: E=McAfee;i="6200,9189,10223"; a="242135056" X-IronPort-AV: E=Sophos;i="5.88,278,1635231600"; d="scan'208";a="242135056" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2022 13:08:38 -0800 X-IronPort-AV: E=Sophos;i="5.88,278,1635231600"; d="scan'208";a="490132599" Received: from smile.fi.intel.com ([10.237.72.61]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2022 13:08:20 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1n71sd-00915P-Sm; Mon, 10 Jan 2022 23:07:03 +0200 Date: Mon, 10 Jan 2022 23:07:03 +0200 From: Andy Shevchenko To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Sergey Shtylyov , 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, 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 =?iso-8859-1?Q?S=F6derlund?= , linux-mediatek@lists.infradead.org, Brian Norris , "David S. Miller" Subject: Re: [PATCH 1/2] platform: make platform_get_irq_optional() optional Message-ID: References: <20220110195449.12448-1-s.shtylyov@omp.ru> <20220110195449.12448-2-s.shtylyov@omp.ru> <20220110201014.mtajyrfcfznfhyqm@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220110201014.mtajyrfcfznfhyqm@pengutronix.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 10, 2022 at 09:10:14PM +0100, Uwe Kleine-K?nig wrote: > On Mon, Jan 10, 2022 at 10:54:48PM +0300, Sergey Shtylyov wrote: > > This patch is based on the former Andy Shevchenko's patch: > > > > https://lore.kernel.org/lkml/20210331144526.19439-1-andriy.shevchenko@linux.intel.com/ > > > > 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: > > > > ret = platform_get_irq_optional(...); > > if (ret < 0 && ret != -ENXIO) > > return ret; // respect deferred probe > > if (ret > 0) > > ...we get an IRQ... > > > > 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: > > > > ret = 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. The problem is not only there, but also in the platform_get_irq() and that problem is called vIRQ0. Or as Linus put it "_cookie_" for IRQ, which never ever should be 0. > 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(). This won't fix the issue with vIRQ0. -- With Best Regards, Andy Shevchenko