mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
[PATCH] Fix ST 5481 USB driver
The old driver was not fully adapted to new USB ABI and does not work. Signed-off-by: Karsten Keil <kkeil@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
27b2f6792f
commit
61ffcafafb
@ -466,10 +466,10 @@ void st5481_stop(struct st5481_adapter *adapter);
|
|||||||
#define __debug_variable st5481_debug
|
#define __debug_variable st5481_debug
|
||||||
#include "hisax_debug.h"
|
#include "hisax_debug.h"
|
||||||
|
|
||||||
#ifdef CONFIG_HISAX_DEBUG
|
|
||||||
|
|
||||||
extern int st5481_debug;
|
extern int st5481_debug;
|
||||||
|
|
||||||
|
#ifdef CONFIG_HISAX_DEBUG
|
||||||
|
|
||||||
#define DBG_ISO_PACKET(level,urb) \
|
#define DBG_ISO_PACKET(level,urb) \
|
||||||
if (level & __debug_variable) dump_iso_packet(__FUNCTION__,urb)
|
if (level & __debug_variable) dump_iso_packet(__FUNCTION__,urb)
|
||||||
|
|
||||||
|
@ -172,14 +172,18 @@ static void usb_b_out_complete(struct urb *urb, struct pt_regs *regs)
|
|||||||
test_and_clear_bit(buf_nr, &b_out->busy);
|
test_and_clear_bit(buf_nr, &b_out->busy);
|
||||||
|
|
||||||
if (unlikely(urb->status < 0)) {
|
if (unlikely(urb->status < 0)) {
|
||||||
if (urb->status != -ENOENT && urb->status != -ESHUTDOWN) {
|
switch (urb->status) {
|
||||||
WARN("urb status %d",urb->status);
|
case -ENOENT:
|
||||||
if (b_out->busy == 0) {
|
case -ESHUTDOWN:
|
||||||
st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL);
|
case -ECONNRESET:
|
||||||
}
|
DBG(4,"urb killed status %d", urb->status);
|
||||||
} else {
|
return; // Give up
|
||||||
DBG(1,"urb killed");
|
default:
|
||||||
return; // Give up
|
WARN("urb status %d",urb->status);
|
||||||
|
if (b_out->busy == 0) {
|
||||||
|
st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +209,9 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode)
|
|||||||
bcs->mode = mode;
|
bcs->mode = mode;
|
||||||
|
|
||||||
// Cancel all USB transfers on this B channel
|
// Cancel all USB transfers on this B channel
|
||||||
|
b_out->urb[0]->transfer_flags |= URB_ASYNC_UNLINK;
|
||||||
usb_unlink_urb(b_out->urb[0]);
|
usb_unlink_urb(b_out->urb[0]);
|
||||||
|
b_out->urb[1]->transfer_flags |= URB_ASYNC_UNLINK;
|
||||||
usb_unlink_urb(b_out->urb[1]);
|
usb_unlink_urb(b_out->urb[1]);
|
||||||
b_out->busy = 0;
|
b_out->busy = 0;
|
||||||
|
|
||||||
|
@ -382,16 +382,20 @@ static void usb_d_out_complete(struct urb *urb, struct pt_regs *regs)
|
|||||||
test_and_clear_bit(buf_nr, &d_out->busy);
|
test_and_clear_bit(buf_nr, &d_out->busy);
|
||||||
|
|
||||||
if (unlikely(urb->status < 0)) {
|
if (unlikely(urb->status < 0)) {
|
||||||
if (urb->status != -ENOENT && urb->status != -ESHUTDOWN) {
|
switch (urb->status) {
|
||||||
WARN("urb status %d",urb->status);
|
case -ENOENT:
|
||||||
if (d_out->busy == 0) {
|
case -ESHUTDOWN:
|
||||||
st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter);
|
case -ECONNRESET:
|
||||||
}
|
DBG(1,"urb killed status %d", urb->status);
|
||||||
return;
|
break;
|
||||||
} else {
|
default:
|
||||||
DBG(1,"urb killed");
|
WARN("urb status %d",urb->status);
|
||||||
return; // Give up
|
if (d_out->busy == 0) {
|
||||||
|
st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return; // Give up
|
||||||
}
|
}
|
||||||
|
|
||||||
FsmEvent(&adapter->d_out.fsm, EV_DOUT_COMPLETE, (void *) buf_nr);
|
FsmEvent(&adapter->d_out.fsm, EV_DOUT_COMPLETE, (void *) buf_nr);
|
||||||
@ -709,14 +713,14 @@ int st5481_setup_d(struct st5481_adapter *adapter)
|
|||||||
|
|
||||||
adapter->l1m.fsm = &l1fsm;
|
adapter->l1m.fsm = &l1fsm;
|
||||||
adapter->l1m.state = ST_L1_F3;
|
adapter->l1m.state = ST_L1_F3;
|
||||||
adapter->l1m.debug = 1;
|
adapter->l1m.debug = st5481_debug & 0x100;
|
||||||
adapter->l1m.userdata = adapter;
|
adapter->l1m.userdata = adapter;
|
||||||
adapter->l1m.printdebug = l1m_debug;
|
adapter->l1m.printdebug = l1m_debug;
|
||||||
FsmInitTimer(&adapter->l1m, &adapter->timer);
|
FsmInitTimer(&adapter->l1m, &adapter->timer);
|
||||||
|
|
||||||
adapter->d_out.fsm.fsm = &dout_fsm;
|
adapter->d_out.fsm.fsm = &dout_fsm;
|
||||||
adapter->d_out.fsm.state = ST_DOUT_NONE;
|
adapter->d_out.fsm.state = ST_DOUT_NONE;
|
||||||
adapter->d_out.fsm.debug = 1;
|
adapter->d_out.fsm.debug = st5481_debug & 0x100;
|
||||||
adapter->d_out.fsm.userdata = adapter;
|
adapter->d_out.fsm.userdata = adapter;
|
||||||
adapter->d_out.fsm.printdebug = dout_debug;
|
adapter->d_out.fsm.printdebug = dout_debug;
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ static int number_of_leds = 2; /* 2 LEDs on the adpater default */
|
|||||||
module_param(number_of_leds, int, 0);
|
module_param(number_of_leds, int, 0);
|
||||||
|
|
||||||
#ifdef CONFIG_HISAX_DEBUG
|
#ifdef CONFIG_HISAX_DEBUG
|
||||||
static int debug = 0x1;
|
static int debug = 0;
|
||||||
module_param(debug, int, 0);
|
module_param(debug, int, 0);
|
||||||
int st5481_debug;
|
|
||||||
#endif
|
#endif
|
||||||
|
int st5481_debug;
|
||||||
|
|
||||||
static LIST_HEAD(adapter_list);
|
static LIST_HEAD(adapter_list);
|
||||||
|
|
||||||
|
@ -132,11 +132,15 @@ static void usb_ctrl_complete(struct urb *urb, struct pt_regs *regs)
|
|||||||
struct ctrl_msg *ctrl_msg;
|
struct ctrl_msg *ctrl_msg;
|
||||||
|
|
||||||
if (unlikely(urb->status < 0)) {
|
if (unlikely(urb->status < 0)) {
|
||||||
if (urb->status != -ENOENT && urb->status != -ESHUTDOWN) {
|
switch (urb->status) {
|
||||||
WARN("urb status %d",urb->status);
|
case -ENOENT:
|
||||||
} else {
|
case -ESHUTDOWN:
|
||||||
DBG(1,"urb killed");
|
case -ECONNRESET:
|
||||||
return; // Give up
|
DBG(1,"urb killed status %d", urb->status);
|
||||||
|
return; // Give up
|
||||||
|
default:
|
||||||
|
WARN("urb status %d",urb->status);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,22 +188,22 @@ static void usb_int_complete(struct urb *urb, struct pt_regs *regs)
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
switch (urb->status) {
|
switch (urb->status) {
|
||||||
case 0:
|
case 0:
|
||||||
/* success */
|
/* success */
|
||||||
break;
|
break;
|
||||||
case -ECONNRESET:
|
case -ECONNRESET:
|
||||||
case -ENOENT:
|
case -ENOENT:
|
||||||
case -ESHUTDOWN:
|
case -ESHUTDOWN:
|
||||||
/* this urb is terminated, clean up */
|
/* this urb is terminated, clean up */
|
||||||
DBG(1, "urb shutting down with status: %d", urb->status);
|
DBG(2, "urb shutting down with status: %d", urb->status);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
WARN("nonzero urb status received: %d", urb->status);
|
WARN("nonzero urb status received: %d", urb->status);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DBG_PACKET(1, data, INT_PKT_SIZE);
|
DBG_PACKET(2, data, INT_PKT_SIZE);
|
||||||
|
|
||||||
if (urb->actual_length == 0) {
|
if (urb->actual_length == 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -250,7 +254,7 @@ int st5481_setup_usb(struct st5481_adapter *adapter)
|
|||||||
struct urb *urb;
|
struct urb *urb;
|
||||||
u8 *buf;
|
u8 *buf;
|
||||||
|
|
||||||
DBG(1,"");
|
DBG(2,"");
|
||||||
|
|
||||||
if ((status = usb_reset_configuration (dev)) < 0) {
|
if ((status = usb_reset_configuration (dev)) < 0) {
|
||||||
WARN("reset_configuration failed,status=%d",status);
|
WARN("reset_configuration failed,status=%d",status);
|
||||||
@ -330,15 +334,17 @@ void st5481_release_usb(struct st5481_adapter *adapter)
|
|||||||
DBG(1,"");
|
DBG(1,"");
|
||||||
|
|
||||||
// Stop and free Control and Interrupt URBs
|
// Stop and free Control and Interrupt URBs
|
||||||
usb_unlink_urb(ctrl->urb);
|
usb_kill_urb(ctrl->urb);
|
||||||
if (ctrl->urb->transfer_buffer)
|
if (ctrl->urb->transfer_buffer)
|
||||||
kfree(ctrl->urb->transfer_buffer);
|
kfree(ctrl->urb->transfer_buffer);
|
||||||
usb_free_urb(ctrl->urb);
|
usb_free_urb(ctrl->urb);
|
||||||
|
ctrl->urb = NULL;
|
||||||
|
|
||||||
usb_unlink_urb(intr->urb);
|
usb_kill_urb(intr->urb);
|
||||||
if (intr->urb->transfer_buffer)
|
if (intr->urb->transfer_buffer)
|
||||||
kfree(intr->urb->transfer_buffer);
|
kfree(intr->urb->transfer_buffer);
|
||||||
usb_free_urb(intr->urb);
|
usb_free_urb(intr->urb);
|
||||||
|
ctrl->urb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -406,6 +412,7 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev,
|
|||||||
spin_lock_init(&urb->lock);
|
spin_lock_init(&urb->lock);
|
||||||
urb->dev=dev;
|
urb->dev=dev;
|
||||||
urb->pipe=pipe;
|
urb->pipe=pipe;
|
||||||
|
urb->interval = 1;
|
||||||
urb->transfer_buffer=buf;
|
urb->transfer_buffer=buf;
|
||||||
urb->number_of_packets = num_packets;
|
urb->number_of_packets = num_packets;
|
||||||
urb->transfer_buffer_length=num_packets*packet_size;
|
urb->transfer_buffer_length=num_packets*packet_size;
|
||||||
@ -452,7 +459,9 @@ st5481_setup_isocpipes(struct urb* urb[2], struct usb_device *dev,
|
|||||||
if (urb[j]) {
|
if (urb[j]) {
|
||||||
if (urb[j]->transfer_buffer)
|
if (urb[j]->transfer_buffer)
|
||||||
kfree(urb[j]->transfer_buffer);
|
kfree(urb[j]->transfer_buffer);
|
||||||
|
urb[j]->transfer_buffer = NULL;
|
||||||
usb_free_urb(urb[j]);
|
usb_free_urb(urb[j]);
|
||||||
|
urb[j] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
@ -463,10 +472,11 @@ void st5481_release_isocpipes(struct urb* urb[2])
|
|||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
usb_unlink_urb(urb[j]);
|
usb_kill_urb(urb[j]);
|
||||||
if (urb[j]->transfer_buffer)
|
if (urb[j]->transfer_buffer)
|
||||||
kfree(urb[j]->transfer_buffer);
|
kfree(urb[j]->transfer_buffer);
|
||||||
usb_free_urb(urb[j]);
|
usb_free_urb(urb[j]);
|
||||||
|
urb[j] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,11 +495,15 @@ static void usb_in_complete(struct urb *urb, struct pt_regs *regs)
|
|||||||
int len, count, status;
|
int len, count, status;
|
||||||
|
|
||||||
if (unlikely(urb->status < 0)) {
|
if (unlikely(urb->status < 0)) {
|
||||||
if (urb->status != -ENOENT && urb->status != -ESHUTDOWN) {
|
switch (urb->status) {
|
||||||
WARN("urb status %d",urb->status);
|
case -ENOENT:
|
||||||
} else {
|
case -ESHUTDOWN:
|
||||||
DBG(1,"urb killed");
|
case -ECONNRESET:
|
||||||
return; // Give up
|
DBG(1,"urb killed status %d", urb->status);
|
||||||
|
return; // Give up
|
||||||
|
default:
|
||||||
|
WARN("urb status %d",urb->status);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +645,9 @@ void st5481_in_mode(struct st5481_in *in, int mode)
|
|||||||
|
|
||||||
in->mode = mode;
|
in->mode = mode;
|
||||||
|
|
||||||
|
in->urb[0]->transfer_flags |= URB_ASYNC_UNLINK;
|
||||||
usb_unlink_urb(in->urb[0]);
|
usb_unlink_urb(in->urb[0]);
|
||||||
|
in->urb[1]->transfer_flags |= URB_ASYNC_UNLINK;
|
||||||
usb_unlink_urb(in->urb[1]);
|
usb_unlink_urb(in->urb[1]);
|
||||||
|
|
||||||
if (in->mode != L1_MODE_NULL) {
|
if (in->mode != L1_MODE_NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user