Skip to contentSkip to conversation

xhci: Use __ffs() to find page size in xhci_mem_init()

PATCH New Andrey Smirnov 1 participant 1 message Feb 8, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xhci: Use __ffs() to find page size in xhci_mem_init()

Get page size order using __ffs() instead of open coding it with a loop.

---

Changes since [v1]:

- Code changed to use __ffs()
- Added check for page_size == 0

[v1] https://lore.kernel.org/lkml/[email protected]

 drivers/usb/host/xhci-mem.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/usb/host/xhci-mem.c +1 -5
index 36a3eb8849f1..4b350125e1cc 100644
@@ -2362,11 +2362,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 	page_size = readl(&xhci->op_regs->page_size);
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"Supported page size register = 0x%x", page_size);
-	for (i = 0; i < 16; i++) {
-		if ((0x1 & page_size) != 0)
-			break;
-		page_size = page_size >> 1;
-	}
+	i = page_size ? __ffs(page_size) : INT_MAX;
 	if (i < 16)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"Supported page size of %iK", (1 << (i+12)) / 1024);