diff mbox series

[03/14] iio: accel: fxls8962af: Use devm_regulator_get_enable()

Message ID 20221016163409.320197-4-jic23@kernel.org (mailing list archive)
State Accepted
Headers show
Series IIO: More devm_regulator[_bulk]_get_enable() users | expand

Commit Message

Jonathan Cameron Oct. 16, 2022, 4:33 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Sean Nyekjaer <sean@geanix.com>
---
 drivers/iio/accel/fxls8962af-core.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

Comments

Matti Vaittinen Oct. 17, 2022, 5:27 a.m. UTC | #1
On 10/16/22 19:33, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Sean Nyekjaer <sean@geanix.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Sean Nyekjaer Oct. 17, 2022, 9:23 a.m. UTC | #2
On Sun, Oct 16, 2022 at 05:33:58PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This driver only turns the power on at probe and off via a custom
> devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
> replaces this boilerplate code.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Sean Nyekjaer <sean@geanix.com>
> ---
>  drivers/iio/accel/fxls8962af-core.c | 24 +++---------------------
>  1 file changed, 3 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
> index bf259db281f5..0d672b1469e8 100644
> --- a/drivers/iio/accel/fxls8962af-core.c
> +++ b/drivers/iio/accel/fxls8962af-core.c
> @@ -159,7 +159,6 @@ struct fxls8962af_chip_info {
>  struct fxls8962af_data {
>  	struct regmap *regmap;
>  	const struct fxls8962af_chip_info *chip_info;
> -	struct regulator *vdd_reg;
>  	struct {
>  		__le16 channels[3];
>  		s64 ts __aligned(8);
> @@ -1051,13 +1050,6 @@ static irqreturn_t fxls8962af_interrupt(int irq, void *p)
>  	return IRQ_NONE;
>  }
>  
> -static void fxls8962af_regulator_disable(void *data_ptr)
> -{
> -	struct fxls8962af_data *data = data_ptr;
> -
> -	regulator_disable(data->vdd_reg);
> -}
> -
>  static void fxls8962af_pm_disable(void *dev_ptr)
>  {
>  	struct device *dev = dev_ptr;
> @@ -1171,20 +1163,10 @@ int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
>  	if (ret)
>  		return ret;
>  
> -	data->vdd_reg = devm_regulator_get(dev, "vdd");
> -	if (IS_ERR(data->vdd_reg))
> -		return dev_err_probe(dev, PTR_ERR(data->vdd_reg),
> -				     "Failed to get vdd regulator\n");
> -
> -	ret = regulator_enable(data->vdd_reg);
> -	if (ret) {
> -		dev_err(dev, "Failed to enable vdd regulator: %d\n", ret);
> -		return ret;
> -	}
> -
> -	ret = devm_add_action_or_reset(dev, fxls8962af_regulator_disable, data);
> +	ret = devm_regulator_get_enable(dev, "vdd");
>  	if (ret)
> -		return ret;
> +		return dev_err_probe(dev, ret,
> +				     "Failed to get vdd regulator\n");
>  
>  	ret = regmap_read(data->regmap, FXLS8962AF_WHO_AM_I, &reg);
>  	if (ret)
> -- 
> 2.37.2
>
diff mbox series

Patch

diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
index bf259db281f5..0d672b1469e8 100644
--- a/drivers/iio/accel/fxls8962af-core.c
+++ b/drivers/iio/accel/fxls8962af-core.c
@@ -159,7 +159,6 @@  struct fxls8962af_chip_info {
 struct fxls8962af_data {
 	struct regmap *regmap;
 	const struct fxls8962af_chip_info *chip_info;
-	struct regulator *vdd_reg;
 	struct {
 		__le16 channels[3];
 		s64 ts __aligned(8);
@@ -1051,13 +1050,6 @@  static irqreturn_t fxls8962af_interrupt(int irq, void *p)
 	return IRQ_NONE;
 }
 
-static void fxls8962af_regulator_disable(void *data_ptr)
-{
-	struct fxls8962af_data *data = data_ptr;
-
-	regulator_disable(data->vdd_reg);
-}
-
 static void fxls8962af_pm_disable(void *dev_ptr)
 {
 	struct device *dev = dev_ptr;
@@ -1171,20 +1163,10 @@  int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
 	if (ret)
 		return ret;
 
-	data->vdd_reg = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(data->vdd_reg))
-		return dev_err_probe(dev, PTR_ERR(data->vdd_reg),
-				     "Failed to get vdd regulator\n");
-
-	ret = regulator_enable(data->vdd_reg);
-	if (ret) {
-		dev_err(dev, "Failed to enable vdd regulator: %d\n", ret);
-		return ret;
-	}
-
-	ret = devm_add_action_or_reset(dev, fxls8962af_regulator_disable, data);
+	ret = devm_regulator_get_enable(dev, "vdd");
 	if (ret)
-		return ret;
+		return dev_err_probe(dev, ret,
+				     "Failed to get vdd regulator\n");
 
 	ret = regmap_read(data->regmap, FXLS8962AF_WHO_AM_I, &reg);
 	if (ret)