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

Andy Shevchenko <[email protected]>
Newsgroups org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
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/[email protected]/

-- 
With Best Regards,
Andy Shevchenko
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.