Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1612439 > unrolled thread
| Started by | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| First post | 2017-03-30 01:20 +0200 |
| Last post | 2017-03-31 01:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] kernel/reboot: add devm_register_reboot_notifier Andrew Morton <akpm@linux-foundation.org> - 2017-03-30 01:20 +0200
Re: [PATCH] kernel/reboot: add devm_register_reboot_notifier Andrey Smirnov <andrew.smirnov@gmail.com> - 2017-03-31 01:00 +0200
Re: [PATCH] kernel/reboot: add devm_register_reboot_notifier Andrew Morton <akpm@linux-foundation.org> - 2017-03-31 01:30 +0200
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2017-03-30 01:20 +0200 |
| Subject | Re: [PATCH] kernel/reboot: add devm_register_reboot_notifier |
| Message-ID | <tqv2G-5Ex-13@gated-at.bofh.it> |
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?
[toc] | [next] | [standalone]
| From | Andrey Smirnov <andrew.smirnov@gmail.com> |
|---|---|
| Date | 2017-03-31 01:00 +0200 |
| Message-ID | <tqRcR-4Gj-1@gated-at.bofh.it> |
| In reply to | #1612439 |
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.
Thanks,
Andrey Smirnov
[toc] | [prev] | [next] | [standalone]
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2017-03-31 01:30 +0200 |
| Message-ID | <tqRFU-55I-15@gated-at.bofh.it> |
| In reply to | #1613537 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web