Don't wait for the printer to become ready before allowing the open to
succeed. There are many printers that return status over the read channel, and if we wait for the status to become ready, then we can't find the status automatically. Linux doesn't wait, nor does it ever seem to really check the status in any meaningful way... If there really is a problem, the writes to the bulk out endpoint will still fail (like they would if the printer was ready and then ran out of paper or became unready). In addition, there are a number of printers being made that emulate the 'status' byte by returning '0' always rather than '0x18'. This fixes the EBUSY on open timeouts on those printer as well. Reviewed by: the defining silence on usb@
This commit is contained in:
parent
ce71e8d87f
commit
f83fe7ce90
@ -509,7 +509,7 @@ ulptopen(struct cdev *dev, int flag, int mode, usb_proc_ptr p)
|
||||
u_char flags = ULPTFLAGS(dev);
|
||||
struct ulpt_softc *sc;
|
||||
usbd_status err;
|
||||
int spin, error;
|
||||
int error;
|
||||
|
||||
USB_GET_SC_OPEN(ulpt, ULPTUNIT(dev), sc);
|
||||
|
||||
@ -543,28 +543,6 @@ ulptopen(struct cdev *dev, int flag, int mode, usb_proc_ptr p)
|
||||
}
|
||||
}
|
||||
|
||||
for (spin = 0; (ulpt_status(sc) & LPS_SELECT) == 0; spin += STEP) {
|
||||
DPRINTF(("ulpt_open: waiting a while\n"));
|
||||
if (spin >= TIMEOUT) {
|
||||
error = EBUSY;
|
||||
sc->sc_state = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* wait 1/4 second, give up if we get a signal */
|
||||
error = tsleep(sc, LPTPRI | PCATCH, "ulptop", STEP);
|
||||
if (error != EWOULDBLOCK) {
|
||||
sc->sc_state = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (sc->sc_dying) {
|
||||
error = ENXIO;
|
||||
sc->sc_state = 0;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
err = usbd_open_pipe(sc->sc_iface, sc->sc_out, 0, &sc->sc_out_pipe);
|
||||
if (err) {
|
||||
error = EIO;
|
||||
|
Loading…
x
Reference in New Issue
Block a user