2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-30 16:13:54 +08:00

Input: iforce - use usb_kill_urb instead of usb_unlink_urb

Using usb_unlink_urb can cause iforce_open to fail when called
soon after iforce_release. Also updated my email address and
replaced calls to printk() by dbg(), warn(), info(), err()...

Signed-off-by: Johann Deneux <johann.deneux@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
Johann Deneux 2007-04-12 01:30:24 -04:00 committed by Dmitry Torokhov
parent d542ed82fd
commit 598972d4fb
6 changed files with 33 additions and 38 deletions

View File

@ -2,7 +2,7 @@
* $Id: iforce-ff.c,v 1.9 2002/02/02 19:28:35 jdeneux Exp $ * $Id: iforce-ff.c,v 1.9 2002/02/02 19:28:35 jdeneux Exp $
* *
* Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
* Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
* *
* USB/RS232 I-Force joysticks and wheels. * USB/RS232 I-Force joysticks and wheels.
*/ */
@ -205,7 +205,7 @@ static int need_condition_modifier(struct ff_effect *old, struct ff_effect *new)
int i; int i;
if (new->type != FF_SPRING && new->type != FF_FRICTION) { if (new->type != FF_SPRING && new->type != FF_FRICTION) {
printk(KERN_WARNING "iforce.c: bad effect type in need_condition_modifier\n"); warn("bad effect type in need_condition_modifier");
return 0; return 0;
} }
@ -227,7 +227,7 @@ static int need_condition_modifier(struct ff_effect *old, struct ff_effect *new)
static int need_magnitude_modifier(struct ff_effect *old, struct ff_effect *effect) static int need_magnitude_modifier(struct ff_effect *old, struct ff_effect *effect)
{ {
if (effect->type != FF_CONSTANT) { if (effect->type != FF_CONSTANT) {
printk(KERN_WARNING "iforce.c: bad effect type in need_envelope_modifier\n"); warn("bad effect type in need_envelope_modifier");
return 0; return 0;
} }
@ -258,7 +258,7 @@ static int need_envelope_modifier(struct ff_effect *old, struct ff_effect *effec
break; break;
default: default:
printk(KERN_WARNING "iforce.c: bad effect type in need_envelope_modifier\n"); warn("bad effect type in need_envelope_modifier");
} }
return 0; return 0;
@ -271,7 +271,7 @@ static int need_envelope_modifier(struct ff_effect *old, struct ff_effect *effec
static int need_period_modifier(struct ff_effect *old, struct ff_effect *new) static int need_period_modifier(struct ff_effect *old, struct ff_effect *new)
{ {
if (new->type != FF_PERIODIC) { if (new->type != FF_PERIODIC) {
printk(KERN_WARNING "iforce.c: bad effect type in need_period_modifier\n"); warn("bad effect type in need_period_modifier");
return 0; return 0;
} }
return (old->u.periodic.period != new->u.periodic.period return (old->u.periodic.period != new->u.periodic.period

View File

@ -2,7 +2,7 @@
* $Id: iforce-main.c,v 1.19 2002/07/07 10:22:50 jdeneux Exp $ * $Id: iforce-main.c,v 1.19 2002/07/07 10:22:50 jdeneux Exp $
* *
* Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
* Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
* *
* USB/RS232 I-Force joysticks and wheels. * USB/RS232 I-Force joysticks and wheels.
*/ */
@ -29,7 +29,7 @@
#include "iforce.h" #include "iforce.h"
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>, Johann Deneux <deneux@ifrance.com>"); MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>, Johann Deneux <johann.deneux@gmail.com>");
MODULE_DESCRIPTION("USB/RS232 I-Force joysticks and wheels driver"); MODULE_DESCRIPTION("USB/RS232 I-Force joysticks and wheels driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
@ -220,7 +220,7 @@ static void iforce_release(struct input_dev *dev)
/* Check: no effects should be present in memory */ /* Check: no effects should be present in memory */
for (i = 0; i < dev->ff->max_effects; i++) { for (i = 0; i < dev->ff->max_effects; i++) {
if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags)) { if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags)) {
printk(KERN_WARNING "iforce_release: Device still owns effects\n"); warn("iforce_release: Device still owns effects");
break; break;
} }
} }
@ -232,7 +232,7 @@ static void iforce_release(struct input_dev *dev)
switch (iforce->bus) { switch (iforce->bus) {
#ifdef CONFIG_JOYSTICK_IFORCE_USB #ifdef CONFIG_JOYSTICK_IFORCE_USB
case IFORCE_USB: case IFORCE_USB:
usb_unlink_urb(iforce->irq); usb_kill_urb(iforce->irq);
/* The device was unplugged before the file /* The device was unplugged before the file
* was released */ * was released */
@ -324,7 +324,7 @@ int iforce_init_device(struct iforce *iforce)
break; break;
if (i == 20) { /* 5 seconds */ if (i == 20) { /* 5 seconds */
printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n"); err("Timeout waiting for response from device.");
error = -ENODEV; error = -ENODEV;
goto fail; goto fail;
} }
@ -336,26 +336,26 @@ int iforce_init_device(struct iforce *iforce)
if (!iforce_get_id_packet(iforce, "M")) if (!iforce_get_id_packet(iforce, "M"))
input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1];
else else
printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet M\n"); warn("Device does not respond to id packet M");
if (!iforce_get_id_packet(iforce, "P")) if (!iforce_get_id_packet(iforce, "P"))
input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1]; input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1];
else else
printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet P\n"); warn("Device does not respond to id packet P");
if (!iforce_get_id_packet(iforce, "B")) if (!iforce_get_id_packet(iforce, "B"))
iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1]; iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1];
else else
printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet B\n"); warn("Device does not respond to id packet B");
if (!iforce_get_id_packet(iforce, "N")) if (!iforce_get_id_packet(iforce, "N"))
ff_effects = iforce->edata[1]; ff_effects = iforce->edata[1];
else else
printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet N\n"); warn("Device does not respond to id packet N");
/* Check if the device can store more effects than the driver can really handle */ /* Check if the device can store more effects than the driver can really handle */
if (ff_effects > IFORCE_EFFECTS_MAX) { if (ff_effects > IFORCE_EFFECTS_MAX) {
printk(KERN_WARNING "iforce: Limiting number of effects to %d (device reports %d)\n", warn("Limiting number of effects to %d (device reports %d)",
IFORCE_EFFECTS_MAX, ff_effects); IFORCE_EFFECTS_MAX, ff_effects);
ff_effects = IFORCE_EFFECTS_MAX; ff_effects = IFORCE_EFFECTS_MAX;
} }
@ -457,8 +457,6 @@ int iforce_init_device(struct iforce *iforce)
if (error) if (error)
goto fail; goto fail;
printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open);
return 0; return 0;
fail: input_free_device(input_dev); fail: input_free_device(input_dev);

View File

@ -2,7 +2,7 @@
* $Id: iforce-packets.c,v 1.16 2002/07/07 10:22:50 jdeneux Exp $ * $Id: iforce-packets.c,v 1.16 2002/07/07 10:22:50 jdeneux Exp $
* *
* Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
* Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
* *
* USB/RS232 I-Force joysticks and wheels. * USB/RS232 I-Force joysticks and wheels.
*/ */
@ -39,10 +39,10 @@ void iforce_dump_packet(char *msg, u16 cmd, unsigned char *data)
{ {
int i; int i;
printk(KERN_DEBUG "iforce.c: %s ( cmd = %04x, data = ", msg, cmd); printk(KERN_DEBUG __FILE__ ": %s cmd = %04x, data = ", msg, cmd);
for (i = 0; i < LO(cmd); i++) for (i = 0; i < LO(cmd); i++)
printk("%02x ", data[i]); printk("%02x ", data[i]);
printk(")\n"); printk("\n");
} }
/* /*
@ -65,8 +65,9 @@ int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data)
head = iforce->xmit.head; head = iforce->xmit.head;
tail = iforce->xmit.tail; tail = iforce->xmit.tail;
if (CIRC_SPACE(head, tail, XMIT_SIZE) < n+2) { if (CIRC_SPACE(head, tail, XMIT_SIZE) < n+2) {
printk(KERN_WARNING "iforce.c: not enough space in xmit buffer to send new packet\n"); warn("not enough space in xmit buffer to send new packet");
spin_unlock_irqrestore(&iforce->xmit_lock, flags); spin_unlock_irqrestore(&iforce->xmit_lock, flags);
return -1; return -1;
} }
@ -126,8 +127,6 @@ int iforce_control_playback(struct iforce* iforce, u16 id, unsigned int value)
{ {
unsigned char data[3]; unsigned char data[3];
printk(KERN_DEBUG "iforce-packets.c: control_playback %d %d\n", id, value);
data[0] = LO(id); data[0] = LO(id);
data[1] = (value > 0) ? ((value > 1) ? 0x41 : 0x01) : 0; data[1] = (value > 0) ? ((value > 1) ? 0x41 : 0x01) : 0;
data[2] = LO(value); data[2] = LO(value);
@ -151,7 +150,7 @@ static int mark_core_as_ready(struct iforce *iforce, unsigned short addr)
return 0; return 0;
} }
} }
printk(KERN_WARNING "iforce-packets.c: unused effect %04x updated !!!\n", addr); warn("unused effect %04x updated !!!", addr);
return -1; return -1;
} }
@ -162,7 +161,7 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data)
static int being_used = 0; static int being_used = 0;
if (being_used) if (being_used)
printk(KERN_WARNING "iforce-packets.c: re-entrant call to iforce_process %d\n", being_used); warn("re-entrant call to iforce_process %d", being_used);
being_used++; being_used++;
#ifdef CONFIG_JOYSTICK_IFORCE_232 #ifdef CONFIG_JOYSTICK_IFORCE_232
@ -266,7 +265,7 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
return -1; return -1;
} }
#else #else
printk(KERN_ERR "iforce_get_id_packet: iforce->bus = USB!\n"); err("iforce_get_id_packet: iforce->bus = USB!");
#endif #endif
break; break;
@ -284,13 +283,12 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
return -1; return -1;
} }
#else #else
printk(KERN_ERR "iforce_get_id_packet: iforce->bus = SERIO!\n"); err("iforce_get_id_packet: iforce->bus = SERIO!");
#endif #endif
break; break;
default: default:
printk(KERN_ERR "iforce_get_id_packet: iforce->bus = %d\n", err("iforce_get_id_packet: iforce->bus = %d", iforce->bus);
iforce->bus);
break; break;
} }

View File

@ -2,7 +2,7 @@
* $Id: iforce-serio.c,v 1.4 2002/01/28 22:45:00 jdeneux Exp $ * $Id: iforce-serio.c,v 1.4 2002/01/28 22:45:00 jdeneux Exp $
* *
* Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@ucw.cz> * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@ucw.cz>
* Copyright (c) 2001 Johann Deneux <deneux@ifrance.com> * Copyright (c) 2001, 2007 Johann Deneux <johann.deneux@gmail.com>
* *
* USB/RS232 I-Force joysticks and wheels. * USB/RS232 I-Force joysticks and wheels.
*/ */

View File

@ -2,7 +2,7 @@
* $Id: iforce-usb.c,v 1.16 2002/06/09 11:08:04 jdeneux Exp $ * $Id: iforce-usb.c,v 1.16 2002/06/09 11:08:04 jdeneux Exp $
* *
* Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
* Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
* *
* USB/RS232 I-Force joysticks and wheels. * USB/RS232 I-Force joysticks and wheels.
*/ */
@ -65,7 +65,7 @@ void iforce_usb_xmit(struct iforce *iforce)
XMIT_INC(iforce->xmit.tail, n); XMIT_INC(iforce->xmit.tail, n);
if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) { if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) {
printk(KERN_WARNING "iforce-usb.c: iforce_usb_xmit: usb_submit_urb failed %d\n", n); warn("usb_submit_urb failed %d\n", n);
} }
/* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended. /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended.
@ -110,7 +110,7 @@ static void iforce_usb_out(struct urb *urb)
struct iforce *iforce = urb->context; struct iforce *iforce = urb->context;
if (urb->status) { if (urb->status) {
printk(KERN_DEBUG "iforce_usb_out: urb->status %d, exiting", urb->status); dbg("urb->status %d, exiting", urb->status);
return; return;
} }
@ -190,10 +190,9 @@ fail:
/* Called by iforce_delete() */ /* Called by iforce_delete() */
void iforce_usb_delete(struct iforce* iforce) void iforce_usb_delete(struct iforce* iforce)
{ {
usb_unlink_urb(iforce->irq); usb_kill_urb(iforce->irq);
/* Is it ok to unlink those ? */ usb_kill_urb(iforce->out);
usb_unlink_urb(iforce->out); usb_kill_urb(iforce->ctrl);
usb_unlink_urb(iforce->ctrl);
usb_free_urb(iforce->irq); usb_free_urb(iforce->irq);
usb_free_urb(iforce->out); usb_free_urb(iforce->out);

View File

@ -2,7 +2,7 @@
* $Id: iforce.h,v 1.13 2002/07/07 10:22:50 jdeneux Exp $ * $Id: iforce.h,v 1.13 2002/07/07 10:22:50 jdeneux Exp $
* *
* Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz> * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@ucw.cz>
* Copyright (c) 2001-2002 Johann Deneux <deneux@ifrance.com> * Copyright (c) 2001-2002, 2007 Johann Deneux <johann.deneux@gmail.com>
* *
* USB/RS232 I-Force joysticks and wheels. * USB/RS232 I-Force joysticks and wheels.
*/ */