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

From: Andy Shevchenko

Date: Tue Oct 20 2026 - 04:34:15 EST


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.

--
With Best Regards,
Andy Shevchenko