[PARPORT] Bug in parport_pc.c

From: Roland Kuck (rci@cityweb.de)
Date: Tue Nov 21 2000 - 11:13:00 EST

  • Next message: Tim Waugh: "Re: [PARPORT] Bug in parport_pc.c"

    Hello,

    writting a printer driver I discoverd a bug in the parport_pc code. When
    using the FIFO to write data in ECP mode to the printer after data was read
    it an error occurs. No error occured when not using the FIFO (i.e. the
    software implementation of the ECP protocol in ieee1284_ops.c). I used
    kernel 2.4.0-test10 and 2.4.0-test11 and my driver used the user level api.

    The bug is in function "parport_pc_ecp_write_block_pio":

     /* Switch to forward mode if necessary. */
     if (port->physport->ieee1284.phase != IEEE1284_PH_FWD_IDLE) {
      /* Event 47: Set nInit high. */
      parport_frob_control (port, PARPORT_CONTROL_INIT, 0);

      /* Event 40: PError goes high. */
      r = parport_wait_peripheral (port,
              PARPORT_STATUS_PAPEROUT,
              PARPORT_STATUS_PAPEROUT);
      if (r)
       printk (KERN_DEBUG "%s: PError timeout (%d) "
        "in ecp_write_block_pio\n", port->name, r);
     }

    Setting nInit high is done by setting the control bit, not clearing it. The
    software driven implementation of the ecp protocol (ieee1284_ops.c) does
    this and thus works fine. A corrected version follows (which also corrects
    the typo (event 40 instead of event 49)):

     /* Switch to forward mode if necessary. */
     if (port->physport->ieee1284.phase != IEEE1284_PH_FWD_IDLE) {
      /* Event 47: Set nInit high */
      parport_frob_control (port,
              PARPORT_CONTROL_INIT
              | PARPORT_CONTROL_AUTOFD,
              PARPORT_CONTROL_INIT
              | PARPORT_CONTROL_AUTOFD);

      /* Event 49: PError goes high. */
      r = parport_wait_peripheral (port,
              PARPORT_STATUS_PAPEROUT,
              PARPORT_STATUS_PAPEROUT);
      if (r)
       printk (KERN_DEBUG "%s: PError timeout (%d) "
        "in ecp_write_block_pio\n", port->name, r);
     }

    The read-routine seems to have the same bug, but as it isn't used at the
    momement anyways ...

    Roland Kuck (rci@cityweb.de)

    -- To unsubscribe, send mail to: linux-parport-request@torque.net --
    -- with the single word "unsubscribe" in the body of the message. --



    This archive was generated by hypermail 2b29 : Tue Nov 21 2000 - 11:14:31 EST