lkml.org 
[lkml]   [2021]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 05/31] opp: Add devres wrapper for dev_pm_opp_register_notifier
    On 01-01-21, 16:54, Yangtao Li wrote:
    > Add devres wrapper for dev_pm_opp_register_notifier() to simplify driver
    > code.
    >
    > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
    > ---
    > drivers/opp/core.c | 38 ++++++++++++++++++++++++++++++++++++++
    > include/linux/pm_opp.h | 6 ++++++
    > 2 files changed, 44 insertions(+)
    >
    > diff --git a/drivers/opp/core.c b/drivers/opp/core.c
    > index 6b83e373f0d8..ef3544f8cecd 100644
    > --- a/drivers/opp/core.c
    > +++ b/drivers/opp/core.c
    > @@ -2599,6 +2599,44 @@ int dev_pm_opp_unregister_notifier(struct device *dev,
    > }
    > EXPORT_SYMBOL(dev_pm_opp_unregister_notifier);
    >
    > +static void devm_pm_opp_notifier_release(struct device *dev, void *res)
    > +{
    > + struct notifier_block *nb = *(struct notifier_block **)res;
    > +
    > + WARN_ON(dev_pm_opp_unregister_notifier(dev, nb));
    > +}
    > +
    > +/**
    > + * devm_pm_opp_register_notifier() - Register OPP notifier for the device
    > + * @dev: Device for which notifier needs to be registered
    > + * @nb: Notifier block to be registered
    > + *
    > + * Return: 0 on success or a negative error value.
    > + *
    > + * The notifier will be unregistered after the device is destroyed.
    > + */
    > +int devm_pm_opp_register_notifier(struct device *dev, struct notifier_block *nb)
    > +{
    > + struct notifier_block **ptr;
    > + int ret;
    > +
    > + ptr = devres_alloc(devm_pm_opp_notifier_release, sizeof(*ptr), GFP_KERNEL);
    > + if (!ptr)
    > + return -ENOMEM;
    > +
    > + ret = dev_pm_opp_register_notifier(dev, nb);
    > + if (ret) {
    > + devres_free(ptr);
    > + return ret;
    > + }
    > +
    > + *ptr = nb;
    > + devres_add(dev, ptr);
    > +
    > + return 0;
    > +}
    > +EXPORT_SYMBOL(devm_pm_opp_register_notifier);

    I am not in favor of this patch, and it only has one user, which makes
    it more unwanted.

    --
    viresh

    \
     
     \ /
      Last update: 2021-01-04 08:18    [W:4.048 / U:0.340 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site