public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] driver core: bus: move bus notifier logic into bus.c
Date: Tue, 10 Jan 2023 14:04:09 +0100	[thread overview]
Message-ID: <Y71iSTMgO2i5cShl@kroah.com> (raw)
In-Reply-To: <CAJZ5v0gmG98awEVCU_TDK1kkuM6z6DQfRtGZGuKfj3oWpomgEg@mail.gmail.com>

On Tue, Jan 10, 2023 at 01:55:51PM +0100, Rafael J. Wysocki wrote:
> On Tue, Jan 10, 2023 at 1:43 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > The logic to touch the bus notifier was open-coded in numberous places
> > in the driver core.  Clean that up by creating a local bus_notify()
> > function and have everyone call this function instead, making the
> > reading of the caller code simpler and easier to maintain over time.
> >
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  drivers/base/base.h |  1 +
> >  drivers/base/bus.c  |  8 ++++++++
> >  drivers/base/core.c | 13 +++----------
> >  drivers/base/dd.c   | 28 +++++++---------------------
> >  4 files changed, 19 insertions(+), 31 deletions(-)
> >
> > diff --git a/drivers/base/base.h b/drivers/base/base.h
> > index 7d4803c03d3e..2e08258ce82e 100644
> > --- a/drivers/base/base.h
> > +++ b/drivers/base/base.h
> > @@ -130,6 +130,7 @@ struct kobject *virtual_device_parent(struct device *dev);
> >  extern int bus_add_device(struct device *dev);
> >  extern void bus_probe_device(struct device *dev);
> >  extern void bus_remove_device(struct device *dev);
> > +void bus_notify(struct device *dev, enum bus_notifier_event value);
> >
> >  extern int bus_add_driver(struct device_driver *drv);
> >  extern void bus_remove_driver(struct device_driver *drv);
> > diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> > index 428c26c6b615..cf1b8f00b4c0 100644
> > --- a/drivers/base/bus.c
> > +++ b/drivers/base/bus.c
> > @@ -850,6 +850,14 @@ int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb)
> >  }
> >  EXPORT_SYMBOL_GPL(bus_unregister_notifier);
> >
> > +void bus_notify(struct device *dev, enum bus_notifier_event value)
> > +{
> > +       struct bus_type *bus = dev->bus;
> > +
> > +       if (bus)
> > +               blocking_notifier_call_chain(&bus->p->bus_notifier, value, dev);
> 
> I'm not sure if the local var is really helpful.  Personally, I
> wouldn't use it, but anyway
> 
> Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>

It will be helpful in the next set of patches I send out for this file
where I work to make all 'struct bus_type' variables in the kernel
constant so they can go into read-only memory.  Right now there are only
2 variables that we actually write to in the structure, one will move
out to the private field and then the private pointer can go away as we
already keep the reference in a different way.  This will also fix up
some layering violations that I know the platform driver code has, odds
are it's in other parts of the kernel too that will be unearthed over
time.

Sorry for not making that more obvious, that patch series it not yet
finished, more to come over the next few weeks...

thanks for the reviews of these patches!

greg k-h

  reply	other threads:[~2023-01-10 13:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 12:42 [PATCH 1/2] driver core: bus.h: document bus notifiers better Greg Kroah-Hartman
2023-01-10 12:42 ` [PATCH 2/2] driver core: bus: move bus notifier logic into bus.c Greg Kroah-Hartman
2023-01-10 12:55   ` Rafael J. Wysocki
2023-01-10 13:04     ` Greg Kroah-Hartman [this message]
2023-01-10 12:52 ` [PATCH 1/2] driver core: bus.h: document bus notifiers better Rafael J. Wysocki
2023-01-10 13:04   ` Greg Kroah-Hartman

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=Y71iSTMgO2i5cShl@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@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