Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752216AbbKJJgy (ORCPT ); Tue, 10 Nov 2015 04:36:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42511 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551AbbKJJgv (ORCPT ); Tue, 10 Nov 2015 04:36:51 -0500 Date: Tue, 10 Nov 2015 17:36:34 +0800 From: Dave Young To: Lu Baolu Cc: Mathias Nyman , Greg Kroah-Hartman , Alan Stern , linux-usb@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI debug port Message-ID: <20151110093634.GA22332@localhost.localdomain> References: <1447054721-7390-1-git-send-email-baolu.lu@linux.intel.com> <1447054721-7390-2-git-send-email-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447054721-7390-2-git-send-email-baolu.lu@linux.intel.com> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2075 Lines: 75 [snip] > diff --git a/drivers/usb/host/xhci-sysfs.c b/drivers/usb/host/xhci-sysfs.c > new file mode 100644 > index 0000000..0192ac4 > --- /dev/null > +++ b/drivers/usb/host/xhci-sysfs.c > @@ -0,0 +1,100 @@ > +/* > + * sysfs interface for xHCI host controller driver > + * > + * Copyright (C) 2015 Intel Corp. > + * > + * Author: Lu Baolu > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + */ > +#include > + > +#include "xhci.h" > + > +/* > + * Return the register offset of a extended capability specified > + * by @cap_id. Return 0 if @cap_id capability is not supported or > + * in error cases. > + */ > +static int get_extended_capability_offset(struct xhci_hcd *xhci, > + int cap_id) > +{ > + u32 cap_reg; > + unsigned long flags; > + int offset; > + void __iomem *base = (void __iomem *) xhci->cap_regs; > + struct usb_hcd *hcd = xhci_to_hcd(xhci); > + int time_to_leave = XHCI_EXT_MAX_CAPID; > + > + spin_lock_irqsave(&xhci->lock, flags); > + > + offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET); > + if (!HCD_HW_ACCESSIBLE(hcd) || !offset) { > + spin_unlock_irqrestore(&xhci->lock, flags); > + return 0; > + } > + > + while (time_to_leave--) { > + cap_reg = readl(base + offset); > + > + if (XHCI_EXT_CAPS_ID(cap_reg) == cap_id) > + break; > + > + offset = xhci_find_next_cap_offset(base, offset); > + if (!offset) > + break; > + } > + > + spin_unlock_irqrestore(&xhci->lock, flags); I'm not sure spin_lock is good and necessary here, also seems there's already a function to find the cap offset: xhci_find_ext_cap_by_id() in xhci-ext-caps.h > + > + return offset; > +} > + Thanks Dave -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/