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 93981C4332F for ; Tue, 18 Jan 2022 08:25:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344164AbiARIZR convert rfc822-to-8bit (ORCPT ); Tue, 18 Jan 2022 03:25:17 -0500 Received: from mail-ua1-f45.google.com ([209.85.222.45]:42760 "EHLO mail-ua1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232989AbiARIZQ (ORCPT ); Tue, 18 Jan 2022 03:25:16 -0500 Received: by mail-ua1-f45.google.com with SMTP id p1so35034049uap.9; Tue, 18 Jan 2022 00:25:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=wwyuk2lsKqIfL1r34uR4hiV5J4os/EyMOhjZZucVxAA=; b=I2i1nK3KE49ayM/k/7+QwdNB1Zw/V8rfgqp4QCmvWpqWYqVHuXXZLHkoGFbUNZwQoa 5n58deiE9GIRaPOlMyVpmgpPhdeM6+XjSafr9D/U+9wMw7QnCwIKSHifBPKaKoKI7ghV GPjZiS0nW+lz1lWDERj4p5QQ60xQw9CHXpsjRJ1hmG+OzAfo7VdqIEEb5MXSZJ4tk/sN wK6lF0d8e/ePocJHJLPejU1HF8xld5m/zmPX0RLIdCeaaIPTzpkjHd0Jw8D0cXvhbrYZ FHbmY3rE4GmX6ZIIgeSp6MmNKyIiUbHsjMTOOage5nc+kV1Al0PTA5oAEiRtF6XNNBFK UC4A== X-Gm-Message-State: AOAM531TjjIono2QQrSzMZER0NUpWw9YWmdyoa4VDcXGutV5AUI3N5Qk NMu4UvqkxsalSADZQSGZWKANBWSt+9lqXV/t X-Google-Smtp-Source: ABdhPJxEapMDT1TLJpP3jj0kK0vs2RhIajlcXxONwhZS+EvdSgowj8ApkJ3nRAIXNWOHwgyRPrDJbQ== X-Received: by 2002:ab0:e13:: with SMTP id g19mr9097770uak.135.1642494314740; Tue, 18 Jan 2022 00:25:14 -0800 (PST) Received: from mail-ua1-f44.google.com (mail-ua1-f44.google.com. [209.85.222.44]) by smtp.gmail.com with ESMTPSA id j76sm4044397vke.27.2022.01.18.00.25.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jan 2022 00:25:13 -0800 (PST) Received: by mail-ua1-f44.google.com with SMTP id 2so10353317uax.10; Tue, 18 Jan 2022 00:25:13 -0800 (PST) X-Received: by 2002:ab0:4d42:: with SMTP id k2mr7281422uag.78.1642494312957; Tue, 18 Jan 2022 00:25:12 -0800 (PST) MIME-Version: 1.0 References: <29f0c65d-77f2-e5b2-f6cc-422add8a707d@omp.ru> <20220114092557.jrkfx7ihg26ekzci@pengutronix.de> <61b80939-357d-14f5-df99-b8d102a4e1a1@omp.ru> <20220114202226.ugzklxv4wzr6egwj@pengutronix.de> <20220117092444.opoedfcf5k5u6otq@pengutronix.de> <20220117114923.d5vajgitxneec7j7@pengutronix.de> <20220117170609.yxaamvqdkivs56ju@pengutronix.de> In-Reply-To: <20220117170609.yxaamvqdkivs56ju@pengutronix.de> From: Geert Uytterhoeven Date: Tue, 18 Jan 2022 09:25:01 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] platform: make platform_get_irq_optional() optional To: =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= 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, 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 , Sergey Shtylyov , Vinod Koul , James Morse , Zha Qipeng , Sebastian Reichel , =?UTF-8?Q?Niklas_S=C3=B6derlund?= , linux-mediatek@lists.infradead.org, Brian Norris , netdev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Hi Uwe, On Mon, Jan 17, 2022 at 6:06 PM Uwe Kleine-König wrote: > On Mon, Jan 17, 2022 at 02:08:19PM +0100, Geert Uytterhoeven wrote: > > On Mon, Jan 17, 2022 at 12:49 PM Uwe Kleine-König > > wrote: > > > > The logic in e.g. drivers/tty/serial/sh-sci.c and > > > > drivers/spi/spi-rspi.c could be simplified and improved (currently > > > > it doesn't handle deferred probe) if platform_get_irq_optional() > > > > would return 0 instead of -ENXIO. > > > Also for spi-rspi.c I don't see how platform_get_irq_byname_optional() > > > returning 0 instead of -ENXIO would help. Please talk in patches. [...] > This is not a simplification, just looking at the line count and the > added gotos. That's because it also improves error handling and so the > effect isn't easily spotted. Yes, it's larger because it adds currently missing error handling. > What about the following idea (in pythonic pseudo code for simplicity): No idea what you gain by throwing in a language that is irrelevant to kernel programming (why no Rust? ;-) > > > > So there are three reasons: because the absence of an optional IRQ > > > > is not an error, and thus that should not cause (a) an error code > > > > to be returned, and (b) an error message to be printed, and (c) > > > > because it can simplify the logic in device drivers. > > > > > > I don't agree to (a). If the value signaling not-found is -ENXIO or 0 > > > (or -ENODEV) doesn't matter much. I wouldn't deviate from the return > > > code semantics of platform_get_irq() just for having to check against 0 > > > instead of -ENXIO. Zero is then just another magic value. > > > > Zero is a natural magic value (also for pointers). > > Errors are always negative. > > Positive values are cookies (or pointers) associated with success. > > Yeah, the issue where we don't agree is if "not-found" is special enough > to deserve the natural magic value. For me -ENXIO is magic enough to > handle the absence of an irq line. I consider it even the better magic > value. It differs from other subsystems (clk, gpio, reset), which do return zero on not found. What's the point in having *_optional() APIs if they just return the same values as the non-optional ones? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds