Re: [PATCH v3 1/2] usb: xhci: correct debug message page size calculation

Michał Pecio
2025-03-05T08:32:54Z

On Tue, 4 Feb 2025 14:41:43 +0200, Niklas Neronin wrote:
> The ffs() function returns the index of the first set bit, starting
> from 1. If no bits are set, it returns zero. This behavior causes an
> off-by-one page size in the debug message, as the page size
> calculation [1] is zero-based, while ffs() is one-based.
>
> Fix this by subtracting one from the result of ffs(). Note that since
> variable 'val' is unsigned, subtracting one from zero will result in
> the maximum unsigned integer value. Consequently, the condition 'if
> (val < 16)' will still function correctly.
>
> [1], Page size: (2^(n+12)), where 'n' is the set page size bit.
>
> Fixes: 81720ec5320c ("usb: host: xhci: use ffs() in xhci_mem_init()")
> Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>

Actually, is it useful to fix this code if the next patch in the series
removes it completely?

I thought that you perhaps meant this simple fix to go to stable, but
it isn't marked as such.

Regards,
Michal