Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux...
[pandora-kernel.git] / drivers / parport / ieee1284_ops.c
index ce1e2aa..2e21af4 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/parport.h>
 #include <linux/delay.h>
@@ -165,17 +164,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. */
@@ -225,18 +214,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 */
 }
 
@@ -256,17 +252,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. */
@@ -318,11 +304,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;
@@ -893,7 +888,7 @@ size_t parport_ieee1284_epp_read_addr (struct parport *port,
 
                /* Event 59: set nSelectIn (nAStrb) high */
                parport_frob_control (port, PARPORT_CONTROL_SELECT,
-                                     PARPORT_CONTROL_SELECT);
+                                     0);
 
                /* Event 60: wait for Busy to go low */
                if (parport_poll_peripheral (port, PARPORT_STATUS_BUSY,