summaryrefslogtreecommitdiff
path: root/kernel/xpp/xpp_usb.c
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-03-19 20:08:29 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-03-19 20:08:29 +0000
commitd8562c778088ff6ab3383df5ceead41eff4bf124 (patch)
tree43e394ae225fd7183018c2ae08d3fb1e5bcb12cb /kernel/xpp/xpp_usb.c
parentb6b3226735f5e3b3fb000fa92daa7a574265c817 (diff)
xpp: a massive backport from DAHDI. From Xorcom branch-rel-6839-r6908 .
Sun Mar 1 2009 Oron Peled <oron@actcom.co.il> - xpp.r6795 * Fix cases where the command_queue overflowed during initialization. - Also add a 'command_queue_length' parameter to xpp.ko * More migrations to sysfs: - Add a 'transport' attribute to our astribank devices which points to the usb device we use. E.g: /sys/bus/astribanks/devices/xbus-00/transport is symlinked to ../../../../../../devices/pci0000:00/0000:00:10.4/usb5/5-4 - Move /proc/xpp/XBUS-??/XPD-??/span to /sys/bus/xpds/devices/??:?:?/span - Migrate from /proc/xpp/sync to: /sys/bus/astribanks/drivers/xppdrv/sync - New 'offhook' attribute in: /sys/bus/xpds/devices/??:?:?/offhook * PRI: change the "timing" priority to match the convention used by other PRI cards -- I.e: lower numbers (not 0) have higher priority. * FXO: - Power denial: create two module parameters instead of hard-coded constants (power_denial_safezone, power_denial_minlen). For sites that get non-standard power-denial signals from central office on offhook. - Don't hangup on power-denial, just notify Dahdi and wait for - Fix caller-id detection for the case central office sends it before first ring without any indication before. Asterisk's desicion. Mon, Dec 8 2008 Oron Peled <oron@actcom.co.il> - xpp.r6430 * PRI: - Match our span clocking priorities (in system.conf) to Digium -- this is a reversal of the previous state. Now lower numbers (greater than 0) are better. - Synchronization fixes for PRI ports other than 0. - Fix T1 CRC for some countries (e.g: China). * FXS: fix bug in VMWI detection if using old asterisk which does not provide ZT_VMWI ioctl(). * FXO: - Improve caller_id_style module parameter. This provide a workaround for countries that send this information without any notification (reverse polarity, ring, etc.) - Don't force on-hook upon power-denial. So, loopstart devices would ignore these as expected. * Implement a flow-control to prevent user space (init_card_* scripts) from pressuring our command queue. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4631 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/xpp_usb.c')
-rw-r--r--kernel/xpp/xpp_usb.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/kernel/xpp/xpp_usb.c b/kernel/xpp/xpp_usb.c
index 2b633c6..0340768 100644
--- a/kernel/xpp/xpp_usb.c
+++ b/kernel/xpp/xpp_usb.c
@@ -439,7 +439,7 @@ static int xframe_send_cmd(xbus_t *xbus, xframe_t *xframe)
*/
static bool xusb_listen(xusb_t *xusb)
{
- xbus_t *xbus = get_xbus(xusb->xbus_num);
+ xbus_t *xbus = xbus_num(xusb->xbus_num);
xframe_t *xframe;
struct uframe *uframe;
int ret = 0;
@@ -465,7 +465,6 @@ static bool xusb_listen(xusb_t *xusb)
atomic_inc(&xusb->pending_reads);
ret = 1;
out:
- put_xbus(xbus);
return ret;
}
@@ -710,7 +709,7 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
xusb->present = 1;
/* we can register the device now, as it is ready */
- usb_set_intfdata (interface, xusb);
+ usb_set_intfdata(interface, xusb);
retval = usb_register_dev (interface, &xusb_class);
if (retval) {
/* something prevented us from registering this driver */
@@ -722,7 +721,7 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
/* let the user know what node this device is now attached to */
DBG(DEVICES, "USB XPP device now attached to minor %d\n", xusb->minor);
- xbus = xbus_new(&xusb_ops, min(xusb->endpoints[XUSB_SEND].max_size, xusb->endpoints[XUSB_RECV].max_size), xusb);
+ xbus = xbus_new(&xusb_ops, min(xusb->endpoints[XUSB_SEND].max_size, xusb->endpoints[XUSB_RECV].max_size), &udev->dev, xusb);
if(!xbus) {
retval = -ENOMEM;
goto probe_failed;
@@ -739,12 +738,12 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
goto probe_failed;
}
usb_make_path(udev, xusb->path, XBUS_DESCLEN); // May trunacte... ignore
- snprintf(xbus->location, XBUS_DESCLEN, "%s", xusb->path);
+ snprintf(xbus->connector, XBUS_DESCLEN, "%s", xusb->path);
if(xusb->serial && xusb->serial[0])
snprintf(xbus->label, LABEL_SIZE, "usb:%s", xusb->serial);
xusb->index = i;
xusb_array[i] = xusb;
- XUSB_DBG(DEVICES, xusb, "GOT XPP USB BUS: %s\n", xbus->location);
+ XUSB_DBG(DEVICES, xusb, "GOT XPP USB BUS: %s\n", xbus->connector);
#ifdef CONFIG_PROC_FS
DBG(PROC, "Creating proc entry " PROC_USBXPP_SUMMARY " in bus proc dir.\n");
@@ -763,11 +762,11 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
/* prepare several pending frames for receive side */
for(i = 0; i < 10; i++)
xusb_listen(xusb);
- xbus_activate(xbus);
+ xbus_connect(xbus);
return retval;
probe_failed:
ERR("Failed to initialize xpp usb bus: %d\n", retval);
- usb_set_intfdata (interface, NULL);
+ usb_set_intfdata(interface, NULL);
if(xusb) {
if(xusb->minor) { // passed registration phase
ERR("Calling usb_deregister_dev()\n");
@@ -801,18 +800,20 @@ probe_failed:
*/
static void xusb_disconnect(struct usb_interface *interface)
{
+ struct usb_host_interface *iface_desc = usb_altnum_to_altsetting(interface, 0);
xusb_t *xusb;
xbus_t *xbus;
int minor;
int i;
- DBG(DEVICES, "CALLED\n");
+ DBG(DEVICES, "CALLED on interface #%d\n", iface_desc->desc.bInterfaceNumber);
/* prevent races with open() */
down (&disconnect_sem);
- xusb = usb_get_intfdata (interface);
+ xusb = usb_get_intfdata(interface);
+ usb_set_intfdata(interface, NULL);
xusb->present = 0;
- xbus = get_xbus(xusb->xbus_num);
+ xbus = xbus_num(xusb->xbus_num);
/* find our xusb */
for(i = 0; i < MAX_BUSES; i++) {
@@ -828,17 +829,13 @@ static void xusb_disconnect(struct usb_interface *interface)
remove_proc_entry(PROC_USBXPP_SUMMARY, xbus->proc_xbus_dir);
}
#endif
- /*
- * put_xbus() would be called during xbus_disconnect()
- */
xbus_disconnect(xbus); // Blocking until fully deactivated!
- usb_set_intfdata (interface, NULL);
down (&xusb->sem);
minor = xusb->minor;
/* give back our minor */
- usb_deregister_dev (interface, &xusb_class);
+ usb_deregister_dev(interface, &xusb_class);
up (&xusb->sem);
DBG(DEVICES, "Semaphore released\n");
@@ -853,7 +850,7 @@ static void xpp_send_callback(USB_PASS_CB(urb))
struct uframe *uframe = urb_to_uframe(urb);
xframe_t *xframe = &uframe->xframe;
xusb_t *xusb = uframe->xusb;
- xbus_t *xbus = get_xbus(xusb->xbus_num);
+ xbus_t *xbus = xbus_num(xusb->xbus_num);
struct timeval now;
long usec;
int writes = atomic_read(&xusb->pending_writes);
@@ -904,7 +901,6 @@ static void xpp_send_callback(USB_PASS_CB(urb))
FREE_SEND_XFRAME(xbus, xframe);
if(!xusb->present)
XUSB_ERR(xusb, "A urb from non-connected device?\n");
- put_xbus(xbus);
}
static void xpp_receive_callback(USB_PASS_CB(urb))
@@ -912,7 +908,7 @@ static void xpp_receive_callback(USB_PASS_CB(urb))
struct uframe *uframe = urb_to_uframe(urb);
xframe_t *xframe = &uframe->xframe;
xusb_t *xusb = uframe->xusb;
- xbus_t *xbus = get_xbus(xusb->xbus_num);
+ xbus_t *xbus = xbus_num(xusb->xbus_num);
size_t size;
bool do_resubmit = 1;
bool is_inuse = 0;
@@ -924,11 +920,6 @@ static void xpp_receive_callback(USB_PASS_CB(urb))
XUSB_ERR(xusb, "Received URB does not belong to a valid xbus anymore...\n");
return;
}
- if(!XBUS_GET(xbus)) {
- XUSB_ERR(xusb, "Dropping urb. Is shutting down.\n");
- do_resubmit = 0;
- goto err;
- }
is_inuse = 1;
if(!xusb->present) {
do_resubmit = 0;
@@ -957,11 +948,8 @@ static void xpp_receive_callback(USB_PASS_CB(urb))
/* Send UP */
xbus_receive_xframe(xbus, xframe);
end:
- if(is_inuse)
- XBUS_PUT(xbus);
if(do_resubmit)
xusb_listen(xusb);
- put_xbus(xbus);
return;
err:
FREE_RECV_XFRAME(xbus, xframe);