All of lore.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 1/2] driver core: bus.h: document bus notifiers better
Date: Tue, 10 Jan 2023 14:04:40 +0100	[thread overview]
Message-ID: <Y71iaLwVCbVEVUB1@kroah.com> (raw)
In-Reply-To: <CAJZ5v0g63jNzqsnvg_UC7aBhX9_aNT=s=K9JpU9x8UpfoJ=dXQ@mail.gmail.com>

On Tue, Jan 10, 2023 at 01:52:24PM +0100, Rafael J. Wysocki wrote:
> On Tue, Jan 10, 2023 at 1:43 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > The bus notifier values are not documented all that well, so clean this
> > up and make a real enumerated type for them and document them much
> > better.
> >
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  include/linux/device/bus.h | 43 +++++++++++++++++++++++++-------------
> >  1 file changed, 29 insertions(+), 14 deletions(-)
> >
> > diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
> > index d529f644e92b..1e1a593348bc 100644
> > --- a/include/linux/device/bus.h
> > +++ b/include/linux/device/bus.h
> > @@ -257,21 +257,36 @@ extern int bus_register_notifier(struct bus_type *bus,
> >  extern int bus_unregister_notifier(struct bus_type *bus,
> >                                    struct notifier_block *nb);
> >
> > -/* All 4 notifers below get called with the target struct device *
> > - * as an argument. Note that those functions are likely to be called
> > - * with the device lock held in the core, so be careful.
> > +/**
> > + * enum bus_notifier_event: Bus Notifier events that have happened
> > + *
> > + * These are the value passed to a bus notifier when a specific event happens.
> > + *
> > + * Note that bus notifiers are likely to be called with the device lock already
> > + * held by the driver core, so be careful in any notifier callback as to what
> > + * you do with the device structure.
> > + *
> > + * All bus notifiers are called with the target struct device * as an argument.
> > + *
> > + * BUS_NOTIFY_ADD_DEVICE: device is added to this bus
> > + * BUS_NOTIFY_DEL_DEVICE: device is about to be removed from this bus
> > + * BUS_NOTIFY_REMOVED_DEVICE: device is successfully removed from this bus
> > + * BUS_NOTIFY_BIND_DRIVER: a driver is about to be bound to this device on this bus
> > + * BUS_NOTIFY_BOUND_DRIVER: a driver is successfully bound to this device on this bus
> > + * BUS_NOTIFY_UNBIND_DRIVER: a driver is about to be unbound from this device on this bus
> > + * BUS_NOTIFY_UNBOUND_DRIVER: a driver is successfully unbound from this device on this bus
> > + * BUS_NOTIFY_DRIVER_NOT_BOUND: a driver failed to be bound to this device on this bus
> >   */
> > -#define BUS_NOTIFY_ADD_DEVICE          0x00000001 /* device added */
> > -#define BUS_NOTIFY_DEL_DEVICE          0x00000002 /* device to be removed */
> > -#define BUS_NOTIFY_REMOVED_DEVICE      0x00000003 /* device removed */
> > -#define BUS_NOTIFY_BIND_DRIVER         0x00000004 /* driver about to be
> > -                                                     bound */
> > -#define BUS_NOTIFY_BOUND_DRIVER                0x00000005 /* driver bound to device */
> > -#define BUS_NOTIFY_UNBIND_DRIVER       0x00000006 /* driver about to be
> > -                                                     unbound */
> > -#define BUS_NOTIFY_UNBOUND_DRIVER      0x00000007 /* driver is unbound
> > -                                                     from the device */
> > -#define BUS_NOTIFY_DRIVER_NOT_BOUND    0x00000008 /* driver fails to be bound */
> > +enum bus_notifier_event {
> > +       BUS_NOTIFY_ADD_DEVICE =         0x00000001,
> > +       BUS_NOTIFY_DEL_DEVICE =         0x00000002,
> > +       BUS_NOTIFY_REMOVED_DEVICE =     0x00000003,
> > +       BUS_NOTIFY_BIND_DRIVER =        0x00000004,
> > +       BUS_NOTIFY_BOUND_DRIVER =       0x00000005,
> > +       BUS_NOTIFY_UNBIND_DRIVER =      0x00000006,
> > +       BUS_NOTIFY_UNBOUND_DRIVER =     0x00000007,
> > +       BUS_NOTIFY_DRIVER_NOT_BOUND =   0x00000008,
> 
> I'm wondering why the values are in hex (the 0x prefix doesn't matter
> for these numbers AFAICS) and what the initial zeros are for (AFAICS
> they don't matter either).

I have no idea why they are this way.  I'll go change them to just be
decimal, thanks!

greg k-h

      reply	other threads:[~2023-01-10 13:05 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
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 [this message]

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=Y71iaLwVCbVEVUB1@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.