usblp: Implement the ENOSPC convention
authorPete Zaitcev <zaitcev@redhat.com>
Mon, 23 Jul 2007 08:58:15 +0000 (01:58 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 12 Oct 2007 21:54:58 +0000 (14:54 -0700)
commit7f477358e2384c54b190cc3b6ce28277050a041b
treec22c0dc67906eefed165f7abcf90b3c9a820756c
parentca337db6f92a32347172a20b96f6f51b7bb63b7c
usblp: Implement the ENOSPC convention

This patch implements a mode when a printer returns ENOSPC when it runs
out of paper. The default remains the same as before. An application which
wishes to use this function has to enable it explicitly with an ioctl
LPABORT.

This is done on a request by our (Fedora) CUPS guy, Tim Waugh. The API is
similar enough to the lp0's one that CUPS works with both (but see below),
but it's has some differences.

Most importantly, the abort mode is persistent in case of lp0: once tunelp
was run your cat fill blow up until you reboot or run tunelp again. For
usblp, I made it so the abort mode is only in effect as long as device
is open. This way you can mix and match CUPS and cat(1) freely and nothing
bad happens even if you run out of paper. It is also safer in the face
of any unexpected crashes.

It has to be noted that mixing LPABORT and O_NONBLOCK is not advised.
It probably does not do what you want: instead of returning -ENOSPC
it will always return -EAGAIN (because it would otherwise block while
waiting for the paper). Applications which use O_NONBLOCK should continue
to use LPGETSTATUS like before.

Finally, CUPS actually requires patching to take full advantage of this.
It has several components; those which invoke LPABORT work, but some of
them need the ioctl added. This is completely compatible, you can mix
old CUPS and new kernels or vice versa.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/class/usblp.c