X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/blobdiff_plain/d377df04c9ee2d7e7fb94168b5e0a3df5e3152f5..e8f8e2d0600cb7b3f8a5b9a32f496d7e14c692b4:/usb-driver.c diff --git a/usb-driver.c b/usb-driver.c index 1fcfae1..5d1528e 100644 --- a/usb-driver.c +++ b/usb-driver.c @@ -47,9 +47,9 @@ static int windrvrfd = -1; static unsigned long ppbase = 0; static unsigned long ecpbase = 0; static struct parport_config *pport = NULL; -FILE *modulesfp = NULL; -FILE *baseaddrfp = NULL; -int baseaddrnum = 0; +static FILE *modulesfp = NULL; +static FILE *baseaddrfp = NULL; +static int baseaddrnum = 0; static int modules_read = 0; static struct usb_bus *busses = NULL; static struct usb_device *usbdevice; @@ -72,7 +72,7 @@ void hexdump(unsigned char *buf, int len) { fprintf(stderr,"\n"); } -int usb_deviceinfo(unsigned char *buf) { +static int usb_deviceinfo(unsigned char *buf) { int i,j,k,l; int len = 0; WDU_CONFIGURATION **pConfigs, **pActiveConfig; @@ -232,7 +232,7 @@ int usb_deviceinfo(unsigned char *buf) { return len; } -int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { +static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { struct header_struct* wdheader = (struct header_struct*)wdioctl; struct version_struct *version; int ret = 0; @@ -466,9 +466,8 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { { struct event *e = (struct event*)(wdheader->data); struct usb_bus *bus; - char* device_num; - char* remainder; - int devnum = -1; + char* devpos; + int busnum = -1, devnum = -1; int i; DPRINTF("handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n", @@ -480,14 +479,36 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { e->u.Usb.dwUniqueID, e->dwEventVer, e->dwNumMatchTables); - device_num=getenv("XILINX_USB_DEVNUM"); - if (device_num!=NULL) { - DPRINTF("XILINX_USB_BUS=%s\n",device_num); - devnum=strtol(device_num,&remainder,10); - if (device_num==remainder) /* no integer in env variable */ - devnum=-1; - } + devpos = getenv("XILINX_USB_DEV"); + if (devpos != NULL) { + int j; + char *devstr = NULL, *remainder; + + DPRINTF("XILINX_USB_DEV=%s\n", devpos); + for (j = 0; j < strlen(devpos) && devpos[j] != 0; j++) { + if (devpos[j] == ':') { + devpos[j] = 0; + devstr = &(devpos[j+1]); + } + } + + if (devstr && strlen(devstr) > 0) { + busnum = strtol(devpos, &remainder, 10); + if (devpos == remainder) { + busnum = -1; + } else { + devnum = strtol(devstr, &remainder, 10); + if (devstr == remainder) { + busnum = -1; + devnum = -1; + } else { + fprintf(stderr,"Using XILINX platform cable USB at %03d:%03d\n", + busnum, devnum); + } + } + } + } for (i = 0; i < e->dwNumMatchTables; i++) { @@ -503,6 +524,9 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { for (bus = busses; bus; bus = bus->next) { struct usb_device *dev; + if ((devnum != -1) && (strtol(bus->dirname, NULL, 10) != busnum)) + continue; + for (dev = bus->devices; dev; dev = dev->next) { struct usb_device_descriptor *desc = &(dev->descriptor); @@ -510,7 +534,7 @@ int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { (desc->idProduct == e->matchTables[i].ProductId) && (desc->bDeviceClass == e->matchTables[i].bDeviceClass) && (desc->bDeviceSubClass == e->matchTables[i].bDeviceSubClass) && - ((devnum == -1) || (dev->devnum == devnum)) ) { + ((devnum == -1) || (strtol(dev->filename, NULL, 10) == devnum)) ) { int ac; for (ac = 0; ac < desc->bNumConfigurations; ac++) { struct usb_interface *interface = dev->config[ac].interface;