Commit 77060bee authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge kroah.com:/home/greg/linux/BK/bleeding_edge-2.5

into kroah.com:/home/greg/linux/BK/gregkh-2.5
parents 2140dbb5 db8f65c8
......@@ -123,8 +123,8 @@ static struct usb_midi_device usb_midi_devices[] = {
/* for Hot-Plugging */
static struct usb_device_id usb_midi_ids [] = {
{ match_flags: (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS),
bInterfaceClass: USB_CLASS_AUDIO, bInterfaceSubClass: USB_SUBCLASS_MIDISTREAMING},
{ .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS),
.bInterfaceClass = USB_CLASS_AUDIO, .bInterfaceSubClass = USB_SUBCLASS_MIDISTREAMING},
{ USB_DEVICE( USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_UM1 ) },
{ USB_DEVICE( USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_UM2 ) },
{ USB_DEVICE( USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_UA100G ) },
......
......@@ -484,14 +484,17 @@ static int usbdev_open(struct inode *inode, struct file *file)
* and the hub thread have the kernel lock
* (still acquire the kernel lock for safety)
*/
ret = -ENOMEM;
if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL)))
goto out_nolock;
lock_kernel();
ret = -ENOENT;
dev = inode->u.generic_ip;
if (!dev)
goto out;
ret = -ENOMEM;
if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL)))
if (!dev) {
kfree(ps);
goto out;
}
ret = 0;
ps->dev = dev;
ps->file = file;
......@@ -509,6 +512,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
file->private_data = ps;
out:
unlock_kernel();
out_nolock:
return ret;
}
......
......@@ -978,13 +978,18 @@ scan_async (struct ehci_hcd *ehci)
do {
/* clean any finished work for this qh */
if (!list_empty (&qh->qtd_list)) {
// dbg_qh ("scan_async", ehci, qh);
qh = qh_get (qh);
int temp;
/* concurrent unlink could happen here */
count += qh_completions (ehci, qh);
/* unlinks could happen here; completion
* reporting drops the lock.
*/
qh = qh_get (qh);
temp = qh_completions (ehci, qh);
qh_put (ehci, qh);
goto rescan;
if (temp != 0) {
count += temp;
goto rescan;
}
}
/* unlink idle entries, reducing HC PCI usage as
......
......@@ -65,22 +65,22 @@ static int hpusbscsi_scsi_abort (Scsi_Cmnd *srb);
static void issue_request_sense (struct hpusbscsi *hpusbscsi);
static Scsi_Host_Template hpusbscsi_scsi_host_template = {
name: "hpusbscsi",
detect: hpusbscsi_scsi_detect,
// release: hpusbscsi_scsi_release,
queuecommand: hpusbscsi_scsi_queuecommand,
eh_abort_handler: hpusbscsi_scsi_abort,
eh_host_reset_handler: hpusbscsi_scsi_host_reset,
sg_tablesize: SG_ALL,
can_queue: 1,
this_id: -1,
cmd_per_lun: 1,
present: 0,
unchecked_isa_dma: FALSE,
use_clustering: TRUE,
emulated: TRUE
.name = "hpusbscsi",
.detect = hpusbscsi_scsi_detect,
// .release = hpusbscsi_scsi_release,
.queuecommand = hpusbscsi_scsi_queuecommand,
.eh_abort_handler = hpusbscsi_scsi_abort,
.eh_host_reset_handler = hpusbscsi_scsi_host_reset,
.sg_tablesize = SG_ALL,
.can_queue = 1,
.this_id = -1,
.cmd_per_lun = 1,
.present = 0,
.unchecked_isa_dma = FALSE,
.use_clustering = TRUE,
.emulated = TRUE
};
/* defines for internal driver state */
......
......@@ -265,7 +265,8 @@ static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
case VIDIOCSFREQ:
{
int *freq = arg;
*freq = radio->curfreq;
radio->curfreq = *freq;
if (dsbr100_setfreq(radio, radio->curfreq)==-1)
warn("set frequency failed");
return 0;
......
......@@ -326,6 +326,25 @@ config USB_SERIAL_KLSI
The module will be called kl5kusb105.o. If you want to compile it as
a module, say M here and read <file:Documentation/modules.txt>.
config USB_SERIAL_KOBIL_SCT
tristate "USB KOBIL chipcard reader (EXPERIMENTAL)"
depends on USB_SERIAL && EXPERIMENTAL
---help---
Say Y here if you want to use one of the following KOBIL USB chipcard
readers:
- USB TWIN
- KAAN Standard Plus
- SecOVID Reader Plus
- B1 Professional
- KAAN Professional
Note that you need a current CT-API.
This code is also available as a module ( = code which can be
inserted in and removed from the running kernel whenever you want).
The module will be called kobil_sct.o. If you want to compile it as
a module, say M here and read <file:Documentation/modules.txt>.
config USB_SERIAL_MCT_U232
tristate "USB MCT Single Port Serial Driver"
depends on USB_SERIAL
......
......@@ -24,6 +24,7 @@ obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o
obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o
obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o
obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
......
......@@ -98,91 +98,91 @@ static struct usb_device_id id_table_combined [] = {
MODULE_DEVICE_TABLE (usb, id_table_combined);
static struct usb_serial_device_type edgeport_1port_device = {
owner: THIS_MODULE,
name: "Edgeport 1 port adapter",
id_table: edgeport_1port_id_table,
num_interrupt_in: 1,
num_bulk_in: 1,
num_bulk_out: 1,
num_ports: 1,
open: edge_open,
close: edge_close,
throttle: edge_throttle,
unthrottle: edge_unthrottle,
attach: edge_startup,
shutdown: edge_shutdown,
ioctl: edge_ioctl,
set_termios: edge_set_termios,
write: edge_write,
write_room: edge_write_room,
chars_in_buffer: edge_chars_in_buffer,
break_ctl: edge_break,
.owner = THIS_MODULE,
.name = "Edgeport 1 port adapter",
.id_table = edgeport_1port_id_table,
.num_interrupt_in = 1,
.num_bulk_in = 1,
.num_bulk_out = 1,
.num_ports = 1,
.open = edge_open,
.close = edge_close,
.throttle = edge_throttle,
.unthrottle = edge_unthrottle,
.attach = edge_startup,
.shutdown = edge_shutdown,
.ioctl = edge_ioctl,
.set_termios = edge_set_termios,
.write = edge_write,
.write_room = edge_write_room,
.chars_in_buffer = edge_chars_in_buffer,
.break_ctl = edge_break,
};
static struct usb_serial_device_type edgeport_2port_device = {
owner: THIS_MODULE,
name: "Edgeport 2 port adapter",
id_table: edgeport_2port_id_table,
num_interrupt_in: 1,
num_bulk_in: 1,
num_bulk_out: 1,
num_ports: 2,
open: edge_open,
close: edge_close,
throttle: edge_throttle,
unthrottle: edge_unthrottle,
attach: edge_startup,
shutdown: edge_shutdown,
ioctl: edge_ioctl,
set_termios: edge_set_termios,
write: edge_write,
write_room: edge_write_room,
chars_in_buffer: edge_chars_in_buffer,
break_ctl: edge_break,
.owner = THIS_MODULE,
.name = "Edgeport 2 port adapter",
.id_table = edgeport_2port_id_table,
.num_interrupt_in = 1,
.num_bulk_in = 1,
.num_bulk_out = 1,
.num_ports = 2,
.open = edge_open,
.close = edge_close,
.throttle = edge_throttle,
.unthrottle = edge_unthrottle,
.attach = edge_startup,
.shutdown = edge_shutdown,
.ioctl = edge_ioctl,
.set_termios = edge_set_termios,
.write = edge_write,
.write_room = edge_write_room,
.chars_in_buffer = edge_chars_in_buffer,
.break_ctl = edge_break,
};
static struct usb_serial_device_type edgeport_4port_device = {
owner: THIS_MODULE,
name: "Edgeport 4 port adapter",
id_table: edgeport_4port_id_table,
num_interrupt_in: 1,
num_bulk_in: 1,
num_bulk_out: 1,
num_ports: 4,
open: edge_open,
close: edge_close,
throttle: edge_throttle,
unthrottle: edge_unthrottle,
attach: edge_startup,
shutdown: edge_shutdown,
ioctl: edge_ioctl,
set_termios: edge_set_termios,
write: edge_write,
write_room: edge_write_room,
chars_in_buffer: edge_chars_in_buffer,
break_ctl: edge_break,
.owner = THIS_MODULE,
.name = "Edgeport 4 port adapter",
.id_table = edgeport_4port_id_table,
.num_interrupt_in = 1,
.num_bulk_in = 1,
.num_bulk_out = 1,
.num_ports = 4,
.open = edge_open,
.close = edge_close,
.throttle = edge_throttle,
.unthrottle = edge_unthrottle,
.attach = edge_startup,
.shutdown = edge_shutdown,
.ioctl = edge_ioctl,
.set_termios = edge_set_termios,
.write = edge_write,
.write_room = edge_write_room,
.chars_in_buffer = edge_chars_in_buffer,
.break_ctl = edge_break,
};
static struct usb_serial_device_type edgeport_8port_device = {
owner: THIS_MODULE,
name: "Edgeport 8 port adapter",
id_table: edgeport_8port_id_table,
num_interrupt_in: 1,
num_bulk_in: 1,
num_bulk_out: 1,
num_ports: 8,
open: edge_open,
close: edge_close,
throttle: edge_throttle,
unthrottle: edge_unthrottle,
attach: edge_startup,
shutdown: edge_shutdown,
ioctl: edge_ioctl,
set_termios: edge_set_termios,
write: edge_write,
write_room: edge_write_room,
chars_in_buffer: edge_chars_in_buffer,
break_ctl: edge_break,
.owner = THIS_MODULE,
.name = "Edgeport 8 port adapter",
.id_table = edgeport_8port_id_table,
.num_interrupt_in = 1,
.num_bulk_in = 1,
.num_bulk_out = 1,
.num_ports = 8,
.open = edge_open,
.close = edge_close,
.throttle = edge_throttle,
.unthrottle = edge_unthrottle,
.attach = edge_startup,
.shutdown = edge_shutdown,
.ioctl = edge_ioctl,
.set_termios = edge_set_termios,
.write = edge_write,
.write_room = edge_write_room,
.chars_in_buffer = edge_chars_in_buffer,
.break_ctl = edge_break,
};
#endif
......
This diff is collapsed.
This diff is collapsed.
#define SUSBCRequest_SetBaudRateParityAndStopBits 1
#define SUSBCR_SBR_MASK 0xFF00
#define SUSBCR_SBR_1200 0x0100
#define SUSBCR_SBR_9600 0x0200
#define SUSBCR_SBR_19200 0x0400
#define SUSBCR_SBR_28800 0x0800
#define SUSBCR_SBR_38400 0x1000
#define SUSBCR_SBR_57600 0x2000
#define SUSBCR_SBR_115200 0x4000
#define SUSBCR_SPASB_MASK 0x0070
#define SUSBCR_SPASB_NoParity 0x0010
#define SUSBCR_SPASB_OddParity 0x0020
#define SUSBCR_SPASB_EvenParity 0x0040
#define SUSBCR_SPASB_STPMASK 0x0003
#define SUSBCR_SPASB_1StopBit 0x0001
#define SUSBCR_SPASB_2StopBits 0x0002
#define SUSBCRequest_SetStatusLinesOrQueues 2
#define SUSBCR_SSL_SETRTS 0x0001
#define SUSBCR_SSL_CLRRTS 0x0002
#define SUSBCR_SSL_SETDTR 0x0004
#define SUSBCR_SSL_CLRDTR 0x0010
#define SUSBCR_SSL_PURGE_TXABORT 0x0100 // Kill the pending/current writes to the comm port.
#define SUSBCR_SSL_PURGE_RXABORT 0x0200 // Kill the pending/current reads to the comm port.
#define SUSBCR_SSL_PURGE_TXCLEAR 0x0400 // Kill the transmit queue if there.
#define SUSBCR_SSL_PURGE_RXCLEAR 0x0800 // Kill the typeahead buffer if there.
#define SUSBCRequest_GetStatusLineState 4
#define SUSBCR_GSL_RXCHAR 0x0001 // Any Character received
#define SUSBCR_GSL_TXEMPTY 0x0004 // Transmitt Queue Empty
#define SUSBCR_GSL_CTS 0x0008 // CTS changed state
#define SUSBCR_GSL_DSR 0x0010 // DSR changed state
#define SUSBCR_GSL_RLSD 0x0020 // RLSD changed state
#define SUSBCR_GSL_BREAK 0x0040 // BREAK received
#define SUSBCR_GSL_ERR 0x0080 // Line status error occurred
#define SUSBCR_GSL_RING 0x0100 // Ring signal detected
#define SUSBCRequest_Misc 8
#define SUSBCR_MSC_ResetReader 0x0001 // use a predefined reset sequence
#define SUSBCR_MSC_ResetAllQueues 0x0002 // use a predefined sequence to reset the internal queues
#define SUSBCRequest_GetMisc 0x10
#define SUSBCR_MSC_GetFWVersion 0x0001 /* get the firmware version from device,
coded like this 0xHHLLBBPP
with HH = Firmware Version High Byte
LL = Firmware Version Low Byte
BB = Build Number
PP = Further Attributes
*/
#define SUSBCR_MSC_GetHWVersion 0x0002 /* get the hardware version from device
coded like this 0xHHLLPPRR
with HH = Software Version High Byte
LL = Software Version Low Byte
PP = Further Attributes
RR = Reserved for the hardware ID
*/
......@@ -132,13 +132,13 @@ MODULE_PARM_DESC (padded, "Pad to full wMaxPacketSize On/Off");
#define MY_USB_DEVICE(vend,prod,dc,ic,isc) \
match_flags: USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS | \
.match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS | \
USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, \
idVendor: (vend), \
idProduct: (prod),\
bDeviceClass: (dc),\
bInterfaceClass: (ic), \
bInterfaceSubClass: (isc),
.idVendor = (vend), \
.idProduct = (prod),\
.bDeviceClass = (dc),\
.bInterfaceClass = (ic), \
.bInterfaceSubClass = (isc),
static struct usb_device_id id_table[] = {
{MY_USB_DEVICE (0x49f, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Itsy
......
......@@ -175,6 +175,7 @@ static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsi
static void visor_set_termios (struct usb_serial_port *port, struct termios *old_termios);
static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs);
static int clie_3_5_startup (struct usb_serial *serial);
......@@ -189,6 +190,7 @@ static struct usb_device_id id_table [] = {
{ USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID) },
{ USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE_ID) },
{ USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID) },
{ USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_TREO_ID) },
{ USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_0_ID) },
{ USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_S360_ID) },
{ USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID) },
......@@ -203,6 +205,7 @@ static struct usb_device_id clie_id_3_5_table [] = {
static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID) },
{ USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_TREO_ID) },
{ USB_DEVICE(PALM_VENDOR_ID, PALM_M500_ID) },
{ USB_DEVICE(PALM_VENDOR_ID, PALM_M505_ID) },
{ USB_DEVICE(PALM_VENDOR_ID, PALM_M515_ID) },
......@@ -232,9 +235,9 @@ static struct usb_driver visor_driver = {
/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
static struct usb_serial_device_type handspring_device = {
.owner = THIS_MODULE,
.name = "Handspring Visor / Palm 4.0 / Clié 4.x",
.name = "Handspring Visor / Treo / Palm 4.0 / Clié 4.x",
.id_table = id_table,
.num_interrupt_in = 0,
.num_interrupt_in = NUM_DONT_CARE,
.num_bulk_in = 2,
.num_bulk_out = 2,
.num_ports = 2,
......@@ -252,6 +255,7 @@ static struct usb_serial_device_type handspring_device = {
.chars_in_buffer = visor_chars_in_buffer,
.write_bulk_callback = visor_write_bulk_callback,
.read_bulk_callback = visor_read_bulk_callback,
.read_int_callback = visor_read_int_callback,
};
/* device info for the Sony Clie OS version 3.5 */
......@@ -320,9 +324,20 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
port->read_urb->transfer_buffer_length,
visor_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result)
err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
if (result) {
err("%s - failed submitting read urb, error %d",
__FUNCTION__, result);
goto exit;
}
if (port->interrupt_in_urb) {
dbg("%s - adding interrupt input for treo", __FUNCTION__);
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
if (result)
err("%s - failed submitting interrupt urb, error %d",
__FUNCTION__, result);
}
exit:
return result;
}
......@@ -358,6 +373,9 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
}
/* shutdown our bulk read */
usb_unlink_urb (port->read_urb);
if (port->interrupt_in_urb)
usb_unlink_urb (port->interrupt_in_urb);
}
/* Uncomment the following line if you want to see some statistics in your syslog */
/* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */
......@@ -523,6 +541,43 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
return;
}
static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs)
{
int result;
switch (urb->status) {
case 0:
/* success */
break;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d",
__FUNCTION__, urb->status);
return;
default:
dbg("%s - nonzero urb status received: %d",
__FUNCTION__, urb->status);
goto exit;
}
/*
* This information is still unknown what it can be used for.
* If anyone has an idea, please let the author know...
*
* Rumor has it this endpoint is used to notify when data
* is ready to be read from the bulk ones.
*/
usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length,
urb->transfer_buffer);
exit:
result = usb_submit_urb (urb, GFP_ATOMIC);
if (result)
err("%s - Error %d submitting interrupt urb",
__FUNCTION__, result);
}
static void visor_throttle (struct usb_serial_port *port)
{
......
......@@ -19,6 +19,7 @@
#define HANDSPRING_VENDOR_ID 0x082d
#define HANDSPRING_VISOR_ID 0x0100
#define HANDSPRING_TREO_ID 0x0200
#define PALM_VENDOR_ID 0x0830
#define PALM_M500_ID 0x0001
......
......@@ -503,6 +503,35 @@ int usb_stor_bulk_msg(struct us_data *us, void *data, unsigned int pipe,
return status;
}
/* This is our function to submit interrupt URBs with enough control
* to make aborts/resets/timeouts work
*
* This routine always uses us->recv_intr_pipe as the pipe and
* us->ep_bInterval as the interrupt interval.
*/
int usb_stor_interrupt_msg(struct us_data *us, void *data,
unsigned int len, unsigned int *act_len)
{
unsigned int pipe = us->recv_intr_pipe;
unsigned int maxp;
int status;
/* calculate the max packet size */
maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe));
if (maxp > len)
maxp = len;
/* fill and submit the URB */
usb_fill_int_urb(us->current_urb, us->pusb_dev, pipe, data,
maxp, usb_stor_blocking_completion, NULL,
us->ep_bInterval);
status = usb_stor_msg_common(us);
/* store the actual length of the data transferred */
*act_len = us->current_urb->actual_length;
return status;
}
/* This is a version of usb_clear_halt() that doesn't read the status from
* the device -- this is because some devices crash their internal firmware
* when the status is requested after a halt.
......@@ -626,6 +655,29 @@ int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
return interpret_urb_result(us, pipe, size, result, partial);
}
/*
* Receive one buffer via interrupt transfer
*
* This function does basically the same thing as usb_stor_interrupt_msg()
* above, except that return codes are USB_STOR_XFER_xxx rather than the
* urb status.
*/
int usb_stor_intr_transfer(struct us_data *us, void *buf,
unsigned int length, unsigned int *act_len)
{
int result;
unsigned int partial;
/* transfer the data */
US_DEBUGP("usb_stor_intr_transfer(): xfer %u bytes\n", length);
result = usb_stor_interrupt_msg(us, buf, length, &partial);
if (act_len)
*act_len = partial;
return interpret_urb_result(us, us->recv_intr_pipe,
length, result, partial);
}
/*
* Transfer one buffer via bulk transfer
*
......@@ -947,7 +999,7 @@ void usb_stor_abort_transport(struct us_data *us)
host = us->srb->host;
scsi_unlock(host);
/* If the state machine is blocked waiting for an URB or an IRQ,
/* If the state machine is blocked waiting for an URB,
* let's wake it up */
/* If we have an URB pending, cancel it. The test_and_clear_bit()
......@@ -964,12 +1016,6 @@ void usb_stor_abort_transport(struct us_data *us)
usb_sg_cancel(us->current_sg);
}
/* If we are waiting for an IRQ, simulate it */
if (test_bit(US_FLIDX_IP_WANTED, &us->flags)) {
US_DEBUGP("-- simulating missing IRQ\n");
usb_stor_CBI_irq(us->irq_urb, NULL);
}
/* Wait for the aborted command to finish */
wait_for_completion(&us->notify);
......@@ -981,94 +1027,11 @@ void usb_stor_abort_transport(struct us_data *us)
* Control/Bulk/Interrupt transport
*/
/* The interrupt handler for CBI devices */
void usb_stor_CBI_irq(struct urb *urb, struct pt_regs *regs)
{
struct us_data *us = (struct us_data *)urb->context;
int status;
US_DEBUGP("USB IRQ received for device on host %d\n", us->host_no);
US_DEBUGP("-- IRQ data length is %d\n", urb->actual_length);
US_DEBUGP("-- IRQ state is %d\n", urb->status);
US_DEBUGP("-- Interrupt Status (0x%x, 0x%x)\n",
us->irqbuf[0], us->irqbuf[1]);
/* has the current command been aborted? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
/* was this a wanted interrupt? */
if (!test_and_clear_bit(US_FLIDX_IP_WANTED, &us->flags)) {
US_DEBUGP("ERROR: Unwanted interrupt received!\n");
goto exit;
}
US_DEBUGP("-- command aborted\n");
/* wake up the command thread */
up(&us->ip_waitq);
goto exit;
}
/* is the device removed? */
if (urb->status == -ENOENT) {
US_DEBUGP("-- device has been removed\n");
/* was this a wanted interrupt? */
if (!test_and_clear_bit(US_FLIDX_IP_WANTED, &us->flags))
return;
/* indicate a transport error -- this is the best we can do */
us->irqdata[0] = us->irqdata[1] = 0xFF;
/* wake up the command thread */
up(&us->ip_waitq);
return;
}
/* reject improper IRQs */
if (urb->actual_length != 2) {
US_DEBUGP("-- IRQ too short\n");
goto exit;
}
/* was this a command-completion interrupt? */
if (us->irqbuf[0] && (us->subclass != US_SC_UFI)) {
US_DEBUGP("-- not a command-completion IRQ\n");
goto exit;
}
/* was this a wanted interrupt? */
if (!test_and_clear_bit(US_FLIDX_IP_WANTED, &us->flags)) {
US_DEBUGP("ERROR: Unwanted interrupt received!\n");
goto exit;
}
/* copy the valid data */
us->irqdata[0] = us->irqbuf[0];
us->irqdata[1] = us->irqbuf[1];
/* wake up the command thread */
up(&(us->ip_waitq));
exit:
/* resubmit the urb */
status = usb_submit_urb (urb, GFP_ATOMIC);
if (status)
err ("%s - usb_submit_urb failed with result %d",
__FUNCTION__, status);
}
int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
{
unsigned int transfer_length = usb_stor_transfer_length(srb);
int result;
/* re-initialize the mutex so that we avoid any races with
* early/late IRQs from previous commands */
init_MUTEX_LOCKED(&(us->ip_waitq));
/* Set up for status notification */
set_bit(US_FLIDX_IP_WANTED, &us->flags);
/* COMMAND STAGE */
/* let's send the command via the control pipe */
result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
......@@ -1079,8 +1042,6 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
/* check the return code for the command */
US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result);
if (result != USB_STOR_XFER_GOOD) {
/* Reset flag for status notification */
clear_bit(US_FLIDX_IP_WANTED, &us->flags);
/* Uh oh... serious problem here */
return USB_STOR_TRANSPORT_ERROR;
}
......@@ -1093,25 +1054,17 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
result = usb_stor_bulk_transfer_srb(us, pipe, srb,
transfer_length);
US_DEBUGP("CBI data stage result is 0x%x\n", result);
if (result == USB_STOR_XFER_ERROR) {
clear_bit(US_FLIDX_IP_WANTED, &us->flags);
if (result == USB_STOR_XFER_ERROR)
return USB_STOR_TRANSPORT_ERROR;
}
}
/* STATUS STAGE */
/* go to sleep until we get this interrupt */
down(&(us->ip_waitq));
/* has the current command been aborted? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("CBI interrupt aborted\n");
return USB_STOR_TRANSPORT_ERROR;
}
result = usb_stor_intr_transfer(us, us->irqdata,
sizeof(us->irqdata), NULL);
US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n",
us->irqdata[0], us->irqdata[1]);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
/* UFI gives us ASC and ASCQ, like a request sense
*
......
......@@ -145,7 +145,6 @@ struct bulk_cs_wrap {
#define US_CBI_ADSC 0
extern void usb_stor_CBI_irq(struct urb*, struct pt_regs *);
extern int usb_stor_CBI_transport(Scsi_Cmnd*, struct us_data*);
extern int usb_stor_CB_transport(Scsi_Cmnd*, struct us_data*);
......@@ -164,11 +163,15 @@ extern int usb_stor_bulk_msg(struct us_data *us, void *data,
extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
u8 request, u8 requesttype, u16 value, u16 index,
void *data, u16 size);
extern int usb_stor_interrupt_msg(struct us_data *us, void *data,
unsigned int len, unsigned int *act_len);
extern int usb_stor_clear_halt(struct us_data*, unsigned int pipe);
extern int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
u8 request, u8 requesttype, u16 value, u16 index,
void *data, u16 size);
extern int usb_stor_intr_transfer(struct us_data *us, void *buf,
unsigned int length, unsigned int *act_len);
extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
void *buf, unsigned int length, unsigned int *act_len);
extern int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
......
......@@ -174,7 +174,7 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
.productName = product_name, \
.useProtocol = use_protocol, \
.useTransport = use_transport, \
initFunction : init_function, \
.initFunction = init_function, \
.flags = Flags, \
}
......@@ -477,24 +477,20 @@ static int usb_stor_control_thread(void * __us)
return 0;
}
/* Set up the URB, the usb_ctrlrequest, and the IRQ pipe and handler.
/* Set up the URB and the usb_ctrlrequest.
* ss->dev_semaphore must already be locked.
* Note that this function assumes that all the data in the us_data
* strucuture is current. This includes the ep_int field, which gives us
* the endpoint for the interrupt.
* structure is current.
* Returns non-zero on failure, zero on success
*/
static int usb_stor_allocate_urbs(struct us_data *ss)
{
unsigned int pipe;
int maxp;
int result;
/* calculate and store the pipe values */
ss->send_bulk_pipe = usb_sndbulkpipe(ss->pusb_dev, ss->ep_out);
ss->recv_bulk_pipe = usb_rcvbulkpipe(ss->pusb_dev, ss->ep_in);
ss->send_ctrl_pipe = usb_sndctrlpipe(ss->pusb_dev, 0);
ss->recv_ctrl_pipe = usb_rcvctrlpipe(ss->pusb_dev, 0);
ss->send_bulk_pipe = usb_sndbulkpipe(ss->pusb_dev, ss->ep_out);
ss->recv_bulk_pipe = usb_rcvbulkpipe(ss->pusb_dev, ss->ep_in);
ss->recv_intr_pipe = usb_rcvintpipe(ss->pusb_dev, ss->ep_int);
/* allocate the usb_ctrlrequest for control packets */
US_DEBUGP("Allocating usb_ctrlrequest\n");
......@@ -519,45 +515,6 @@ static int usb_stor_allocate_urbs(struct us_data *ss)
return 5;
}
/* allocate the IRQ URB, if it is needed */
if (ss->protocol == US_PR_CBI) {
US_DEBUGP("Allocating IRQ for CBI transport\n");
/* lock access to the data structure */
down(&(ss->irq_urb_sem));
/* allocate the URB */
ss->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!ss->irq_urb) {
up(&(ss->irq_urb_sem));
US_DEBUGP("couldn't allocate interrupt URB");
return 3;
}
/* calculate the pipe and max packet size */
pipe = usb_rcvintpipe(ss->pusb_dev,
ss->ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
maxp = usb_maxpacket(ss->pusb_dev, pipe, usb_pipeout(pipe));
if (maxp > sizeof(ss->irqbuf))
maxp = sizeof(ss->irqbuf);
/* fill in the URB with our data */
usb_fill_int_urb(ss->irq_urb, ss->pusb_dev, pipe, ss->irqbuf,
maxp, usb_stor_CBI_irq, ss, ss->ep_int->bInterval);
/* submit the URB for processing */
result = usb_submit_urb(ss->irq_urb, GFP_KERNEL);
US_DEBUGP("usb_submit_urb() returns %d\n", result);
if (result) {
up(&(ss->irq_urb_sem));
return 4;
}
/* unlock the data structure */
up(&(ss->irq_urb_sem));
} /* ss->protocol == US_PR_CBI */
return 0; /* success */
}
......@@ -568,17 +525,6 @@ static void usb_stor_deallocate_urbs(struct us_data *ss)
{
int result;
/* release the IRQ, if we have one */
down(&(ss->irq_urb_sem));
if (ss->irq_urb) {
US_DEBUGP("-- releasing irq URB\n");
result = usb_unlink_urb(ss->irq_urb);
US_DEBUGP("-- usb_unlink_urb() returned %d\n", result);
usb_free_urb(ss->irq_urb);
ss->irq_urb = NULL;
}
up(&(ss->irq_urb_sem));
/* free the scatter-gather request block */
if (ss->current_sg) {
kfree(ss->current_sg);
......@@ -782,7 +728,9 @@ static int storage_probe(struct usb_interface *intf,
USB_ENDPOINT_NUMBER_MASK;
ss->ep_out = ep_out->bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
ss->ep_int = ep_int;
ss->ep_int = ep_int->bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
ss->ep_bInterval = ep_int->bInterval;
/* allocate the URB, the usb_ctrlrequest, and the IRQ URB */
if (usb_stor_allocate_urbs(ss))
......@@ -810,8 +758,6 @@ static int storage_probe(struct usb_interface *intf,
/* Initialize the mutexes only when the struct is new */
init_completion(&(ss->notify));
init_MUTEX_LOCKED(&(ss->ip_waitq));
init_MUTEX(&(ss->irq_urb_sem));
init_MUTEX_LOCKED(&(ss->dev_semaphore));
/* copy over the subclass and protocol data */
......@@ -825,7 +771,9 @@ static int storage_probe(struct usb_interface *intf,
USB_ENDPOINT_NUMBER_MASK;
ss->ep_out = ep_out->bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
ss->ep_int = ep_int;
ss->ep_int = ep_int->bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK;
ss->ep_bInterval = ep_int->bInterval;
/* establish the connection to the new device */
ss->ifnum = ifnum;
......
......@@ -105,7 +105,6 @@ struct us_unusual_dev {
#define US_FL_FIX_CAPACITY 0x00000080 /* READ CAPACITY response too big */
#define US_FL_DEV_ATTACHED 0x00010000 /* is the device attached? */
#define US_FLIDX_IP_WANTED 17 /* 0x00020000 is an IRQ expected? */
#define US_FLIDX_CAN_CANCEL 18 /* 0x00040000 okay to cancel current_urb? */
#define US_FLIDX_CANCEL_SG 19 /* 0x00080000 okay to cancel current_sg? */
......@@ -139,6 +138,7 @@ struct us_data {
unsigned int recv_bulk_pipe;
unsigned int send_ctrl_pipe;
unsigned int recv_ctrl_pipe;
unsigned int recv_intr_pipe;
/* information about the device -- always good */
char vendor[USB_STOR_STRING_LEN];
......@@ -154,7 +154,8 @@ struct us_data {
u8 ifnum; /* interface number */
u8 ep_in; /* bulk in endpoint */
u8 ep_out; /* bulk out endpoint */
struct usb_endpoint_descriptor *ep_int; /* interrupt endpoint */
u8 ep_int; /* interrupt endpoint */
u8 ep_bInterval; /* interrupt interval */
/* function pointers for this device */
trans_cmnd transport; /* transport function */
......@@ -173,13 +174,7 @@ struct us_data {
int pid; /* control thread */
atomic_t sm_state; /* what we are doing */
/* interrupt info for CBI devices -- only good if attached */
struct semaphore ip_waitq; /* for CBI interrupts */
/* interrupt communications data */
struct semaphore irq_urb_sem; /* to protect irq_urb */
struct urb *irq_urb; /* for USB int requests */
unsigned char irqbuf[2]; /* buffer for USB IRQ */
unsigned char irqdata[2]; /* data from USB IRQ */
/* control and bulk communications data */
......
......@@ -217,7 +217,7 @@ static void snd_usbmidi_in_midiman_complete(struct urb* urb, struct pt_regs *reg
}
}
}
snd_usbmidi_in_urb_complete(urb);
snd_usbmidi_in_urb_complete(urb, regs);
}
static void snd_usbmidi_out_urb_complete(struct urb* urb, struct pt_regs *regs)
......
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