Re: [PATCH 2/5] power: supply: bd71828: Fix current direction

From: Andy Shevchenko

Date: Tue Aug 11 2026 - 06:11:11 EST


On Tue, Aug 11, 2026 at 11:46:59AM +0300, Matti Vaittinen wrote:
> On 10/08/2026 20:18, Andy Shevchenko wrote:
> > On Mon, Aug 10, 2026 at 01:09:07PM +0300, Matti Vaittinen wrote:

...

> > > 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.
>
> Nope. I'm not a fan of introducing variables inside loop conditions. It's
> too easy for me to miss them. And, even if I liked the idea (and I don't),
> it is not a change related to the actual fix - and making it for this loop
> only would make the style inconsistent in this file.

This is a preferred style [1]. So, I would still do it independently on this
being a fix. This is practically a small change that's coupled with what you
are doing. A separate patch would be an unneeded churn, indeed.

[1]: (sub-thread) https://lore.kernel.org/lkml/alCoTEDUY8AO9OzD@ashevche-desk.local/

--
With Best Regards,
Andy Shevchenko