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: <20240928172245.6d69df95@jic23-huawei>
Date: Sat, 28 Sep 2024 17:22:45 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Javier Carrasco <javier.carrasco.cruz@...il.com>
Cc: Lars-Peter Clausen <lars@...afoo.de>, Rob Herring <robh@...nel.org>,
 Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
 <conor+dt@...nel.org>, Rishi Gupta <gupt21@...il.com>,
 linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
 linux-kernel@...r.kernel.org, Jonathan Cameron
 <Jonathan.Cameron@...wei.com>
Subject: Re: [PATCH v2 08/10] iio: light: veml6030: power off device in
 probe error paths

On Mon, 23 Sep 2024 00:17:56 +0200
Javier Carrasco <javier.carrasco.cruz@...il.com> wrote:

> Move devm_add_action_or_reset() with a device shut down action above the
> hardware initialization function to ensure that any error path after
> powering on the device leads to a power off.
> 
> The power off action is carried out by setting the VEML6030_ALS_SD bit
> of the VEML6030_REG_ALS_CONF, which is harmless in error paths were the
> device is already off. On the other hand, making use of the registered
> action in all error paths makes them more homogeneous by avoiding
> special action depending on the current power state of the device.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@...il.com>
As per my very late reply, I'd move the devm_add_action_or_reset()
into the hw_init function so it's closely coupled with the thing
it is undoing rather than with a function that does lots of other
things.

You'll want to pass dev into the init function though so it is
easy to see what device the devm_ call is against.
Don't use the parent of the IIO dev as that's an implementation
detail!

Jonathan
> ---
>  drivers/iio/light/veml6030.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c
> index 861bdf2edd4d..19c69bfad8cb 100644
> --- a/drivers/iio/light/veml6030.c
> +++ b/drivers/iio/light/veml6030.c
> @@ -853,12 +853,12 @@ static int veml6030_probe(struct i2c_client *client)
>  		indio_dev->info = &veml6030_info_no_irq;
>  	}
>  
> -	ret = veml6030_hw_init(indio_dev);
> +	ret = devm_add_action_or_reset(&client->dev,
> +				       veml6030_als_shut_down_action, data);
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = devm_add_action_or_reset(&client->dev,
> -					veml6030_als_shut_down_action, data);
> +	ret = veml6030_hw_init(indio_dev);
>  	if (ret < 0)
>  		return ret;
>  
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ