Skip to content

Commit

Permalink
xhci: Add option to get next extended capability in list by passing i…
Browse files Browse the repository at this point in the history
…d = 0

Modify xhci_find_next_ext_cap(base, offset, id) to return the next
capability offset if 0 is passed for id. Otherwise it will behave as
previously and return the offset of the next capability with matching id

capability id 0 is not used by xHCI (reserved)

This is useful when we want to loop through all capabilities.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Mathias Nyman authored and Greg Kroah-Hartman committed Mar 22, 2018
1 parent 2000016 commit d0a0fa9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/usb/host/xhci-ext-caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
* @base PCI MMIO registers base address.
* @start address at which to start looking, (0 or HCC_PARAMS to start at
* beginning of list)
* @id Extended capability ID to search for.
* @id Extended capability ID to search for, or 0 for the next
* capability
*
* Returns the offset of the next matching extended capability structure.
* Some capabilities can occur several times, e.g., the XHCI_EXT_CAPS_PROTOCOL,
Expand All @@ -110,7 +111,7 @@ static inline int xhci_find_next_ext_cap(void __iomem *base, u32 start, int id)
val = readl(base + offset);
if (val == ~0)
return 0;
if (XHCI_EXT_CAPS_ID(val) == id && offset != start)
if (offset != start && (id == 0 || XHCI_EXT_CAPS_ID(val) == id))
return offset;

next = XHCI_EXT_CAPS_NEXT(val);
Expand Down

0 comments on commit d0a0fa9

Please sign in to comment.