Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4565055rwb; Tue, 17 Jan 2023 02:30:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXut8HhB/ghMWlMwV9i6jXAPsS3bIeitCKyMx28LSfb+2PgDr1DvY/Ow9TRfhBkolNMrzvmQ X-Received: by 2002:a05:6402:27d3:b0:499:b3db:6aa3 with SMTP id c19-20020a05640227d300b00499b3db6aa3mr3344647ede.1.1673951417102; Tue, 17 Jan 2023 02:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673951417; cv=none; d=google.com; s=arc-20160816; b=ZTYaQh3zHVGqD0EnnQv8CXnEGjGq6oowaGxMk2I9fCZkYBXz4j1MGPVKPXZX6Xy6LM Mcw3q3RU4bLk0DRSQdn4whsIg8jBlVYfRqW3Fzat7G4YctsDHEdewZUZ9qYUPb2Ocn3Y szeAzUMN/qxVxophHfSZYtuh2yvDeZgknXHnh61l2Klwl+jSd7iP6ADsZpcaHm5yWczO 2JQxSWiPdmZg3tj7nxYjYSlmXZdj6d/9yZljik49UeLRiZ3HLFz68XXRBTkTZDsIlkd7 PJ07DHWAMJWGFL4qL4UUJceukzyUgO0/oXl1WlwIOOc4xQuOoZMIliT9nfpsshBiHXT9 5qjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SPLRrX/lkmvIYyo+lXDf/6xOCiRheu67g1vboFBjt4k=; b=EU8x3yueC2g7CkuCv5zjansb7A1lgsT5T2BLqktme9IkK1wlCxRzOgwNp1zCSlIAm9 oZ1d5Z01H0X6K7LEThZwcEFNJHusxQeKx/zaxKwMW9Ix8Dpb8pJGXhsDJJF1ZS7Zr32e zgV85HuotynxT3Uu6zLolpqOUy0+WBUg+LqqovpBhwcwbBQsrqcwi5pHLcvGHBFJNJQx iuuEskcFVQidgHWE14LiUq7mT2yahVuFRrXwbTIeqvFFzpgMKayxpWGnG8mHAQ51ToOS n0F5mkAqj8jHZtiAnD/sDKbfCP4epdef0FPq6a//beUkOxHXwfHNP7FiD86rqOOR62ds vuEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=YhkxfUPu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fj13-20020a0564022b8d00b00499cc326a54si20966803edb.170.2023.01.17.02.30.05; Tue, 17 Jan 2023 02:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=YhkxfUPu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235995AbjAQJfo (ORCPT + 49 others); Tue, 17 Jan 2023 04:35:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236415AbjAQJeW (ORCPT ); Tue, 17 Jan 2023 04:34:22 -0500 Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 170422709 for ; Tue, 17 Jan 2023 01:34:15 -0800 (PST) Received: by mail-vs1-xe30.google.com with SMTP id i188so31567702vsi.8 for ; Tue, 17 Jan 2023 01:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SPLRrX/lkmvIYyo+lXDf/6xOCiRheu67g1vboFBjt4k=; b=YhkxfUPuOSnAZKIC5PVYRU0HHkKDR83Qc5FTJDrN9KEKPwOzxV6TOmJyEKXuP3SFmo bv4bDO5yAfeI6dg9kjobthIQA+Xb2Y/wEvnF/1FYGW6zKncwfp2aTUtFQh6qfF9wD4HJ ScJ/Y60+buCEPvbvj3GoPrZ+2EPLH7gMGvAr+vJxSodohUlrqPD1accL10ZDBkIkNMTL LJXocAkHl3qfoFJvgayG0Nj0VQnxi33lUKfgQpCuEu7R+D6pmryBYN2P7s0w1tuaLXQ/ EiwM8kwFrTkCeFE/QPyp7t7g1AwmcYQyYDs9CbJpZD9twrGyUiV+D7cTIsoNSYRR4beY rZcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SPLRrX/lkmvIYyo+lXDf/6xOCiRheu67g1vboFBjt4k=; b=SIIRGWZ6Y6R0vH9LNWqGLVr/NRRWNKz/hreT0biq7jnNqonTzRHRP88dQOYJ79bkpH Z0DniPt9Ruwy6pPc6D706ejuGvA1nboLM3kb2aUurhH49c5Pfvmr3J3om6y26paNXZ+W dySCpWCzY5DT3+8sLmG+KjOJIump4ORyf0tmoFShnQ9diSswsNApOLv5ov/GJLkrK1aO wrKkRQ35tNmjNXFOBzA1R9Jjl//+EPSY+ytqEAEskM1f7+wwm7w4sI/S4CbzpUtCDlsQ 0uJkmi0+FRvA6ynqnW91IeXJoBfAweq9RorqvwwzwTMZpHWBv8Fpb0Mz7F8iq+nTj0RI YkEQ== X-Gm-Message-State: AFqh2kp8YrGs+nqyptP2m78iY5fGS2tSZwjM+nIn0uvpFiP9iH/LLff8 qVO2oybtU5Ndpwv3CfTOfFA6QtqWNuIFeb24AuJ20Q== X-Received: by 2002:a05:6102:3e08:b0:3c5:1ac1:bf38 with SMTP id j8-20020a0561023e0800b003c51ac1bf38mr309928vsv.78.1673948054194; Tue, 17 Jan 2023 01:34:14 -0800 (PST) MIME-Version: 1.0 References: <20230116140811.27201-1-pierluigi.p@variscite.com> <2403894.jE0xQCEvom@steina-w> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 17 Jan 2023 10:34:03 +0100 Message-ID: Subject: Re: [PATCH] gpiolib: fix linker errors when GPIOLIB is disabled To: Pierluigi Passaro Cc: Alexander Stein , "linus.walleij@linaro.org" , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Eran Matityahu , Nate Drude , Francesco Ferraro , "pierluigi.passaro@gmail.com" , kernel test robot Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 17, 2023 at 8:44 AM Pierluigi Passaro wrote: > > On Tue, Jan 17, 2023 at 7:23 AM Alexander Stein wrote: > > Hi, > > > > Am Montag, 16. Januar 2023, 15:08:11 CET schrieb Pierluigi Passaro: > > > Both the functions gpiochip_request_own_desc and > > > gpiochip_free_own_desc are exported from > > > drivers/gpio/gpiolib.c > > > but this file is compiled only when CONFIG_GPIOLIB is enabled. > > > Move the protototypes under "#ifdef CONFIG_GPIOLIB" and provide > > > reasonable definitions in the "#else" branch. > > > > > > Signed-off-by: Pierluigi Passaro > > > Reported-by: kernel test robot > > > --- > > > include/linux/gpio/driver.h | 20 ++++++++++++++++++-- > > > 1 file changed, 18 insertions(+), 2 deletions(-) > > > > > > diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h > > > index 44783fc16125..ed77c6fc0beb 100644 > > > --- a/include/linux/gpio/driver.h > > > +++ b/include/linux/gpio/driver.h > > > @@ -758,6 +758,8 @@ gpiochip_remove_pin_ranges(struct gpio_chip *gc) > > > > > > #endif /* CONFIG_PINCTRL */ > > > > > > +#ifdef CONFIG_GPIOLIB > > > + > > > struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *gc, > > > unsigned int hwnum, > > > const char *label, > > > @@ -765,8 +767,6 @@ struct gpio_desc *gpiochip_request_own_desc(struct > > > gpio_chip *gc, enum gpiod_flags dflags); > > > void gpiochip_free_own_desc(struct gpio_desc *desc); > > > > > > -#ifdef CONFIG_GPIOLIB > > > - > > > /* lock/unlock as IRQ */ > > > int gpiochip_lock_as_irq(struct gpio_chip *gc, unsigned int offset); > > > void gpiochip_unlock_as_irq(struct gpio_chip *gc, unsigned int offset); > > > @@ -776,6 +776,22 @@ struct gpio_chip *gpiod_to_chip(const struct gpio_desc > > > *desc); > > > > > > #else /* CONFIG_GPIOLIB */ > > > > > > +static inline struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip > > > *gc, + unsigned int hwnum, > > > + const char *label, > > > + enum gpio_lookup_flags > > lflags, > > > + enum gpiod_flags dflags) > > > +{ > > > + /* GPIO can never have been requested */ > > > + WARN_ON(1); > > > > This will raise the warning on each invocation. How about using > > WARN_ON_ONCE(1), or even WARN_ONCE("Kernel compiled without CONFIG_GPIOLIB > > support")? > > > No problem on my side, but this would create a misalignment with all other > GPIOLIB "dummy" calls. > Personally I would prefer WARN_ONCE("Kernel compiled without CONFIG_GPIOLIB > support"). > Please confirm your preferences and I'll provide a patch v2. > Thanks > > > > > + return ERR_PTR(-ENODEV); > > > +} > > > + > > > +static inline void gpiochip_free_own_desc(struct gpio_desc *desc) > > > +{ > > > + WARN_ON(1); > > > > Same as above. > > > > Best regards, > > Alexander > > > > > +} > > > + > > > static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) > > > { > > > /* GPIO can never have been requested */ If someone calls these functions without GPIOLIB enabled then they deserve lots of warnings to remind them to fix their config. :) Let's keep it like in other places. Bart