From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933949AbeBPKpm (ORCPT ); Fri, 16 Feb 2018 05:45:42 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54224 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933737AbeBPKnb (ORCPT ); Fri, 16 Feb 2018 05:43:31 -0500 From: Hans de Goede To: Tejun Heo Cc: Hans de Goede , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Mathias Nyman Subject: [PATCH 07/12] xhci: Add option to get next extended capability in list by passing id = 0 Date: Fri, 16 Feb 2018 11:43:16 +0100 Message-Id: <20180216104321.8259-8-hdegoede@redhat.com> In-Reply-To: <20180216104321.8259-1-hdegoede@redhat.com> References: <20180216104321.8259-1-hdegoede@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathias Nyman 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 Signed-off-by: Hans de Goede --- drivers/usb/host/xhci-ext-caps.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h index bf7316e130d3..631e7cc62604 100644 --- a/drivers/usb/host/xhci-ext-caps.h +++ b/drivers/usb/host/xhci-ext-caps.h @@ -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, @@ -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); -- 2.14.3