Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] power: supply: qcom_battmgr: remove bogus do_div()
@ 2023-02-14 13:20 Arnd Bergmann
  2023-02-14 13:36 ` Konrad Dybcio
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Arnd Bergmann @ 2023-02-14 13:20 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Sebastian Reichel
  Cc: Arnd Bergmann, Konrad Dybcio, Neil Armstrong, linux-arm-msm,
	linux-pm, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The argument to do_div() is a 32-bit integer, and it was read from a
32-bit register so there is no point in doing a 64-bit division on it.

On 32-bit arm, do_div() causes a compile-time warning here:

include/asm-generic/div64.h:238:22: error: passing argument 1 of '__div64_32' from incompatible pointer type [-Werror=incompatible-pointer-types]
  238 |   __rem = __div64_32(&(n), __base); \
      |                      ^~~~
      |                      |
      |                      unsigned int *
drivers/power/supply/qcom_battmgr.c:1130:4: note: in expansion of macro 'do_div'
 1130 |    do_div(battmgr->status.percent, 100);

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/power/supply/qcom_battmgr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index ec31f887184f..de77df97b3a4 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -1126,8 +1126,7 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
 			battmgr->info.charge_type = le32_to_cpu(resp->intval.value);
 			break;
 		case BATT_CAPACITY:
-			battmgr->status.percent = le32_to_cpu(resp->intval.value);
-			do_div(battmgr->status.percent, 100);
+			battmgr->status.percent = le32_to_cpu(resp->intval.value) / 100;
 			break;
 		case BATT_VOLT_OCV:
 			battmgr->status.voltage_ocv = le32_to_cpu(resp->intval.value);
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread
[parent not found: <MN0PR12MB6101F4408960BDB9CF63DD53E2AB9@MN0PR12MB6101.namprd12.prod.outlook.com>]

end of thread, other threads:[~2023-03-06 20:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-14 13:20 [PATCH] power: supply: qcom_battmgr: remove bogus do_div() Arnd Bergmann
2023-02-14 13:36 ` Konrad Dybcio
2023-02-14 22:02   ` Sebastian Reichel
2023-02-28  8:51 ` Geert Uytterhoeven
2023-03-01 18:16 ` Nathan Chancellor
2023-03-01 18:50   ` Linus Torvalds
     [not found] <MN0PR12MB6101F4408960BDB9CF63DD53E2AB9@MN0PR12MB6101.namprd12.prod.outlook.com>
2023-03-03 23:05 ` "proximity" attribute for input devices Jason Gerecke
2023-03-04  1:09   ` Sebastian Reichel
2023-03-04  1:37     ` [PATCH] power: supply: qcom_battmgr: remove bogus do_div() Sebastian Reichel
2023-03-06 20:43     ` "proximity" attribute for input devices Limonciello, Mario

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox