Received: by 2002:aa6:c46f:0:b029:96:faae:e639 with SMTP id i15csp342901lkq; Thu, 5 Nov 2020 04:04:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvjsZtWWRfv+eJ1otSToIg5V5CFgERraGC0kkbKvdn4kFzqgBCdFgtjLdbncnWsaUb9Dse X-Received: by 2002:aa7:cf90:: with SMTP id z16mr2278285edx.174.1604577872983; Thu, 05 Nov 2020 04:04:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604577872; cv=none; d=google.com; s=arc-20160816; b=Efi+ARZZpIFYg2AUelkXPfBx4XGI2v9UurdecNnB/smIWHiZBBRzoJsou7rUTQ8sVO plfr0rFXakZqXuaiCr6zwOfcIwabVyY9o/A8qiZhmNDPxyVveR+a4PlYHiQ5Mp5AyGJC wEBlUedO16BrVwNO4y2FOvYWA6zUcFIOBNamhz87KLzSY2TYbERZ04MGjLxWR2xFDSPq sjp2N+cdS8XUGKivIE8VV2tlrYolXhl2GX6+e71Nn5dp0Vj4Y+UjusKZVJazsY1ecY0e MpjwuvVmjuGKbTlaGRmizlxDajK03yYzE6utRzZ3BLm7g60+ky+3OTmTaQxtlyrUe1l5 sgOA== 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=acijxDiGDEUt4I2cDxK+O6StwjSex3WB5cQlpv1FYyQ=; b=WVYKuuSPu7xz7y0+Ubc3lhwuAeEaGRJVLUoJigruQGpSU+Pwyb4P49m3vr0L/XIBdW W+BnQ8QLej5hXqbK6OyTihU68dHUS1BY2XafY88lsbO3DG/8K0uLf/ldi+He4duxZhuc Q+ZWME2LN9Edi9kuNpV3RCUOq7H9+O96MYWAdzSlU781H5jd+lxHHHGPuoQ8EybnstRD NppKlj5sVdegVxhmyNqq08XcS57LYnvW6wBoBgVldJiOmsAi5RxIrJwYrf6XvG/D+GVt 2m5ybs2BrZgrVCoCqZ2uMq5V2z5RzWkBvJvmrPBwAFrrbsDqYj1iLVFNgMGEFfAgPE1M nqJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@freebox-fr.20150623.gappssmtp.com header.s=20150623 header.b=c1DuOiIS; 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 s19si1105415eja.14.2020.11.05.04.04.08; Thu, 05 Nov 2020 04:04:32 -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; dkim=pass header.i=@freebox-fr.20150623.gappssmtp.com header.s=20150623 header.b=c1DuOiIS; 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 S1729990AbgKEMCJ (ORCPT + 99 others); Thu, 5 Nov 2020 07:02:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726777AbgKEMCJ (ORCPT ); Thu, 5 Nov 2020 07:02:09 -0500 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2632C0613D2 for ; Thu, 5 Nov 2020 04:02:08 -0800 (PST) Received: by mail-lf1-x141.google.com with SMTP id y184so1875803lfa.12 for ; Thu, 05 Nov 2020 04:02:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebox-fr.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=acijxDiGDEUt4I2cDxK+O6StwjSex3WB5cQlpv1FYyQ=; b=c1DuOiIS8rPp2H8sU37QjdQYjSswWCIIgyzuwlAyEbZIntV825P2HzlPSSjZTjmu+L PszfPceqjXJZE3LxcculepH396McEkrMcacEBfbWTKDIuxFJVLdyR/r2uTu1xEmz4NHS O7B/VMMq90xd9ZL2fdZZjfC3kqEm5bCiAF6kK18Lx9BstIArgNFaCCPh1RABYhNPFmbf 85kT9ZILCNVzdgY5lbbKVIb3iBW2U8IOnhGugZhsMXUEr5iklI+lSWALVeFO5tNZEgny Y2lZGPiSFIXOwpnvMNrP7RjvrGt+OU5J33PbFiC65pUc0Fd46LHxGknOTccCnCyPlexE nV0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=acijxDiGDEUt4I2cDxK+O6StwjSex3WB5cQlpv1FYyQ=; b=jSs0xUu+5vQmArHVieAO0+z0DKIuyUgZXvDMW/MmWenh+r/xmXspvss3pxWMrW+S8L WamgiLdAWjY2WNRP6o3qAE6OK+HlGSZhjdscajovu6N8pIV8BSuud6kulsXhYDBtDHy6 X/xaZOW/4W/gcD7K1f5vX1fvGcdzp17y5Puw3N8IkYZIoVHVW6dKyoYO3trujW+qa8px IDxPy1szBC0n8JVYlnD0kwv8IJFqB3xbXsZj0a+mosmeiz+IdUaOeKcGZYNgVe300r+l kFf/K8X9pJBBGO5EP3dL2zH672oURNENZQ9xly5+toauFgxOeeArL2/mNrkT9mvhJjB7 YH5Q== X-Gm-Message-State: AOAM533KsNpRKIP4Dw+HUcR/NpVdugelkdhfXe3xA/ws2zti/bxefAzy emiFB0aJdPq4KrCdieeR8+uFs9XI09IEnPLRMM/bZA== X-Received: by 2002:a19:6a0e:: with SMTP id u14mr815519lfu.254.1604577726840; Thu, 05 Nov 2020 04:02:06 -0800 (PST) MIME-Version: 1.0 References: <20201105104049.91077-1-warthog618@gmail.com> In-Reply-To: <20201105104049.91077-1-warthog618@gmail.com> From: Nicolas Schichan Date: Thu, 5 Nov 2020 13:01:55 +0100 Message-ID: Subject: Re: [PATCH] gpiolib: fix sysfs when cdev is not selected To: Kent Gibson Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Kent, On Thu, Nov 5, 2020 at 11:41 AM Kent Gibson wrote: > > In gpiochip_setup_dev() the call to gpiolib_cdev_register() indirectly > calls device_add(). This is still required for the sysfs even when > CONFIG_GPIO_CDEV is not selected in the build. > > Replace the stubbed functions in gpiolib-cdev.h with macros in gpiolib.c > that perform the required device_add() and device_del() when > CONFIG_GPIO_CDEV is not selected. > > Fixes: d143493c01b7 (gpiolib: make cdev a build option) > Reported-by: Nicolas Schichan > Signed-off-by: Kent Gibson > --- > drivers/gpio/gpiolib-cdev.h | 15 --------------- > drivers/gpio/gpiolib.c | 18 +++++++++++++++--- > 2 files changed, 15 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpio/gpiolib-cdev.h b/drivers/gpio/gpiolib-cdev.h > index cb41dd757338..b42644cbffb8 100644 > --- a/drivers/gpio/gpiolib-cdev.h > +++ b/drivers/gpio/gpiolib-cdev.h > @@ -7,22 +7,7 @@ > > struct gpio_device; > > -#ifdef CONFIG_GPIO_CDEV > - > int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt); > void gpiolib_cdev_unregister(struct gpio_device *gdev); > > -#else > - > -static inline int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt) > -{ > - return 0; > -} > - > -static inline void gpiolib_cdev_unregister(struct gpio_device *gdev) > -{ > -} > - > -#endif /* CONFIG_GPIO_CDEV */ > - > #endif /* GPIOLIB_CDEV_H */ > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index 8e29a60c3697..c980ddcda833 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -480,11 +480,23 @@ static void gpiodevice_release(struct device *dev) > kfree(gdev); > } > > +#ifdef CONFIG_GPIO_CDEV > +#define gcdev_register(gdev, devt) gpiolib_cdev_register((gdev), (devt)) > +#define gcdev_unregister(gdev) gpiolib_cdev_unregister((gdev)) > +#else > +/* > + * gpiolib_cdev_register() indirectly calls device_add(), which is still > + * required even when cdev is not selected. > + */ > +#define gcdev_register(gdev, devt) device_add(&(gdev)->dev) > +#define gcdev_unregister(gdev) device_del(&(gdev)->dev) > +#endif > + > static int gpiochip_setup_dev(struct gpio_device *gdev) > { > int ret; > > - ret = gpiolib_cdev_register(gdev, gpio_devt); > + ret = gcdev_register(gdev, gpio_devt); > if (ret) > return ret; > > @@ -500,7 +512,7 @@ static int gpiochip_setup_dev(struct gpio_device *gdev) > return 0; > > err_remove_device: > - gpiolib_cdev_unregister(gdev); > + gcdev_unregister(gdev); > return ret; > } > > @@ -825,7 +837,7 @@ void gpiochip_remove(struct gpio_chip *gc) > * be removed, else it will be dangling until the last user is > * gone. > */ > - gpiolib_cdev_unregister(gdev); > + gcdev_unregister(gdev); > put_device(&gdev->dev); > } > EXPORT_SYMBOL_GPL(gpiochip_remove); > -- > 2.29.2 > I have tested your patch and it works for both CONFIG_GPIO_CDEV set and unset. Tested-by: Nicolas Schichan Regards, -- Nicolas Schichan Freebox SAS