lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250713151925.3d34f79b@jic23-huawei>
Date: Sun, 13 Jul 2025 15:19:25 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Sean Nyekjaer <sean@...nix.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@....com>, David Lechner
 <dlechner@...libre.com>, Nuno Sá <nuno.sa@...log.com>, Andy
 Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/6] iio: imu: inv_icm42600: Use
 devm_regulator_get_enable() for vdd regulator

On Wed, 09 Jul 2025 14:35:10 +0200
Sean Nyekjaer <sean@...nix.com> wrote:

> The vdd regulator is not used for runtime power management, so it does
> not need explicit enable/disable handling.
> Use devm_regulator_get_enable() to let the regulator be managed
> automatically by devm.
> 
> This simplifies the code by removing the manual enable and cleanup
> logic.
> 
> Signed-off-by: Sean Nyekjaer <sean@...nix.com>
In general good, but I think it has a small code organisation side
effect we probably don't want!

> ---
>  drivers/iio/imu/inv_icm42600/inv_icm42600.h      |  1 -
>  drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 25 ++++--------------------
>  2 files changed, 4 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600.h b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
> index 1430ab4f1dea5d5ba6277d74275fc44a6cd30eb8..c8b48a5c5ed0677bb35201d32934936faaf7a1a6 100644
> --- a/drivers/iio/imu/inv_icm42600/inv_icm42600.h
> +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
> @@ -167,7 +167,6 @@ struct inv_icm42600_state {
>  	enum inv_icm42600_chip chip;
>  	const char *name;
>  	struct regmap *map;
> -	struct regulator *vdd_supply;
>  	struct regulator *vddio_supply;
>  	int irq;
>  	struct iio_mount_matrix orientation;
> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
> index 69496d1c1ff73132f5e7bd076d18a62c293285a2..35f7c66d77790829a739d2c54ba77e53903a9297 100644
> --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
> +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
> @@ -697,17 +697,6 @@ static int inv_icm42600_enable_regulator_vddio(struct inv_icm42600_state *st)
>  	return 0;
>  }
>  
> -static void inv_icm42600_disable_vdd_reg(void *_data)
> -{
> -	struct inv_icm42600_state *st = _data;
> -	const struct device *dev = regmap_get_device(st->map);
> -	int ret;
> -
> -	ret = regulator_disable(st->vdd_supply);
> -	if (ret)
> -		dev_err(dev, "failed to disable vdd error %d\n", ret);
> -}
> -
>  static void inv_icm42600_disable_vddio_reg(void *_data)
>  {
>  	struct inv_icm42600_state *st = _data;
> @@ -773,23 +762,17 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip,
>  		return ret;
>  	}
>  
> -	st->vdd_supply = devm_regulator_get(dev, "vdd");
> -	if (IS_ERR(st->vdd_supply))
> -		return PTR_ERR(st->vdd_supply);
> +	ret = devm_regulator_get_enable(dev, "vdd");
> +	if (ret)
> +		return dev_err_probe(dev, ret,
> +				     "Failed to get vdd regulator\n");
>  
>  	st->vddio_supply = devm_regulator_get(dev, "vddio");
>  	if (IS_ERR(st->vddio_supply))
>  		return PTR_ERR(st->vddio_supply);
>  
> -	ret = regulator_enable(st->vdd_supply);
> -	if (ret)
> -		return ret;
>  	msleep(INV_ICM42600_POWER_UP_TIME_MS);
This sleep is associated with the enabling of vdd.  So we probably want
to keep those together.  So either move this up, or pull the
vdd handling down to just above this.

Thanks,

Jonathan

>  
> -	ret = devm_add_action_or_reset(dev, inv_icm42600_disable_vdd_reg, st);
> -	if (ret)
> -		return ret;
> -
>  	ret = inv_icm42600_enable_regulator_vddio(st);
>  	if (ret)
>  		return ret;
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ