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: <201203021113.11269.marek.vasut@gmail.com>
Date:	Fri, 2 Mar 2012 11:13:11 +0100
From:	Marek Vasut <marek.vasut@...il.com>
To:	Axel Lin <axel.lin@...il.com>
Cc:	linux-kernel@...r.kernel.org, Liam Girdwood <lrg@...com>,
	Mark Brown <broonie@...nsource.wolfsonmicro.com>
Subject: Re: [PATCH] regulator: Simplify the code to get selector in isl6271a_set_voltage

> Signed-off-by: Axel Lin <axel.lin@...il.com>
> ---
>  drivers/regulator/isl6271a-regulator.c |   14 +++-----------
>  1 files changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/regulator/isl6271a-regulator.c
> b/drivers/regulator/isl6271a-regulator.c index c1a456c..775f5fd 100644
> --- a/drivers/regulator/isl6271a-regulator.c
> +++ b/drivers/regulator/isl6271a-regulator.c
> @@ -63,23 +63,15 @@ static int isl6271a_set_voltage(struct regulator_dev
> *dev, unsigned *selector)
>  {
>  	struct isl_pmic *pmic = rdev_get_drvdata(dev);
> -	int vsel, err, data;
> +	int err, data;
> 
>  	if (minuV < ISL6271A_VOLTAGE_MIN || minuV > ISL6271A_VOLTAGE_MAX)
>  		return -EINVAL;
>  	if (maxuV < ISL6271A_VOLTAGE_MIN || maxuV > ISL6271A_VOLTAGE_MAX)
>  		return -EINVAL;
> 
> -	/* Align to 50000 mV */

Heh ... 50000mV ? :-)

> -	vsel = minuV - (minuV % ISL6271A_VOLTAGE_STEP);
> -
> -	/* If the result fell out of [minuV,maxuV] range, put it back */
> -	if (vsel < minuV)
> -		vsel += ISL6271A_VOLTAGE_STEP;
> -
> -	/* Convert the microvolts to data for the chip */
> -	data = (vsel - ISL6271A_VOLTAGE_MIN) / ISL6271A_VOLTAGE_STEP;
> -
> +	data = DIV_ROUND_UP(minuV - ISL6271A_VOLTAGE_MIN,
> +			    ISL6271A_VOLTAGE_STEP);

Ok, this makes sense.

Acked-by: Marek Vasut <marek.vasut@...il.com>

>  	*selector = data;
> 
>  	mutex_lock(&pmic->mtx);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ