Re: [PATCH v2 2/4] serial: 8250_dw: Only accept a contiguous DLF readback

From: Ilpo Järvinen

Date: Tue Oct 20 2026 - 07:51:14 EST


On Tue, 20 Oct 2026, Andy Shevchenko wrote:

> On Tue, Oct 20, 2026 at 08:11:06AM +0200, Jiri Slaby wrote:
> > On 19. 10. 26, 22:06, Vinicius Pedrosa wrote:
>
> ...
>
> > > - if (reg) {
> > > + /*
> > > + * DLF is a bit field starting at bit 0, so a real one reads back as
> > > + * 2^n - 1. Any other value means this offset is something else.
> > > + */
> > > + if (reg && !(reg & (reg + 1))) {
> >
> > Do I understand correctly, that this equivalent to:
> > if (is_power_of_2(reg + 1))
> > ?
>
> Yes, and since we check for reg to be "not zero", this will work the rest.

For is_power_of_2(), 0 is not a power of two. And it also wouldn't make
sense to have zero bits in the bit field as it's same as no bit field so
using just is_power_of_2() should be enough.

It could be that's what Andy meant, but the wording left too much room
for interpretation.

--
i.