Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5272695pxb; Wed, 19 Jan 2022 15:00:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxy7n7BOPDzTvBJIr/pBq9k1zReKAkaYOj/ANiFcyqGok2QyqKoHQEwWpS+20gEKTnITzyX X-Received: by 2002:a05:6a00:188c:b0:4c0:ecce:784b with SMTP id x12-20020a056a00188c00b004c0ecce784bmr32547399pfh.22.1642633236156; Wed, 19 Jan 2022 15:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642633236; cv=none; d=google.com; s=arc-20160816; b=HY3sous3rnSbbthOfG7s87BGGCtDWW/GyWeQvOmw0CFX53jETltAPxTDv24LYtwX2n vTibwkmdtvfzzf90+fQiDNhy1s7lv8CSa6Bk6MkAWNx5cwXVXui3lVA0ccviuuRthPc/ 4h6zjxjVds3kF9QQ89hJSuybptzJQqJLVyLnB/JCH21y6fKMJkyiJkgrw8Q0n9dmoocY 8x3dQ2wOKM+BCxXxxN0O57aWuoPvPKQ3Dvti1y8qnf4dh3ITI5z2NpsnDmwDh0mHm/AZ bHfTn2K7OLDv+j9qSl7bqpWxVMXnHUpBW3CNZbkQRPsDuJ48oSocOQ0bzwbk9NJ9spaa 6dFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=oOrFMIBCUsJXb3OUxj/5jNj4XlBxThXbZ8xigDbZizM=; b=Zr3E/flGDGFjOFpY3EyDtWfdihvSfvWvZoMn+hldNpCyLQOuTR8k+KK16LPWysf+u/ fgev0RzMhCDkRosMfLxEpS4omaUDBOzNWjExOi2tGhjNLCcMun496NuBtflP4rRytlC4 dmGyBF142GOkNl1g4BzyLftcnNi7WMXfrLQUXakOxNXNR5qFaiftb30VK5UEeLntkBFJ 5W+Ke3kMceYgmHwA9WWtRnrKtaOyg16Du5LCjcyNDSA2yEUgdS+M0WV5k1+uMIp39h06 NDkvQ2oHzYfw/6Dzp2ytL9UdZG66mYo0WoKyh9sQe7cMwuPcrHBknByg0SvgfFDE8Sel oFCQ== 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 h24si1215539pgg.628.2022.01.19.15.00.23; Wed, 19 Jan 2022 15:00:36 -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 S1344197AbiARIZT convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Jan 2022 03:25:19 -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-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-kernel@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