From 421dd9e2c37b9c203e6fce7b1410453c2e8de217 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Thu, 20 Sep 2012 13:40:40 +0000 Subject: xtalk: Caller passes xusb_spec to xusb_find_iface() * This xusb_spec: - Is a dummy struct used for this xusb instance only. - Is now passed by reference from caller. - So caller now manage the life cycle of this struct * Also, demote one INFO() to DBG() (library should not print on its own) * Also minor fix to DBG() output of spec initialization (leading 0) Signed-off-by: Oron Peled Acked-by: Tzafrir Cohen Origin: Xorcom xtalk (r9303) git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@10711 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- xpp/xtalk/xusb.c | 16 ++++++++++------ xpp/xtalk/xusb.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/xpp/xtalk/xusb.c b/xpp/xtalk/xusb.c index b1c7c74..6a85fd2 100644 --- a/xpp/xtalk/xusb.c +++ b/xpp/xtalk/xusb.c @@ -67,7 +67,7 @@ void xusb_init_spec(struct xusb_spec *spec, char *name, uint16_t vendor_id, uint16_t product_id, int nifaces, int iface, int nep, int ep_out, int ep_in) { - DBG("Initialize %s: interfaces=%d using interface num=%d endpoints=%d (OUT=0x%2X, IN=0x%2X)\n", + DBG("Initialize %s: interfaces=%d using interface num=%d endpoints=%d (OUT=0x%02X, IN=0x%02X)\n", name, nifaces, iface, nep, ep_out, ep_in); memset(spec, 0, sizeof(*spec)); spec->name = name; @@ -365,7 +365,11 @@ fail: return NULL; } -struct xusb *xusb_find_iface(const char *devpath, int iface_num, int ep_out, int ep_in) +struct xusb *xusb_find_iface(const char *devpath, + int iface_num, + int ep_out, + int ep_in, + struct xusb_spec *dummy_spec) { struct usb_bus *bus; @@ -387,7 +391,6 @@ struct xusb *xusb_find_iface(const char *devpath, int iface_num, int ep_out, int struct usb_device_descriptor *dev_desc; struct usb_config_descriptor *config_desc; struct usb_interface *interface; - struct xusb_spec spec; struct xusb *xusb; int device_num; @@ -402,14 +405,15 @@ struct xusb *xusb_find_iface(const char *devpath, int iface_num, int ep_out, int assert(config_desc); interface = config_desc->interface; assert(interface); - INFO("Matched device %s: %X:%X\n", tmppath, dev_desc->idVendor, dev_desc->idProduct); - xusb_init_spec(&spec, "Astribank", + DBG("Matched device %s: %X:%X\n", tmppath, dev_desc->idVendor, dev_desc->idProduct); + assert(dummy_spec); + xusb_init_spec(dummy_spec, "", dev_desc->idVendor, dev_desc->idProduct, config_desc->bNumInterfaces, iface_num, interface->altsetting->bNumEndpoints, ep_out, ep_in); - if((xusb = xusb_new(dev, &spec)) == NULL) { + if((xusb = xusb_new(dev, dummy_spec)) == NULL) { ERR("xusb allocation failed\n"); } return xusb; diff --git a/xpp/xtalk/xusb.h b/xpp/xtalk/xusb.h index 65da029..2859475 100644 --- a/xpp/xtalk/xusb.h +++ b/xpp/xtalk/xusb.h @@ -67,7 +67,7 @@ typedef int (*xusb_filter_t)(const struct xusb *xusb, void *data); struct xlist_node *xusb_find_byproduct(const struct xusb_spec *specs, int numspecs, xusb_filter_t filterfunc, void *data); struct xusb *xusb_find_bypath(const struct xusb_spec *specs, int numspecs, const char *path); struct xusb *xusb_open_one(const struct xusb_spec *specs, int numspecs, xusb_filter_t filterfunc, void *data); -struct xusb *xusb_find_iface(const char *devpath, int iface_num, int ep_out, int ep_in); +struct xusb *xusb_find_iface(const char *devpath, int iface_num, int ep_out, int ep_in, struct xusb_spec *dummy); /* * A convenience filter -- cgit v1.2.3