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]
Date:   Sat, 20 Aug 2022 12:22:26 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Matti Vaittinen <mazziesaccount@...il.com>
Cc:     Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Miaoqian Lin <linmq006@...il.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Xiang wangx <wangxiang@...rlc.com>, linux-iio@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 08/14] iio: bmg160_core: Simplify using
 devm_regulator_*get_enable()

On Fri, 19 Aug 2022 22:19:31 +0300
Matti Vaittinen <mazziesaccount@...il.com> wrote:

> Use devm_regulator_bulk_get_enable() instead of open coded bulk-get,
> bulk-enable, add-action-to-disable-at-detach - pattern.
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@...il.com>
> 
> ---
> v2 => v3
> Split to own patch.
> ---
>  drivers/iio/gyro/bmg160_core.c | 24 +++---------------------
>  1 file changed, 3 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
> index cedd9f02ea21..baa80980c99f 100644
> --- a/drivers/iio/gyro/bmg160_core.c
> +++ b/drivers/iio/gyro/bmg160_core.c
> @@ -93,7 +93,6 @@
>  
>  struct bmg160_data {
>  	struct regmap *regmap;
> -	struct regulator_bulk_data regulators[2];
>  	struct iio_trigger *dready_trig;
>  	struct iio_trigger *motion_trig;
>  	struct iio_mount_matrix orientation;
> @@ -1067,19 +1066,13 @@ static const char *bmg160_match_acpi_device(struct device *dev)
>  	return dev_name(dev);
>  }
>  
> -static void bmg160_disable_regulators(void *d)
> -{
> -	struct bmg160_data *data = d;
> -
> -	regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> -}
> -
>  int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
>  		      const char *name)
>  {
>  	struct bmg160_data *data;
>  	struct iio_dev *indio_dev;
>  	int ret;
> +	static const char * const regulators[] = {"vdd", "vddio"};

As in previous, small preference for spaces after { and before }

>  
>  	indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
>  	if (!indio_dev)
> @@ -1090,22 +1083,11 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
>  	data->irq = irq;
>  	data->regmap = regmap;
>  
> -	data->regulators[0].supply = "vdd";
> -	data->regulators[1].supply = "vddio";
> -	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators),
> -				      data->regulators);
> +	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators),
> +					     regulators);
>  	if (ret)
>  		return dev_err_probe(dev, ret, "Failed to get regulators\n");
>  
> -	ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
> -				    data->regulators);
> -	if (ret)
> -		return ret;
> -
> -	ret = devm_add_action_or_reset(dev, bmg160_disable_regulators, data);
> -	if (ret)
> -		return ret;
> -
>  	ret = iio_read_mount_matrix(dev, &data->orientation);
>  	if (ret)
>  		return ret;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ