Re: [PATCH 2/5] power: supply: bd71828: Fix current direction
From: Andy Shevchenko
Date: Mon Aug 10 2026 - 13:21:48 EST
On Mon, Aug 10, 2026 at 01:09:07PM +0300, Matti Vaittinen wrote:
> Both the current and the average current registers contain same
> 'direction' -bit to denote the direction of the current. The code
> reading these registers incorrectly caches the direction read from the
> first register, and uses it also for the second.
>
> Fix this by initializing the direction bit for both register reads.
...
> static int bd71828_get_current_ds_adc(struct bd71828_power *pwr, int *curr, int
> {
> __be16 tmp_curr;
> char *tmp = (char *)&tmp_curr;
> - int dir = 1;
> int regs[] = { pwr->regs->ibat, pwr->regs->ibat_avg };
> int *vals[] = { curr, curr_avg };
> int ret, i;
> - for (dir = 1, i = 0; i < ARRAY_SIZE(regs); i++) {
> + for (i = 0; i < ARRAY_SIZE(regs); i++) {
While at it
for (unsigned int i = 0; i < ARRAY_SIZE(regs); i++) {
> + int dir = 1;
...and drop it from the top declaration.
--
With Best Regards,
Andy Shevchenko