]> git.zerfleddert.de Git - usb-driver/commitdiff
cleanup parallel support a bit
authormichael <michael>
Sat, 17 Mar 2007 00:13:23 +0000 (00:13 +0000)
committermichael <michael>
Sat, 17 Mar 2007 00:13:23 +0000 (00:13 +0000)
usb-driver.c
usb-driver.h

index 1c5b18b2d8f4b3ae3b29f116b8729f73bda1865f..b4a15490f807824f5b18cf379e34f6f4b1c81af6 100644 (file)
@@ -258,33 +258,65 @@ int pp_transfer(WD_TRANSFER *tr, int fd, unsigned int request, unsigned char *wd
        if (parportfd < 0)
                return ret;
 
-       switch(tr->cmdTrans) {
-               case 10: /* Read Byte */
-                       if ((unsigned long)tr->dwPort == ppbase) { /* Data Port */
-                               ret = 0; /* We don't support reading of the data port */
-                       } else if ((unsigned long)tr->dwPort == ppbase + 1) { /* Status Port */
-                               DPRINTF("status port\n");
-                               ret = ioctl(parportfd, PPRSTATUS, &val);
-                       } else if ((unsigned long)tr->dwPort == ppbase + 2) { /* Control Port */
-                               DPRINTF("control port\n");
-                               ret = ioctl(parportfd, PPRCONTROL, &val);
+       switch((unsigned long)tr->dwPort - ppbase) {
+               case PP_DATA:
+                       DPRINTF("data port\n");
+                       switch(tr->cmdTrans) {
+                               case PP_READ:
+                                       ret = 0; /* We don't support reading of the data port */
+                                       break;
+
+                               case PP_WRITE:
+                                       ret = ioctl(parportfd, PPWDATA, &val);
+                                       break;
+
+                               default:
+                                       fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
+                                       ret = -1;
+                                       break;
                        }
-                       break;
-               case 13: /* Write Byte */
-                       if ((unsigned long)tr->dwPort == ppbase) { /* Data Port */
-                               DPRINTF("data port\n");
-                               ret = ioctl(parportfd, PPWDATA, &val);
-                       } else if ((unsigned long)tr->dwPort == ppbase + 1) { /* Status Port */
-                               ret = 0; /* Status Port is readonly */
-                       } else if ((unsigned long)tr->dwPort == ppbase + 2) { /* Control Port */
-                               DPRINTF("control port\n");
-                               ret = ioctl(parportfd, PPWCONTROL, &val);
+               break;
+
+               case PP_STATUS:
+                       DPRINTF("status port\n");
+                       switch(tr->cmdTrans) {
+                               case PP_READ:
+                                       ret = ioctl(parportfd, PPRSTATUS, &val);
+                                       break;
+
+                               case PP_WRITE:
+                                       ret = 0; /* Status Port is readonly */
+                                       break;
+
+                               default:
+                                       fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
+                                       ret = -1;
+                                       break;
                        }
-                       break;
+               break;
+
+               case PP_CONTROL:
+                       DPRINTF("control port\n");
+                       switch(tr->cmdTrans) {
+                               case PP_READ:
+                                       ret = ioctl(parportfd, PPRCONTROL, &val);
+                                       break;
+
+                               case PP_WRITE:
+                                       ret = ioctl(parportfd, PPWCONTROL, &val);
+                                       break;
+
+                               default:
+                                       fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
+                                       ret = -1;
+                                       break;
+                       }
+               break;
+
                default:
-                       fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
-                       ret = -1;
-                       break;
+                       DPRINTF("access to unsupported address range (probably ECP)!\n");
+                       ret = 0;
+               break;
        }
 
        tr->Data.Byte = val;
index 77b60f2ae48da53c9d47ce5d92cf61d14c9aebd4..187be1bb9b6449eb7168b2eba9ebe1519eda6558 100644 (file)
 
 #define MAGIC 0xa410b413UL
 
+#define PP_DATA                        0
+#define PP_STATUS              1
+#define PP_CONTROL             2
+#define PP_READ                        10
+#define PP_WRITE               13
+
 #define WDU_GET_MAX_PACKET_SIZE(x)                ((unsigned short) (((x) & 0x7ff) * (1 + (((x) & 0x1800) >> 11))))
 
 /* http://www.jungo.com/support/documentation/windriver/811/wdusb_man_mhtml/node78.html#SECTION001734000000000000000 */
Impressum, Datenschutz