summaryrefslogtreecommitdiff
path: root/xpp/utils/fpga_load.c
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/utils/fpga_load.c')
-rw-r--r--xpp/utils/fpga_load.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/xpp/utils/fpga_load.c b/xpp/utils/fpga_load.c
index 1cbd749..cc9cf81 100644
--- a/xpp/utils/fpga_load.c
+++ b/xpp/utils/fpga_load.c
@@ -107,6 +107,18 @@ const char *load_status2str(enum fpga_load_status s)
}
}
+/* return 1 if:
+ * - str has a number
+ * - It is larger than 0
+ * - It equals num
+ */
+int num_matches(int num, const char* str) {
+ int str_val = atoi(str);
+ if (str_val <= 0)
+ return 0;
+ return (str_val == num);
+}
+
struct usb_device *dev_of_path(const char *path)
{
struct usb_bus *bus;
@@ -149,10 +161,12 @@ struct usb_device *dev_of_path(const char *path)
sprintf(dirname, "%03d", bnum);
sprintf(filename, "%03d", dnum);
for (bus = usb_busses; bus; bus = bus->next) {
- if(strcmp(bus->dirname, dirname) != 0)
+ if (! num_matches(bnum, bus->dirname))
+ //if(strcmp(bus->dirname, dirname) != 0)
continue;
for (dev = bus->devices; dev; dev = dev->next) {
- if(strcmp(dev->filename, filename) == 0)
+ //if(strcmp(dev->filename, filename) == 0)
+ if (num_matches(dnum, dev->filename))
return dev;
}
}