safe/jmp/linux-2.6
14 years agoUSB: xhci: Avoid compiler reordering in Link TRB giveback.
Sarah Sharp [Thu, 30 Apr 2009 02:05:58 +0000 (19:05 -0700)]
USB: xhci: Avoid compiler reordering in Link TRB giveback.

Force the compiler to write the cycle bit of the Link TRB last.  This
ensures that the hardware doesn't think it owns the Link TRB before we set
the chain bit.  Reported by Oliver in this thread:
http://marc.info/?l=linux-usb&m=124091532410219&w=2

Reported-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Clean up xhci_irq() function.
Sarah Sharp [Thu, 30 Apr 2009 02:05:40 +0000 (19:05 -0700)]
USB: xhci: Clean up xhci_irq() function.

Drop spinlock in xhci_irq() error path.
This fixes the issue reported by Oliver Neukum on this thread:
http://marc.info/?l=linux-usb&m=124090924401444&w=2

Remove unnecessary register read reported by Viral Mehta:
http://marc.info/?l=linux-usb&m=124091326007398&w=2

Reported-by: Oliver Neukum <oliver@neukum.org>
Reported-by: Viral Mehta <viral.mehta@einfochips.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Avoid global namespace pollution.
Sarah Sharp [Thu, 30 Apr 2009 02:05:20 +0000 (19:05 -0700)]
USB: xhci: Avoid global namespace pollution.

Make all globally visible functions start with xhci_ and mark functions as
static if they're only called within the same C file.  Fix some long lines
while we're at it.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Fix Link TRB handoff bit twiddling.
Sarah Sharp [Thu, 30 Apr 2009 02:04:59 +0000 (19:04 -0700)]
USB: xhci: Fix Link TRB handoff bit twiddling.

Make sure to preserve all bits *except* the TRB_CHAIN bit when giving a
Link TRB to the hardware.  We need to save things like TRB type and the
toggle bit in the control dword.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Fix register write order.
Sarah Sharp [Thu, 30 Apr 2009 02:04:32 +0000 (19:04 -0700)]
USB: xhci: Fix register write order.

The 0.95 xHCI spec says that if the xHCI HW support 64-bit addressing, you
must write the whole 64-bit address as one atomic operation, or write the
low 32 bits, and then the high 32 bits.  I had the register writes
swapped in some places.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: fix some compiler warnings in xhci.h
Greg Kroah-Hartman [Thu, 30 Apr 2009 02:12:44 +0000 (19:12 -0700)]
USB: xhci: fix some compiler warnings in xhci.h

This fixes the warning:
drivers/usb/host/xhci.h:1083: warning: passing argument 1 of ‘xhci_to_hcd’ discards qualifiers from pointer target type
drivers/usb/host/xhci.h:1083: warning: passing argument 1 of ‘xhci_to_hcd’ discards qualifiers from pointer target type

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: fix lots of compiler warnings.
Greg Kroah-Hartman [Thu, 30 Apr 2009 02:14:08 +0000 (19:14 -0700)]
USB: xhci: fix lots of compiler warnings.

Turns out someone never built this code on a 64bit platform.

Someone owes me a beer...

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: use xhci_handle_event instead of handle_event
Stephen Rothwell [Thu, 30 Apr 2009 02:02:47 +0000 (19:02 -0700)]
USB: xhci: use xhci_handle_event instead of handle_event

The former is way to generic for a global symbol.

Fixes this build error:

drivers/usb/built-in.o: In function `.handle_event': (.text+0x67dd0): multiple definition of `.handle_event'
drivers/pcmcia/built-in.o:(.text+0xcfcc): first defined here
drivers/usb/built-in.o: In function `handle_event': (.opd+0x5bc8): multiple definition of `handle_event'
drivers/pcmcia/built-in.o:(.opd+0xed0): first defined here

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: URB cancellation support.
Sarah Sharp [Thu, 30 Apr 2009 02:02:31 +0000 (19:02 -0700)]
USB: xhci: URB cancellation support.

Add URB cancellation support to the xHCI host controller driver.  This
currently supports cancellation for endpoints that do not have streams
enabled.

An URB is represented by a number of Transaction Request Buffers (TRBs),
that are chained together to make one (or more) Transaction Descriptors
(TDs) on an endpoint ring.  The ring is comprised of contiguous segments,
linked together with Link TRBs (which may or may not be chained into a TD).

To cancel an URB, we must stop the endpoint ring, make the hardware skip
over the TDs in the URB (either by turning them into No-op TDs, or by
moving the hardware's ring dequeue pointer past the last TRB in the last
TD), and then restart the ring.

There are times when we must drop the xHCI lock during this process, like
when we need to complete cancelled URBs.  We must ensure that additional
URBs can be marked as cancelled, and that new URBs can be enqueued (since
the URB completion handlers can do either).  The new endpoint ring
variables cancels_pending and state (which can only be modified while
holding the xHCI lock) ensure that future cancellation and enqueueing do
not interrupt any pending cancellation code.

To facilitate cancellation, we must keep track of the starting ring
segment, first TRB, and last TRB for each URB.  We also need to keep track
of the list of TDs that have been marked as cancelled, separate from the
list of TDs that are queued for this endpoint.  The new variables and
cancellation list are stored in the xhci_td structure.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Scatter gather list support for bulk transfers.
Sarah Sharp [Tue, 28 Apr 2009 02:59:19 +0000 (19:59 -0700)]
USB: xhci: Scatter gather list support for bulk transfers.

Add support for bulk URBs that pass scatter gather lists to xHCI.  This allows
xHCI to more efficiently enqueue these transfers, and allows the host
controller to take advantage of USB 3.0 "bursts" for bulk endpoints.

Use requested length to calculate the number of TRBs needed for a scatter gather
list transfer, instead of using the number of sglist entries.  The application
can pass down a scatter gather list that is bigger than it needs for the
requested transfer.

Scatter gather entries can cross 64KB boundaries, so be careful to setup TRBs
such that no buffer crosses a 64KB boundary.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Push scatter gather lists down to host controller drivers.
Sarah Sharp [Tue, 28 Apr 2009 02:59:01 +0000 (19:59 -0700)]
USB: Push scatter gather lists down to host controller drivers.

This is the original patch I created before David Vrabel posted a better
patch (http://marc.info/?l=linux-usb&m=123377477209109&w=2) that does
basically the same thing.  This patch will get replaced with his
(modified) patch later.

Allow USB device drivers that use usb_sg_init() and usb_sg_wait() to push
bulk endpoint scatter gather lists down to the host controller drivers.
This allows host controller drivers to more efficiently enqueue these
transfers, and allows the xHCI host controller to better take advantage of
USB 3.0 "bursts" for bulk endpoints.

This patch currently only enables scatter gather lists for bulk endpoints.
Other endpoint types that use the usb_sg_* functions will not have their
scatter gather lists pushed down to the host controller.  For periodic
endpoints, we want each scatterlist entry to be a separate transfer.
Eventually, HCDs could parse these scatter-gather lists for periodic
endpoints also.  For now, we use the old code and call usb_submit_urb()
for each scatterlist entry.

The caller of usb_sg_init() can request that all bytes in the scatter
gather list be transferred by passing in a length of zero.  Handle that
request for a bulk endpoint under xHCI by walking the scatter gather list
and calculating the length.  We could let the HCD handle a zero length in
this case, but I'm not sure if the core layers in between will get
confused by this.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Bulk transfer support
Sarah Sharp [Tue, 28 Apr 2009 02:58:50 +0000 (19:58 -0700)]
USB: xhci: Bulk transfer support

Allow device drivers to submit URBs to bulk endpoints on devices under an
xHCI host controller.  Share code between the control and bulk enqueueing
functions when it makes sense.

To get the best performance out of bulk transfers, SuperSpeed devices must
have the bMaxBurst size copied from their endpoint companion controller
into the xHCI device context.  This allows the host controller to "burst"
up to 16 packets before it has to wait for the device to acknowledge the
first packet.

The buffers in Transfer Request Blocks (TRBs) can cross page boundaries,
but they cannot cross 64KB boundaries.  The buffer must be broken into
multiple TRBs if a 64KB boundary is crossed.

The sum of buffer lengths in all the TRBs in a Transfer Descriptor (TD)
cannot exceed 64MB.  To work around this, the enqueueing code must enqueue
multiple TDs.  The transfer event handler may incorrectly give back the
URB in this case, if it gets a transfer event that points somewhere in the
first TD.  FIXME later.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Bandwidth allocation support
Sarah Sharp [Tue, 28 Apr 2009 02:58:38 +0000 (19:58 -0700)]
USB: xhci: Bandwidth allocation support

Since the xHCI host controller hardware (xHC) has an internal schedule, it
needs a better representation of what devices are consuming bandwidth on
the bus.  Each device is represented by a device context, with data about
the device, endpoints, and pointers to each endpoint ring.

We need to update the endpoint information for a device context before a
new configuration or alternate interface setting is selected.  We setup an
input device context with modified endpoint information and newly
allocated endpoint rings, and then submit a Configure Endpoint Command to
the hardware.

The host controller can reject the new configuration if it exceeds the bus
bandwidth, or the host controller doesn't have enough internal resources
for the configuration.  If the command fails, we still have the older
device context with the previous configuration.  If the command succeeds,
we free the old endpoint rings.

The root hub isn't a real device, so always say yes to any bandwidth
changes for it.

The USB core will enable, disable, and then enable endpoint 0 several
times during the initialization sequence.  The device will always have an
endpoint ring for endpoint 0 and bandwidth allocated for that, unless the
device is disconnected or gets a SetAddress 0 request.  So we don't pay
attention for when xhci_check_bandwidth() is called for a re-add of
endpoint 0.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Support for bandwidth allocation.
Sarah Sharp [Tue, 28 Apr 2009 02:58:26 +0000 (19:58 -0700)]
USB: Support for bandwidth allocation.

Originally, the USB core had no support for allocating bandwidth when a
particular configuration or alternate setting for an interface was
selected.  Instead, the device driver's URB submission would fail if
there was not enough bandwidth for a periodic endpoint.  Drivers could
work around this, by using the scatter-gather list API to guarantee
bandwidth.

This patch adds host controller API to allow the USB core to allocate or
deallocate bandwidth for an endpoint.  Endpoints are added to or dropped
from a copy of the current schedule by calling add_endpoint() or
drop_endpoint(), and then the schedule is atomically evaluated with a
call to check_bandwidth().  This allows all the endpoints for a new
configuration or alternate setting to be added at the same time that the
endpoints from the old configuration or alt setting are dropped.

Endpoints must be added to the schedule before any URBs are submitted to
them.  The HCD must be allowed to reject a new configuration or alt
setting before the control transfer is sent to the device requesting the
change.  It may reject the change because there is not enough bandwidth,
not enough internal resources (such as memory on an embedded host
controller), or perhaps even for security reasons in a virtualized
environment.

If the call to check_bandwidth() fails, the USB core must call
reset_bandwidth().  This causes the schedule to be reverted back to the
state it was in just after the last successful check_bandwidth() call.

If the call succeeds, the host controller driver (and hardware) will have
changed its internal state to match the new configuration or alternate
setting.  The USB core can then issue a control transfer to the device to
change the configuration or alt setting.  This allows the core to test new
configurations or alternate settings before unbinding drivers bound to
interfaces in the old configuration.

WIP:

The USB core must add endpoints from all interfaces in a configuration
to the schedule, because a driver may claim that interface at any time.
A slight optimization might be to add the endpoints to the schedule once
a driver claims that interface.  FIXME

This patch does not cover changing alternate settings, but it does
handle a configuration change or de-configuration.  FIXME

The code for managing the schedule is currently HCD specific.  A generic
scheduling algorithm could be added for host controllers without
built-in scheduling support.  For now, if a host controller does not
define the check_bandwidth() function, the call to
usb_hcd_check_bandwidth() will always succeed.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Parse and store the SuperSpeed endpoint companion descriptors.
Sarah Sharp [Tue, 28 Apr 2009 02:58:14 +0000 (19:58 -0700)]
USB: Parse and store the SuperSpeed endpoint companion descriptors.

The USB 3.0 bus specification added an "Endpoint Companion" descriptor that is
supposed to follow all SuperSpeed Endpoint descriptors.  This descriptor is used
to extend the bus protocol to allow more packets to be sent to an endpoint per
"microframe".  The word microframe was removed from the USB 3.0 specification
because the host controller does not send Start Of Frame (SOF) symbols down the
USB 3.0 wires.

The descriptor defines a bMaxBurst field, which indicates the number of packets
of wMaxPacketSize that a SuperSpeed device can send or recieve in a service
interval.  All non-control endpoints may set this value as high as 16 packets
(bMaxBurst = 15).

The descriptor also allows isochronous endpoints to further specify that they
can send and receive multiple bursts per service interval.  The bmAttributes
allows them to specify a "Mult" of up to 3 (bmAttributes = 2).

Bulk endpoints use bmAttributes to report the number of "Streams" they support.
This was an extension of the endpoint pipe concept to allow multiple mass
storage device commands to be outstanding for one bulk endpoint at a time.  This
should allow USB 3.0 mass storage devices to support SCSI command queueing.
Bulk endpoints can say they support up to 2^16 (65,536) streams.

The information in the endpoint companion descriptor must be stored with the
other device, config, interface, and endpoint descriptors because the host
controller needs to access them quickly, and we need to install some default
values if a SuperSpeed device doesn't provide an endpoint companion descriptor.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Control transfer support.
Sarah Sharp [Tue, 28 Apr 2009 02:58:01 +0000 (19:58 -0700)]
USB: xhci: Control transfer support.

Allow device drivers to enqueue URBs to control endpoints on devices under
an xHCI host controller.  Each control transfer is represented by a
series of Transfer Descriptors (TDs) written to an endpoint ring.  There
is one TD for the Setup phase, (optionally) one TD for the Data phase, and
one TD for the Status phase.

Enqueue these TDs onto the endpoint ring that represents the control
endpoint.  The host controller hardware will return an event on the event
ring that points to the (DMA) address of one of the TDs on the endpoint
ring.  If the transfer was successful, the transfer event TRB will have a
completion code of success, and it will point to the Status phase TD.
Anything else is considered an error.

This should work for control endpoints besides the default endpoint, but
that hasn't been tested.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Support for submitting control URBs under xHCI.
Sarah Sharp [Tue, 28 Apr 2009 02:57:50 +0000 (19:57 -0700)]
USB: Support for submitting control URBs under xHCI.

Warn users of URB_NO_SETUP_DMA_MAP about xHCI behavior.

Device drivers can choose to DMA map the setup packet of a control transfer
before submitting the URB to the USB core.  Drivers then set the
URB_NO_SETUP_DMA_MAP and pass in the DMA memory address in setup_dma, instead of
providing a kernel address for setup_packet.  However, xHCI requires that the
setup packet be copied into an internal data structure, and we need a kernel
memory address pointer for that.  Warn users of URB_NO_SETUP_DMA_MAP that they
should provide a valid pointer for setup_packet, along with the DMA address.

FIXME:  I'm not entirely sure how to work around this in the xHCI driver
or USB core.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Allocate and address USB devices
Sarah Sharp [Tue, 28 Apr 2009 02:57:38 +0000 (19:57 -0700)]
USB: xhci: Allocate and address USB devices

xHCI needs to get a "Slot ID" from the host controller and allocate other
data structures for every USB device.  Make usb_alloc_dev() and
usb_release_dev() allocate and free these device structures.  After
setting up the xHC device structures, usb_alloc_dev() must wait for the
hardware to respond to an Enable Slot command.  usb_alloc_dev() fires off
a Disable Slot command and does not wait for it to complete.

When the USB core wants to choose an address for the device, the xHCI
driver must issue a Set Address command and wait for an event for that
command.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Support for addressing a USB device under xHCI
Sarah Sharp [Tue, 28 Apr 2009 02:57:26 +0000 (19:57 -0700)]
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>
14 years agoUSB: xhci: Root hub support.
Sarah Sharp [Tue, 28 Apr 2009 02:57:12 +0000 (19:57 -0700)]
USB: xhci: Root hub support.

Add functionality for getting port status and hub descriptor for xHCI root
hubs.  This is WIP because the USB 3.0 hub descriptor is different from
the USB 2.0 hub descriptor.  For now, we lie about the root hub descriptor
because the changes won't effect how the core talks to the root hub.
Later we will need to add the USB 3.0 hub descriptor for real hubs, and
this code might change.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Add route string to struct usb_device.
Sarah Sharp [Tue, 28 Apr 2009 02:54:49 +0000 (19:54 -0700)]
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>
14 years agoUSB: Don't reset USB 3.0 devices on port change detection.
Sarah Sharp [Tue, 28 Apr 2009 02:54:26 +0000 (19:54 -0700)]
USB: Don't reset USB 3.0 devices on port change detection.

The USB 3.0 bus specification defines a new connection sequence for USB 3.0
hubs and roothubs.  USB 3.0 devices are reset and link trained by the hub
before the port status change notification is sent to the host OS.  This means
that an entire tree of devices can be trained in parallel on power up, and the
OS no longer needs to reset USB 3.0 devices.  Change the USB core's hub port
init sequence so that it does not reset USB 3.0 devices.

The port status change from the roothub and from the USB 3.0 hub will report
the SuperSpeed connect correctly.  This patch currently only handles the
roothub case.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Add USB 3.0 roothub support to USB core.
Sarah Sharp [Tue, 28 Apr 2009 02:55:01 +0000 (19:55 -0700)]
USB: Add USB 3.0 roothub support to USB core.

Add USB 3.0 root hub descriptors.  This is a kludge because I reused the old
USB 2.0 descriptors, instead of using the new USB 3.0 hub descriptors with
endpoint companion descriptors and other descriptors.  I did this because I
wasn't ready to add USB 3.0 hub changes to khubd.  For now, a USB 3.0 roothub
looks like a USB 2.0 roothub, with a higher speed.

USB 3.0 hubs have no transaction translator (TT).

Make USB core debugging handle super speed ports.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Add SuperSpeed to the list of USB device speeds.
Sarah Sharp [Tue, 28 Apr 2009 02:54:10 +0000 (19:54 -0700)]
USB: Add SuperSpeed to the list of USB device speeds.

Modify the USB core to handle the new USB 3.0 speed, "SuperSpeed".  This
is 5.0 Gbps (wire speed).  There are probably more places that check for
speed that I've missed.

SuperSpeed devices have a 512 byte endpoint 0 max packet size.  This shows
up as a bMaxPacketSize0 set to 0x09 (see table 9-8 of the USB 3.0 bus
spec).

xHCI spec says that the xHC can handle intervals up to 2^15 microframes.  That
might change when real silicon becomes available.

Add FIXME note for SuperSpeed isochronous endpoints.  They can transmit up
to 16 packets in one "burst" before they wait for an acknowledgment of the
packets.  They can do up to 3 bursts per microframe (determined by the
mult value in the endpoint companion descriptor).  The xHCI driver doesn't
have support for isoc yet, so fix this later.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: No-op command queueing and irq handler.
Sarah Sharp [Tue, 28 Apr 2009 02:53:56 +0000 (19:53 -0700)]
USB: xhci: No-op command queueing and irq handler.

xHCI host controllers can optionally implement a no-op test.  This
simple test ensures the OS has correctly setup all basic data structures
and can correctly respond to interrupts from the host controller
hardware.

There are two rings exercised by the no-op test:  the command ring, and
the event ring.

The host controller driver writes a no-op command TRB to the command
ring, and rings the doorbell for the command ring (the first entry in
the doorbell array).  The hardware receives this event, places a command
completion event on the event ring, and fires an interrupt.

The host controller driver sees the interrupt, and checks the event ring
for TRBs it can process, and sees the command completion event.  (See
the rules in xhci-ring.c for who "owns" a TRB.  This is a simplified set
of rules, and may not contain all the details that are in the xHCI 0.95
spec.)

A timer fires every 60 seconds to debug the state of the hardware and
command and event rings.  This timer only runs if
CONFIG_USB_XHCI_HCD_DEBUGGING is 'y'.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Device context array allocation.
Sarah Sharp [Tue, 28 Apr 2009 02:53:42 +0000 (19:53 -0700)]
USB: xhci: Device context array allocation.

Instead of keeping a "frame list" like older host controllers, the xHCI
host controller keeps internal representations of the USB devices, with a
transfer ring per endpoint.  The host controller queues Transfer Request
Blocks (TRBs) to the endpoint ring, and then "rings the doorbell" for that
device.  The host controller processes the transfer, places a transfer
completion event on the event ring, and interrupts the system.

The device context base address array must be allocated by the xHCI host
controller driver, along with the device contexts it points to.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Ring allocation and initialization.
Sarah Sharp [Tue, 28 Apr 2009 02:52:34 +0000 (19:52 -0700)]
USB: xhci: Ring allocation and initialization.

Allocate basic xHCI host controller data structures.  For every xHC, there
is a command ring, an event ring, and a doorbell array.

The doorbell array is used to notify the host controller that work has
been enqueued onto one of the rings.  The host controller driver enqueues
commands on the command ring.  The HW enqueues command completion events
on the event ring and interrupts the system (currently using PCI
interrupts, although the xHCI HW will use MSI interrupts eventually).

All rings and the doorbell array must be allocated by the xHCI host
controller driver.

Each ring is comprised of one or more segments, which consists of 16-byte
Transfer Request Blocks (TRBs) that can be chained to form a Transfer
Descriptor (TD) that represents a multiple-buffer request.  Segments are
linked into a ring using Link TRBs, which means they are dynamically
growable.

The producer of the ring enqueues a TD by writing one or more TRBs in the
ring and toggling the TRB cycle bit for each TRB.  The consumer knows it
can process the TRB when the cycle bit matches its internal consumer cycle
state for the ring.  The consumer cycle state is toggled an odd amount of
times in the ring.

An example ring (a ring must have a minimum of 16 TRBs on it, but that's
too big to draw in ASCII art):

              chain  cycle
               bit    bit
 ------------------------
| TD A TRB 1 |  1  |  1  |<-------------  <-- consumer dequeue ptr
 ------------------------               |     consumer cycle state = 1
| TD A TRB 2 |  1  |  1  |              |
 ------------------------               |
| TD A TRB 3 |  0  |  1  |  segment 1   |
 ------------------------               |
| TD B TRB 1 |  1  |  1  |              |
 ------------------------               |
| TD B TRB 2 |  0  |  1  |              |
 ------------------------               |
| Link TRB   |  0  |  1  |-----         |
 ------------------------     |         |
                              |         |
              chain  cycle    |         |
               bit    bit     |         |
 ------------------------     |         |
| TD C TRB 1 |  0  |  1  |<----         |
 ------------------------               |
| TD D TRB 1 |  1  |  1  |              |
 ------------------------               |
| TD D TRB 2 |  1  |  1  |   segment 2  |
 ------------------------               |
| TD D TRB 3 |  1  |  1  |              |
 ------------------------               |
| TD D TRB 4 |  1  |  1  |              |
 ------------------------               |
| Link TRB   |  1  |  1  |-----         |
 ------------------------     |         |
                              |         |
              chain  cycle    |         |
               bit    bit     |         |
 ------------------------     |         |
| TD D TRB 5 |  1  |  1  |<----         |
 ------------------------               |
| TD D TRB 6 |  0  |  1  |              |
 ------------------------               |
| TD E TRB 1 |  0  |  1  |   segment 3  |
 ------------------------               |
|            |  0  |  0  |              | <-- producer enqueue ptr
 ------------------------               |
|            |  0  |  0  |              |
 ------------------------               |
| Link TRB   |  0  |  0  |---------------
 ------------------------

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: BIOS handoff and HW initialization.
Sarah Sharp [Tue, 28 Apr 2009 02:52:28 +0000 (19:52 -0700)]
USB: xhci: BIOS handoff and HW initialization.

Add PCI initialization code to take control of the xHCI host controller
away from the BIOS, halt, and reset the host controller.  The xHCI spec
says that BIOSes must give up the host controller within 5 seconds.

Add some host controller glue functions to handle hardware initialization
and memory allocation for the host controller.  The current xHCI
prototypes use PCI interrupts, but the xHCI spec requires MSI-X
interrupts.  Add code to support MSI-X interrupts, but use the PCI
interrupts for now.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: xhci: Support xHCI host controllers and USB 3.0 devices.
Sarah Sharp [Tue, 28 Apr 2009 02:52:22 +0000 (19:52 -0700)]
USB: xhci: Support xHCI host controllers and USB 3.0 devices.

This is the first of many patches to add support for USB 3.0 devices and
the hardware that implements the eXtensible Host Controller Interface
(xHCI) 0.95 specification.  This specification is not yet publicly
available, but companies can receive a copy by becoming an xHCI
Contributor (see http://www.intel.com/technology/usb/xhcispec.htm).

No xHCI hardware has made it onto the market yet, but these patches have
been tested under the Fresco Logic host controller prototype.

This patch adds the xHCI register sets, which are grouped into five sets:
 - Generic PCI registers
 - Host controller "capabilities" registers (cap_regs) short
 - Host controller "operational" registers (op_regs)
 - Host controller "runtime" registers (run_regs)
 - Host controller "doorbell" registers

These some of these registers may be virtualized if the Linux driver is
running under a VM.  Virtualization has not been tested for this patch.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbtmc: fix switch statment
Greg Kroah-Hartman [Mon, 15 Jun 2009 20:13:05 +0000 (13:13 -0700)]
USB: usbtmc: fix switch statment

Steve Holland pointed out that we forgot to call break; in the switch
statment.  This probably resolves a lot of the bug reports I've gotten
for the driver lately.

Stupid me...

Reported-by: Steve Holland <sdh4@iastate.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usbtest fix endless loop in unlink tests.
Martin Fuzzey [Thu, 4 Jun 2009 21:20:38 +0000 (23:20 +0200)]
USB: usbtest fix endless loop in unlink tests.

In tests 11 and 12 if the URB completes with an error status (eg babble)
the asynchrous unlink entered an endless loop trying to unlink
a non resubmitted URB.

Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: atmel_usba_udc: change way of specifying bias function
Nicolas Ferre [Fri, 5 Jun 2009 15:46:16 +0000 (17:46 +0200)]
USB: atmel_usba_udc: change way of specifying bias function

The toggle_bias() function was specified differently for avr32 and at91
architectures. Now, new at91 have the same behavior as avr32.
Consequently, we change to a particular chip function definition: only for
at91sam9rl.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Avoid PM error messages during resume if a device was disconnected
Frans Pop [Thu, 4 Jun 2009 20:30:48 +0000 (22:30 +0200)]
USB: Avoid PM error messages during resume if a device was disconnected

Currently if a laptop is suspended e.g. while docked and then resumed after
undocking it, the following errors get generated because the USB hub in the
docking station and the devices connected to it are no longer available:
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2 failed to resume: error -19
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2.2 failed to resume: error -19
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2.3 failed to resume: error -19

As the removal of USB devices while a system is suspended is a relatively
common use case and in most cases not an error, just return success on
-ENODEV. The user gets informed anyway as the USB subsystem generates
regular disconnect messages for the devices shortly afterwards:
usb 1-2: USB disconnect, address 3
usb 1-2.2: USB disconnect, address 4
usblp0: removed
usb 1-2.3: USB disconnect, address 5

Signed-off-by: Frans Pop <elendil@planet.nl>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Add Intel Langwell USB OTG Transceiver Drive
Hao Wu [Thu, 4 Jun 2009 08:06:50 +0000 (16:06 +0800)]
USB: Add Intel Langwell USB OTG Transceiver Drive

Description:
This driver is used for Intel Langwell* USB OTG controller in Intel
Moorestown* platform. It tries to implement host/device role switch
according to OTG spec.  The actual hsot and device functions are
accomplished in modified EHCI driver and Intel Langwell USB OTG client
controller driver.

* Langwell and Moorestown are names used in development. They are not
  approved official name.

Note:
This patch is the first version Intel Langwell USB OTG Transceiver
driver. The development is not finished, and the bug fixing is on going
for some hardware and software issues. The main purpose of this
submission is for code view.

Supported features:
- Data-line Pulsing SRP
- Support HNP to switch roles
- PCI D0/D3 power management support

Known issues:
- HNP is only tested with another Moorestown platform.
- PCI D0/D3 power management support is not fully tested.
- VBus Pulsing SRP is not support in current version.

Signed-off-by: Hao Wu <hao.wu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Add Intel Langwell USB Device Controller driver
Xiaochen Shen [Thu, 4 Jun 2009 07:34:49 +0000 (15:34 +0800)]
USB: Add Intel Langwell USB Device Controller driver

Intel Langwell USB Device Controller is a High-Speed USB OTG device
controller in Intel Moorestown platform. It can work in OTG device mode
with Intel Langwell USB OTG transceiver driver as well as device-only
mode. The number of programmable endpoints is different through
controller revision.

NOTE:
This patch is the first version Intel Langwell USB OTG device controller
driver. The bug fixing is on going for some hardware and software
issues.  Intel Langwell USB OTG transceiver driver and EHCI driver
patches will be submitted later.

Supported features:
 - USB OTG protocol support with Intel Langwell USB OTG transceiver
   driver (turn on CONFIG_USB_LANGWELL_OTG)
 - Support control, bulk, interrupt and isochronous endpoints
   (isochronous not tested)
 - PCI D0/D3 power management support
 - Link Power Management (LPM) support

Tested gadget drivers:
 - g_file_storage
 - g_ether
 - g_zero

The passed tests:
 - g_file_storage: USBCV Chapter 9 tests
 - g_file_storage: USBCV MSC tests
 - g_file_storage: from/to host files copying
 - g_ether: ping, ftp and scp files from/to host
 - Hotplug, with and without hubs

Known issues:
 - g_ether: failed part of USBCV chap9 tests
 - LPM support not fully tested

TODO:
 - g_ether: pass all USBCV chap9 tests
 - g_zero: pass usbtest tests
 - Stress tests on different gadget drivers
 - On-chip private SRAM caching support

Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb-serial: replace shutdown with disconnect, release
Alan Stern [Tue, 2 Jun 2009 15:53:55 +0000 (11:53 -0400)]
USB: usb-serial: replace shutdown with disconnect, release

This patch (as1254) splits up the shutdown method of usb_serial_driver
into a disconnect and a release method.

The problem is that the usb-serial core was calling shutdown during
disconnect handling, but drivers didn't expect it to be called until
after all the open file references had been closed.  The result was an
oops when the close method tried to use memory that had been
deallocated by shutdown.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb-serial: call port_probe and port_remove at the right times
Alan Stern [Tue, 2 Jun 2009 15:54:11 +0000 (11:54 -0400)]
USB: usb-serial: call port_probe and port_remove at the right times

This patch (as1253) prevents the usb-serial core from calling a
driver's port_probe and port_remove methods more than once per port.
It also removes some unnecessary try_module_get() calls and adds a
missing port_remove method call in a failure path.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: add USB Audio Gadget driver
Bryan Wu [Wed, 3 Jun 2009 13:17:58 +0000 (09:17 -0400)]
USB: gadget: add USB Audio Gadget driver

Funtions added:
 - setup all the USB audio class device descriptors
 - handle class specific setup request
 - receive data from USB host by ISO transfer
 - play audio data by ALSA sound card
 - open and setup playback PCM interface
 - set default playback PCM parameters
 - provide playback functions for USB audio driver
 - provide PCM parameters set/get functions

Test on:
 - Host: Ubuntu 8.10, kernel 2.6.27
 - Gadget: EZKIT-BF548 with ASoC AD1980 codec

Todo:
 - add real Mute control code
 - add real Volume control code
 - maybe find another way to replace dynamic buffer handling
   with static buffer allocation
 - test on Windows system
 - provide control interface to handle mute/volume control
 - provide capture interface in the future
 - test on BF527, other USB device controler and other audio codec

Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: audio: add USB audio class definitions
Bryan Wu [Wed, 3 Jun 2009 13:17:57 +0000 (09:17 -0400)]
USB: audio: add USB audio class definitions

Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Gadget driver for Samsung HS/OtG block
Ben Dooks [Tue, 2 Jun 2009 13:58:06 +0000 (14:58 +0100)]
USB: Gadget driver for Samsung HS/OtG block

Driver support for the new high-speed/OtG block that is
in the newer line of Samsung SoC devices such as the
S3C64XX series.

This driver does not currntly have DMA support enabled due
to issues with buffer alignment which need to be sorted out.

Signed-off-by: Ben Dooks <ben@simtec.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: Add i.MX3x support to the fsl_usb2_udc driver
Guennadi Liakhovetski [Wed, 15 Apr 2009 12:25:33 +0000 (14:25 +0200)]
USB: gadget: Add i.MX3x support to the fsl_usb2_udc driver

This patch adds support for i.MX3x (only tested with i.MX31 so far) ARM
SoCs to the fsl_usb2_udc driver. It also moves PHY configuration before
controller reset, because otherwise an ULPI PHY doesn't get a reset and
doesn't function after a reboot. The problem with longer control transfers
is still not fixed. The patch renames the fsl_usb2_udc.c file to
fsl_udc_core.c to preserve the same module name for user-space
backwards compatibility.

Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb_serial: only allow sysrq on a console port
Jason Wessel [Fri, 29 May 2009 18:34:17 +0000 (13:34 -0500)]
USB: usb_serial: only allow sysrq on a console port

The only time a sysrq should get processed is if the attached device
is a console.  This is intended to protect sysrq execution on a host
connected with a terminal program.

Here is the problem scenario:

host A <-- rs232 link --> host B

Host A is using mincom and a usb pl2303 device to connect to host b
which is a linux system with a usb pl2303 device acting as the serial
console.  When host B is rebooted the pl2303 emits random junk
characters on reset.  These character sequences contain serial break
signals most of the time and when translated to a sysrq have caused
host A to get random processes killed, reboots or power down.

It is true that in this setup with this patch host B might still have
the same problem as host A if you reboot host A.  In most cases host A
is a development host which seldom gets rebooted, and you could turn
off sysrq temporarily on host B if you need to reboot host A.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: pl2303 usb_serial: implement sysrq handling on break
Jason Wessel [Fri, 29 May 2009 18:34:16 +0000 (13:34 -0500)]
USB: pl2303 usb_serial: implement sysrq handling on break

Add callbacks to process the sysrq when using a pl2303 usb device as a
console.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget : Fix RNDIS code to pass USB Compliance tests (USBCV) with g_ether
Maulik Mankad [Fri, 29 May 2009 13:04:40 +0000 (18:34 +0530)]
USB: gadget : Fix RNDIS code to pass USB Compliance tests (USBCV) with g_ether

This patch fixes a bug in the RNDIS code.

Due to this bug gether_connect() fails as the port remains un-initialized.

As a result following USB Compliance Tests were failing.
(1)EndpointDescriptorTest_DeviceConfigured
(2)Interface Descriptor Test.
(3)Halt Endpoint Test.
(4)SetConfigurationTest

The fix aligns rndis code with the CDC ECM for xxx_set_alt().

The above listed USB Compliance test passes with this fix.

Tested working fine on SDP with OMAP 3430.

Signed-off-by: Maulik Mankad <x0082077@ti.com>
CC: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: cdc-acm: quirk for Alcatel OT-I650
Kir Kolyshkin [Thu, 28 May 2009 16:33:58 +0000 (20:33 +0400)]
USB: cdc-acm: quirk for Alcatel OT-I650

This mobile phone fails to work as a modem, failing with:
 cdc_acm: Zero length descriptor references
 cdc_acm: probe of 1-6.1.3:1.1 failed with error -22

Tested to work fine with this patch.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: imx_udc: don't queue more data when zlp is to be sent
Daniel Glöckner [Thu, 28 May 2009 11:00:14 +0000 (13:00 +0200)]
USB: gadget: imx_udc: don't queue more data when zlp is to be sent

When a zero-length packet has been requested and another packet is
written into the fifo, the MX1 tends to send the first byte of the
previous packet instead of the first byte of the current packet.
The CRC is adjusted accordingly so that this packet is _not_
discarded by the host.

Waiting for the ZLPS bit to clear avoids these bad packets.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: gadget: g_serial: append zlp when tx buffer becomes empty
Daniel Glöckner [Thu, 28 May 2009 10:53:24 +0000 (12:53 +0200)]
USB: gadget: g_serial: append zlp when tx buffer becomes empty

Some usb serial host drivers expect a short packet before they forward
the data to the application. This is caused by them trying to read more
than one packet at a time. So when the gadget sends an exact multiple
of the maximum packet size, it should append a zero-length packet.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: replace dma_sync_single and dma_sync_sg with dma_sync_single_for_cpu and dma_syn...
FUJITA Tomonori [Thu, 28 May 2009 01:10:44 +0000 (10:10 +0900)]
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>
14 years agoUSB: EHCI: update toggle state for linked QHs
Alan Stern [Wed, 27 May 2009 22:21:56 +0000 (18:21 -0400)]
USB: EHCI: update toggle state for linked QHs

This patch (as1245) fixes a bug in ehci-hcd.  When an URB is queued
for an endpoint whose QH is already in the LINKED state, the QH
doesn't get refreshed.  As a result, if usb_clear_halt() was called
during the time that the QH was linked but idle, the data toggle value
in the QH doesn't get reset.

The symptom is that after a clear_halt, data gets lost and transfers
time out.  This problem is starting to show up now because the
"ehci-hcd unlink speedups" patch causes QHs with no queued URBs to
remain linked for a suitable time.

The patch utilizes the new endpoint_reset mechanism to fix the
problem.  When an endpoint is reset, the new method forcibly unlinks
the QH (if necessary) and safely updates the toggle value.  This
allows qh_update() to be simplified and avoids using usb_device's
toggle bits in a rather unintuitive way.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: David Brownell <david-b@pacbell.net>
Tested-by: David <david@unsolicited.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: r8a66597-hcd: use platform_data instead of module_param
Yoshihiro Shimoda [Tue, 26 May 2009 09:24:34 +0000 (18:24 +0900)]
USB: r8a66597-hcd: use platform_data instead of module_param

CPU/board specific parameters (PLL clock, vif etc...) can be set
by platform_data instead of module_param.

v2: remove irq_sense member in platform_data because it can OR in
    IRQF_TRIGGER_LOW or IRQF_TRIGGER_FALLING against IORESOURCE_IRQ in
    the struct resource.

Signed-off-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
Reviewed-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb-storage: add filter to "option_ms" to leave unrecognized devices alone
Josua Dietze [Sun, 24 May 2009 21:21:42 +0000 (23:21 +0200)]
USB: usb-storage: add filter to "option_ms" to leave unrecognized devices alone

Some unusual usb devices from the maker "Option" are switched from
storage to serial/modem mode by sending a SCSI REZERO command. In one
case a fairly common vendor/device ID is affected which led to problems
for users of other modems or phones which are not supposed to be
switched.

The patch adds a filter by reading the vendor name with the SCSI INQUIRY
command, and skips the switching code for all unrecognized entries.

Further changes are cleanups and corrections pointed out by Alan Stern.

Tested with two devices with the IDs 05c6:1000, one from "Option" and
switchable, and one from Samsung (cell phone).

Signed-off-by: Josua Dietze <digidietze@draisberghof.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: stagger frames for interrupt transfers
Alan Stern [Fri, 22 May 2009 21:02:33 +0000 (17:02 -0400)]
USB: EHCI: stagger frames for interrupt transfers

This patch (as1243) tries to improve ehci-hcd's scheduling of
interrupt transfers.  Instead of trying to cram all transfers with the
same period into the same frame, the new code will spread the
transfers out among lots of different frames.  This should reduce the
periodic schedule load in any one frame -- some host controllers have
trouble when there's too much work to do.

A more thorough approach would stagger the uframe values as well.  But
this is enough to make a big improvement.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Dwayne Fontenot <dwayne.fontenot@att.net>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb-storage: fix return values from init functions
Alan Stern [Thu, 21 May 2009 21:37:58 +0000 (17:37 -0400)]
USB: usb-storage: fix return values from init functions

This patch (as1242) fixes the return values from the special
init functions in usb-storage.  They are supposed to return 0 for
success, not USB_STOR_TRANSPORT_GOOD.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agousb: musb: disable OTG AUTOIDLE only with omap3430
Niilo Minkkinen [Mon, 18 May 2009 14:54:16 +0000 (17:54 +0300)]
usb: musb: disable OTG AUTOIDLE only with omap3430

Omap3 MUSB AUTOIDLE functionality configured through OTG_SYSCONFIG
register prevents the device from going into retention.
This is a workaround (by Richard Woodruff/TI), as his comment :
> A new MUSB bug which is a match to data below was identified very
> recently (on hardware and in simulation).
> This bug is in 3430 and not 3630.
> As a priority test (and as new default) you should have engineers
> disable autoidle for MUSB block.
> This is the workaround which will show up in next errata.

Signed-off-by: Niilo Minkkinen <ext-niilo.1.minkkinen@nokia.com>
Signed-off-by: Richard Woodruff <r-woodruff2@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: support for cdc-acm of single interface devices
Oliver Neukum [Sat, 16 May 2009 19:13:19 +0000 (21:13 +0200)]
USB: support for cdc-acm of single interface devices

This implement support in cdc-acm for acm devices another popular OS can handle

- adds support for autodetection of devices that use one interface
- autodetection of endpoints
- add a quirk for surpressing a setting that OS doesn't use
- autoassume that quirk for single interface devices

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years ago+ drivers-usb-serial-sierrac-fix-printk-warning.patch added to -mm tree
Andrew Morton [Tue, 12 May 2009 22:27:59 +0000 (15:27 -0700)]
+ drivers-usb-serial-sierrac-fix-printk-warning.patch added to -mm tree

drivers/usb/serial/sierra.c: In function 'sierra_write':
drivers/usb/serial/sierra.c:375: warning: format '%d' expects type 'int', but argument 5 has type 'size_t'

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Elina Pasheva <epasheva@sierrawireless.com>
Cc: Rory Filer <rfiler@SierraWireless.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: imx_udc: fix leak in imx_ep_alloc_request()
Daniel Mack [Tue, 12 May 2009 20:50:34 +0000 (13:50 -0700)]
USB: imx_udc: fix leak in imx_ep_alloc_request()

cppcheck found another leak in drivers/usb/gadget/imx_udc.c

Cc: Mike Lee <eemike@gmail.com>
Cc: Darius Augulis <augulis.darius@gmail.com>
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agousb: convert endpoint devices to bus-less childs of the usb interface
Kay Sievers [Mon, 4 May 2009 17:48:32 +0000 (19:48 +0200)]
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>
14 years agoUSB: serial: sierra driver sierra_calc_num_ports() fix
Elina Pasheva [Tue, 12 May 2009 20:12:54 +0000 (13:12 -0700)]
USB: serial: sierra driver sierra_calc_num_ports() fix

- Removed potential kernel oops from sierra_calc_num_ports() function.
  Calling this function twice would likely have caused an oops because
  the function releases allocated memory after the first call.
- Modified sierra_probe() function to reflect the changes in
  sierra_calc_num_ports().

Signed-off-by: Elina Pasheva <epasheva@sierrawireless.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: sierra driver interrupt urb resubmit fix
Elina Pasheva [Tue, 12 May 2009 20:12:37 +0000 (13:12 -0700)]
USB: serial: sierra driver interrupt urb resubmit fix

- Fixed a problem when re-submitting urb from interrupt callback in
  function sierra_instat_callback(). This suppresses also issuing of
  error messages in /var/log/kern.log
- Removed redundant debug message at the beginning of
  sierra_instat_callback() function
- Changed a debug message to be an error message

Signed-off-by: Elina Pasheva <epasheva@sierrawireless.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: sierra driver zero length packet fix
Elina Pasheva [Tue, 12 May 2009 20:12:24 +0000 (13:12 -0700)]
USB: serial: sierra driver zero length packet fix

- Fixed a problem with transferring packets with size a multiple of Bulk
  Xfer size in function sierra_write(). Added transfer flag
  URB_ZERO_PACKET before submitting the urb to trigger Zero-length data
  transfer when packet size is a multiple of Bulk Xfer.

Signed-off-by: Elina Pasheva <epasheva@sierrawireless.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: ftd_sio: implement sysrq handling on break
Jason Wessel [Mon, 11 May 2009 20:24:10 +0000 (15:24 -0500)]
USB: serial: ftd_sio: implement sysrq handling on break

Change driver to make use of the new functions in
include/linux/usb/serial.h so as to allow the driver to handle the
sysrq

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: usb_debug,usb_generic_serial: implement sysrq and serial break
Jason Wessel [Mon, 11 May 2009 20:24:09 +0000 (15:24 -0500)]
USB: serial: usb_debug,usb_generic_serial: implement sysrq and serial break

The usb_debug driver was modified to implement serial break handling
by using a "magic" data packet comprised of the sequence:

       0x00 0xff 0x01 0xfe   0x00 0xfe 0x01 0xff

When the tty layer requests a serial break the usb_debug driver sends
the magic packet.  On the receiving side the magic packet is thrown
away or a sysrq is activated depending on what kernel .config options
have been set.

The generic serial driver was modified as well as the usb serial
headers to generically implement sysrq processing in the same way the
non usb uart based drivers implement the sysrq handling.  This will
allow other usb serial devices to implement sysrq handling as desired.

The new usb serial functions are named similarly and implemented
similarly to the uart functions as follows:

usb_serial_handle_break <-> uart_handle_break
usb_serial_handle_sysrq_char <-> uart_handle_sysrq_char

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: ftd_sio usb: move status check
Jason Wessel [Mon, 11 May 2009 20:24:08 +0000 (15:24 -0500)]
USB: serial: ftd_sio usb: move status check

Alan Stern commented that the private driver counts must be updated
regard less of the status return on the urb when the write call back
is executed.

This patch alters the behavior to update the private driver counts by
simply moving the status check to after the driver count update.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb_debug, usb_generic_serial: implement multi urb write
Jason Wessel [Mon, 11 May 2009 20:24:07 +0000 (15:24 -0500)]
USB: usb_debug, usb_generic_serial: implement multi urb write

The usb_debug driver, when used as the console, will always fail to
insert the carriage return and new line sequence as well as randomly
drop console output.  This is a result of only having the single
write_urb and that the tty layer will have a lock that prevents the
processing of the back to back urb requests.

The solution is to allow more than one urb to be outstanding and have
a slightly deeper transmit queue.  The idea and some code is borrowed
from the ftdi_sio usb driver.

The generic usb serial driver was modified so as to allow the classic
method of 1 write urb, or a multi write urb scheme with N allowed
outstanding urbs where N is controlled by max_in_flight_urbs.  When
max_in_flight_urbs in a "struct usb_serial_driver" is non zero the
multi write urb scheme will be used.

The size of 4000 was selected for the usb_debug driver so that the
driver lowers possibility of losing the queued console messages during
the kernel startup.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: sierra driver read path bug fix
Elina Pasheva [Wed, 29 Apr 2009 17:29:21 +0000 (10:29 -0700)]
USB: serial: sierra driver read path bug fix

This patch fixes a problem in function sierra_indat_callback() which
would stop receiving traffic from a modem if a number of URB failures
occur.  Failed URBs are not resubmitted for the next read and there is
only a limited number of URBs allocated for the IN path. After this
number of failures, the receive path stops working on a particular
interface.

Signed-off-by: Elina Pasheva <epasheva@sierrawireless.com>
14 years agoUSB: serial: sierra driver write path improvements
Elina Pasheva [Wed, 29 Apr 2009 17:26:46 +0000 (10:26 -0700)]
USB: serial: sierra driver write path improvements

- Updated Copyright notice with new authors names
 - Version number set to 1.3.6
 - Added a MAX_TRANSFER constant following Greg Kroah-Hartman's
   recommended setting of PAGE_SIZE-512 for USB transfer buffers and
   modified accordingly sierra_write() function.

Signed-off-by: Elina Pasheva <epasheva@sierrawireless.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: janitor storage initializers
Pete Zaitcev [Wed, 29 Apr 2009 22:02:18 +0000 (16:02 -0600)]
USB: janitor storage initializers

We all know that pointless janitoring is bad, but this code is just
offensive. So:

- The error code goes directly to probe return, so don't return -1.
- Don't return return internal usb-storage codes either.
- usb_stor_control_msg takes timeout in milliseconds.
- Sanitize messages.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: usb.h: change private: kernel-doc for new format requirement
Randy Dunlap [Thu, 30 Apr 2009 04:02:49 +0000 (21:02 -0700)]
USB: usb.h: change private: kernel-doc for new format requirement

Use "/* private:" to mark struct members as private so that
scripts/kernel-doc will handle them correctly.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: composite.h: mark private struct members as private:
Randy Dunlap [Thu, 30 Apr 2009 04:04:19 +0000 (21:04 -0700)]
USB: composite.h: mark private struct members as private:

Mark internal struct members as /* private: */ so that kernel-doc
won't produce warnings about missing descriptions for them.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agowusb: hwa-hc: Drop unused pci_suspend/resume hooks.
Paul Mundt [Thu, 30 Apr 2009 08:41:02 +0000 (17:41 +0900)]
wusb: hwa-hc: Drop unused pci_suspend/resume hooks.

CC      drivers/usb/host/hwa-hc.o
drivers/usb/host/hwa-hc.c:601: warning: initialization from incompatible pointer type
drivers/usb/host/hwa-hc.c:602: warning: initialization from incompatible pointer type

The prototype for these changed, so the message itself was dropped. As the only
thing these hooks were doing was printing out the message for debugging, there
is not much point in keeping them around. So, just kill them off.

Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: garmin_gps: removes usb_reset_device from garmin_close
Hermann Kneissel [Sun, 26 Apr 2009 20:42:04 +0000 (22:42 +0200)]
USB: garmin_gps: removes usb_reset_device from garmin_close

The following patch removes the call to usb_reset_device which may occur
when closing the driver by implementing a new session initialization
code based on the method used by gpsbabel.

The patch is against  linux-2.6.30-rc3-git1.

Signed-off-by: Hermann Kneissel herkne@users.sourceforge.net
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: Identify Novatel MC760 in option driver
Richard Laager [Mon, 27 Apr 2009 01:56:20 +0000 (20:56 -0500)]
USB: Identify Novatel MC760 in option driver

Identify the Novatel MC760/U760/USB760 in the option USB serial driver.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: new flag for resume-from-hibernation
Alan Stern [Mon, 27 Apr 2009 17:33:41 +0000 (13:33 -0400)]
USB: new flag for resume-from-hibernation

This patch (as1237) changes the way the PCI host controller drivers
avoid retaining bogus hardware states during resume-from-hibernation.
Previously we had reset the hardware as part of preparing to reinstate
the memory image.  But we can do better now with the new PM framework,
since we know exactly which resume operations are from hibernation.

The pci_resume method is changed to accept a flag indicating whether
the system is resuming from hibernation.  When this flag is set, the
drivers will reset the hardware to get rid of any existing state.

Similarly, the pci_suspend method is changed to remove the
pm_message_t argument.  It's no longer needed, since no special action
has to be taken when preparing to reinstate the memory image.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: move PCI host controllers to new PM framework
Alan Stern [Mon, 27 Apr 2009 17:33:24 +0000 (13:33 -0400)]
USB: move PCI host controllers to new PM framework

This patch (as1236) converts the USB PCI power management routines
over to the new PM framework.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoPCI: add power-state name strings
Alan Stern [Mon, 27 Apr 2009 17:33:16 +0000 (13:33 -0400)]
PCI: add power-state name strings

This patch (as1235) adds an array of PCI power-state names, together
with a simple inline accessor routine.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: g_file_storage: use the "unaligned" accessors
Alan Stern [Mon, 27 Apr 2009 17:19:41 +0000 (13:19 -0400)]
USB: g_file_storage: use the "unaligned" accessors

This patch (as1233) makes g_file_storage use the "unaligned" accessors.
This is based on work originally done by Harvey Harrison.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Harvey Harrison <harvey.harrison@gmail.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: sierra driver debug info visibility improvement
Elina Pasheva [Tue, 28 Apr 2009 01:41:52 +0000 (18:41 -0700)]
USB: serial: sierra driver debug info visibility improvement

- Version number set to 1.3.5
 - Added "\n" at the end of each string in dev_dbg() code to improve the debug
   information visibility. Without this change the debug logs are very
   difficult to read.

Signed-off-by: Elina Pasheva <epasheva@sierrawireless.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: serial: sierra driver performance improvements
Elina Pasheva [Sat, 25 Apr 2009 01:41:49 +0000 (18:41 -0700)]
USB: serial: sierra driver performance improvements

- Version number set to 1.3.4
 - Increased the number of input/output URBs for improved performance
   (numbers based on an measurement study triggered by a user request).
   We performed the testing using a network simulator that provided full
   speeds in the uplink and downlink directions and this combination of
   URBs provided the best throughput.

Signed-off-by: Elina Pasheva <epasheva@sierrawireless.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: remove unused usb_host class
Greg Kroah-Hartman [Mon, 27 Apr 2009 20:17:21 +0000 (13:17 -0700)]
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>
14 years agoUSB: EHCI: create sysfs companion files directly in the controller device
Greg Kroah-Hartman [Mon, 27 Apr 2009 20:15:38 +0000 (13:15 -0700)]
USB: EHCI: create sysfs companion files directly in the controller device

The controller device is where we want this sysfs file, especially as
the dev pointer is about to go away...

Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: OHCI: use the ohci structure directly in debugfs files.
Greg Kroah-Hartman [Mon, 27 Apr 2009 20:12:58 +0000 (13:12 -0700)]
USB: OHCI: use the ohci structure directly in debugfs files.

Right now we jump through some hoops to get to the struct ohci_hcd
struct in the ohci debugfs files.  Remove all of the fun casting around
and just use the pointer directly.

This is needed as the dev pointer in the hcd structure is going away,
and it makes the code simpler and smaller

Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoNLS: update handling of Unicode
Alan Stern [Thu, 30 Apr 2009 14:08:18 +0000 (10:08 -0400)]
NLS: update handling of Unicode

This patch (as1239) updates the kernel's treatment of Unicode.  The
character-set conversion routines are well behind the current state of
the Unicode specification: They don't recognize the existence of code
points beyond plane 0 or of surrogate pairs in the UTF-16 encoding.

The old wchar_t 16-bit type is retained because it's still used in
lots of places.  This shouldn't cause any new problems; if a
conversion now results in an invalid 16-bit code then before it must
have yielded an undefined code.

Difficult-to-read names like "utf_mbstowcs" are replaced with more
transparent names like "utf8s_to_utf16s" and the ordering of the
parameters is rationalized (buffer lengths come immediate after the
pointers they refer to, and the inputs precede the outputs).
Fortunately the low-level conversion routines are used in only a few
places; the interfaces to the higher-level uni2char and char2uni
methods have been left unchanged.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agousb: return device strings in UTF-8
Clemens Ladisch [Fri, 24 Apr 2009 08:12:18 +0000 (10:12 +0200)]
usb: return device strings in UTF-8

Change the encoding of strings returned by usb_string() from ISO 8859-1
to UTF-8.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agonls: utf8_wcstombs: fix buffer overflow
Clemens Ladisch [Fri, 24 Apr 2009 08:11:56 +0000 (10:11 +0200)]
nls: utf8_wcstombs: fix buffer overflow

utf8_wcstombs forgot to include one-byte UTF-8 characters when
calculating the output buffer size, i.e., theoretically, it was possible
to overflow the output buffer with an input string that contains enough
ASCII characters.

In practice, this was no problem because the only user so far (VFAT)
always uses a big enough output buffer.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agonls: utf8_wcstombs: use correct buffer size in error case
Clemens Ladisch [Fri, 24 Apr 2009 08:11:40 +0000 (10:11 +0200)]
nls: utf8_wcstombs: use correct buffer size in error case

When utf8_wcstombs encounters a character that cannot be encoded, we
must not decrease the remaining output buffer size because nothing has
been written to the output buffer.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: add the usbfs devices file to debugfs
Greg Kroah-Hartman [Fri, 24 Apr 2009 22:16:04 +0000 (15:16 -0700)]
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>
14 years agoUSB: usbmon: use the new usb debugfs directory
Greg Kroah-Hartman [Fri, 24 Apr 2009 22:15:49 +0000 (15:15 -0700)]
USB: usbmon: use the new usb debugfs directory

All usb debugfs files should be behind the usb directory, not at the
root of debugfs.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: UHCI: use the new usb debugfs directory
Greg Kroah-Hartman [Fri, 24 Apr 2009 22:15:00 +0000 (15:15 -0700)]
USB: UHCI: use the new usb debugfs directory

All usb debugfs files should be behind the usb directory, not at the
root of debugfs.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: OHCI: use the new usb debugfs directory
Greg Kroah-Hartman [Fri, 24 Apr 2009 22:14:38 +0000 (15:14 -0700)]
USB: OHCI: use the new usb debugfs directory

All usb debugfs files should be behind the usb directory, not at the
root of debugfs.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: FHCI: use the new usb debugfs directory
Greg Kroah-Hartman [Fri, 24 Apr 2009 22:14:25 +0000 (15:14 -0700)]
USB: FHCI: use the new usb debugfs directory

All usb debugfs files should be behind the usb directory, not at the
root of debugfs.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: EHCI: use the new usb debugfs directory
Greg Kroah-Hartman [Fri, 24 Apr 2009 22:13:18 +0000 (15:13 -0700)]
USB: EHCI: use the new usb debugfs directory

All usb debugfs files should be behind the usb directory, not at the
root of debugfs.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: add usb debugfs directory
Greg Kroah-Hartman [Fri, 24 Apr 2009 21:56:26 +0000 (14:56 -0700)]
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>
14 years agoUSB: mos7840: fix debug log messages
Tony Cook [Sat, 18 Apr 2009 13:25:06 +0000 (22:55 +0930)]
USB: mos7840: fix debug log messages

This patch removes all the unnecessary "\n"s that the debug print
statements have, which result in everything appearing double spaced
and unreadable in the logs.

Signed-off-by: Tony Cook <tony-cook@bigpond.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: hub.c: fix sparse warnings
H Hartley Sweeten [Wed, 22 Apr 2009 20:03:05 +0000 (16:03 -0400)]
USB: hub.c: fix sparse warnings

Fix sparse warning in drivers/usb/core/hub.c.

The following sparse warning is seen when building on ARM due
do the macro raw_local_irq_save():

warning: symbol 'temp' shadows an earlier one

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: host/ohci-hcd.c: fix sparse warnings
H Hartley Sweeten [Wed, 22 Apr 2009 20:18:59 +0000 (16:18 -0400)]
USB: host/ohci-hcd.c: fix sparse warnings

Fix sparse warnings in drivers/usb/host/ohci-hcd.c.

Four of the following sparse warning are seen when building on
ARM due do the macro raw_local_irq_save():

warning: symbol 'temp' shadows an earlier one

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: pxa27x_udc: single-thread setup requests
Robert Jarzmik [Wed, 22 Apr 2009 03:41:03 +0000 (20:41 -0700)]
USB: pxa27x_udc: single-thread setup requests

Since the PXA 27x UDC automatically ACK's some control
packets such as SET_INTERFACE, the gadgets may not get a
chance to process the request before another control packet
is received. The Linux gadgets do not expect to receive
setup callbacks out of order. The file storage gadget only
saves the "highest" priority request.

The PXA27x UDC driver must make sure it only sends one up at
a time, allowing the gadget to make changes before
continuing. In theory, the host would be NACK'd while the
gadget processes the change but the UDC has already ACK'd
the request. If another request is sent by the host that is
not automatically ACK'd by the UDC, then the throttling
happens properly to regain sync.

The observed case was the file_storage gadget timing out on
a BulkReset request because the SET_INTERFACE was being
processed by the gadget. Since SET_INTERFACE is higher
priority than BulkReset, the BulkReset was dropped.  This
was exacerbated by turning on the debug which delayed the
fsg signal processing thread.

This also fixes the "should never get in
WAIT_ACK_SET_CONF_INTERF state here!!!" warning.

Reported-by: Vernon Sauder <vernoninhand@gmail.com>
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
index 51790b0..1937d8c 100644

14 years agoUSB: pxa27x_udc: compatibility with pxa320 SoC
Robert Jarzmik [Wed, 22 Apr 2009 03:34:44 +0000 (20:34 -0700)]
USB: pxa27x_udc: compatibility with pxa320 SoC

Got pxa27x_udc working on the pxa320 Nomad platform.  The
problem was that the pxa3xx UDC is not quite compatible with
the pxa27x UDC in how it handles back-to-back control
packets.  The pxa27x probably drops them by default, but the
pxa320 does not, and you have to detect it and set the OPC
bit to clear the zero-length packet.

Signed-off-by: Aric Blumer <aric@sdgsystems.com>
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 years agoUSB: pxa27x_udc: introduce pxa27x_clear_otgph()
David Brownell [Wed, 22 Apr 2009 03:34:24 +0000 (20:34 -0700)]
USB: pxa27x_udc: introduce pxa27x_clear_otgph()

Follow pxa27x change in OTGPH handling, and use the newly
defined pxa27x_clear_otgph().

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Eric Miao <eric.miao@marvell.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
14 years agoUSB: UHCI queue: use usb_endpoint_type()
Matthias Kaehlcke [Wed, 15 Apr 2009 20:28:28 +0000 (22:28 +0200)]
USB: UHCI queue: use usb_endpoint_type()

use usb_endpoint_type() instead of fiddling manually with bmAttributes

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>