LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Finn Thain <fthain@telegraphics.com.au>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nubus: Unconditionally register bus type
Date: Tue, 8 May 2018 09:01:29 +0200	[thread overview]
Message-ID: <20180508070129.GB4792@kroah.com> (raw)
In-Reply-To: <alpine.LNX.2.21.1805070930240.8@nippy.intranet>

On Mon, May 07, 2018 at 09:57:22AM +1000, Finn Thain wrote:
> On Sun, 6 May 2018, Greg Kroah-Hartman wrote:
> 
> > > > Why not just have an "bus is registered" flag in your driver 
> > > > register function that refuses to let drivers register with the 
> > > > driver core if it isn't set?
> > > 
> > > Perhaps that should happen in the core driver_register() function. 
> > > BUG_ON is frowned upon, after all. Would that be acceptable?
> > 
> > I don't understand what you mean here, perhaps make a patch to show it?
> > 
> 
> As an alternative to your suggestion (add flag to avoid the BUG_ON):
> 
> --- a/drivers/base/driver.c
> +++ b/drivers/base/driver.c
> @@ -148,7 +148,10 @@ int driver_register(struct device_driver *drv)
>  	int ret;
>  	struct device_driver *other;
>  
> -	BUG_ON(!drv->bus->p);
> +	if (!drv->bus->p) {
> +		WARN_ONCE(1, "Cannot register driver with invalid bus\n");
> +		return -EPROBE_DEFER;
> +	}
>  
>  	if ((drv->bus->probe && drv->probe) ||
>  	    (drv->bus->remove && drv->remove) ||
> 
> I'm not actually proposing this change; just responding to your question.
> 
> For the bug at hand, I still prefer the patch at the beginning of this 
> thread, because it seems to follow the conventional pattern.
> 
> > > I found a few drivers that set a flag the way you describe, which 
> > > could then be simplified.
> > > 
> > > But that pattern is rare. Most buses use the postcore_initcall() 
> > > pattern, and so my patch took the conventional approach.
> > 
> > It all depends on link order, not necessarily the postcore stuff.
> > 
> > > > And then fix your linking error, the bus should come first in link 
> > > > order, before your drivers :)
> > > > 
> > > 
> > > I didn't encounter any errors. How shall I reproduce this?
> > 
> > If you have not seen this error, then why change the code at all if it 
> > is working properly?
> 
> I never saw the link error you mentioned.
> 
> Please see this thread for one example of how to hit the BUG_ON.
> https://marc.info/?l=linux-m68k&m=152522162801182&w=2
> 
> Another way to trigger the BUG_ON is to set,
> CONFIG_ATARI=y
> CONFIG_MAC=y
> CONFIG_NUBUS=y
> CONFIG_MAC8390=y
> and try to boot the result on aranym.

See my other response in this thread describing the link order problem.
But if you can't resolve this that way, then yes, your original patch
should be fine.

thanks,

greg k-h

  parent reply	other threads:[~2018-05-08  7:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-06  1:47 Finn Thain
2018-05-06  4:55 ` Greg Kroah-Hartman
2018-05-06  6:00   ` Finn Thain
2018-05-06 20:20     ` Greg Kroah-Hartman
2018-05-06 21:51       ` Michael Schmitz
2018-05-08  7:00         ` Greg Kroah-Hartman
2018-05-08  7:07           ` Geert Uytterhoeven
2018-05-08  7:25             ` Greg Kroah-Hartman
2018-05-08  7:35               ` Geert Uytterhoeven
2018-05-08  7:41                 ` Greg Kroah-Hartman
2018-05-08  8:01               ` Michael Schmitz
2018-05-06 23:57       ` Finn Thain
2018-05-07 12:53         ` Geert Uytterhoeven
2018-05-07 14:45           ` Greg Kroah-Hartman
2018-05-08  6:28             ` Geert Uytterhoeven
2018-05-07 23:44         ` Finn Thain
2018-05-08  6:32           ` Geert Uytterhoeven
2018-05-08  7:59             ` Finn Thain
2018-05-08  7:01         ` Greg Kroah-Hartman [this message]
2018-05-06  1:47 Finn Thain
     [not found] <5aee5ede.1c69fb81.353b4.5021SMTPIN_ADDED_MISSING@mx.google.com>
2018-05-08  7:39 ` Geert Uytterhoeven
2018-05-08  8:27   ` Finn Thain

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=20180508070129.GB4792@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=fthain@telegraphics.com.au \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --subject='Re: [PATCH] nubus: Unconditionally register bus type' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).