2024-02-20 14:18:13

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v13 2/3] iio: adc: ad_sigma_delta: Add optional irq selection

On Tue, Feb 20, 2024 at 04:13:12PM +0200, Ceclan Dumitru wrote:
> On 2/20/24 16:11, Andy Shevchenko wrote:
> > On Tue, Feb 20, 2024 at 11:43:39AM +0200, Dumitru Ceclan wrote:

..

> >> + if (!info->irq_num)
> >> + sigma_delta->irq_num = spi->irq;
> >> + else
> >> + sigma_delta->irq_num = info->irq_num;
> >
> > Why not positive check?
> >
> Considered that selecting spi->irq is usually the default case, so it should
> be the first branch

Let compiler do its job, the negative conditions are harder to read/parse by
human beings.

--
With Best Regards,
Andy Shevchenko




2024-02-24 17:02:54

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v13 2/3] iio: adc: ad_sigma_delta: Add optional irq selection

On Tue, 20 Feb 2024 16:17:52 +0200
Andy Shevchenko <[email protected]> wrote:

> On Tue, Feb 20, 2024 at 04:13:12PM +0200, Ceclan Dumitru wrote:
> > On 2/20/24 16:11, Andy Shevchenko wrote:
> > > On Tue, Feb 20, 2024 at 11:43:39AM +0200, Dumitru Ceclan wrote:
>
> ...
>
> > >> + if (!info->irq_num)
> > >> + sigma_delta->irq_num = spi->irq;
> > >> + else
> > >> + sigma_delta->irq_num = info->irq_num;
> > >
> > > Why not positive check?
> > >
> > Considered that selecting spi->irq is usually the default case, so it should
> > be the first branch
>
> Let compiler do its job, the negative conditions are harder to read/parse by
> human beings.
>
FWIW compiler almost certainly won't figure this out as it has nothing to go on
- history based branch prediction in processors will though! We don't want to
be hinting direction to the compiler for a case like this as that will make
it very painful if we get it wrong. Anyhow Andy's comment is valid even if
I disagree with the reason.

Jonathan