Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / parport / ieee1284_ops.c
index 6624278..d6c7765 100644 (file)
@@ -60,7 +60,7 @@ size_t parport_ieee1284_write_compat (struct parport *port,
        parport_data_forward (port);
        while (count < len) {
                unsigned long expire = jiffies + dev->timeout;
-               long wait = (HZ + 99) / 100;
+               long wait = msecs_to_jiffies(10);
                unsigned char mask = (PARPORT_STATUS_ERROR
                                      | PARPORT_STATUS_BUSY);
                unsigned char val = (PARPORT_STATUS_ERROR
@@ -97,8 +97,7 @@ size_t parport_ieee1284_write_compat (struct parport *port,
                            our interrupt handler called. */
                        if (count && no_irq) {
                                parport_release (dev);
-                               __set_current_state (TASK_INTERRUPTIBLE);
-                               schedule_timeout (wait);
+                               schedule_timeout_interruptible(wait);
                                parport_claim_or_block (dev);
                        }
                        else
@@ -166,17 +165,7 @@ size_t parport_ieee1284_read_nibble (struct parport *port,
                /* Does the error line indicate end of data? */
                if (((i & 1) == 0) &&
                    (parport_read_status(port) & PARPORT_STATUS_ERROR)) {
-                       port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA;
-                       DPRINTK (KERN_DEBUG
-                               "%s: No more nibble data (%d bytes)\n",
-                               port->name, i/2);
-
-                       /* Go to reverse idle phase. */
-                       parport_frob_control (port,
-                                             PARPORT_CONTROL_AUTOFD,
-                                             PARPORT_CONTROL_AUTOFD);
-                       port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
-                       break;
+                       goto end_of_data;
                }
 
                /* Event 7: Set nAutoFd low. */
@@ -226,18 +215,25 @@ size_t parport_ieee1284_read_nibble (struct parport *port,
                        byte = nibble;
        }
 
-       i /= 2; /* i is now in bytes */
-
        if (i == len) {
                /* Read the last nibble without checking data avail. */
-               port = port->physport;
-               if (parport_read_status (port) & PARPORT_STATUS_ERROR)
-                       port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA;
+               if (parport_read_status (port) & PARPORT_STATUS_ERROR) {
+               end_of_data:
+                       DPRINTK (KERN_DEBUG
+                               "%s: No more nibble data (%d bytes)\n",
+                               port->name, i/2);
+
+                       /* Go to reverse idle phase. */
+                       parport_frob_control (port,
+                                             PARPORT_CONTROL_AUTOFD,
+                                             PARPORT_CONTROL_AUTOFD);
+                       port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
+               }
                else
-                       port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL;
+                       port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL;
        }
 
-       return i;
+       return i/2;
 #endif /* IEEE1284 support */
 }
 
@@ -257,17 +253,7 @@ size_t parport_ieee1284_read_byte (struct parport *port,
 
                /* Data available? */
                if (parport_read_status (port) & PARPORT_STATUS_ERROR) {
-                       port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA;
-                       DPRINTK (KERN_DEBUG
-                                "%s: No more byte data (%Zd bytes)\n",
-                                port->name, count);
-
-                       /* Go to reverse idle phase. */
-                       parport_frob_control (port,
-                                             PARPORT_CONTROL_AUTOFD,
-                                             PARPORT_CONTROL_AUTOFD);
-                       port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
-                       break;
+                       goto end_of_data;
                }
 
                /* Event 14: Place data bus in high impedance state. */
@@ -319,11 +305,20 @@ size_t parport_ieee1284_read_byte (struct parport *port,
 
        if (count == len) {
                /* Read the last byte without checking data avail. */
-               port = port->physport;
-               if (parport_read_status (port) & PARPORT_STATUS_ERROR)
-                       port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA;
+               if (parport_read_status (port) & PARPORT_STATUS_ERROR) {
+               end_of_data:
+                       DPRINTK (KERN_DEBUG
+                                "%s: No more byte data (%Zd bytes)\n",
+                                port->name, count);
+
+                       /* Go to reverse idle phase. */
+                       parport_frob_control (port,
+                                             PARPORT_CONTROL_AUTOFD,
+                                             PARPORT_CONTROL_AUTOFD);
+                       port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
+               }
                else
-                       port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL;
+                       port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL;
        }
 
        return count;
@@ -542,13 +537,12 @@ size_t parport_ieee1284_ecp_read_data (struct parport *port,
                        /* Yield the port for a while. */
                        if (count && dev->port->irq != PARPORT_IRQ_NONE) {
                                parport_release (dev);
-                               __set_current_state (TASK_INTERRUPTIBLE);
-                               schedule_timeout ((HZ + 24) / 25);
+                               schedule_timeout_interruptible(msecs_to_jiffies(40));
                                parport_claim_or_block (dev);
                        }
                        else
                                /* We must have the device claimed here. */
-                               parport_wait_event (port, (HZ + 24) / 25);
+                               parport_wait_event (port, msecs_to_jiffies(40));
 
                        /* Is there a signal pending? */
                        if (signal_pending (current))