diff mbox series

[31/31] PM / devfreq: convert to devm_pm_opp_register_notifier and remove unused API

Message ID 20210103035706.24168-1-tiny.windzz@gmail.com
State New
Headers show
Series None | expand

Commit Message

Yangtao Li Jan. 3, 2021, 3:57 a.m. UTC
Use devm_pm_opp_* API to simplify code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/devfreq/devfreq.c | 66 +--------------------------------------
 include/linux/devfreq.h   | 23 --------------
 2 files changed, 1 insertion(+), 88 deletions(-)

Comments

Viresh Kumar Jan. 4, 2021, 7:40 a.m. UTC | #1
On 03-01-21, 03:57, Yangtao Li wrote:
>  Use devm_pm_opp_* API to simplify code.
> 
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  drivers/devfreq/devfreq.c | 66 +--------------------------------------
>  include/linux/devfreq.h   | 23 --------------
>  2 files changed, 1 insertion(+), 88 deletions(-)

Remove the unused stuff in a separate patch and let this layer keep
doing the devm thing, I don't think others would need it.
Chanwoo Choi Jan. 5, 2021, 5:36 a.m. UTC | #2
On Sun, Jan 3, 2021 at 12:59 PM Yangtao Li <tiny.windzz@gmail.com> wrote:
>
>  Use devm_pm_opp_* API to simplify code.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  drivers/devfreq/devfreq.c | 66 +--------------------------------------
>  include/linux/devfreq.h   | 23 --------------
>  2 files changed, 1 insertion(+), 88 deletions(-)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 6aa10de792b3..f593f30529ec 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -2004,40 +2004,6 @@ struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
>  }
>  EXPORT_SYMBOL(devfreq_recommended_opp);
>
> -/**
> - * devfreq_register_opp_notifier() - Helper function to get devfreq notified
> - *                                  for any changes in the OPP availability
> - *                                  changes
> - * @dev:       The devfreq user device. (parent of devfreq)
> - * @devfreq:   The devfreq object.
> - */
> -int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq)
> -{
> -       return dev_pm_opp_register_notifier(dev, &devfreq->nb);
> -}
> -EXPORT_SYMBOL(devfreq_register_opp_notifier);
> -
> -/**
> - * devfreq_unregister_opp_notifier() - Helper function to stop getting devfreq
> - *                                    notified for any changes in the OPP
> - *                                    availability changes anymore.
> - * @dev:       The devfreq user device. (parent of devfreq)
> - * @devfreq:   The devfreq object.
> - *
> - * At exit() callback of devfreq_dev_profile, this must be included if
> - * devfreq_recommended_opp is used.
> - */
> -int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq)
> -{
> -       return dev_pm_opp_unregister_notifier(dev, &devfreq->nb);
> -}
> -EXPORT_SYMBOL(devfreq_unregister_opp_notifier);
> -
> -static void devm_devfreq_opp_release(struct device *dev, void *res)
> -{
> -       devfreq_unregister_opp_notifier(dev, *(struct devfreq **)res);
> -}
> -
>  /**
>   * devm_devfreq_register_opp_notifier() - Resource-managed
>   *                                       devfreq_register_opp_notifier()
> @@ -2047,40 +2013,10 @@ static void devm_devfreq_opp_release(struct device *dev, void *res)
>  int devm_devfreq_register_opp_notifier(struct device *dev,
>                                        struct devfreq *devfreq)
>  {
> -       struct devfreq **ptr;
> -       int ret;
> -
> -       ptr = devres_alloc(devm_devfreq_opp_release, sizeof(*ptr), GFP_KERNEL);
> -       if (!ptr)
> -               return -ENOMEM;
> -
> -       ret = devfreq_register_opp_notifier(dev, devfreq);
> -       if (ret) {
> -               devres_free(ptr);
> -               return ret;
> -       }
> -
> -       *ptr = devfreq;
> -       devres_add(dev, ptr);
> -
> -       return 0;
> +       return devm_pm_opp_register_notifier(dev, &devfreq->nb);
>  }
>  EXPORT_SYMBOL(devm_devfreq_register_opp_notifier);
>
> -/**
> - * devm_devfreq_unregister_opp_notifier() - Resource-managed
> - *                                         devfreq_unregister_opp_notifier()
> - * @dev:       The devfreq user device. (parent of devfreq)
> - * @devfreq:   The devfreq object.
> - */
> -void devm_devfreq_unregister_opp_notifier(struct device *dev,
> -                                        struct devfreq *devfreq)
> -{
> -       WARN_ON(devres_release(dev, devm_devfreq_opp_release,
> -                              devm_devfreq_dev_match, devfreq));
> -}
> -EXPORT_SYMBOL(devm_devfreq_unregister_opp_notifier);

Need to support devm_devfreq_unregister_opp_notifier()
because sometimes, the user wants to release the resource by himself.

(snip)

Best Regards,
Chanwoo Choi
diff mbox series

Patch

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 6aa10de792b3..f593f30529ec 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -2004,40 +2004,6 @@  struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
 }
 EXPORT_SYMBOL(devfreq_recommended_opp);
 
-/**
- * devfreq_register_opp_notifier() - Helper function to get devfreq notified
- *				     for any changes in the OPP availability
- *				     changes
- * @dev:	The devfreq user device. (parent of devfreq)
- * @devfreq:	The devfreq object.
- */
-int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq)
-{
-	return dev_pm_opp_register_notifier(dev, &devfreq->nb);
-}
-EXPORT_SYMBOL(devfreq_register_opp_notifier);
-
-/**
- * devfreq_unregister_opp_notifier() - Helper function to stop getting devfreq
- *				       notified for any changes in the OPP
- *				       availability changes anymore.
- * @dev:	The devfreq user device. (parent of devfreq)
- * @devfreq:	The devfreq object.
- *
- * At exit() callback of devfreq_dev_profile, this must be included if
- * devfreq_recommended_opp is used.
- */
-int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq)
-{
-	return dev_pm_opp_unregister_notifier(dev, &devfreq->nb);
-}
-EXPORT_SYMBOL(devfreq_unregister_opp_notifier);
-
-static void devm_devfreq_opp_release(struct device *dev, void *res)
-{
-	devfreq_unregister_opp_notifier(dev, *(struct devfreq **)res);
-}
-
 /**
  * devm_devfreq_register_opp_notifier() - Resource-managed
  *					  devfreq_register_opp_notifier()
@@ -2047,40 +2013,10 @@  static void devm_devfreq_opp_release(struct device *dev, void *res)
 int devm_devfreq_register_opp_notifier(struct device *dev,
 				       struct devfreq *devfreq)
 {
-	struct devfreq **ptr;
-	int ret;
-
-	ptr = devres_alloc(devm_devfreq_opp_release, sizeof(*ptr), GFP_KERNEL);
-	if (!ptr)
-		return -ENOMEM;
-
-	ret = devfreq_register_opp_notifier(dev, devfreq);
-	if (ret) {
-		devres_free(ptr);
-		return ret;
-	}
-
-	*ptr = devfreq;
-	devres_add(dev, ptr);
-
-	return 0;
+	return devm_pm_opp_register_notifier(dev, &devfreq->nb);
 }
 EXPORT_SYMBOL(devm_devfreq_register_opp_notifier);
 
-/**
- * devm_devfreq_unregister_opp_notifier() - Resource-managed
- *					    devfreq_unregister_opp_notifier()
- * @dev:	The devfreq user device. (parent of devfreq)
- * @devfreq:	The devfreq object.
- */
-void devm_devfreq_unregister_opp_notifier(struct device *dev,
-					 struct devfreq *devfreq)
-{
-	WARN_ON(devres_release(dev, devm_devfreq_opp_release,
-			       devm_devfreq_dev_match, devfreq));
-}
-EXPORT_SYMBOL(devm_devfreq_unregister_opp_notifier);
-
 /**
  * devfreq_register_notifier() - Register a driver with devfreq
  * @devfreq:	The devfreq object.
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index b6d3bae1c74d..aca2cc4f4fa4 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -230,14 +230,8 @@  int update_devfreq(struct devfreq *devfreq);
 /* Helper functions for devfreq user device driver with OPP. */
 struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
 				unsigned long *freq, u32 flags);
-int devfreq_register_opp_notifier(struct device *dev,
-				struct devfreq *devfreq);
-int devfreq_unregister_opp_notifier(struct device *dev,
-				struct devfreq *devfreq);
 int devm_devfreq_register_opp_notifier(struct device *dev,
 				struct devfreq *devfreq);
-void devm_devfreq_unregister_opp_notifier(struct device *dev,
-				struct devfreq *devfreq);
 int devfreq_register_notifier(struct devfreq *devfreq,
 				struct notifier_block *nb,
 				unsigned int list);
@@ -355,29 +349,12 @@  static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
 	return ERR_PTR(-EINVAL);
 }
 
-static inline int devfreq_register_opp_notifier(struct device *dev,
-					struct devfreq *devfreq)
-{
-	return -EINVAL;
-}
-
-static inline int devfreq_unregister_opp_notifier(struct device *dev,
-					struct devfreq *devfreq)
-{
-	return -EINVAL;
-}
-
 static inline int devm_devfreq_register_opp_notifier(struct device *dev,
 					struct devfreq *devfreq)
 {
 	return -EINVAL;
 }
 
-static inline void devm_devfreq_unregister_opp_notifier(struct device *dev,
-					struct devfreq *devfreq)
-{
-}
-
 static inline int devfreq_register_notifier(struct devfreq *devfreq,
 					struct notifier_block *nb,
 					unsigned int list)