lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151110093634.GA22332@localhost.localdomain>
Date:	Tue, 10 Nov 2015 17:36:34 +0800
From:	Dave Young <dyoung@...hat.com>
To:	Lu Baolu <baolu.lu@...ux.intel.com>
Cc:	Mathias Nyman <mathias.nyman@...el.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Alan Stern <stern@...land.harvard.edu>,
	linux-usb@...r.kernel.org, x86@...nel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 01/12] usb: xhci: add sysfs file for xHCI debug port

[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@...ux.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ