Re: [PATCH 05/31] opp: Add devres wrapper for dev_pm_opp_register_notifier
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Re: [PATCH 05/31] opp: Add devres wrapper for dev_pm_opp_register_notifier
- From: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
- Date: Mon, 4 Jan 2021 12:45:31 +0530
- Cc: myungjoo.ham@xxxxxxxxxxx, kyungmin.park@xxxxxxxxxxx, cw00.choi@xxxxxxxxxxx, krzk@xxxxxxxxxx, shawnguo@xxxxxxxxxx, s.hauer@xxxxxxxxxxxxxx, kernel@xxxxxxxxxxxxxx, festevam@xxxxxxxxx, linux-imx@xxxxxxx, digetx@xxxxxxxxx, thierry.reding@xxxxxxxxx, jonathanh@xxxxxxxxxx, yuq825@xxxxxxxxx, airlied@xxxxxxxx, daniel@xxxxxxxx, robdclark@xxxxxxxxx, sean@xxxxxxxxxx, robh@xxxxxxxxxx, tomeu.vizoso@xxxxxxxxxxxxx, steven.price@xxxxxxx, alyssa.rosenzweig@xxxxxxxxxxxxx, stanimir.varbanov@xxxxxxxxxx, agross@xxxxxxxxxx, bjorn.andersson@xxxxxxxxxx, mchehab@xxxxxxxxxx, lukasz.luba@xxxxxxx, adrian.hunter@xxxxxxxxx, ulf.hansson@xxxxxxxxxx, vireshk@xxxxxxxxxx, nm@xxxxxx, sboyd@xxxxxxxxxx, broonie@xxxxxxxxxx, gregkh@xxxxxxxxxxxxxxxxxxx, jirislaby@xxxxxxxxxx, rjw@xxxxxxxxxxxxx, jcrouse@xxxxxxxxxxxxxx, hoegsberg@xxxxxxxxxx, eric@xxxxxxxxxxxxxxxxxx, tzimmermann@xxxxxxx, marijn.suijten@xxxxxxxxxxxxxx, gustavoars@xxxxxxxxxx, emil.velikov@xxxxxxxxxxxxx, jonathan@xxxxxxxx, akhilpo@xxxxxxxxxxxxxx, smasetty@xxxxxxxxxxxxxx, airlied@xxxxxxxxxx, masneyb@xxxxxxxxxxxxx, kalyan_t@xxxxxxxxxxxxxx, tanmay@xxxxxxxxxxxxxx, ddavenport@xxxxxxxxxxxx, jsanka@xxxxxxxxxxxxxx, rnayak@xxxxxxxxxxxxxx, tongtiangen@xxxxxxxxxx, miaoqinglang@xxxxxxxxxx, khsieh@xxxxxxxxxxxxxx, abhinavk@xxxxxxxxxxxxxx, chandanu@xxxxxxxxxxxxxx, groeck@xxxxxxxxxxxx, varar@xxxxxxxxxxxxxx, mka@xxxxxxxxxxxx, harigovi@xxxxxxxxxxxxxx, rikard.falkeborn@xxxxxxxxx, natechancellor@xxxxxxxxx, georgi.djakov@xxxxxxxxxx, akashast@xxxxxxxxxxxxxx, parashar@xxxxxxxxxxxxxx, dianders@xxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-samsung-soc@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-tegra@xxxxxxxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, lima@xxxxxxxxxxxxxxxxxxxxx, linux-arm-msm@xxxxxxxxxxxxxxx, freedreno@xxxxxxxxxxxxxxxxxxxxx, linux-media@xxxxxxxxxxxxxxx, linux-mmc@xxxxxxxxxxxxxxx, linux-spi@xxxxxxxxxxxxxxx, linux-serial@xxxxxxxxxxxxxxx
- In-reply-to: <20210101165507.19486-6-tiny.windzz@gmail.com>
- References: <20210101165507.19486-1-tiny.windzz@gmail.com> <20210101165507.19486-6-tiny.windzz@gmail.com>
- User-agent: NeoMutt/20180716-391-311a52
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@xxxxxxxxx>
> ---
> 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
[Index of Archives]
[Linux Kernel]
[Linux ARM (vger)]
[Linux ARM MSM]
[Linux Omap]
[Linux Arm]
[Linux Tegra]
[Fedora ARM]
[Linux for Samsung SOC]
[eCos]
[Linux Fastboot]
[Gcc Help]
[Git]
[DCCP]
[IETF Announce]
[Security]
[Linux MIPS]
[Yosemite Campsites]
|