All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Chris Healy <cphealy@gmail.com>
Subject: Re: [PATCH] kernel/reboot: add devm_register_reboot_notifier
Date: Thu, 30 Mar 2017 16:24:16 -0700	[thread overview]
Message-ID: <20170330162416.cd517a26b872358737b20909@linux-foundation.org> (raw)
In-Reply-To: <CAHQ1cqEUTo3J2zzbiwZ7COHJs6oLbs_Mh88JU8zk7jEjFzyHEg@mail.gmail.com>

On Thu, 30 Mar 2017 15:55:43 -0700 Andrey Smirnov <andrew.smirnov@gmail.com> wrote:

> On Wed, Mar 29, 2017 at 4:17 PM, Andrew Morton
> <akpm@linux-foundation.org> wrote:
> > On Mon, 20 Mar 2017 10:17:53 -0700 Andrey Smirnov <andrew.smirnov@gmail.com> wrote:
> >
> >> Add devm_* wrapper around register_reboot_notifier to simplify device
> >> specific reboot notifier registration/unregistration.
> >>
> >> --- a/kernel/reboot.c
> >> +++ b/kernel/reboot.c
> >> @@ -104,6 +104,33 @@ int unregister_reboot_notifier(struct notifier_block *nb)
> >>  }
> >>  EXPORT_SYMBOL(unregister_reboot_notifier);
> >>
> >> +static void devm_unregister_reboot_notifier(struct device *dev, void *res)
> >> +{
> >> +     WARN_ON(unregister_reboot_notifier(*(struct notifier_block **)res));
> >> +}
> >> +
> >> +int devm_register_reboot_notifier(struct device *dev, struct notifier_block *nb)
> >> +{
> >> +     struct notifier_block **rcnb;
> >> +     int ret;
> >> +
> >> +     rcnb = devres_alloc(devm_unregister_reboot_notifier,
> >> +                         sizeof(*rcnb), GFP_KERNEL);
> >> +     if (!rcnb)
> >> +             return -ENOMEM;
> >> +
> >> +     ret = register_reboot_notifier(nb);
> >> +     if (!ret) {
> >> +             *rcnb = nb;
> >> +             devres_add(dev, rcnb);
> >> +     } else {
> >> +             devres_free(rcnb);
> >> +     }
> >> +
> >> +     return ret;
> >> +}
> >> +EXPORT_SYMBOL(devm_register_reboot_notifier);
> >
> > Seems reasonable.  Can we please have some patches which actually use
> > this?
> 
> I will be submitting a serdev/watchdog driver in next couple of weeks,
> I can CC you on that thread.

It would be nice to convert some other call sites as well, please - at
least to get additional test coverage and to demonstrate the usefulness
of the new interface.

      reply	other threads:[~2017-03-30 23:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 17:17 [PATCH] kernel/reboot: add devm_register_reboot_notifier Andrey Smirnov
2017-03-29 23:17 ` Andrew Morton
2017-03-30 22:55   ` Andrey Smirnov
2017-03-30 23:24     ` Andrew Morton [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=20170330162416.cd517a26b872358737b20909@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=andrew.smirnov@gmail.com \
    --cc=cphealy@gmail.com \
    --cc=linux-kernel@vger.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.