summaryrefslogtreecommitdiff
path: root/xpp/xpp_usb.c
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-10-16 17:55:05 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-10-16 17:55:05 +0000
commit6bc1dbffe9f77eb3c85a655ffeaff64d963c6b43 (patch)
treee94ccfa1c5bf43ffac9eb4ec251eee58ae8fe39a /xpp/xpp_usb.c
parent37886eb9069e5a088d721f41202e7c3dd4ca0a09 (diff)
xpp r4892:
* Zaptel/Hardware perl modules: - Use sysfs directly. Don't rely on lspci/lsusb. - Each device has a description and driver name. - Zaptel::Hardware::drivers() to show the list of required drivers for this system (see zaptel_drivers). - zaptel_hardware shows a description and a (suggested?) driver. * zt_registration sorts by Serial first and only then by connector. * USB_FW.hex replaces all the USB_11x0.hex . - Separate USB interface for the management processor. - Hence fpga_load can now work even with drivers loaded. * Fix firmware upgrading. * Fix manual firmware loading while auto-loading. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3142 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/xpp_usb.c')
-rw-r--r--xpp/xpp_usb.c60
1 files changed, 48 insertions, 12 deletions
diff --git a/xpp/xpp_usb.c b/xpp/xpp_usb.c
index 6ed7a39..5d34554 100644
--- a/xpp/xpp_usb.c
+++ b/xpp/xpp_usb.c
@@ -28,6 +28,24 @@
# undef USB_FIELDS_MISSING
#else
# define USB_FIELDS_MISSING
+
+# define USB_MAX_STRING 128
+# define USB_GET_STRING(udev,field,buf) \
+ do { \
+ if((udev)->descriptor.field) { \
+ char tmp[USB_MAX_STRING]; \
+ if(usb_string((udev), (udev)->descriptor.field, tmp, sizeof(tmp)) > 0) \
+ snprintf((buf), USB_MAX_STRING, "%s", tmp); \
+ } \
+ } while(0);
+# define USB_GET_IFACE_NAME(udev,iface,buf) \
+ do { \
+ if((iface)->desc.iInterface) { \
+ char tmp[USB_MAX_STRING]; \
+ if(usb_string((udev), (iface)->desc.iInterface, tmp, sizeof(tmp)) > 0) \
+ snprintf((buf), USB_MAX_STRING, "%s", tmp); \
+ } \
+ } while(0);
#endif
#include <linux/kernel.h>
@@ -173,6 +191,20 @@ typedef struct xpp_usb_bus {
/* metrics */
struct timeval last_tx;
unsigned int max_tx_delay;
+
+#ifdef USB_FIELDS_MISSING
+ /* storage for missing strings in old kernels */
+ char manufacturer[USB_MAX_STRING];
+ char product[USB_MAX_STRING];
+ char serial[USB_MAX_STRING];
+ char interface_name[USB_MAX_STRING];
+#else
+ const char *manufacturer;
+ const char *product;
+ const char *serial;
+ const char *interface_name;
+#endif
+
} xusb_t;
static spinlock_t xusb_lock = SPIN_LOCK_UNLOCKED;
@@ -657,9 +689,18 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
goto probe_failed;
}
#ifndef USB_FIELDS_MISSING
- INFO("XUSB: manufacturer=[%s] product=[%s] serial=[%s] interface=[%s]\n",
- udev->manufacturer, udev->product, udev->serial, iface_desc->string);
+ xusb->serial = udev->serial;
+ xusb->manufacturer = udev->manufacturer;
+ xusb->product = udev->product;
+ xusb->interface_name = iface_desc->string;
+#else
+ USB_GET_STRING(udev, iSerialNumber, xusb->serial);
+ USB_GET_STRING(udev, iManufacturer, xusb->manufacturer);
+ USB_GET_STRING(udev, iProduct, xusb->product);
+ USB_GET_IFACE_NAME(udev, iface_desc, xusb->interface_name);
#endif
+ INFO("XUSB: manufacturer=[%s] product=[%s] serial=[%s] interface=[%s]\n",
+ xusb->manufacturer, xusb->product, xusb->serial, xusb->interface_name);
/* allow device read, write and ioctl */
xusb->present = 1;
@@ -704,11 +745,8 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
usb_make_path(udev, path, XBUS_DESCLEN); // May trunacte... ignore
snprintf(xbus->busdesc, XBUS_DESCLEN, "%s", path);
}
-#ifndef USB_FIELDS_MISSING
- if(udev->serial)
- memcpy(xbus->serialnum, udev->serial, SERIAL_SIZE);
-#endif
-
+ if(xusb->serial && xusb->serial[0])
+ snprintf(xbus->serialnum, SERIALNUM_SIZE, "usb:%s", xusb->serial);
DBG(GENERAL, "GOT XPP USB BUS #%d: %s (type=%d)\n", i, xbus->busdesc, xbus->bus_type);
xusb_array[i] = xusb;
@@ -992,11 +1030,9 @@ static int xusb_read_proc(char *page, char **start, off_t off, int count, int *e
xusb->udev->bus->busnum,
xusb->udev->devnum
);
-#ifndef USB_FIELDS_MISSING
- len += sprintf(page + len, "USB: manufacturer=%s\n", xusb->udev->manufacturer);
- len += sprintf(page + len, "USB: product=%s\n", xusb->udev->product);
- len += sprintf(page + len, "USB: serial=%s\n", xusb->udev->serial);
-#endif
+ len += sprintf(page + len, "USB: manufacturer=%s\n", xusb->manufacturer);
+ len += sprintf(page + len, "USB: product=%s\n", xusb->product);
+ len += sprintf(page + len, "USB: serial=%s\n", xusb->serial);
len += sprintf(page + len, "Minor: %d\n"
"Model Info: Bus Type=%d (%s)\n",
xusb->minor,