On Mon, 2003-07-07 at 19:16, Randy.Dunlap wrote:
> | Seems like drivers/usb/class/usblp.c have the same problem.
> | Maybe someone with the hardware can fix it.
>
> Hi,
> It's not required that you have hardware to make such a patch.
> Would you fix usblp.c and post it?
> If not, I'll get around to it.
Here is the blind flight :-)
thanks
Kay
===
drivers/usb/class/usblp.c
usblp->dev was set to NULL to indicate a device disconnect but we need
this value for usb_buffer_free() when device is still opened and cleanup
is delayed until usblp_release().
We have a usblp->present now for preventing device read, write, open and ioctl.
===
--- usblp.c.orig 2003-07-07 20:29:27.000000000 +0200
+++ usblp.c 2003-07-07 21:33:32.000000000 +0200
@@ -146,6 +146,7 @@
int rcomplete; /* reading is completed */
unsigned int quirks; /* quirks flags */
unsigned char used; /* True if open */
+ unsigned char present; /* True if not disconnected */
unsigned char bidir; /* interface is bidirectional
*/
unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string
(ptr) */
/* first 2 bytes are
(big-endian) length */
@@ -157,6 +158,7 @@
dbg("usblp=0x%p", usblp);
dbg("dev=0x%p", usblp->dev);
+ dbg("present=%d", usblp->present);
dbg("buf=0x%p", usblp->buf);
dbg("readcount=%d", usblp->readcount);
dbg("ifnum=%d", usblp->ifnum);
@@ -253,7 +255,7 @@
{
struct usblp *usblp = urb->context;
- if (!usblp || !usblp->dev || !usblp->used)
+ if (!usblp || !usblp->dev || !usblp->used || !usblp->present)
return;
if (unlikely(urb->status))
@@ -267,7 +269,7 @@
{
struct usblp *usblp = urb->context;
- if (!usblp || !usblp->dev || !usblp->used)
+ if (!usblp || !usblp->dev || !usblp->used || !usblp->present)
return;
if (unlikely(urb->status))
@@ -332,7 +334,7 @@
goto out;
}
usblp = usb_get_intfdata (intf);
- if (!usblp || !usblp->dev)
+ if (!usblp || !usblp->dev || !usblp->present)
goto out;
retval = -EBUSY;
@@ -404,7 +406,7 @@
down (&usblp->sem);
lock_kernel();
usblp->used = 0;
- if (usblp->dev) {
+ if (usblp->present) {
usblp_unlink_urbs(usblp);
up(&usblp->sem);
} else /* finish cleanup from disconnect */
@@ -432,7 +434,7 @@
int retval = 0;
down (&usblp->sem);
- if (!usblp->dev) {
+ if (!usblp->present) {
retval = -ENODEV;
goto done;
}
@@ -630,7 +632,7 @@
}
down (&usblp->sem);
- if (!usblp->dev) {
+ if (!usblp->present) {
up (&usblp->sem);
return -ENODEV;
}
@@ -691,7 +693,7 @@
return -EINVAL;
down (&usblp->sem);
- if (!usblp->dev) {
+ if (!usblp->present) {
count = -ENODEV;
goto done;
}
@@ -726,7 +728,7 @@
remove_wait_queue(&usblp->wait, &wait);
}
- if (!usblp->dev) {
+ if (!usblp->present) {
count = -ENODEV;
goto done;
}
@@ -916,6 +918,8 @@
usb_set_intfdata (intf, usblp);
+ usblp->present = 1;
+
return 0;
abort_minor:
@@ -1115,14 +1119,14 @@
down (&usblp->sem);
lock_kernel();
- usblp->dev = NULL;
+ usblp->present = 0;
usb_set_intfdata (intf, NULL);
usblp_unlink_urbs(usblp);
if (!usblp->used)
usblp_cleanup (usblp);
- else /* cleanup later, on close */
+ else /* cleanup later, on release */
up (&usblp->sem);
unlock_kernel();
}