Commit c2a84d00 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://linuxusb.bkbits.net/linus-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents 6188af0c 27f49742
...@@ -113,6 +113,9 @@ APISOURCES := $(TOPDIR)/drivers/media/video/videodev.c \ ...@@ -113,6 +113,9 @@ APISOURCES := $(TOPDIR)/drivers/media/video/videodev.c \
$(TOPDIR)/drivers/net/wan/syncppp.c \ $(TOPDIR)/drivers/net/wan/syncppp.c \
$(TOPDIR)/drivers/net/wan/z85230.c \ $(TOPDIR)/drivers/net/wan/z85230.c \
$(TOPDIR)/drivers/usb/core/hcd.c \ $(TOPDIR)/drivers/usb/core/hcd.c \
$(TOPDIR)/drivers/usb/core/urb.c \
$(TOPDIR)/drivers/usb/core/message.c \
$(TOPDIR)/drivers/usb/core/config.c \
$(TOPDIR)/drivers/usb/core/usb.c \ $(TOPDIR)/drivers/usb/core/usb.c \
$(TOPDIR)/drivers/video/fbmem.c \ $(TOPDIR)/drivers/video/fbmem.c \
$(TOPDIR)/drivers/video/fbcmap.c \ $(TOPDIR)/drivers/video/fbcmap.c \
......
...@@ -282,6 +282,9 @@ ...@@ -282,6 +282,9 @@
</sect1> </sect1>
<sect1><title>USB Core APIs</title> <sect1><title>USB Core APIs</title>
!Edrivers/usb/core/urb.c
!Edrivers/usb/core/config.c
!Edrivers/usb/core/message.c
!Edrivers/usb/core/usb.c !Edrivers/usb/core/usb.c
</sect1> </sect1>
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
# Makefile for USB Core files and filesystem # Makefile for USB Core files and filesystem
# #
export-objs := usb.o hcd.o export-objs := usb.o hcd.o urb.o message.o config.o
usbcore-objs := usb.o usb-debug.o hub.o hcd.o usbcore-objs := usb.o usb-debug.o hub.o hcd.o urb.o message.o \
config.o
ifeq ($(CONFIG_USB_DEVICEFS),y) ifeq ($(CONFIG_USB_DEVICEFS),y)
usbcore-objs += devio.o inode.o drivers.o devices.o usbcore-objs += devio.o inode.o drivers.o devices.o
......
This diff is collapsed.
This diff is collapsed.
#include <linux/config.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/bitops.h>
#include <linux/slab.h>
#include <linux/init.h>
#ifdef CONFIG_USB_DEBUG
#define DEBUG
#else
#undef DEBUG
#endif
#include <linux/usb.h>
#include "hcd.h"
/**
* usb_alloc_urb - creates a new urb for a USB driver to use
* @iso_packets: number of iso packets for this urb
* @mem_flags: the type of memory to allocate, see kmalloc() for a list of
* valid options for this.
*
* Creates an urb for the USB driver to use, initializes a few internal
* structures, incrementes the usage counter, and returns a pointer to it.
*
* If no memory is available, NULL is returned.
*
* If the driver want to use this urb for interrupt, control, or bulk
* endpoints, pass '0' as the number of iso packets.
*
* The driver must call usb_free_urb() when it is finished with the urb.
*/
struct urb *usb_alloc_urb(int iso_packets, int mem_flags)
{
struct urb *urb;
urb = (struct urb *)kmalloc(sizeof(struct urb) +
iso_packets * sizeof(struct usb_iso_packet_descriptor),
mem_flags);
if (!urb) {
err("alloc_urb: kmalloc failed");
return NULL;
}
memset(urb, 0, sizeof(*urb));
urb->count = (atomic_t)ATOMIC_INIT(1);
spin_lock_init(&urb->lock);
return urb;
}
/**
* usb_free_urb - frees the memory used by a urb when all users of it are finished
* @urb: pointer to the urb to free
*
* Must be called when a user of a urb is finished with it. When the last user
* of the urb calls this function, the memory of the urb is freed.
*
* Note: The transfer buffer associated with the urb is not freed, that must be
* done elsewhere.
*/
void usb_free_urb(struct urb *urb)
{
if (urb)
if (atomic_dec_and_test(&urb->count))
kfree(urb);
}
/**
* usb_get_urb - increments the reference count of the urb
* @urb: pointer to the urb to modify
*
* This must be called whenever a urb is transfered from a device driver to a
* host controller driver. This allows proper reference counting to happen
* for urbs.
*
* A pointer to the urb with the incremented reference counter is returned.
*/
struct urb * usb_get_urb(struct urb *urb)
{
if (urb) {
atomic_inc(&urb->count);
return urb;
} else
return NULL;
}
/*-------------------------------------------------------------------*/
/**
* usb_submit_urb - asynchronously issue a transfer request for an endpoint
* @urb: pointer to the urb describing the request
* @mem_flags: the type of memory to allocate, see kmalloc() for a list
* of valid options for this.
*
* This submits a transfer request, and transfers control of the URB
* describing that request to the USB subsystem. Request completion will
* indicated later, asynchronously, by calling the completion handler.
* This call may be issued in interrupt context.
*
* The caller must have correctly initialized the URB before submitting
* it. Functions such as usb_fill_bulk_urb() and usb_fill_control_urb() are
* available to ensure that most fields are correctly initialized, for
* the particular kind of transfer, although they will not initialize
* any transfer flags.
*
* Successful submissions return 0; otherwise this routine returns a
* negative error number. If the submission is successful, the complete
* fuction of the urb will be called when the USB host driver is
* finished with the urb (either a successful transmission, or some
* error case.)
*
* Unreserved Bandwidth Transfers:
*
* Bulk or control requests complete only once. When the completion
* function is called, control of the URB is returned to the device
* driver which issued the request. The completion handler may then
* immediately free or reuse that URB.
*
* Bulk URBs will be queued if the USB_QUEUE_BULK transfer flag is set
* in the URB. This can be used to maximize bandwidth utilization by
* letting the USB controller start work on the next URB without any
* delay to report completion (scheduling and processing an interrupt)
* and then submit that next request.
*
* For control endpoints, the synchronous usb_control_msg() call is
* often used (in non-interrupt context) instead of this call.
*
* Reserved Bandwidth Transfers:
*
* Periodic URBs (interrupt or isochronous) are completed repeatedly,
* until the original request is aborted. When the completion callback
* indicates the URB has been unlinked (with a special status code),
* control of that URB returns to the device driver. Otherwise, the
* completion handler does not control the URB, and should not change
* any of its fields.
*
* Note that isochronous URBs should be submitted in a "ring" data
* structure (using urb->next) to ensure that they are resubmitted
* appropriately.
*
* If the USB subsystem can't reserve sufficient bandwidth to perform
* the periodic request, and bandwidth reservation is being done for
* this controller, submitting such a periodic request will fail.
*
* Memory Flags:
*
* General rules for how to decide which mem_flags to use:
*
* Basically the rules are the same as for kmalloc. There are four
* different possible values; GFP_KERNEL, GFP_NOFS, GFP_NOIO and
* GFP_ATOMIC.
*
* GFP_NOFS is not ever used, as it has not been implemented yet.
*
* There are three situations you must use GFP_ATOMIC.
* a) you are inside a completion handler, an interrupt, bottom half,
* tasklet or timer.
* b) you are holding a spinlock or rwlock (does not apply to
* semaphores)
* c) current->state != TASK_RUNNING, this is the case only after
* you've changed it.
*
* GFP_NOIO is used in the block io path and error handling of storage
* devices.
*
* All other situations use GFP_KERNEL.
*
* Specfic rules for how to decide which mem_flags to use:
*
* - start_xmit, timeout, and receive methods of network drivers must
* use GFP_ATOMIC (spinlock)
* - queuecommand methods of scsi drivers must use GFP_ATOMIC (spinlock)
* - If you use a kernel thread with a network driver you must use
* GFP_NOIO, unless b) or c) apply
* - After you have done a down() you use GFP_KERNEL, unless b) or c)
* apply or your are in a storage driver's block io path
* - probe and disconnect use GFP_KERNEL unless b) or c) apply
* - Changing firmware on a running storage or net device uses
* GFP_NOIO, unless b) or c) apply
*
*/
int usb_submit_urb(struct urb *urb, int mem_flags)
{
if (urb && urb->dev && urb->dev->bus && urb->dev->bus->op) {
if (usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)) <= 0) {
err("%s: pipe %x has invalid size (<= 0)", __FUNCTION__, urb->pipe);
return -EMSGSIZE;
}
return urb->dev->bus->op->submit_urb(urb, mem_flags);
}
return -ENODEV;
}
/*-------------------------------------------------------------------*/
/**
* usb_unlink_urb - abort/cancel a transfer request for an endpoint
* @urb: pointer to urb describing a previously submitted request
*
* This routine cancels an in-progress request. The requests's
* completion handler will be called with a status code indicating
* that the request has been canceled, and that control of the URB
* has been returned to that device driver. This is the only way
* to stop an interrupt transfer, so long as the device is connected.
*
* When the USB_ASYNC_UNLINK transfer flag for the URB is clear, this
* request is synchronous. Success is indicated by returning zero,
* at which time the urb will have been unlinked,
* and the completion function will see status -ENOENT. Failure is
* indicated by any other return value. This mode may not be used
* when unlinking an urb from an interrupt context, such as a bottom
* half or a completion handler,
*
* When the USB_ASYNC_UNLINK transfer flag for the URB is set, this
* request is asynchronous. Success is indicated by returning -EINPROGRESS,
* at which time the urb will normally not have been unlinked,
* and the completion function will see status -ECONNRESET. Failure is
* indicated by any other return value.
*/
int usb_unlink_urb(struct urb *urb)
{
if (urb && urb->dev && urb->dev->bus && urb->dev->bus->op)
return urb->dev->bus->op->unlink_urb(urb);
else
return -ENODEV;
}
// asynchronous request completion model
EXPORT_SYMBOL(usb_alloc_urb);
EXPORT_SYMBOL(usb_free_urb);
EXPORT_SYMBOL(usb_get_urb);
EXPORT_SYMBOL(usb_submit_urb);
EXPORT_SYMBOL(usb_unlink_urb);
This diff is collapsed.
...@@ -144,11 +144,13 @@ static inline void qtd_copy_status (struct urb *urb, size_t length, u32 token) ...@@ -144,11 +144,13 @@ static inline void qtd_copy_status (struct urb *urb, size_t length, u32 token)
usb_pipeendpoint (pipe), usb_pipeendpoint (pipe),
usb_pipeout (pipe)); usb_pipeout (pipe));
if (urb->dev->tt && !usb_pipeint (pipe)) { if (urb->dev->tt && !usb_pipeint (pipe)) {
#ifdef DEBUG
struct usb_device *tt = urb->dev->tt->hub; struct usb_device *tt = urb->dev->tt->hub;
dbg ("clear tt %s-%s p%d buffer, a%d ep%d", dbg ("clear tt %s-%s p%d buffer, a%d ep%d",
tt->bus->bus_name, tt->devpath, tt->bus->bus_name, tt->devpath,
urb->dev->ttport, urb->dev->devnum, urb->dev->ttport, urb->dev->devnum,
usb_pipeendpoint (pipe)); usb_pipeendpoint (pipe));
#endif /* DEBUG */
usb_hub_tt_clear_buffer (urb->dev, pipe); usb_hub_tt_clear_buffer (urb->dev, pipe);
} }
} }
......
/* -*- linux-c -*- */ /* -*- linux-c -*- */
/* /*
* Driver for USB Scanners (linux-2.4.12) * Driver for USB Scanners (linux-2.4.18)
* *
* Copyright (C) 1999, 2000, 2001 David E. Nelson * Copyright (C) 1999, 2000, 2001, 2002 David E. Nelson
* *
* Portions may be copyright Brad Keryan and Michael Gee. * Portions may be copyright Brad Keryan and Michael Gee.
* *
* David E. Nelson (dnelson@jump.net) * Brian Beattie <beattie@beattie-home.net>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
...@@ -302,11 +302,24 @@ ...@@ -302,11 +302,24 @@
* *
* 05/21/02 Currently maintained by Brian Beattie <beattie@beattie-home.net> * 05/21/02 Currently maintained by Brian Beattie <beattie@beattie-home.net>
* *
* 0.4.8 5/30/2002
* - Added Mustek BearPaw 2400 TA. Thanks to Sergey
* Vlasov <vsu@mivlgu.murom.ru>.
* - Added Mustek 1200UB Plus and Mustek BearPaw 1200 CU ID's. These use
* the Grandtech GT-6801 chip. Thanks to Henning
* Meier-Geinitz <henning@meier-geinitz.de>.
* - Increased Epson timeout to 60 secs as requested from
* Karl Heinz Kremer <khk@khk.net>.
* - Changed maintainership from David E. Nelson to Brian
* Beattie <beattie@beattie-home.net>.
*
* TODO * TODO
* - Remove the 2/3 endpoint limitation
* - Performance * - Performance
* - Select/poll methods * - Select/poll methods
* - More testing * - More testing
* - Proper registry/assignment for LM9830 ioctl's * - Proper registry/assignment for LM9830 ioctl's
* - More general usage ioctl's
* *
* *
* Thanks to: * Thanks to:
...@@ -322,6 +335,8 @@ ...@@ -322,6 +335,8 @@
* - All the folks who chimed in with reports and suggestions. * - All the folks who chimed in with reports and suggestions.
* - All the developers that are working on USB SANE backends or other * - All the developers that are working on USB SANE backends or other
* applications to use USB scanners. * applications to use USB scanners.
* - Thanks to Greg KH <greg@kroah.com> for setting up Brian Beattie
* to be the new USB Scanner maintainer.
* *
* Performance: * Performance:
* *
...@@ -1035,7 +1050,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum, ...@@ -1035,7 +1050,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
switch (dev->descriptor.idVendor) { /* Scanner specific read timeout parameters */ switch (dev->descriptor.idVendor) { /* Scanner specific read timeout parameters */
case 0x04b8: /* Seiko/Epson */ case 0x04b8: /* Seiko/Epson */
scn->rd_nak_timeout = HZ * 40; scn->rd_nak_timeout = HZ * 60;
break; break;
case 0x055f: /* Mustek */ case 0x055f: /* Mustek */
case 0x0400: /* Another Mustek */ case 0x0400: /* Another Mustek */
......
/* /*
* Driver for USB Scanners (linux-2.4.12) * Driver for USB Scanners (linux-2.4.18)
* *
* Copyright (C) 1999, 2000, 2001 David E. Nelson * Copyright (C) 1999, 2000, 2001, 2002 David E. Nelson
* *
* David E. Nelson (dnelson@jump.net) * Brian Beattie <beattie@beattie-home.net>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
static __s32 vendor=-1, product=-1, read_timeout=0; static __s32 vendor=-1, product=-1, read_timeout=0;
MODULE_AUTHOR("David E. Nelson, dnelson@jump.net, http://www.jump.net/~dnelson"); MODULE_AUTHOR("Brian Beattie, beattie@beattie-home.net");
MODULE_DESCRIPTION(DRIVER_DESC" "DRIVER_VERSION); MODULE_DESCRIPTION(DRIVER_DESC" "DRIVER_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -144,6 +144,8 @@ static struct usb_device_id scanner_device_ids [] = { ...@@ -144,6 +144,8 @@ static struct usb_device_id scanner_device_ids [] = {
{ USB_DEVICE(0x0400, 0x1001) }, /* BearPaw 2400 */ { USB_DEVICE(0x0400, 0x1001) }, /* BearPaw 2400 */
{ USB_DEVICE(0x055f, 0x0008) }, /* 1200 CU Plus */ { USB_DEVICE(0x055f, 0x0008) }, /* 1200 CU Plus */
{ USB_DEVICE(0x0ff5, 0x0010) }, /* BearPaw 1200F */ { USB_DEVICE(0x0ff5, 0x0010) }, /* BearPaw 1200F */
{ USB_DEVICE(0x055f, 0x0218) }, /* BearPaw 2400 TA */
{ USB_DEVICE(0x05d8, 0x4002) }, /* 1200 CU and 1200 UB Plus */
/* Plustek */ /* Plustek */
{ USB_DEVICE(0x07b3, 0x0017) }, /* OpticPro UT12 */ { USB_DEVICE(0x07b3, 0x0017) }, /* OpticPro UT12 */
{ USB_DEVICE(0x07b3, 0x0011) }, /* OpticPro UT24 */ { USB_DEVICE(0x07b3, 0x0011) }, /* OpticPro UT24 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment