Received: by 10.223.185.116 with SMTP id b49csp6301527wrg; Wed, 28 Feb 2018 07:13:44 -0800 (PST) X-Google-Smtp-Source: AH8x226HGiI9mTAPBs20pSHi9TdmpZFPvqr3lztgcf4T0M66CWe1bZmjat72cs+/LlsD6X88sNnU X-Received: by 10.98.93.193 with SMTP id n62mr18095248pfj.83.1519830824535; Wed, 28 Feb 2018 07:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519830824; cv=none; d=google.com; s=arc-20160816; b=JIAtQvruScn4VrylYAAdoKESKSVaxAnZnEmdHsAnJhPWrQWmRuUCeb+52eLij+Rqru ta63iFjQrDvKsMayqAFM5E8fdocJel8aWnaXsSJb/ByaNLsAC/Az9nZC65oP6eqbhBS8 m4wxjaYgyCWuKcETdMS5HYkCgG+SYC5v+Zrepz6JRahaWnAds35WW9zibJ8nB9Eu588x fnpX7kgbT9HNJT1zAfnKr1vzoy3bUMemLn4NpM/8486mjzAnJo+jAQ/2q3khlH+LhhGJ ERi4nkNOZo4GZNj/hMVLKX2HuWvqi+HwR43ZrZo7uYDtfyaOlmWGd5F1Ti/yOtLMAv4g khfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=mKozk9X4pi3dFdMPl4RHm1NR4uEle2VSh9rKn+MrywM=; b=T6HjqXNr2nMfH2UXoWQN1CbK5TQn3S8pYpAsDo6s8WLfkYhJwYrFvSOxx12ORpKab7 qwU+zPoff+OekFCu942EYcsUUomSRap5Gwx8AhmNv3+jeWYk4BFwGwQ2udv/IsHKMIKO xfNgtm4gFvjgmJCEglPCanPtF6ZZk5HMNTycuigT0YZfI/sRmRaF+MZ6FQzuyLLIQYIs hPVJ6Tx+WMOMgyf9P24X6DOMVrp4mJfh0ty7DWPoB3F+7CUlL1tJ0O70g42LApTKx2GV rXrjpIWCjZpnoUk5gTUiRIuhP4J3B1URn2Y8cncFtTAqxgeaBYqVQ+u0RxfckKsmGwhd X/0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k136si1145306pga.44.2018.02.28.07.13.29; Wed, 28 Feb 2018 07:13:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932538AbeB1PLG (ORCPT + 99 others); Wed, 28 Feb 2018 10:11:06 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53496 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932303AbeB1PIK (ORCPT ); Wed, 28 Feb 2018 10:08:10 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A2D4480125D6; Wed, 28 Feb 2018 15:08:09 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-106.ams2.redhat.com [10.36.116.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED9D69C042; Wed, 28 Feb 2018 15:08:07 +0000 (UTC) From: Hans de Goede To: Darren Hart , Andy Shevchenko , MyungJoo Ham , Chanwoo Choi , Mathias Nyman , Heikki Krogerus , Greg Kroah-Hartman , Guenter Roeck Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Mathias Nyman Subject: [PATCH v5 07/12] xhci: Add option to get next extended capability in list by passing id = 0 Date: Wed, 28 Feb 2018 16:07:44 +0100 Message-Id: <20180228150749.26831-8-hdegoede@redhat.com> In-Reply-To: <20180228150749.26831-1-hdegoede@redhat.com> References: <20180228150749.26831-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 28 Feb 2018 15:08:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 28 Feb 2018 15:08:09 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk 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 Reviewed-by: Heikki Krogerus Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- Changes in v4: -Add Andy's Reviewed-by Changes in v2: -Added Heikki's Reviewed-by --- 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