public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Young <dyoung@redhat.com>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	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
Date: Tue, 10 Nov 2015 17:36:34 +0800	[thread overview]
Message-ID: <20151110093634.GA22332@localhost.localdomain> (raw)
In-Reply-To: <1447054721-7390-2-git-send-email-baolu.lu@linux.intel.com>

[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 <baolu.lu@linux.intel.com>
> + *
> + * 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 <linux/kernel.h>
> +
> +#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

  reply	other threads:[~2015-11-10  9:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  7:38 [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Lu Baolu
2015-11-09  7:38 ` [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI " Lu Baolu
2015-11-10  9:36   ` Dave Young [this message]
2015-11-11  2:03     ` Lu, Baolu
2015-11-09  7:38 ` [PATCH v3 02/12] x86: fixmap: add permanent fixmap for xhci " Lu Baolu
2015-11-09  7:38 ` [PATCH v3 03/12] usb: xhci: dbc: probe and setup xhci debug capability Lu Baolu
2015-11-09  7:38 ` [PATCH v3 04/12] usb: xhci: dbc: add support for Intel xHCI dbc quirk Lu Baolu
2015-11-09  7:38 ` [PATCH v3 05/12] usb: xhci: dbc: add debug buffer Lu Baolu
2015-11-09  7:38 ` [PATCH v3 06/12] usb: xhci: dbc: add bulk out and bulk in interfaces Lu Baolu
2015-11-09  7:38 ` [PATCH v3 07/12] usb: xhci: dbc: handle dbc-configured exit Lu Baolu
2015-11-09  7:38 ` [PATCH v3 08/12] usb: xhci: dbc: handle endpoint stall Lu Baolu
2015-11-09  7:38 ` [PATCH v3 09/12] x86: early_printk: add USB3 debug port earlyprintk support Lu Baolu
2015-11-09  7:38 ` [PATCH v3 10/12] usb: xhci: dbc: add handshake between debug target and host Lu Baolu
2015-11-09  7:38 ` [PATCH v3 11/12] usb: serial: usb_debug: add support for dbc debug device Lu Baolu
2015-11-09  7:38 ` [PATCH v3 12/12] usb: doc: add document for xHCI DbC driver Lu Baolu
2015-11-10  9:39 ` [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port Dave Young
2015-11-11  1:32   ` Lu, Baolu
2015-11-11  2:25     ` Dave Young
2015-11-11  2:42       ` Lu, Baolu
2015-11-11  5:57       ` Lu, Baolu
2015-11-12  2:45       ` Lu, Baolu
2015-11-12  6:01         ` Dave Young
2015-11-13  2:04           ` Lu, Baolu
2015-11-13  2:26             ` Dave Young
2015-11-13  6:23               ` Lu Baolu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151110093634.GA22332@localhost.localdomain \
    --to=dyoung@redhat.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox