Hi, this patch add LP_ABORTOPEN ioctl in usb lp device driver. As you can see a member flags is nedeed in struct usblp, i think we could move usblp->used in usblp->flags. For example, in usblp_open rather that check usblp->used we can do something like: if (test_and_set_bit(LP_BUSY_BIT_POS), usblp->flags) return -EBUSY
this is an idea and, offcourse, a TODO if this patch is applied. Greg | Randy: pleasy apply, and tell me if i have to backport in 2.4 Corrections, and suggestions are welcome. Daniele. --- linux-2.5.70/drivers/usb/class/usblp.c 2003-06-08 14:48:17.000000000 +0200 +++ linux-2.5.70-my/drivers/usb/class/usblp.c 2003-06-08 15:21:55.000000000 +0200 @@ -1,5 +1,5 @@ /* - * usblp.c Version 0.13 + * usblp.c Version 0.14 * * Copyright (c) 1999 Michael Gee <[EMAIL PROTECTED]> * Copyright (c) 1999 Pavel Machek <[EMAIL PROTECTED]> @@ -27,6 +27,7 @@ * v0.12 - add hpoj.sourceforge.net ioctls (David Paschal) * v0.13 - alloc space for statusbuf (<status> not on stack); * use usb_buffer_alloc() for read buf & write buf; + * v0.14 - add LPABORTOPEN ioctl, "flags" in struct usblp (Daniele bellucci) */ /* @@ -60,7 +61,7 @@ /* * Version Information */ -#define DRIVER_VERSION "v0.13" +#define DRIVER_VERSION "v0.14" #define DRIVER_AUTHOR "Michael Gee, Pavel Machek, Vojtech Pavlik, Randy Dunlap, Pete Zaitcev, David Paschal" #define DRIVER_DESC "USB Printer Device Class driver" @@ -117,6 +118,8 @@ #define USBLP_LAST_PROTOCOL 3 #define USBLP_MAX_PROTOCOLS (USBLP_LAST_PROTOCOL+1) +#define USB_LP_F(usblp) usblp->flags /* flags for LP_ABORTOPEN,.... */ + /* * some arbitrary status buffer size; * need a status buffer that is allocated via kmalloc(), not on stack @@ -149,6 +152,7 @@ unsigned char bidir; /* interface is bidirectional */ unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */ /* first 2 bytes are (big-endian) length */ + unsigned long flags; }; #ifdef DEBUG @@ -339,19 +343,14 @@ if (usblp->used) goto out; - /* - * TODO: need to implement LP_ABORTOPEN + O_NONBLOCK as in drivers/char/lp.c ??? - * This is #if 0-ed because we *don't* want to fail an open - * just because the printer is off-line. - */ -#if 0 - if ((retval = usblp_check_status(usblp, 0))) { - retval = retval > 1 ? -EIO : -ENOSPC; - goto out; + if ((USB_LP_F(usblp) & LP_ABORTOPEN) && !(file->f_flags & O_NONBLOCK)){ + if ((retval = usblp_check_status(usblp, 0))) { + retval = retval > 1? -EIO: -ENOSPC; + goto out; + } } -#else + retval = 0; -#endif usblp->used = 1; file->private_data = usblp; @@ -588,6 +587,13 @@ retval = -EFAULT; break; + case LPABORTOPEN: + if (arg) + USB_LP_F(usblp) |= LP_ABORTOPEN; + else + USB_LP_F(usblp) &= ~LP_ABORTOPEN; + break; + default: retval = -EINVAL; } ------------------------------------------------------------------------------------------------------------------------------------------------------------- PGP PKEY http://pgp.mit.edu:11371/pks/[EMAIL PROTECTED]&op=index ICQ# 104896040 Netphone/Fax 178.605.7063 Homepage http://web.tiscali.it/bellucda ------------------------------------------------------------------------------------------------------------------------------------------------------------- Daniele Bellucci ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel