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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250128173143.959600-3-isaac.scott@ideasonboard.com>
Date: Tue, 28 Jan 2025 17:31:42 +0000
From: Isaac Scott <isaac.scott@...asonboard.com>
To: michael.hennerich@...log.com
Cc: lgirdwood@...il.com,
	broonie@...nel.org,
	linux-kernel@...r.kernel.org,
	Isaac Scott <isaac.scott@...asonboard.com>
Subject: [PATCH v2 2/3] RFC: regulator: ad5398: Change selector division calculation

If the AD5398 is defined to have a current limit with no range, i.e.
when max_Ua and min_Ua are equal, the DIV_ROUND_UP erroneously tries to
set the current to a higher level than the max_Ua, which causes the
driver to fail to set the current. Fix this so the driver slightly
underestimates the current to set.

Signed-off-by: Isaac Scott <isaac.scott@...asonboard.com>
---
 drivers/regulator/ad5398.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
index e6f45c6e750c..0c60ecd1f0f2 100644
--- a/drivers/regulator/ad5398.c
+++ b/drivers/regulator/ad5398.c
@@ -98,8 +98,7 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
 	if (min_uA > chip->max_uA || max_uA < chip->min_uA)
 		return -EINVAL;
 
-	selector = DIV_ROUND_UP((min_uA - chip->min_uA) * chip->current_level,
-				range_uA);
+	selector = ((min_uA - chip->min_uA) * chip->current_level / range_uA);
 	if (ad5398_calc_current(chip, selector) > max_uA)
 		return -EINVAL;
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ