linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: sc27xx: Use devm_hwspin_lock_request_specific() to simplify code
@ 2019-09-27  2:41 Baolin Wang
  2019-10-06  9:29 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Baolin Wang @ 2019-09-27  2:41 UTC (permalink / raw)
  To: jic23
  Cc: knaack.h, lars, pmeerw, freeman.liu, linux-iio, linux-kernel,
	baolin.wang, orsonzhai, zhang.lyra

Change to use devm_hwspin_lock_request_specific() to help to simplify the
cleanup code for drivers requesting one hwlock.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/iio/adc/sc27xx_adc.c |   16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c
index a6c0465..66b387f 100644
--- a/drivers/iio/adc/sc27xx_adc.c
+++ b/drivers/iio/adc/sc27xx_adc.c
@@ -477,13 +477,6 @@ static void sc27xx_adc_disable(void *_data)
 			   SC27XX_MODULE_ADC_EN, 0);
 }
 
-static void sc27xx_adc_free_hwlock(void *_data)
-{
-	struct hwspinlock *hwlock = _data;
-
-	hwspin_lock_free(hwlock);
-}
-
 static int sc27xx_adc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -520,19 +513,12 @@ static int sc27xx_adc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	sc27xx_data->hwlock = hwspin_lock_request_specific(ret);
+	sc27xx_data->hwlock = devm_hwspin_lock_request_specific(dev, ret);
 	if (!sc27xx_data->hwlock) {
 		dev_err(dev, "failed to request hwspinlock\n");
 		return -ENXIO;
 	}
 
-	ret = devm_add_action_or_reset(dev, sc27xx_adc_free_hwlock,
-			      sc27xx_data->hwlock);
-	if (ret) {
-		dev_err(dev, "failed to add hwspinlock action\n");
-		return ret;
-	}
-
 	sc27xx_data->dev = dev;
 
 	ret = sc27xx_adc_enable(sc27xx_data);
-- 
1.7.9.5


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

* Re: [PATCH] iio: adc: sc27xx: Use devm_hwspin_lock_request_specific() to simplify code
  2019-09-27  2:41 [PATCH] iio: adc: sc27xx: Use devm_hwspin_lock_request_specific() to simplify code Baolin Wang
@ 2019-10-06  9:29 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-10-06  9:29 UTC (permalink / raw)
  To: Baolin Wang
  Cc: knaack.h, lars, pmeerw, freeman.liu, linux-iio, linux-kernel,
	orsonzhai, zhang.lyra

On Fri, 27 Sep 2019 10:41:19 +0800
Baolin Wang <baolin.wang@linaro.org> wrote:

> Change to use devm_hwspin_lock_request_specific() to help to simplify the
> cleanup code for drivers requesting one hwlock.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/sc27xx_adc.c |   16 +---------------
>  1 file changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c
> index a6c0465..66b387f 100644
> --- a/drivers/iio/adc/sc27xx_adc.c
> +++ b/drivers/iio/adc/sc27xx_adc.c
> @@ -477,13 +477,6 @@ static void sc27xx_adc_disable(void *_data)
>  			   SC27XX_MODULE_ADC_EN, 0);
>  }
>  
> -static void sc27xx_adc_free_hwlock(void *_data)
> -{
> -	struct hwspinlock *hwlock = _data;
> -
> -	hwspin_lock_free(hwlock);
> -}
> -
>  static int sc27xx_adc_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -520,19 +513,12 @@ static int sc27xx_adc_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	sc27xx_data->hwlock = hwspin_lock_request_specific(ret);
> +	sc27xx_data->hwlock = devm_hwspin_lock_request_specific(dev, ret);
>  	if (!sc27xx_data->hwlock) {
>  		dev_err(dev, "failed to request hwspinlock\n");
>  		return -ENXIO;
>  	}
>  
> -	ret = devm_add_action_or_reset(dev, sc27xx_adc_free_hwlock,
> -			      sc27xx_data->hwlock);
> -	if (ret) {
> -		dev_err(dev, "failed to add hwspinlock action\n");
> -		return ret;
> -	}
> -
>  	sc27xx_data->dev = dev;
>  
>  	ret = sc27xx_adc_enable(sc27xx_data);


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

end of thread, other threads:[~2019-10-06  9:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27  2:41 [PATCH] iio: adc: sc27xx: Use devm_hwspin_lock_request_specific() to simplify code Baolin Wang
2019-10-06  9:29 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).