History log of /drivers/usb/core/usb.c
Revision Date Author Comments
98d9a82e5f753a2483d7b4638802d60e94e5d2e4 11-Jan-2012 Oliver Neukum <oliver@neukum.org> USB: cleanup the handling of the PM complete call

This eliminates the last instance of a function's behavior
controlled by a parameter as Linus hates such things.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
90ab5ee94171b3e28de6bb42ee30b527014e0be7 13-Jan-2012 Rusty Russell <rusty@rustcorp.com.au> module_param: make bool parameters really bool (drivers & misc)

module_param(bool) used to counter-intuitively take an int. In
fddd5201 (mid-2009) we allowed bool or int/unsigned int using a messy
trick.

It's time to remove the int/unsigned int option. For this version
it'll simply give a warning, but it'll break next kernel version.

Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2c9ede55ecec58099b72e4bb8eab719f32f72c31 24-Jul-2011 Al Viro <viro@zeniv.linux.org.uk> switch device_get_devnode() and ->devnode() to umode_t *

both callers of device_get_devnode() are only interested in lower 16bits
and nobody tries to return anything wider than 16bit anyway.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
3148bf041d169a083aa31bd69bedd5bfb7ffe215 23-Sep-2011 Andiry Xu <andiry.xu@amd.com> usbcore: get BOS descriptor set

This commit gets BOS(Binary Device Object Store) descriptor set for Super
Speed devices and High Speed devices which support BOS descriptor.

BOS descriptor is used to report additional USB device-level capabilities
that are not reported via the Device descriptor. By getting BOS descriptor
set, driver can check device's device-level capability such as LPM
capability.

Signed-off-by: Andiry Xu <andiry.xu@amd.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
643de6240b0b59c420ad71dfeeb3125a3607af92 14-Apr-2011 Michal Nazarewicz <mina86@mina86.com> usb: core: Change usb_create_sysfs_intf_files()' return type to void

The usb_create_sysfs_intf_files() function always returned zero even
if it failed to create sysfs fails. Since this is a desired behaviour
there is no need to return return code at all. This commit changes
function's return type (form int) to void.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e1620d591a75a10b15cf61dbf8243a0b7e6731a2 18-Mar-2011 Rafael J. Wysocki <rjw@sisk.pl> USB: Move runtime PM callbacks to usb_device_pm_ops

USB defines usb_device_type pointing to usb_device_pm_ops that
provides system-wide PM callbacks only and usb_bus_type pointing to
usb_bus_pm_ops that provides runtime PM callbacks only. However,
the USB runtime PM callbacks may be defined in usb_device_pm_ops
which makes it possible to drop usb_bus_pm_ops and will allow us
to consolidate the handling of subsystems by the PM core code.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
fcc4a01eb8661226e80632327673f67bf6a5840b 15-Nov-2010 Alan Stern <stern@rowland.harvard.edu> USB: use the runtime-PM autosuspend implementation

This patch (as1428) converts USB over to the new runtime-PM core
autosuspend framework. One slightly awkward aspect of the conversion
is that USB devices will now have two suspend-delay attributes: the
old power/autosuspend file and the new power/autosuspend_delay_ms
file. One expresses the delay time in seconds and the other in
milliseconds, but otherwise they do the same thing. The old attribute
can be deprecated and then removed eventually.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b409214c683ed06c26e2cdad0be546ad11463354 05-Aug-2010 Alan Stern <stern@rowland.harvard.edu> USB: remove fake "address-of" expressions

Fake "address-of" expressions that evaluate to NULL generally confuse
readers and can provoke compiler warnings. This patch (as1412)
removes three such fake expressions, using "#ifdef"s in their place.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3142788b7967ccfd2f1813ee9e11aeb1e1cf7de2 29-Jan-2010 Thomas Gleixner <tglx@linutronix.de> drivers/base: Convert dev->sem to mutex

The semaphore is semantically a mutex. Convert it to a real mutex and
fix up a few places where code was relying on semaphore.h to be included
by device.h, as well as the users of the trylock function, as that value
is now reversed.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
c024b7260c8f879a2ef3a3e6a853b579a46479f8 17-May-2010 Ming Lei <tom.leiming@gmail.com> USB: remove match_device

usb_find_device was the only one user of match_device, now
it is removed, so remove match_device to fix the compile warning
below reported by Stephen Rothwell:

drivers/usb/core/usb.c:596: warning: 'match_device'
defined but not used

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
22b4b6113ec5d0ff2a9175bc611f3f3f61e4e172 12-May-2010 Ming Lei <tom.leiming@gmail.com> USB: remove usb_find_device

Now on one uses this function and it seems useless,
so remove usb_find_device.

[tom@tom linux-2.6-next]$ grep -r -n -I usb_find_device ./
drivers/media/dvb/dvb-usb/dvb-usb-init.c:160:static struct
dvb_usb_device_description * dvb_usb_find_device(struct usb_device
*udev,struct dvb_usb_device_properties *props, int *cold)

drivers/media/dvb/dvb-usb/dvb-usb-init.c:230: if ((desc =
dvb_usb_find_device(udev,props,&cold)) == NULL) {

drivers/usb/core/usb.c:630: * usb_find_device - find a specific usb device in the system
drivers/usb/core/usb.c:642:struct usb_device *usb_find_device(u16 vendor_id, u16 product_id)

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ff9c895f07d36193c75533bda8193bde8ca99d02 02-Apr-2010 Alan Stern <stern@rowland.harvard.edu> USB: fix usbmon and DMA mapping for scatter-gather URBs

This patch (as1368) fixes a rather obscure bug in usbmon: When tracing
URBs sent by the scatter-gather library, it accesses the data buffers
while they are still mapped for DMA.

The solution is to move the mapping and unmapping out of the s-g
library and into the usual place in hcd.c. This requires the addition
of new URB flag bits to describe the kind of mapping needed, since we
have to call dma_map_sg() if the HCD supports native scatter-gather
operation and dma_map_page() if it doesn't. The nice thing about
having the new flags is that they simplify the testing for unmapping.

The patch removes the only caller of usb_buffer_[un]map_sg(), so those
functions are #if'ed out. A later patch will remove them entirely.

As a result of this change, urb->sg will be set in situations where
it wasn't set previously. Hence the xhci and whci drivers are
adjusted to test urb->num_sgs instead, which retains its original
meaning and is nonzero only when the HCD has to handle a scatterlist.

Finally, even when a submission error occurs we don't want to hand
URBs to usbmon before they are unmapped. The submission path is
rearranged so that map_urb_for_dma() is called only for non-root-hub
URBs and unmap_urb_for_dma() is called immediately after a submission
error. This simplifies the error handling.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0ede76fcec5415ef82a423a95120286895822e2d 05-Mar-2010 Alan Stern <stern@rowland.harvard.edu> USB: remove uses of URB_NO_SETUP_DMA_MAP

This patch (as1350) removes all usages of coherent buffers for USB
control-request setup-packet buffers. There's no good reason to
reserve coherent memory for these things; control requests are hardly
ever used in large quantity (the major exception is firmware
transfers, and they aren't time-critical). Furthermore, only seven
drivers used it. We might as well always use streaming DMA mappings
for setup-packet buffers, and remove some extra complexity from
usbcore.

The DMA-mapping portion of hcd.c is currently in flux. A separate
patch will be submitted to remove support for URB_NO_SETUP_DMA_MAP
after everything else settles down. The removal should go smoothly,
as by then nobody will be using it.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
27729aadd31dafddaaf64c24f8ef6d0ff750f3aa 24-Apr-2010 Eric Lescouet <Eric.Lescouet@virtuallogix.com> USB: make hcd.h public (drivers dependency)

The usbcore headers: hcd.h and hub.h are shared between usbcore,
HCDs and a couple of other drivers (e.g. USBIP modules).
So, it makes sense to move them into a more public location and
to cleanup dependency of those modules on kernel internal headers.
This patch moves hcd.h from drivers/usb/core into include/linux/usb/

Signed-of-by: Eric Lescouet <eric@lescouet.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
073900a28d95c75a706bf40ebf092ea048c7b236 12-Apr-2010 Daniel Mack <daniel@caiaq.de> USB: rename usb_buffer_alloc() and usb_buffer_free()

For more clearance what the functions actually do,

usb_buffer_alloc() is renamed to usb_alloc_coherent()
usb_buffer_free() is renamed to usb_free_coherent()

They should only be used in code which really needs DMA coherency.

[added compatibility macros so we can convert things easier - gregkh]

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Pedro Ribeiro <pedrib@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f7410ced7f931bb1ad79d1336412cf7b7a33cb14 10-Jan-2010 Herbert Xu <herbert@gondor.apana.org.au> USB: Move hcd free_dev call into usb_disconnect to fix oops

USB: Move hcd free_dev call into usb_disconnect

I found a way to oops the kernel:

1. Open a USB device through devio.
2. Remove the hcd module in the host kernel.
3. Close the devio file descriptor.

The problem is that closing the file descriptor does usb_release_dev
as it is the last reference. usb_release_dev then tries to invoke
the hcd free_dev function (or rather dereferencing the hcd driver
struct). This causes an oops as the hcd driver has already been
unloaded so the struct is gone.

This patch tries to fix this by bringing the free_dev call earlier
and into usb_disconnect. I have verified that repeating the
above steps no longer crashes with this patch applied.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
9bbdf1e0afe771ca7650f9f476769310bee9d8f3 08-Jan-2010 Alan Stern <stern@rowland.harvard.edu> USB: convert to the runtime PM framework

This patch (as1329) converts the USB stack over to the PM core's
runtime PM framework. This involves numerous changes throughout
usbcore, especially to hub.c and driver.c. Perhaps the most notable
change is that CONFIG_USB_SUSPEND now depends on CONFIG_PM_RUNTIME
instead of CONFIG_PM.

Several fields in the usb_device and usb_interface structures are no
longer needed. Some code which used to depend on CONFIG_USB_PM now
depends on CONFIG_USB_SUSPEND (requiring some rearrangement of header
files).

The only visible change in behavior should be that following a system
sleep (resume from RAM or resume from hibernation), autosuspended USB
devices will be resumed just like everything else. They won't remain
suspended. But if they aren't in use then they will naturally
autosuspend again in a few seconds.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
70445ae6c669865e464307a155e881096e4a0ae7 13-Dec-2009 Randy Dunlap <randy.dunlap@oracle.com> USB core: fix recent kernel-doc warnings

Fix new kernel-doc warnings in usb core:

Warning(drivers/usb/core/usb.c:79): No description found for parameter 'config'
Warning(drivers/usb/core/usb.c:79): No description found for parameter 'iface_num'
Warning(drivers/usb/core/usb.c:79): No description found for parameter 'alt_num'
Warning(drivers/usb/core/hcd.c:1622): No description found for parameter 'udev'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
471452104b8520337ae2fb48c4e61cd4896e025d 15-Dec-2009 Alexey Dobriyan <adobriyan@gmail.com> const: constify remaining dev_pm_ops

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
c2d284ee04ab6f6718de2ddcf1b43160e046c41d 15-Dec-2009 Russ Dill <Russ.Dill@gmail.com> USB: Close usb_find_interface race v3

USB drivers that create character devices call usb_register_dev in their
probe function. This associates the usb_interface device with that minor
number and creates the character device and announces it to the world.
However, the driver's probe function is called before the new
usb_interface is added to the driver's klist_devices.

This is a problem because userspace will respond to the character device
creation announcement by opening the character device. The driver's open
function will the call usb_find_interface to find the usb_interface
associated with that minor number. usb_find_interface will walk the
driver's list of devices and find the usb_interface with the matching
minor number.

Because the announcement happens before the usb_interface is added to the
driver's klist_devices, a race condition exists. A straightforward fix
is to walk the list of devices on usb_bus_type instead since the device
is added to that list before the announcement occurs.

bus_find_device calls get_device to bump the reference count on the found
device. It is arguable that the reference count should be dropped by the
caller of usb_find_interface instead of usb_find_interface, however,
the current users of usb_find_interface do not expect this.

The original version of this patch only matched against minor number
instead of driver and minor number. This version matches against both.

Signed-off-by: Russ Dill <Russ.Dill@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ab7cd8c76cb47f1bda0ad964d309b4efce81b5e9 15-Dec-2009 Greg Kroah-Hartman <gregkh@suse.de> Revert "USB: Close usb_find_interface race"

This reverts commit a2582bd478c13c574d4c16ef1209d333f2a25935.

It turned out to be buggy and broke USB printers from working.

Cc: Russ Dill <Russ.Dill@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
719a6e8876ee860fcb0c90d4123bff1e3df26dfd 04-Dec-2009 Felipe Balbi <felipe.balbi@nokia.com> USB: core: fix sparse warning for static function

Fix the following sparse warning:

drivers/usb/core/usb.c:1033:15: warning: symbol 'usb_debug_devices' was not declared. Should it be static?

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
91017f9cf5fcfb601b8d583c896ac7de7d200c57 03-Dec-2009 Sarah Sharp <sarah.a.sharp@linux.intel.com> USB: Refactor code to find alternate interface settings.

Refactor out the code to find alternate interface settings into
usb_find_alt_setting(). Print a debugging message and return null if the
alt setting is not found.

While we're at it, correct a bug in the refactored code. The interfaces
in the configuration's interface cache are not necessarily in numerical
order, so we can't just use the interface number as an array index. Loop
through the interface caches, looking for the correct interface.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
a2582bd478c13c574d4c16ef1209d333f2a25935 18-Nov-2009 Russ Dill <russ.dill@gmail.com> USB: Close usb_find_interface race

USB drivers that create character devices call usb_register_dev in their
probe function. This associates the usb_interface device with that minor
number and creates the character device and announces it to the world.
However, the driver's probe function is called before the new
usb_interface is added to the driver's klist_devices.

This is a problem because userspace will respond to the character device
creation announcement by opening the character device. The driver's open
function will the call usb_find_interface to find the usb_interface
associated with that minor number. usb_find_interface will walk the
driver's list of devices and find the usb_interface with the matching
minor number.

Because the announcement happens before the usb_interface is added to the
driver's klist_devices, a race condition exists. A straightforward fix
is to walk the list of devices on usb_bus_type instead since the device
is added to that list before the announcement occurs.

bus_find_device calls get_device to bump the reference count on the found
device. It is arguable that the reference count should be dropped by the
caller of usb_find_interface instead of usb_find_interface, however,
the current users of usb_find_interface do not expect this.

Signed-off-by: Russ Dill <Russ.Dill@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
4a0cd9670f22c308bc5936ee9734d8ee3f1baa52 04-Sep-2009 Sarah Sharp <sarah.a.sharp@linux.intel.com> USB: xhci: Set route string for all devices.

The xHCI driver needs to set the route string in the slot context of all
devices, not just SuperSpeed devices. The route string concept was added
in the USB 3.0 specification, section 10.1.3.2. Each hub in the topology
is expected to have no more than 15 ports in order for the route string of
a device to be unique. SuperSpeed hubs are restricted to only having 15
ports, but FS/LS/HS hubs are not. The xHCI specification says that if the
port number the device is under is greater than 15, that portion of the
route string shall be set to 15.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2912282c06f219cf1634a624653c445329b37acf 22-Aug-2009 Jiri Slaby <jirislaby@gmail.com> USB: make usb_buffer_map_sg consistent with doc

usb_buffer_map_sg should return negative on error according to
its documentation. But dma_map_sg returns 0 on error. Take this
into account and return -ENOMEM in such situation.

While at it, return -EINVAL instead of -1 when wrong input is
passed in.

If this wasn't done, usb_sg_* operations used after usb_sg_init
which returned 0 may cause oopses/deadlocks since we don't init
structures/entries, esp. completion and status entry.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e454cea20bdcff10ee698d11b8882662a0153a47 18-Sep-2009 Kay Sievers <kay.sievers@vrfy.org> Driver-Core: extend devnode callbacks to provide permissions

This allows subsytems to provide devtmpfs with non-default permissions
for the device node. Instead of the default mode of 0600, null, zero,
random, urandom, full, tty, ptmx now have a mode of 0666, which allows
non-privileged processes to access standard device nodes in case no
other userspace process applies the expected permissions.

This also fixes a wrong assignment in pktcdvd and a checkpatch.pl complain.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
c6515272b858742962c1de0f3bf497a048b9abd7 28-Apr-2009 Sarah Sharp <sarah.a.sharp@linux.intel.com> USB: Support for addressing a USB device under xHCI

Add host controller driver API and a slot_id variable to struct
usb_device. This allows the xHCI host controller driver to ask the
hardware to allocate a slot for the device when a struct usb_device is
allocated. The slot needs to be allocated at that point because the
hardware can run out of internal resources, and we want to know that very
early in the device connection process. Don't call this new API for root
hubs, since they aren't real devices.

Add HCD API to let the host controller choose the device address. This is
especially important for xHCI hardware running in a virtualized
environment. The guests running under the VM don't need to know which
addresses on the bus are taken, because the hardware picks the address for
them. Announce SuperSpeed USB devices after the address has been assigned
by the hardware.

Don't use the new get descriptor/set address scheme with xHCI. Unless
special handling is done in the host controller driver, the xHC can't
issue control transfers before you set the device address. Support for
the older addressing scheme will be added when the xHCI driver supports
the Block Set Address Request (BSR) flag in the Address Device command.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7206b00164a1c3ca533e01db285955617e1019f8 28-Apr-2009 Sarah Sharp <sarah.a.sharp@linux.intel.com> USB: Add route string to struct usb_device.

This patch adds a hex route string to each USB device. The route string is used
by the USB 3.0 host controller to send packets through the device tree. USB 3.0
hubs use this string to route packets to the correct port. This is fundamental
bus change from USB 2.0, where all packets were broadcast across the bus.

Devices (including hubs) under a root port receive the route string 0x0. Every
four bits in the route string represent a port on a hub. This length works
because USB 3.0 hubs are limited to 15 ports, and USB 2.0 hubs (with potentially
more ports) will never see packets with a route string. A port number of 0
means the packet is destined for that hub.

For example, a peripheral device might have a route string of 0x00097.
This means the device is connected to port 9 of the hub at depth 1.
The hub at depth 1 is connected to port 7 of a hub at depth 0.
The hub at depth 0 is connected to a root port.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
9b8e7ba68ad0e4273f4897950de65bc311552cd1 28-May-2009 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> USB: replace dma_sync_single and dma_sync_sg with dma_sync_single_for_cpu and dma_sync_sg_for_cpu

This replaces dma_sync_single() and dma_sync_sg() with
dma_sync_single_for_cpu() and dma_sync_sg_for_cpu() respectively
because they is an obsolete API; include/linux/dma-mapping.h says:

/* Backwards compat, remove in 2.7.x */
#define dma_sync_single dma_sync_single_for_cpu
#define dma_sync_sg dma_sync_sg_for_cpu

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5512966643adb17483efc5f61481a38fc33088bb 04-May-2009 Kay Sievers <kay.sievers@vrfy.org> usb: convert endpoint devices to bus-less childs of the usb interface

The endpoint devices look like simple attribute groups now, and no longer
like devices with a specific subsystem. They will also no longer emit uevents.

It also removes the device node requests for endpoint devices, which are not
implemented for now.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
820d7a253c5e59a786d5b608f6e8d0419fdc2f6e 27-Apr-2009 Greg Kroah-Hartman <gregkh@suse.de> USB: remove unused usb_host class

The usb_host class isn't used for anything anymore (it was used for
debug files, but they have moved to debugfs a few kernel releases ago),
so let's delete it before someone accidentally puts a file in it.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
97d7b7a41bd462abceee7dbb2b3afacfd52438ed 25-Apr-2009 Greg Kroah-Hartman <gregkh@suse.de> USB: add the usbfs devices file to debugfs

People are very used to the devices file in usbfs. Now that we have
moved usbfs to be an "embedded" option only, the developers miss the
file, they had grown quite attached to it over all of these years. This
patch brings it back and puts it in the usb debugfs directory, so that
the developers don't feel sad anymore.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
00048b8bde5a6cbd9c3a76f272cc9ddb55705e37 24-Apr-2009 Greg Kroah-Hartman <gregkh@suse.de> USB: add usb debugfs directory

Add a common usb directory in debugfs that the usb subsystem can use.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f7a386c5b8ff34cd84ae922603d1c6f9d234edee 30-Apr-2009 Kay Sievers <kay.sievers@vrfy.org> Driver Core: usb: add nodename support for usb drivers.

This adds support for USB drivers to report their requested nodename to
userspace. It also updates a number of USB drivers to provide the
needed subdirectory and device name to be used for them.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3444b26afa145148951112534f298bdc554ec789 08-Apr-2009 David Vrabel <david.vrabel@csr.com> USB: add reset endpoint operations

Wireless USB endpoint state has a sequence number and a current
window and not just a single toggle bit. So allow HCDs to provide a
endpoint_reset method and call this or clear the software toggles as
required (after a clear halt, set configuration etc.).

usb_settoggle() and friends are then HCD internal and are moved into
core/hcd.h and all device drivers call usb_reset_endpoint() instead.

If the device endpoint state has been reset (with a clear halt) but
the host endpoint state has not then subsequent data transfers will
not complete. The device will only work again after it is reset or
disconnected.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2caf7fcdb8532045680f06b67b9e63f0c9613aaa 31-Dec-2008 Alan Stern <stern@rowland.harvard.edu> USB: re-enable interface after driver unbinds

This patch (as1197) fixes an error introduced recently. Since a
significant number of devices can't handle Set-Interface requests, we
no longer call usb_set_interface() when a driver unbinds from an
interface, provided the interface is already in altsetting 0. However
the interface still does get disabled, and the call to
usb_set_interface() was the only thing re-enabling it. Since the
interface doesn't get re-enabled, further attempts to use it fail.

So the patch adds a call to usb_enable_interface() when a driver
unbinds and the interface is in altsetting 0. For this to work
right, the interface's endpoints have to be re-enabled but their
toggles have to be left alone. Therefore an additional argument is
added to usb_enable_endpoint() and usb_enable_interface(), a flag
indicating whether or not the endpoint toggles should be reset.

This is a forward-ported version of a patch which fixes Bugzilla
#12301.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: David Roka <roka@dawid.hu>
Reported-by: Erik Ekman <erik@kryo.se>
Tested-by: Erik Ekman <erik@kryo.se>
Tested-by: Alon Bar-Lev <alon.barlev@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3b23dd6f8a718e5339de4f7d86ce76a078b5f771 05-Dec-2008 Alan Stern <stern@rowland.harvard.edu> USB: utilize the bus notifiers

This patch (as1185) makes usbcore take advantage of the bus
notifications sent out by the driver core. Now we can create all our
device and interface attribute files before the device or interface
uevent is broadcast.

A side effect is that we no longer create the endpoint "pseudo"
devices at the same time as a device or interface is registered -- it
seems like a bad idea to try registering an endpoint before the
registration of its parent is complete. So the routines for creating
and removing endpoint devices have been split out and renamed, and
they are called explicitly when needed. A new bitflag is used for
keeping track of whether or not the interface's endpoint devices have
been created, since (just as with the interface attributes) they vary
with the altsetting and hence can be changed at random times.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
65bfd2967c906ca322a4bb69a285fe0de8916ac6 25-Nov-2008 Alan Stern <stern@rowland.harvard.edu> USB: Enhance usage of pm_message_t

This patch (as1177) modifies the USB core suspend and resume
routines. The resume functions now will take a pm_message_t argument,
so they will know what sort of resume is occurring. The new argument
is also passed to the port suspend/resume and bus suspend/resume
routines (although they don't use it for anything but debugging).

In addition, special pm_message_t values are used for user-initiated,
device-initiated (i.e., remote wakeup), and automatic suspend/resume.
By testing these values, drivers can tell whether or not a particular
suspend was an autosuspend. Unfortunately, they can't do the same for
resumes -- not until the pm_message_t argument is also passed to the
drivers' resume methods. That will require a bigger change.

IMO, the whole Power Management framework should have been set up this
way in the first place.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
785895ff1fedddd09576d2c600d90404fef6506c 22-Nov-2008 Rusty Russell <rusty@rustcorp.com.au> USB: Don't use __module_param_call; use core_param.

Impact: cleanup

Found this when I changed args to __module_param_call. We now have
core_param for exactly this, but Greg assures me "nousb" is used as a
module parameter, so we need the #ifdef MODULE.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
9ac39f28b5237a629e41ccfc1f73d3a55723045c 12-Nov-2008 Alan Stern <stern@rowland.harvard.edu> USB: add asynchronous autosuspend/autoresume support

This patch (as1160b) adds support routines for asynchronous autosuspend
and autoresume, with accompanying documentation updates. There
already are several potential users of this interface, and others are
likely to arise as autosuspend support becomes more widespread.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
011b15df465745474e3ec85482633685933ed5a7 04-Nov-2008 Alan Stern <stern@rowland.harvard.edu> USB: change interface to usb_lock_device_for_reset()

This patch (as1161) changes the interface to
usb_lock_device_for_reset(). The existing interface is apparently not
very clear, judging from the fact that several of its callers don't
use it correctly. The new interface always returns 0 for success and
it always requires the caller to unlock the device afterward.

The new routine will not return immediately if it is called while the
driver's probe method is running. Instead it will wait until the
probe is over and the device has been unlocked. This shouldn't cause
any problems; I don't know of any cases where drivers call
usb_lock_device_for_reset() during probe.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
adf094931ffb25ef4b381559918f1a34181a5273 06-Oct-2008 Rafael J. Wysocki <rjw@sisk.pl> PM: Simplify the new suspend/hibernation framework for devices

PM: Simplify the new suspend/hibernation framework for devices

Following the discussion at the Kernel Summit, simplify the new
device PM framework by merging 'struct pm_ops' and
'struct pm_ext_ops' and removing pointers to 'struct pm_ext_ops'
from 'struct platform_driver' and 'struct pci_driver'.

After this change, the suspend/hibernation callbacks will only
reside in 'struct device_driver' as well as at the bus type/
device class/device type level. Accordingly, PCI and platform
device drivers are now expected to put their suspend/hibernation
callbacks into the 'struct device_driver' embedded in
'struct pci_driver' or 'struct platform_driver', respectively.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@suse.cz>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f2189c477c986db47ac7f9cc32d05f6df18bfe9e 12-Aug-2008 Alan Stern <stern@rowland.harvard.edu> USB: Add new PM callback methods for USB

This patch (as1129) adds support for the new PM callbacks to usbcore.
The new callbacks merely invoke the same old USB power management
routines as the old ones did.

A minor improvement is that the callbacks are present only in the
"USB-device" device_type structure, rather than in the bus_type
structure. This way they will be invoked only for USB devices, not
for USB interfaces. The core USB PM routines automatically handle
suspending and resuming interfaces along with their devices.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0031a06e2f07ab0d1bc98c31dbb6801f95f4bf01 02-May-2008 Kay Sievers <kay.sievers@vrfy.org> USB: usb dev_set_name() instead of dev->bus_id

The bus_id field is going away, use the dev_set_name() function
to set it properly.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7071a3ce0ca058ad2a9e3e8c33f30fb0bce62005 02-May-2008 Kay Sievers <kay.sievers@vrfy.org> USB: usb dev_name() instead of dev->bus_id

The bus_id field is going away, use the dev_name() function instead.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2e5f10e4f0a9649186d8a8c793822b2e0dae8373 30-Apr-2008 Alan Stern <stern@rowland.harvard.edu> USB: create attributes before sending uevent

This patch (as1087d) fixes a long-standing problem in usbcore: Device,
interface, and endpoint attributes aren't added until _after_ the
creation uevent has already been broadcast.

Unfortunately there are a few attributes which cannot be created that
early. The "descriptors" attribute is binary and so must be created
separately. The power-management attributes can't be created until
the dev/power/ group exists. And the interface string can vary from
one altsetting to another, so it has to be created dynamically.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7a8d37a37380e2b1500592d40b7ec384dbebe7a0 25-Feb-2008 Rafael J. Wysocki <rjw@sisk.pl> PM: Do not acquire device semaphores upfront during suspend

Remove the code that acquires all device semaphores from the suspend
code path as it causes multiple problems to appear (most notably,
http://bugzilla.kernel.org/show_bug.cgi?id=10030) and revert the
change introduced by commit 4145ed6dc597a9bea5f6ae8c574653b2de10620f
depending on the code being removed.

Remove pm_sleep_lock()/pm_sleep_unlock() from device_add() to avoid
the issue reported at http://bugzilla.kernel.org/show_bug.cgi?id=9874.

It should fix the regreesions reported at:
http://bugzilla.kernel.org/show_bug.cgi?id=9874
http://bugzilla.kernel.org/show_bug.cgi?id=10030

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d0bcabcd72dda5f553322a1ca92ae31c15b408b6 01-Mar-2008 Randy Dunlap <randy.dunlap@oracle.com> docbook: fix usb source files

Fix docbook problems in USB source files.
These cause the generated docbook to be incorrect.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2c044a4803804708984931bcbd03314732e995d5 31-Jan-2008 Greg Kroah-Hartman <gregkh@suse.de> USB: fix codingstyle issues in drivers/usb/core/*.c

Fixes a number of coding style issues in the remaining .c files in
drivers/usb/core/

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
782e70c6fc2290a0395850e8e02583b8b62264d8 25-Jan-2008 Greg Kroah-Hartman <gregkh@suse.de> USB: mark USB drivers as being GPL only

Over two years ago, the Linux USB developers stated that they believed
there was no way to create a USB kernel driver that was not under the
GPL. This patch moves the USB apis to enforce that decision.

There are no known closed source USB drivers in the wild, so this patch
should cause no problems.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1512300689426cb98bfd7e567ee9fdfaaf61b7c7 22-Dec-2007 Sarah Sharp <saharabeara@gmail.com> USB: Export suspend statistics

This patch exports two statistics to userspace:
/sys/bus/usb/device/.../power/connected_duration
/sys/bus/usb/device/.../power/active_duration

connected_duration is the total time (in msec) that the device has
been connected. active_duration is the total time the device has not
been suspended. With these two statistics, tools like PowerTOP can
calculate the percentage time that a device is active, i.e. not
suspended or auto-suspended.

Users can also use the active_duration to check if a device is actually
autosuspended. Currently, they can set power/level to auto and
power/autosuspend to a positive timeout, but there's no way to know from
userspace if a device was actually autosuspended without looking at the
dmesg output. These statistics will be useful in creating an automated
userspace script to test autosuspend for USB devices.

Signed-off-by: Sarah Sharp <sarah.a.sharp@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
4145ed6dc597a9bea5f6ae8c574653b2de10620f 19-Nov-2007 Alan Stern <stern@rowland.harvard.edu> USB: make ksuspend_usbd thread non-freezable

This patch (as1012b) makes the ksuspend_usbd kernel thread
non-freezable. Since the PM core has been changed to lock all devices
during a system sleep, the thread no longer needs to be frozen. It
won't interfere with a system sleep because before trying to resume a
root hub device, it acquires the device's lock.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
4a9bee8256a2dec26290a3bfff86ab86b8992547 06-Nov-2007 Alan Stern <stern@rowland.harvard.edu> USB: uevent environment key fix

This patch (as1010) was written by both Kay Sievers and me. It solves
the problem of duplicated keys in USB uevent structures by refactoring
the uevent subroutines, taking advantage of the way the hotplug core
calls uevent handlers for the device's bus and for the device's type.
Keys needed for both USB-device and USB-interface events are added in
usb_uevent(), which is the bus handler. Keys appropriate only for
USB-device or USB-interface events are added in usb_dev_uevent() or
usb_if_uevent() respectively, the type handlers.

In addition, unnecessary tests for NULL pointers are removed as are
duplicated debugging log statements.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
87ae9afdcada236d0a1b38ce2c465a65916961dc 30-Oct-2007 Adrian Bunk <bunk@kernel.org> cleanup asm/scatterlist.h includes

Not architecture specific code should not #include <asm/scatterlist.h>.

This patch therefore either replaces them with
#include <linux/scatterlist.h> or simply removes them if they were
unused.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
cbfee34520666862f8ff539e580c48958fbb7706 17-Oct-2007 Adrian Bunk <bunk@kernel.org> security/ cleanups

This patch contains the following cleanups that are now possible:
- remove the unused security_operations->inode_xattr_getsuffix
- remove the no longer used security_operations->unregister_security
- remove some no longer required exit code
- remove a bunch of no longer used exports

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Acked-by: James Morris <jmorris@namei.org>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4d59d8a11383ebf0e0260ee481a4e766959fd7d9 03-Oct-2007 Sarah Sharp <sarah.a.sharp@intel.com> USB: Export URB statistics for powertop

powertop currently tracks interrupts generated by uhci, ehci, and ohci,
but it has no way of telling which USB device to blame USB bus activity on.
This patch exports the number of URBs that are submitted for a given device.
Cat the file 'urbnum' in /sys/bus/usb/devices/.../

Signed-off-by: Sarah Sharp <sarah.a.sharp@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6840d2555afd66290be7a39b400b5e66a840b82d 10-Sep-2007 Alan Stern <stern@rowland.harvard.edu> USB: flush outstanding URBs when suspending

This patch (as989) makes usbcore flush all outstanding URBs for each
device as the device is suspended. This will be true even when
CONFIG_USB_SUSPEND is not enabled.

In addition, an extra can_submit flag is added to the usb_device
structure. That flag will be turned off whenever a suspend request
has been received for the device, even if the device isn't actually
suspended because CONFIG_USB_SUSPEND isn't set.

It's no longer necessary to check for the device state being equal to
USB_STATE_SUSPENDED during URB submission; that check can be replaced
by a check of the can_submit flag. This also permits us to remove
some questionable references to the deprecated power.power_state field.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d7d07255d3f5607802b0af29e11448d18e9ed558 01-Aug-2007 Inaky Perez-Gonzalez <inaky@linux.intel.com> usb: initialize authorization and wusb bits in USB devices

Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5e60a16139c2a48b9876b0ff910671eee5fb32ec 30-Jul-2007 Alan Stern <stern@rowland.harvard.edu> USB: avoid using urb->pipe in usbcore

This patch (as946) eliminates many of the uses of urb->pipe in
usbcore. Unfortunately there will have to be a significant API
change, affecting all USB drivers, before we can remove it entirely.
This patch contents itself with changing only the interface to
usb_buffer_map_sg() and friends: The pipe argument is replaced with a
direction flag. That can be done easily because those routines get
used in only one place.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
bdd016ba64d909329cb4bacacc8443901c00e112 30-Jul-2007 Alan Stern <stern@rowland.harvard.edu> USB: add ep->enable

This patch (as944) adds an explicit "enabled" field to the
usb_host_endpoint structure and uses it in place of the current
mechanism. This is merely a time-space tradeoff; it makes checking
whether URBs may be submitted to an endpoint simpler. The existing
mechanism is efficient when converting urb->pipe to an endpoint
pointer, but it's not so efficient when urb->ep is used instead.

As a side effect, the procedure for enabling an endpoint is now a
little more complicated. The ad-hoc inline code in usb.c and hub.c
for enabling ep0 is now replaced with calls to usb_enable_endpoint,
which is no longer static.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fbf54dd32001359ccda6a9d8577f7b00e67357c7 02-Jul-2007 David Brownell <david-b@pacbell.net> USB: usb/dma doc updates

This patch updates some of the documentation about DMA buffer management
for USB, and ways to avoid extra copying. Our understanding of the issues
has improved over time.

- Most drivers should *avoid* the dma-coherent allocators. There are
a few exceptions (like the HID driver).

- Some methods are currently commented out; it seems folk writing
USB drivers aren't doing performance tuning at that level yet.

- Just avoid highmem; there's no good way to pass an "I can do highmem
DMA" capability through a driver stack. This is easy, everything
already avoids highmem. But it'd be nice if x86_32 systems with much
physical memory could use it directly with network adapters and mass
storage devices. (Patch, anyone?)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
70f458f668aa09cc45384728dec434f2975a3947 09-Jul-2007 Yinghai Lu <Yinghai.Lu@Sun.COM> USB: make the usb_device numa_node get assigned from controller

So we can use dev_to_node(&usb_dev->dev) later in kmalloc_node to dma buffer

Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Cc: Andi Kleen <ak@suse.de>
Acked-by: Christoph Lameter <clameter@sgi.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d5d4db704b962773c03ee3beb3258b6450611e66 29-May-2007 Alan Stern <stern@rowland.harvard.edu> USB: replace flush_workqueue with cancel_sync_work

This patch (as912) replaces a couple of calls to flush_workqueue()
with cancel_sync_work() and cancel_rearming_delayed_work(). Using a
more directed approach allows us to avoid some nasty deadlocks. The
prime example occurs when a first-level device (the parent is a root
hub) is removed while at the same time the root hub gets a remote
wakeup request. khubd would try to flush the autosuspend workqueue
while holding the root-hub's lock, and the remote-wakeup workqueue
routine would be waiting to lock the root hub.

The patch also reorganizes the power management portion of
usb_disconnect(), separating it out into its own routine. The
autosuspend workqueue entry is cancelled immediately instead of
waiting for the device's release routine. In addition,
synchronization with the autosuspend thread is carried out even for
root hubs (an oversight in the original code).

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg KH <gregkh@suse.de>
Cc: Mark Lord <lkml@rtr.ca>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7ed92f1a149dddc3cb537ccd7441e98adac12c3e 22-May-2007 Alan Stern <stern@rowland.harvard.edu> USB: make the autosuspend workqueue thread freezable

This patch (as881b) makes the ksuspend_usb_wq workqueue freezable. We
don't want a rogue workqueue thread running around, unexpectedly
suspending or resuming USB devices in the middle of a system sleep
transition.

This fixes Bugzilla #8498.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e63340ae6b6205fef26b40a75673d1c9c0c8bb90 08-May-2007 Randy Dunlap <randy.dunlap@oracle.com> header cleaning: don't include smp_lock.h when not used

Remove includes of <linux/smp_lock.h> where it is not used/needed.
Suggested by Al Viro.

Builds cleanly on x86_64, i386, alpha, ia64, powerpc, sparc,
sparc64, and arm (all 59 defconfigs).

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9f8b17e643fe6aa505629658445849397bda4e4f 13-Mar-2007 Kay Sievers <kay.sievers@vrfy.org> USB: make usbdevices export their device nodes instead of using a separate class

o The "real" usb-devices export now a device node which can
populate /dev/bus/usb.

o The usb_device class is optional now and can be disabled in the
kernel config. Major/minor of the "real" devices and class devices
are the same.

o The environment of the usb-device event contains DEVNUM and BUSNUM to
help udev and get rid of the ugly udev rule we need for the class
devices.

o The usb-devices and usb-interfaces share the same bus, so I used
the new "struct device_type" to let these devices identify
themselves. This also removes the current logic of using a magic
platform-pointer.
The name of the device_type is also added to the environment
which makes it easier to distinguish the different kinds of devices
on the same subsystem.

It looks like this:
add@/devices/pci0000:00/0000:00:1d.1/usb2/2-1
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb2/2-1
SUBSYSTEM=usb
SEQNUM=1533
MAJOR=189
MINOR=131
DEVTYPE=usb_device
PRODUCT=46d/c03e/2000
TYPE=0/0/0
BUSNUM=002
DEVNUM=004

This udev rule works as a replacement for usb_device class devices:
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", \
NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644"

Updated patch, which needs the device_type patches in Greg's tree.

I also got a bugzilla assigned for this. :)
https://bugzilla.novell.com/show_bug.cgi?id=250659


Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
eaafbc3a8adab16babe2c20e54ad3ba40d1fbbc9 13-Mar-2007 Alan Stern <stern@rowland.harvard.edu> USB: Allow autosuspend delay to equal 0

This patch (as867) adds an entry for the new power/autosuspend
attribute in Documentation/ABI/testing, and it changes the behavior of
the delay value. Now a delay of 0 means to autosuspend as soon as
possible, and negative values will prevent autosuspend.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6b157c9bf3bace6eeb4a973da63923ef24995cce 13-Mar-2007 Alan Stern <stern@rowland.harvard.edu> USB: separate autosuspend from external suspend

This patch (as866) adds new entry points for external USB device
suspend and resume requests, as opposed to internally-generated
autosuspend or autoresume. It also changes the existing
remote-wakeup code paths to use the new routines, since remote wakeup
is not the same as autoresume.

As part of the change, it turns out to be necessary to do remote
wakeup of root hubs from a workqueue. We had been using khubd, but it
does autoresume rather than an external resume. Using the
ksuspend_usb_wq workqueue for this purpose seemed a logical choice.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
718efa64e30a5e9db0351d70c5a91969306a12d1 09-Mar-2007 Alan Stern <stern@rowland.harvard.edu> usbcore: move usb_autosuspend_work

This patch (as864) moves the work routine for USB autosuspend from one
source file to another. This permits the removal of one whole global
symbol (!) and should smooth the way for more changes in the future.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b5e795f8df42936590ba9c606edc715fe3593284 20-Feb-2007 Alan Stern <stern@rowland.harvard.edu> USB: make autosuspend delay a module parameter

This patch (as859) makes the default USB autosuspend delay a module
parameter of usbcore. By setting the delay value at boot time, users
will be able to prevent the system from autosuspending devices which
for some reason can't handle it.

The patch also stores the autosuspend delay as a per-device value. A
later patch will allow the user to change the value, tailoring the
delay for each individual device. A delay value of 0 will prevent
autosuspend.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
9251644ab33579d80c038b077f78daa23a04fdcd 23-Jan-2007 Oliver Neukum <oneukum@suse.de> usbcore: trivial whitespace fixes

This patch (as844) makes some trivial whitespace fixes to a few files
in usbcore. Oliver did most of the work and Alan added some tidying up.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
db063507b40664de33a61161c90358fe6fc9565a 13-Nov-2006 Alan Stern <stern@rowland.harvard.edu> USB core: fix compiler warning about usb_autosuspend_work

This patch (as821) fixes a compiler warning when CONFIG_PM isn't on
("usb_autosuspend_work" defined but not used).

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0c1ac4f25f894f9df0ffe9b912c165fb6a185a3c 30-Oct-2006 Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> USB: makes usb_endpoint_* functions inline.

We have no benefits of having the usb_endpoint_* functions as functions,
but making them inline saves text and data segment sizes:

text data bss dec hex filename
14893634 3108770 1108840 19111244 1239d4c vmlinux.func
14893185 3108566 1108840 19110591 1239abf vmlinux.inline

This is the result of a 2.6.19-rc3 kernel compiled with GCC 4.1.1 without
CONFIG_MODULES, CONFIG_CC_OPTIMIZE_FOR_SIZE, CONFIG_REGPARM options set.
USB support is fully enabled (while most of the other drivers are not),
and that kernel has most of the USB code ported to use the endpoint
functions.

That happens because a call to those functions are expensive (in terms
of bytes), while the function's size is smaller or have the same 'size' of
the call.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
c4028958b6ecad064b1a6303a6a5906d4fe48d73 22-Nov-2006 David Howells <dhowells@redhat.com> WorkStruct: make allyesconfig

Fix up for make allyesconfig.

Signed-Off-By: David Howells <dhowells@redhat.com>
f30c2269544bffc7bf1b0d7c0abe5be1be83b8cb 03-Oct-2006 Uwe Zeisberger <Uwe_Zeisberger@digi.com> fix file specification in comments

Many files include the filename at the beginning, serveral used a wrong one.

Signed-off-by: Uwe Zeisberger <Uwe_Zeisberger@digi.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
e0318ebff4d96131bb3524308b845f642e64df81 26-Sep-2006 Alan Stern <stern@rowland.harvard.edu> USB: fix autosuspend when CONFIG_PM isn't set

This patch (as791b) fixes things up to avoid compiler warnings or
errors when CONFIG_USB_SUSPEND or CONFIG_PM isn't set.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
bd859281c09b4318153dc7222b5e9052aad83b61 19-Sep-2006 Alan Stern <stern@rowland.harvard.edu> USB: create new workqueue thread for USB autosuspend

This patch (as787) creates a new workqueue thread to handle delayed
USB autosuspend requests. Previously the code used keventd. However
it turns out that the hub driver's suspend routine calls
flush_scheduled_work(), making it a poor candidate for running in
keventd (the call immediately deadlocks). The solution is to use a
new thread instead of keventd.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1b21d5e166e104f8914441ef52e2cd50ce65b479 28-Aug-2006 Greg Kroah-Hartman <gregkh@suse.de> USB: fix __must_check warnings in drivers/usb/core/

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
645daaab0b6adc35c1838df2a82f9d729fdb1767 30-Aug-2006 Alan Stern <stern@rowland.harvard.edu> usbcore: add autosuspend/autoresume infrastructure

This patch (as739) adds the basic infrastructure for USB autosuspend
and autoresume. The main features are:

PM usage counters added to struct usb_device and struct
usb_interface, indicating whether it's okay to autosuspend
them or they are currently in use.

Flag added to usb_device indicating whether the current
suspend/resume operation originated from outside or as an
autosuspend/autoresume.

Flag added to usb_driver indicating whether the driver
supports autosuspend. If not, no device bound to the driver
will be autosuspended.

Mutex added to usb_device for protecting PM operations.
Unlike the device semaphore, the locking rule for the pm_mutex
is that you must acquire the locks going _up_ the device tree.

New routines handling autosuspend/autoresume requests for
interfaces and devices.

Suspend and resume requests are propagated up the device tree
(but not outside the USB subsystem).

work_struct added to usb_device, for carrying out delayed
autosuspend requests.

Autoresume added (and autosuspend prevented) during probe and
disconnect.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1720058343fa43a1a25bfad9e62ea06e7e9743b6 30-Aug-2006 Alan Stern <stern@rowland.harvard.edu> usbcore: trim down usb_bus structure

As part of the ongoing program to flatten out the HCD bus-glue layer,
this patch (as771b) eliminates the hcpriv, release, and kref fields
from struct usb_bus. hcpriv and release were not being used for
anything worthwhile, and kref has been moved into the enclosing
usb_hcd structure.

Along with those changes, the patch gets rid of usb_bus_get and
usb_bus_put, replacing them with usb_get_hcd and usb_put_hcd.

The one interesting aspect is that the dev_set_drvdata call was
removed from usb_put_hcd, where it clearly doesn't belong. This means
the driver private data won't get reset to NULL. It shouldn't cause
any problems, since the private data is undefined when no driver is
bound.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
a6d2bb9ff919b4685bd684620ec7a1ffa8bf2349 30-Aug-2006 Alan Stern <stern@rowland.harvard.edu> USB: remove struct usb_operations

All of the currently-supported USB host controller drivers use the HCD
bus-glue framework. As part of the program for flattening out the glue
layer, this patch (as769) removes the usb_operations structure. All
function calls now go directly to the HCD routines (slightly renamed
to remain within the "usb_" namespace).

The patch also removes usb_alloc_bus(), because it's not useful in the
HCD framework and it wasn't referenced anywhere.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
095bc335360a51623dd8571839bbf465851a7f4b 27-Aug-2006 Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> USB core: Use const where possible.

This patch marks some USB core's functions parameters as const. This
improves the design (we're saying to the caller that its parameter is
not going to be modified) and may help in compiler's optimisation work.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b7cfaaaf86571732c7728e95a2231a860385463c 27-Sep-2006 Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> USB: New functions to check endpoints info.

These functions makes USB driver's code simpler when dealing with endpoints
by avoiding them from accessing the endpoint's descriptor structure directly
when they only need to know the endpoint's transfer type and/or
direction.

Please, read each functions' documentation in order to know how to use
them.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
782da727b0d59e93c84a627948b1535a3db90392 02-Jul-2006 Alan Stern <stern@rowland.harvard.edu> usbcore: make usb_generic a usb_device_driver

This patch (as714b) makes usb_generic into a usb_device_driver capable
of being probed and unbound, just like other drivers. A fair amount of
the work that used to get done during discovery or removal of a USB
device have been moved to the probe and disconnect methods of
usb_generic: creating the sysfs attributes and selecting an initial
configuration. However the normal behavior should continue to be the
same as before.

We will now have the possibility of creating other USB device drivers,
They will assist with exporting devices to remote systems
(USB-over-TCPIP) or to paravirtual guest operating systems.


Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
8bb54ab573ecd1b4fe2ed66416a8d99a86e65316 02-Jul-2006 Alan Stern <stern@rowland.harvard.edu> usbcore: add usb_device_driver definition

This patch (as732) adds a usb_device_driver structure, for representing
drivers that manage an entire USB device as opposed to just an
interface. Support routines like usb_register_device_driver,
usb_deregister_device_driver, usb_probe_device, and usb_unbind_device
are also added.

Unlike an earlier version of this patch, the new code is type-safe. To
accomplish this, the existing struct driver embedded in struct
usb_driver had to be wrapped in an intermediate wrapper. This enables
the core to tell at runtime whether a particular struct driver belongs
to a device driver or to an interface driver.


Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
36e56a34586783c7986ce09d39db80b27c95ce24 02-Jul-2006 Alan Stern <stern@rowland.harvard.edu> usbcore: move code among source files

This revised patch (as713b) moves a few routines among source files in
usbcore. Some driver-related code in usb.c (claiming interfaces and
matching IDs) is moved to driver.c, where it belongs. Also the
usb_generic stuff in driver.c is moved to a new source file: generic.c.
(That's the reason for revising the patch.) Although not very big now,
it will get bigger in a later patch.

None of the code has been changed; it has only been re-arranged.


Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
140d8f687457c40a66af362838fac0d7893e7df5 02-Jul-2006 Alan Stern <stern@rowland.harvard.edu> usbcore: rename usb_suspend_device to usb_port_suspend

This revised patch (as715b) renames usb_suspend_device to
usb_port_suspend, usb_resume_device to usb_port_resume, and
finish_device_resume to finish_port_resume. There was no objection to
the original version of the patch so this should be okay to apply.

The revision was needed only because I have re-arranged the order of the
earlier patches.


Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b94badbb47cb50f4fca8440efdaa8ebd32604fe4 02-Aug-2006 Dmitry Torokhov <dtor@insightbb.com> USB: Make usb_buffer_free() NULL-safe

kfree() handles NULL arguments which is handy in error handling paths as one
does need to insert bunch of ifs. How about making usb_buffer_free() do the
same?

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6ab3d5624e172c553004ecc862bfeac16d9d68b7 30-Jun-2006 Jörn Engel <joern@wohnheim.fh-wedel.de> Remove obsolete #include <linux/config.h>

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
0517587e5896cef1d5f99d3b24f5f2ca15d952ad 22-Jun-2006 Greg Kroah-Hartman <gregkh@suse.de> [PATCH] USB: get USB suspend to work again

Yeah, it's a hack, but it is only temporary until Alan's patches
reworking this area make it in. We really should not care what devices
below us are doing, especially when we do not really know what type of
devices they are. This patch relies on the fact that the endpoint
devices do not have a driver assigned to us.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
79efa097e75018a2918155f343f0e08e61ee8a8c 01-Jun-2006 Alan Stern <stern@rowland.harvard.edu> [PATCH] usbcore: port reset for composite devices

This patch (as699) adds usb_reset_composite_device(), a routine for
sending a USB port reset to a device with multiple interfaces owned by
different drivers. Drivers are notified about impending and completed
resets through two new methods in the usb_driver structure.

The patch modifieds the usbfs ioctl code to make it use the new routine
instead of usb_reset_device(). Follow-up patches will modify the hub,
usb-storage, and usbhid drivers so they can utilize this new API.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
87ed0aeba8d59fe5d68df8d10ba469d63b254914 04-Apr-2006 Adrian Bunk <bunk@stusta.de> [PATCH] USB: drivers/usb/core/: remove unused exports

This patch removes the following unused EXPORT_SYMBOL's:
- hub.c: usb_set_device_state
- usb.c: usb_alloc_dev
- usb.c: usb_disconnect

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
4186ecf8ad16dd05759a09594de6a87e48759ba6 11-Jan-2006 Arjan van de Ven <arjan@infradead.org> [PATCH] USB: convert a bunch of USB semaphores to mutexes

the patch below converts a bunch of semaphores-used-as-mutex in the USB
code to mutexes

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
312c004d36ce6c739512bac83b452f4c20ab1f62 16-Nov-2005 Kay Sievers <kay.sievers@suse.de> [PATCH] driver core: replace "hotplug" by "uevent"

Leave the overloaded "hotplug" word to susbsystems which are handling
real devices. The driver core does not "plug" anything, it just exports
the state to userspace and generates events.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f5691d70d4aeec0ac9cff11f0cabb7d5a1735705 22-Dec-2005 Pete Zaitcev <zaitcev@redhat.com> [PATCH] USB: fix usb_find_interface for ppc64

Fix usb_find_interface. You cannot case pointers to int and long on
a big-endian 64-bitter without consequences.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
aafbf24a1129480157af7ee780eddcea9b76ee5c 20-Dec-2005 Pete Zaitcev <zaitcev@redhat.com> [PATCH] USB: replace __setup("nousb") with __module_param_call

Fedora users complain that passing "nousbstorage" to the installer causes
the rest of the USB support to disappear. The installer uses kernel command
line as a way to pass options through Syslinux. The problem stems from the
use of strncmp() in obsolete_checksetup().

I used __module_param_call() instead of module_param because I wanted to
preserve the old syntax in grub.conf, and it's the only macro which allows
to remove the prefix.

The fix is tested to accept the option "nousb" correctly now.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
12c3da346eb81b6a281031f62eda3bca993dff5a 23-Nov-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] USB: Store port number in usb_device

This patch (as610) adds a field to struct usb_device to store the device's
port number. This allows us to remove several loops in the hub driver
(searching for a particular device among all the entries in the parent's
array of children).

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
9ad3d6ccf5eee285e233dbaf186369b8d477a666 17-Nov-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] USB: Remove USB private semaphore

This patch (as605) removes the private udev->serialize semaphore,
relying instead on the locking provided by the embedded struct device's
semaphore. The changes are confined to the core, except that the
usb_trylock_device routine now uses the return convention of
down_trylock rather than down_read_trylock (they return opposite values
for no good reason).

A couple of other associated changes are included as well:

Now that we aren't concerned about HCDs that avoid using the
hcd glue layer, usb_disconnect no longer needs to acquire the
usb_bus_lock -- that can be done by usb_remove_hcd where it
belongs.

Devices aren't locked over the same scope of code in
usb_new_device and hub_port_connect_change as they used to be.
This shouldn't cause any trouble.

Along with the preceding driver core patch, this needs a lot of testing.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ddae41be6145f5f9cb4e6df35661a09121b90672 16-Nov-2005 Greg Kroah-Hartman <gregkh@suse.de> [PATCH] USB: reorg some functions out of the main usb.c file

This will make the dynamic-id stuff easier to do, as it will be
self-contained.

No logic was changed at all.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5a9191ff683ce4ebfd2c6a15e2989f5b1f420321 21-Dec-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] usbcore: allow suspend/resume even if drivers don't support it

This patch (as618) changes usbcore to prevent derailing the
suspend/resume sequence when a USB driver doesn't include support for
it. This is a workaround rather than a true fix; the core needs to be
changed so that URB submissions from suspended drivers can be refused
and outstanding URBs cancelled.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
654f31189e550cd5924b786487a5d93d9feaada9 17-Nov-2005 Greg Kroah-Hartman <gregkh@suse.de> [PATCH] USB: move CONFIG_USB_DEBUG checks into the Makefile

This lets us remove a lot of code in the drivers that were all checking
the same thing. It also found some bugs in a few of the drivers, which
has been fixed up.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
0a1ef3b5a765a6f20e7b8caf295aad3276243966 24-Oct-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] usbcore: Use kzalloc instead of kmalloc/memset

This patch (as590) fixes up all the remaining places where usbcore can
use kzalloc rather than kmalloc/memset.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7521803dcc0137668bb30483383092a647671d8b 21-Jun-2005 Greg Kroah-Hartman <gregkh@suse.de> [PATCH] USB: always export interface information for modalias

This fixes a problem with some cdc acm devices that were not getting
automatically loaded as the module alias was not being reported
properly.

This check was for back in the days when we only reported hotplug events
for the main usb device, not the interfaces. We should always give the
interface information for MODALIAS/modalias as it can be needed.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
979d5199fee9e80290ddeb532e5993bd15506712 23-Sep-2005 David Brownell <david-b@pacbell.net> [PATCH] root hub changes (lesser half)

This patch collects various small updates related to root hubs, to shrink
later patches which build on them.

- For root hub suspend/resume support:
* Make the existing usb_hcd_resume_root_hub() routine respect pmcore
locking, exporting and using the dpm_runtime_resume() method.
* Add a new usb_hcd_suspend_root_hub() to pair with that routine.
(Essential to make OHCI autosuspend behave again...)
* HC_SUSPENDED by itself only refers to the root hub's downstream ports.
So let HCDs see root hub URBs unless the parent device is suspended.

- Remove an assertion we no longer need (and now, also don't want).

- Generic suspend/resume updates to work better with swsusp.
* Ignore the FREEZE vs SUSPEND distinction for hardware; trying to
use it breaks the swsusp snapshots it's supposed to help (sigh).
* On resume, mark devices as resumed right away, but then
do nothing else if the device is marked NOTATTACHED.

These changes shouldn't be very noticable by themselves.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

drivers/base/power/runtime.c | 1
drivers/usb/core/hcd.c | 64 ++++++++++++++++++++++++++++++++++++++-----
drivers/usb/core/hcd.h | 1
drivers/usb/core/hub.c | 45 ++++++++++++++++++++++++------
drivers/usb/core/usb.c | 20 +++++++++----
drivers/usb/core/usb.h | 1
6 files changed, 111 insertions(+), 21 deletions(-)
390a8c345e6415cbf811232feedac70b56c9fc8d 14-Sep-2005 David Brownell <david-b@pacbell.net> [PATCH] remove usb_suspend_device() parameter

This patch removes the extra usb_suspend_device() parameter. The original
reason to pass that parameter was so that this routine could suspend any
active children. A previous patch removed that functionality ... leaving
no reason to pass the parameter. A close analogy is pci_set_power_state,
which doesn't need a pm_message_t either.

On the internal code path that comes through the driver model, the parameter
is now used to distinguish cases where USB devices need to "freeze" but not
suspend. It also checks for an error case that's accessible through sysfs:
attempting to suspend a device before its interfaces (or for hubs, ports).

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

drivers/usb/core/hub.c | 34 +++++++++++++++++++++-------------
drivers/usb/core/usb.c | 23 +++++++++++++++++++++--
drivers/usb/host/ehci-hcd.c | 2 +-
drivers/usb/host/isp116x-hcd.c | 2 +-
drivers/usb/host/ohci-pci.c | 2 +-
include/linux/usb.h | 2 +-
6 files changed, 46 insertions(+), 19 deletions(-)
db69087437dd5135a9362da1c37fe072070e8f60 14-Sep-2005 David Brownell <david-b@pacbell.net> [PATCH] usb_interface power state

This updates the handling of power state for USB interfaces.

- Formalizes an existing invariant: interface "power state" is a boolean:
ON when I/O is allowed, and FREEZE otherwise. It does so by defining
some inlined helpers, then using them.

- Adds a useful invariant: the only interfaces marked active are those
bound to non-suspended drivers. Later patches build on this invariant.

- Simplifies the interface driver API (and removes some error paths) by
removing the requirement that they record power state changes during
suspend and resume callbacks. Now usbcore does that.

A few drivers were simplified to address that last change.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

drivers/usb/core/hub.c | 33 +++++++++------------
drivers/usb/core/message.c | 1
drivers/usb/core/usb.c | 65 +++++++++++++++++++++++++++++++++----------
drivers/usb/core/usb.h | 18 +++++++++++
drivers/usb/input/hid-core.c | 2 -
drivers/usb/misc/usbtest.c | 10 ------
drivers/usb/net/pegasus.c | 2 -
drivers/usb/net/usbnet.c | 2 -
8 files changed, 85 insertions(+), 48 deletions(-)
55016f10e31bb15b85d8c500f979dfdceb37d548 21-Oct-2005 Al Viro <viro@zeniv.linux.org.uk> [PATCH] gfp_t: drivers/usb

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
d305ef5d2a4e77bfa66160513f4a7494126a506b 22-Sep-2005 Daniel Ritz <daniel.ritz@gmx.ch> [PATCH] driver core: add helper device_is_registered()

add the helper and use it instead of open coding the klist_node_attached() check
(which is a layering violation IMHO)

idea by Alan Stern.

Signed-off-by: Daniel Ritz <daniel.ritz@gmx.ch>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
3b4d7f79164853e10342d707e32307e0c8054982 11-Aug-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] USB: Support unbinding of the usb_generic driver

This patch (as556) adds support for unbinding the usb_generic "driver".
That driver only binds to USB devices, as opposed to interfaces, and it
does nothing much besides marking which struct device's go with an
overall USB device plus providing suspend/resume methods. Now that
users can unbind drivers at will using the sysfs "unbind" attribute, we
need a rational way of dealing with USB devices that are no longer under
full control of the USB stack. The patch handles this by unconfiguring
the device, thereby removing all the interfaces and their associated
drivers and children.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3ea15966ed59f2bc20928c7b0496b4585f6de206 11-Aug-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] USB: Add timeout to usb_lock_device_for_reset

This patch (as555) modifies the already-awkward
usb_lock_device_for_reset routine in usbcore by adding a timeout. The
whole point of the routine is that the caller wants to acquire some
semaphores in the wrong order; protecting against the possibility of
deadlock by timing out seems only prudent.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fbf82fd2e1f4e679c60516d772d1862c941ca845 31-Jul-2005 Kay Sievers <kay.sievers@vrfy.org> [PATCH] USB: real nodes instead of usbfs

This patch introduces a /sys/class/usb_device/ class
where every connected usb-device will show up:

tree /sys/class/usb_device/
/sys/class/usb_device/
|-- usb1.1
| |-- dev
| `-- device -> ../../../devices/pci0000:00/0000:00:1d.0/usb1
|-- usb2.1
| |-- dev
| `-- device -> ../../../devices/pci0000:00/0000:00:1d.1/usb2
...

The presence of the "dev" file lets udev create real device nodes.
kay@pim:~/src/linux-2.6> tree /dev/bus/usb/
/dev/bus/usb/
|-- 1
| `-- 1
|-- 2
| `-- 1
...

udev rule:
SUBSYSTEM="usb_device", PROGRAM="/sbin/usb_device %k", NAME="%c"
(echo $1 | /bin/sed 's/usb\([0-9]*\)\.\([0-9]*\)/bus\/usb\/\1\/\2/')

This makes libusb pick up the real nodes instead of the mounted usbfs:
export USB_DEVFS_PATH=/dev/bus/usb

Background:
All this makes it possible to manage usb devices with udev instead of
the devfs solution. We are currently working on a pam_console/resmgr
replacement driven by udev and a pam-helper. It applies ACL's to device
nodes, which is required for modern desktop functionalty like
"Fast User Switching" or multiple local login support.

New patch with its own major. I've succesfully disabled usbfs and use real
nodes only on my box. With: "export USB_DEVFS_PATH=/dev/bus/usb" libusb picks
up the udev managed nodes instead of reading usbfs files.

This makes udev to provide symlinks for libusb to pick up:
SUBSYSTEM="usb_device", PROGRAM="/sbin/usbdevice %k", SYMLINK="%c"

/sbin/usbdevice:
#!/bin/sh
echo $1 | /bin/sed 's/usbdev\([0-9]*\)\.\([0-9]*\)/bus\/usb\/\1\/\2/'

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ca078bae813dd46c0f9b102fdfb4a3384641ff48 04-Sep-2005 Pavel Machek <pavel@ucw.cz> [PATCH] swsusp: switch pm_message_t to struct

This adds type-checking to pm_message_t, so that people can't confuse it
with int or u32. It also allows us to fix "disk yoyo" during suspend (disk
spinning down/up/down).

[We've tried that before; since that cpufreq problems were fixed and I've
tried make allyes config and fixed resulting damage.]

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Alexander Nyberg <alexn@telia.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
a3fdf4ebe016ba756de3ca29a2a6117e9acd721c 30-Jun-2005 brian@murphy.dk <brian@murphy.dk> [PATCH] USB: export usb_get_intf() and usb_put_intf()

Export usb_get_intf and usb_put_intf so that modules can increase
usb interface reference counts.

Signed-off-by: brian@murphy.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5db539e49fc7471e23bf3c94ca304f008cb7b7f3 23-Jun-2005 Olav Kongas <ok@artecdesign.ee> [PATCH] USB: Fix kmalloc's flags type in USB

Greg,

This patch fixes the kmalloc() flags argument type in USB
subsystem; hopefully all of its occurences. The patch was
made against patch-2.6.12-git2 from Jun 20.

Cleanup of flags for kmalloc() in USB subsystem.

Signed-off-by: Olav Kongas <ok@artecdesign.ee>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f409661877a25d11c2495bcd879807f17c286684 06-May-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] usbcore: Don't call device_release_driver recursively

This patch fixes usb_driver_release_interface() to make it avoid calling
device_release_driver() recursively, i.e., when invoked from within the
disconnect routine for the same device. The patch applies to your
"driver" tree.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
273971bade8a6d37c1b162146de1a53965cdc245 21-Jun-2005 Patrick Mochel <mochel@digitalimplant.org> [PATCH] usb: klist_node_attached() fix

The original code looks like this:

/* if interface was already added, bind now; else let
* the future device_add() bind it, bypassing probe()
*/
if (!list_empty (&dev->bus_list))
device_bind_driver(dev);

IOW, it's checking to see if the device is attached to the bus or not
and binding the driver if it is. It's checking the device's bus list,
which will only appear empty when the device has been initialized, but
not added. It depends way too much on the driver model internals, but it
seems to be the only way to do the weird crap they want to do with
interfaces.

When I converted it to use klists, I accidentally inverted the logic,
which led to bad things happening. This patch returns the check to its
orginal value.

From: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Index: gregkh-2.6/drivers/usb/core/usb.c
===================================================================
ff710710eae73990dd484ea8e37dba636452502b 24-Mar-2005 gregkh@suse.de <gregkh@suse.de> [PATCH] USB: fix build warning in usb core as pointed out by Andrew.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Index: gregkh-2.6/drivers/usb/core/usb.c
===================================================================
d4a7537122fa47a6ce41c5fdab53d844c78d7023 24-Mar-2005 mochel@digitalimplant.org <mochel@digitalimplant.org> [PATCH] Fix up USB to use klist_node_attached() instead of list_empty() on lists that will go away.

Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Index: gregkh-2.6/drivers/usb/core/usb.c
===================================================================
6034a080f98b0bbc0a058e2ac65a538f75cffeee 21-Mar-2005 mochel@digitalimplant.org <mochel@digitalimplant.org> [PATCH] Use driver_for_each_device() instead of manually walking list.

Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Index: gregkh-2.6/drivers/usb/core/usb.c
===================================================================
fb3b4ebc0be618dbcc2326482a83c920d51af7de 23-Apr-2005 Roman Kagan <rkagan@mail.ru> [PATCH] USB: MODALIAS change for bcdDevice

The patch below adjusts the MODALIAS generated by the usb hotplug
function to match the proposed change to scripts/mod/file2alias.c.

Signed-off-by: Roman Kagan <rkagan@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6d5e8254bf488a40b7ae2faafbffa232ab19d541 19-Apr-2005 Greg KH <gregkh@suse.de> [PATCH] USB: fix up some sparse warnings about static functions that aren't static.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


Index: gregkh-2.6/drivers/usb/core/usb.h
===================================================================
27d72e8572336d9f4e17a12ac924cb5223a5758d 19-Apr-2005 David Brownell <david-b@pacbell.net> [PATCH] usb suspend updates (interface suspend)

This is the first of a few installments of PM API updates to match the
recent switch to "pm_message_t". This installment primarily affects
USB device drivers (for USB interfaces), and it changes the handful of
drivers which currently implement suspend methods:

- <linux/usb.h> and usbcore, signature change

- Some drivers only changed the signature, net effect this just
shuts up "sparse -Wbitwise":
* hid-core
* stir4200

- Two network drivers did that, and also grew slightly more
featureful suspend code ... they now properly shut down
their activities. (As should stir4200...)
* pegasus
* usbnet

Note that the Wake-On-Lan (WOL) support in pegasus doesn't yet work; looks
to me like it's missing a request to turn it on, vs just configuring it.
The ASIX code in usbnet also has WOL hooks that are ready to use; untested.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Index: gregkh-2.6/drivers/net/irda/stir4200.c
===================================================================
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org> Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!