Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752207AbbKKCE3 (ORCPT ); Tue, 10 Nov 2015 21:04:29 -0500 Received: from mga14.intel.com ([192.55.52.115]:51022 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752130AbbKKCE1 (ORCPT ); Tue, 10 Nov 2015 21:04:27 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,273,1444719600"; d="scan'208";a="848104651" Subject: Re: [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI debug port To: Dave Young References: <1447054721-7390-1-git-send-email-baolu.lu@linux.intel.com> <1447054721-7390-2-git-send-email-baolu.lu@linux.intel.com> <20151110093634.GA22332@localhost.localdomain> Cc: Mathias Nyman , Greg Kroah-Hartman , Alan Stern , linux-usb@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org From: "Lu, Baolu" Message-ID: <5642A20F.9020407@linux.intel.com> Date: Wed, 11 Nov 2015 10:03:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151110093634.GA22332@localhost.localdomain> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2291 Lines: 86 On 11/10/2015 05:36 PM, Dave Young wrote: > [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 The lock is unnecessary here. I will remove it. > a function to find the cap offset: > xhci_find_ext_cap_by_id() in xhci-ext-caps.h Yes, I will refactor the code. Thanks, Baolu > >> + >> + 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/