]> git.zerfleddert.de Git - usb-driver/commitdiff
some cleanups
authormichael <michael>
Sun, 29 Apr 2007 00:47:44 +0000 (00:47 +0000)
committermichael <michael>
Sun, 29 Apr 2007 00:47:44 +0000 (00:47 +0000)
usb-driver.c

index d1d59303a148f5c6f6b5a5d6210b5c4ebf9e8547..93950161940d64a4963c2d4ee453b96a80d5314a 100644 (file)
@@ -361,7 +361,7 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
        switch(request & ~(0xc0000000)) {
                case VERSION:
                        version = (struct version_struct*)(wdheader->data);
-                       strcpy(version->version, "libusb-driver.so $Revision: 1.61 $");
+                       strcpy(version->version, "libusb-driver.so $Revision: 1.62 $");
                        version->versionul = 802;
                        DPRINTF("VERSION\n");
                        break;
@@ -394,53 +394,54 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) {
                                
                                /* FIXME: Ugly hack which maps amontec JtagKey to 4. parallel port */
 #ifdef JTAGKEY
-                               if ((unsigned long)cr->Card.Item[0].I.IO.dwAddr != 0x30)
+                               if ((unsigned long)cr->Card.Item[0].I.IO.dwAddr == 0x30) {
+                                       ret=jtagkey_init(0x0403, 0xcff8); /* I need a config file... */
+                                       cr->hCard = 0xff;
+                                       ppbase = (unsigned long)cr->Card.Item[0].I.IO.dwAddr;
+                                       if (ret < 0)
+                                               cr->hCard = 0;
+
+                                       break;
+                               }
 #endif
-                               {
-                                       if (parportfd < 0) {
-                                               snprintf(ppdev, sizeof(ppdev), "/dev/parport%lu",
-                                                               (unsigned long)cr->Card.Item[0].I.IO.dwAddr / 0x10);
-                                               DPRINTF("opening %s\n", ppdev);
-                                               parportfd = open(ppdev, O_RDWR|O_EXCL);
-
-                                               if (parportfd < 0)
-                                                       fprintf(stderr,"Can't open %s: %s\n", ppdev, strerror(errno));
-                                       }
+                               if (parportfd < 0) {
+                                       snprintf(ppdev, sizeof(ppdev), "/dev/parport%lu",
+                                                       (unsigned long)cr->Card.Item[0].I.IO.dwAddr / 0x10);
+                                       DPRINTF("opening %s\n", ppdev);
+                                       parportfd = open(ppdev, O_RDWR|O_EXCL);
+
+                                       if (parportfd < 0)
+                                               fprintf(stderr,"Can't open %s: %s\n", ppdev, strerror(errno));
+                               }
 
-                                       if (parportfd >= 0) {
-                                               int pmode;
+                               if (parportfd >= 0) {
+                                       int pmode;
 
-                                               if (ioctl(parportfd, PPCLAIM) == -1)
-                                                       return ret;
+                                       if (ioctl(parportfd, PPCLAIM) == -1)
+                                               return ret;
 
-                                               ecpbase = 0;
-                                               pmode = IEEE1284_MODE_COMPAT;
-                                               if (ioctl(parportfd, PPNEGOT, &pmode) == -1)
-                                                       return ret;
+                                       ecpbase = 0;
+                                       pmode = IEEE1284_MODE_COMPAT;
+                                       if (ioctl(parportfd, PPNEGOT, &pmode) == -1)
+                                               return ret;
 
-                                               if (cr->Card.dwItems > 1 && cr->Card.Item[1].I.IO.dwAddr) {
-                                                       DPRINTF("ECP mode requested\n");
-                                                       ecpbase = (unsigned long)cr->Card.Item[1].I.IO.dwAddr;
-                                                       /* TODO: Implement ECP mode */
+                                       if (cr->Card.dwItems > 1 && cr->Card.Item[1].I.IO.dwAddr) {
+                                               DPRINTF("ECP mode requested\n");
+                                               ecpbase = (unsigned long)cr->Card.Item[1].I.IO.dwAddr;
+                                               /* TODO: Implement ECP mode */
 #if 0
-                                                       pmode = IEEE1284_MODE_ECP;
+                                               pmode = IEEE1284_MODE_ECP;
 
-                                                       if (ioctl(parportfd, PPNEGOT, &pmode) == -1) {
-                                                               ecpbase = 0;
-                                                               pmode = IEEE1284_MODE_COMPAT;
-                                                               if (ioctl(parportfd, PPNEGOT, &pmode) == -1)
-                                                                       return ret;
-                                                       }
-#endif
+                                               if (ioctl(parportfd, PPNEGOT, &pmode) == -1) {
+                                                       ecpbase = 0;
+                                                       pmode = IEEE1284_MODE_COMPAT;
+                                                       if (ioctl(parportfd, PPNEGOT, &pmode) == -1)
+                                                               return ret;
                                                }
-
-                                               cr->hCard = parportfd;
-                                       }
-#ifdef JTAGKEY
-                               } else {
-                                       ret=jtagkey_init(0x0403, 0xcff8); /* I need a config file... */
-                                       cr->hCard = 0xff;
 #endif
+                                       }
+
+                                       cr->hCard = parportfd;
                                }
 
                                ppbase = (unsigned long)cr->Card.Item[0].I.IO.dwAddr;
Impressum, Datenschutz