public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Danilo Krummrich <dakr@kernel.org>
Cc: rafael@kernel.org, broonie@kernel.org, will@kernel.org,
	grygorii.strashko@ti.com, ssantosh@kernel.org,
	khilman@kernel.org, linusw@kernel.org, brgl@kernel.org,
	driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org
Subject: Re: [PATCH] gpio: omap: do not register driver in probe()
Date: Fri, 23 Jan 2026 15:19:39 +0100	[thread overview]
Message-ID: <2026012354-stinging-lapdog-2a54@gregkh> (raw)
In-Reply-To: <DFW0SC4QG4W8.C7BRHX02W3IK@kernel.org>

On Fri, Jan 23, 2026 at 02:57:45PM +0100, Danilo Krummrich wrote:
> On Fri Jan 23, 2026 at 2:31 PM CET, Danilo Krummrich wrote:
> > diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> > index e136e81794df..8db71a2db9ff 100644
> > --- a/drivers/gpio/gpio-omap.c
> > +++ b/drivers/gpio/gpio-omap.c
> > @@ -800,9 +800,7 @@ static struct platform_device omap_mpuio_device = {
> >  static inline void omap_mpuio_init(struct gpio_bank *bank)
> >  {
> >  	platform_set_drvdata(&omap_mpuio_device, bank);
> > -
> > -	if (platform_driver_register(&omap_mpuio_driver) == 0)
> > -		(void) platform_device_register(&omap_mpuio_device);
> > +	(void)platform_device_register(&omap_mpuio_device);
> >  }
> 
> On a second look, it recognize that this did abuse the fact that
> platform_driver_register() fails when attempting to register a driver multiple
> times to avoid registering the same static device multiple times.
> 
> So, I guess this has to be changed to:
> 
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 8db71a2db9ff..3e1ac34994fb 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -799,8 +799,13 @@ static struct platform_device omap_mpuio_device = {
> 
>  static inline void omap_mpuio_init(struct gpio_bank *bank)
>  {
> +       static bool registered = false;
> +
>         platform_set_drvdata(&omap_mpuio_device, bank);
> -       (void)platform_device_register(&omap_mpuio_device);
> +       if (!registered) {
> +               (void)platform_device_register(&omap_mpuio_device);
> +               registered = true;
> +       }
>  }

But there are no platform resources for this at all, shouldn't this be a
faux device instead?

That being said, ignoring the return value of platform_device_register()
is probably not something we want to keep around.

thanks,

greg k-h

  reply	other threads:[~2026-01-23 14:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-23 13:31 [PATCH] gpio: omap: do not register driver in probe() Danilo Krummrich
2026-01-23 13:44 ` Danilo Krummrich
2026-01-26  9:06   ` Bartosz Golaszewski
2026-01-26 11:35     ` Danilo Krummrich
2026-01-23 13:57 ` Danilo Krummrich
2026-01-23 14:19   ` Greg KH [this message]
2026-01-23 14:25     ` Danilo Krummrich
2026-01-23 15:23       ` Greg KH
2026-01-23 15:48         ` Danilo Krummrich
2026-01-27  9:09 ` Bartosz Golaszewski
2026-01-27 13:37   ` Danilo Krummrich
2026-01-27 19:26     ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2026012354-stinging-lapdog-2a54@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=brgl@kernel.org \
    --cc=broonie@kernel.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=grygorii.strashko@ti.com \
    --cc=khilman@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=ssantosh@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox