All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one
@ 2022-08-26 17:26 Andy Shevchenko
  2022-08-26 17:26 ` [PATCH v2 2/3] pwm: core: Get rid of unused devm_of_pwm_get() Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-08-26 17:26 UTC (permalink / raw)
  To: Andy Shevchenko, Uwe Kleine-König, linux-doc, linux-kernel,
	linux-pwm, linux-hwmon
  Cc: Jonathan Corbet, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Jean Delvare, Guenter Roeck

There is no need to call OF specific devm_of_pwm_get() since
the device node parameter duplicates in the device parameter.
Hence we may safely replace it by plain devm_pwm_get() call.

This allows to drop devm_of_pwm_get() as no more users will be.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
v2: added tag (Uwe), left only one-liner change (Uwe, Guenter)
 drivers/hwmon/pwm-fan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 6c08551d8d14..06fd1d75101d 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -302,7 +302,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
 
 	mutex_init(&ctx->lock);
 
-	ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
+	ctx->pwm = devm_pwm_get(dev, NULL);
 	if (IS_ERR(ctx->pwm))
 		return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n");
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] pwm: core: Get rid of unused devm_of_pwm_get()
  2022-08-26 17:26 [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one Andy Shevchenko
@ 2022-08-26 17:26 ` Andy Shevchenko
  2022-08-26 17:26 ` [PATCH v2 3/3] pwm: core: Make of_pwm_get() static Andy Shevchenko
  2022-08-29 13:57 ` [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one Guenter Roeck
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-08-26 17:26 UTC (permalink / raw)
  To: Andy Shevchenko, Uwe Kleine-König, linux-doc, linux-kernel,
	linux-pwm, linux-hwmon
  Cc: Jonathan Corbet, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Jean Delvare, Guenter Roeck

The devm_of_pwm_get() has recently lost its single user, drop
the dead API as well.

Note, the new code should use either plain pwm_get() or managed
devm_pwm_get() or devm_fwnode_pwm_get() APIs.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
v2: added tag (Uwe)
 .../driver-api/driver-model/devres.rst        |  1 -
 Documentation/driver-api/pwm.rst              |  3 +-
 drivers/pwm/core.c                            | 30 -------------------
 include/linux/pwm.h                           | 10 -------
 4 files changed, 1 insertion(+), 43 deletions(-)

diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst
index eb01a2f0ab80..57f0620d4c8e 100644
--- a/Documentation/driver-api/driver-model/devres.rst
+++ b/Documentation/driver-api/driver-model/devres.rst
@@ -410,7 +410,6 @@ POWER
 
 PWM
   devm_pwm_get()
-  devm_of_pwm_get()
   devm_fwnode_pwm_get()
 
 REGULATOR
diff --git a/Documentation/driver-api/pwm.rst b/Documentation/driver-api/pwm.rst
index fd26c3d895b6..8c71a2055d27 100644
--- a/Documentation/driver-api/pwm.rst
+++ b/Documentation/driver-api/pwm.rst
@@ -40,8 +40,7 @@ after usage with pwm_free().
 
 New users should use the pwm_get() function and pass to it the consumer
 device or a consumer name. pwm_put() is used to free the PWM device. Managed
-variants of the getter, devm_pwm_get(), devm_of_pwm_get(),
-devm_fwnode_pwm_get(), also exist.
+variants of the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist.
 
 After being requested, a PWM has to be configured using::
 
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 0e042410f6b9..dc1b7263a0b0 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -1070,36 +1070,6 @@ struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id)
 }
 EXPORT_SYMBOL_GPL(devm_pwm_get);
 
-/**
- * devm_of_pwm_get() - resource managed of_pwm_get()
- * @dev: device for PWM consumer
- * @np: device node to get the PWM from
- * @con_id: consumer name
- *
- * This function performs like of_pwm_get() but the acquired PWM device will
- * automatically be released on driver detach.
- *
- * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
- * error code on failure.
- */
-struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
-				   const char *con_id)
-{
-	struct pwm_device *pwm;
-	int ret;
-
-	pwm = of_pwm_get(dev, np, con_id);
-	if (IS_ERR(pwm))
-		return pwm;
-
-	ret = devm_add_action_or_reset(dev, devm_pwm_release, pwm);
-	if (ret)
-		return ERR_PTR(ret);
-
-	return pwm;
-}
-EXPORT_SYMBOL_GPL(devm_of_pwm_get);
-
 /**
  * devm_fwnode_pwm_get() - request a resource managed PWM from firmware node
  * @dev: device for PWM consumer
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 9429930c5566..572ba92e4206 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -408,8 +408,6 @@ struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
 void pwm_put(struct pwm_device *pwm);
 
 struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id);
-struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
-				   const char *con_id);
 struct pwm_device *devm_fwnode_pwm_get(struct device *dev,
 				       struct fwnode_handle *fwnode,
 				       const char *con_id);
@@ -517,14 +515,6 @@ static inline struct pwm_device *devm_pwm_get(struct device *dev,
 	return ERR_PTR(-ENODEV);
 }
 
-static inline struct pwm_device *devm_of_pwm_get(struct device *dev,
-						 struct device_node *np,
-						 const char *con_id)
-{
-	might_sleep();
-	return ERR_PTR(-ENODEV);
-}
-
 static inline struct pwm_device *
 devm_fwnode_pwm_get(struct device *dev, struct fwnode_handle *fwnode,
 		    const char *con_id)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] pwm: core: Make of_pwm_get() static
  2022-08-26 17:26 [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one Andy Shevchenko
  2022-08-26 17:26 ` [PATCH v2 2/3] pwm: core: Get rid of unused devm_of_pwm_get() Andy Shevchenko
@ 2022-08-26 17:26 ` Andy Shevchenko
  2022-08-29 13:57 ` [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one Guenter Roeck
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-08-26 17:26 UTC (permalink / raw)
  To: Andy Shevchenko, Uwe Kleine-König, linux-doc, linux-kernel,
	linux-pwm, linux-hwmon
  Cc: Jonathan Corbet, Thierry Reding, Bartlomiej Zolnierkiewicz,
	Jean Delvare, Guenter Roeck

There are no users outside of PWM core of the of_pwm_get().
Make it static.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
v2: added tag (Uwe)
 drivers/pwm/core.c  |  5 ++---
 include/linux/pwm.h | 10 ----------
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index dc1b7263a0b0..cfe3a0327471 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -734,8 +734,8 @@ static struct device_link *pwm_device_link_add(struct device *dev,
  * Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
  * error code on failure.
  */
-struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
-			      const char *con_id)
+static struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
+				     const char *con_id)
 {
 	struct pwm_device *pwm = NULL;
 	struct of_phandle_args args;
@@ -797,7 +797,6 @@ struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
 
 	return pwm;
 }
-EXPORT_SYMBOL_GPL(of_pwm_get);
 
 /**
  * acpi_pwm_get() - request a PWM via parsing "pwms" property in ACPI
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 572ba92e4206..d70c6e5a839d 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -403,8 +403,6 @@ struct pwm_device *of_pwm_single_xlate(struct pwm_chip *pc,
 				       const struct of_phandle_args *args);
 
 struct pwm_device *pwm_get(struct device *dev, const char *con_id);
-struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
-			      const char *con_id);
 void pwm_put(struct pwm_device *pwm);
 
 struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id);
@@ -495,14 +493,6 @@ static inline struct pwm_device *pwm_get(struct device *dev,
 	return ERR_PTR(-ENODEV);
 }
 
-static inline struct pwm_device *of_pwm_get(struct device *dev,
-					    struct device_node *np,
-					    const char *con_id)
-{
-	might_sleep();
-	return ERR_PTR(-ENODEV);
-}
-
 static inline void pwm_put(struct pwm_device *pwm)
 {
 	might_sleep();
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one
  2022-08-26 17:26 [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one Andy Shevchenko
  2022-08-26 17:26 ` [PATCH v2 2/3] pwm: core: Get rid of unused devm_of_pwm_get() Andy Shevchenko
  2022-08-26 17:26 ` [PATCH v2 3/3] pwm: core: Make of_pwm_get() static Andy Shevchenko
@ 2022-08-29 13:57 ` Guenter Roeck
  2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2022-08-29 13:57 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Uwe Kleine-König, linux-doc, linux-kernel, linux-pwm,
	linux-hwmon, Jonathan Corbet, Thierry Reding,
	Bartlomiej Zolnierkiewicz, Jean Delvare

On Fri, Aug 26, 2022 at 08:26:40PM +0300, Andy Shevchenko wrote:
> There is no need to call OF specific devm_of_pwm_get() since
> the device node parameter duplicates in the device parameter.
> Hence we may safely replace it by plain devm_pwm_get() call.
> 
> This allows to drop devm_of_pwm_get() as no more users will be.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

I am going to apply the series to hwmon-next.
Uwe, please holler if that is not ok.

Thanks,
Guenter

> ---
> v2: added tag (Uwe), left only one-liner change (Uwe, Guenter)
>  drivers/hwmon/pwm-fan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 6c08551d8d14..06fd1d75101d 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -302,7 +302,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
>  
>  	mutex_init(&ctx->lock);
>  
> -	ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
> +	ctx->pwm = devm_pwm_get(dev, NULL);
>  	if (IS_ERR(ctx->pwm))
>  		return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n");
>  

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-29 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-26 17:26 [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one Andy Shevchenko
2022-08-26 17:26 ` [PATCH v2 2/3] pwm: core: Get rid of unused devm_of_pwm_get() Andy Shevchenko
2022-08-26 17:26 ` [PATCH v2 3/3] pwm: core: Make of_pwm_get() static Andy Shevchenko
2022-08-29 13:57 ` [PATCH v2 1/3] hwmon: (pwm-fan) Replace OF specific call to PWM by plain one Guenter Roeck

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.