regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector
Subsystems (2)
PATCH 1/3 regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/ad5398.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/ad5398.c +2 -2
@@ -94,8 +94,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, intif (max_uA > chip->max_uA || max_uA < chip->min_uA)return -EINVAL ; - selector = ((min_uA - chip->min_uA) * chip->current_level + - range_uA -1 ) / range_uA; + selector =DIV_ROUND_UP ((min_uA - chip->min_uA) * chip->current_level, + range_uA);if (ad5398_calc_current (chip, selector) > max_uA)return -EINVAL ;
Signature · 1 line
1.7.5.4
PATCH 2/3 regulator: max1586: Use DIV_ROUND_UP macro to calculate selector
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/max1586.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/max1586.c +2 -2
@@ -76,8 +76,8 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV,if (min_uV < max1586->min_uV) min_uV = max1586->min_uV; - *selector = ((min_uV - max1586->min_uV) *MAX1586_V3_MAX_VSEL + - range_uV -1 ) / range_uV; + *selector =DIV_ROUND_UP ((min_uV - max1586->min_uV) * +MAX1586_V3_MAX_VSEL , range_uV);if (max1586_v3_calc_voltage (max1586, *selector) > max_uV)return -EINVAL ;
Signature · 1 line
1.7.5.4
Re: [PATCH 2/3] regulator: max1586: Use DIV_ROUND_UP macro to calculate selector
Quoted 4 lines · Axel Lin
Signed-off-by Axel Lin <[email protected]>--- drivers/regulator/max1586.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
Acked-by Robert Jarzmik <[email protected]>
Signature · 1 line
Robert
PATCH 3/3 regulator: max8660: Use DIV_ROUND_UP macro to calculate selector
In reply to Axel LinSigned-off-by Axel Lin <[email protected]>
--- drivers/regulator/max8660.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-)
drivers/regulator/max8660.c +9 -7
@@ -153,14 +153,15 @@ static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV,if (max_uV <MAX8660_DCDC_MIN_UV || max_uV >MAX8660_DCDC_MAX_UV )return -EINVAL ; - selector = (min_uV - (MAX8660_DCDC_MIN_UV -MAX8660_DCDC_STEP +1 )) - /MAX8660_DCDC_STEP ; - *s = selector; + selector =DIV_ROUND_UP (min_uV -MAX8660_DCDC_MIN_UV , +MAX8660_DCDC_STEP ); ret =max8660_dcdc_list (rdev, selector);if (ret <0 || ret > max_uV)return -EINVAL ; + *s = selector; + reg = (rdev_get_id (rdev) ==MAX8660_V3 ) ?MAX8660_ADTV2 :MAX8660_SDTV2 ; ret =max8660_write (max8660, reg,0 , selector);if (ret)
@@ -210,8 +211,9 @@ static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV,if (max_uV <MAX8660_LDO5_MIN_UV || max_uV >MAX8660_LDO5_MAX_UV )return -EINVAL ; - selector = (min_uV - (MAX8660_LDO5_MIN_UV -MAX8660_LDO5_STEP +1 )) - /MAX8660_LDO5_STEP ; + selector =DIV_ROUND_UP (min_uV -MAX8660_LDO5_MIN_UV , +MAX8660_LDO5_STEP ); + ret =max8660_ldo5_list (rdev, selector);if (ret <0 || ret > max_uV)return -EINVAL ;
@@ -287,8 +289,8 @@ static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV,if (max_uV <MAX8660_LDO67_MIN_UV || max_uV >MAX8660_LDO67_MAX_UV )return -EINVAL ; - selector = (min_uV - (MAX8660_LDO67_MIN_UV -MAX8660_LDO67_STEP +1 )) - /MAX8660_LDO67_STEP ; + selector =DIV_ROUND_UP (min_uV -MAX8660_LDO67_MIN_UV , +MAX8660_LDO67_STEP ); ret =max8660_ldo67_list (rdev, selector);if (ret <0 || ret > max_uV)
Signature · 1 line
1.7.5.4
Acked-by Sonic Zhang <[email protected]>
-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Friday, March 02, 2012 4:21 PM
To: [email protected]
Cc: Zhang, Sonic; Liam Girdwood; Mark Brown
Subject: [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/ad5398.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/ad5398.c +2 -2
@@ -94,8 +94,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, intif (max_uA > chip->max_uA || max_uA < chip->min_uA)return -EINVAL ; - selector = ((min_uA - chip->min_uA) * chip->current_level + - range_uA -1 ) / range_uA; + selector =DIV_ROUND_UP ((min_uA - chip->min_uA) * chip->current_level, + range_uA);if (ad5398_calc_current (chip, selector) > max_uA)return -EINVAL ;
--
1.7.5.4
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Mark Brown
AppliedQuoted 1 line · Axel Lin
Signed-off-by Axel Lin <[email protected]>
Applied all, thanks.