~ubuntu-branches/ubuntu/quantal/zaptel/quantal

« back to all changes in this revision

Viewing changes to xpp/xpp_usb.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2006-10-24 22:41:01 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20061024224101-464p4n2jk16n1jrh
Tags: 1:1.2.10.dfsg-2
* bristuff-0.3.0-PRE-1v
* Remove redundant GPL LICENCE text

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#include "card_fxo.h"
48
48
#endif
49
49
 
50
 
static const char rcsid[] = "$Id: xpp_usb.c 1230 2006-07-14 20:19:48Z tzafrir $";
 
50
static const char rcsid[] = "$Id: xpp_usb.c 1457 2006-09-09 15:24:12Z tzafrir $";
51
51
 
52
52
DEF_PARM(int, print_dbg, 0, "Print DBG statements");    /* must be before zap_debug.h */
53
53
 
292
292
        if(!xusb->present) {
293
293
                NOTICE("tried to send packets to non-exitant USB device. Ignored\n");
294
294
                ret = -ENODEV;
295
 
                goto out;
 
295
                goto freepack;
 
296
        }
 
297
        /*
 
298
         * If something really bad happend, do not overflow the USB stack
 
299
         */
 
300
        if(atomic_read(&xusb->pending_writes) > MAX_PENDING_WRITES) {
 
301
                static  int rate_limit;
 
302
 
 
303
                if((rate_limit++ % 1000) < 10)
 
304
                        ERR("%s: %s: more than %d pending writes. Dropping.\n", __FUNCTION__, xbus->busname, MAX_PENDING_WRITES);
 
305
                ret = -ENODEV;
 
306
                goto freepack;
296
307
        }
297
308
        size = PACKET_LEN(pack);
298
309
        xusb_ep = &xusb->endpoints[XUSB_SEND];
300
311
        if (!urb) {
301
312
                ERR("No free urbs available\n");
302
313
                ret = -ENOMEM;
303
 
                goto out;
 
314
                goto freepack;
304
315
        }
305
316
        packet_debug("USB_PACKET_SEND", xusb, pack);
306
317
 
309
320
 
310
321
        ret = usb_submit_urb(urb, GFP_ATOMIC);
311
322
        if(ret < 0) {
312
 
                ERR("%s: failed submit_urb: %d\n", __FUNCTION__, ret);
 
323
                static int rate_limit;
 
324
 
 
325
                if((rate_limit++ % 1000) < 5)
 
326
                        ERR("%s: failed submit_urb: %d\n", __FUNCTION__, ret);
313
327
                xpp_urb_delete(urb);
314
328
                ret = -EBADF;
315
 
                goto out;
 
329
                goto freepack;
316
330
        }
317
331
        atomic_inc(&xusb->pending_writes);
318
 
        if(atomic_read(&xusb->pending_writes) > MAX_PENDING_WRITES) {
319
 
                static  int rate_limit;
320
 
 
321
 
                if((rate_limit++ % 1000) < 10)
322
 
                        ERR("%s: %s: more than %d pending writes. Dropping.\n", __FUNCTION__, xbus->busname, MAX_PENDING_WRITES);
323
 
                ret = -ENODEV;
324
 
        }
325
332
        if(pack->content.opcode == XPROTO_NAME(GLOBAL,PCM_WRITE))
326
333
                XUSB_COUNTER(xusb, PCM_WRITES)++;
327
 
out:
 
334
freepack:
 
335
        xbus->ops->packet_free(xbus, pack);     // FIXME: eventually will be done in the urb callback
328
336
        if(ret < 0)
329
337
                XUSB_COUNTER(xusb, TX_ERRORS)++;
330
 
        xbus->ops->packet_free(xbus, pack);     // FIXME: eventually will be done in the urb callback
331
338
        return ret;
332
339
}
333
340
 
705
712
 
706
713
#ifdef CONFIG_PROC_FS
707
714
        if(xbus->proc_xbus_dir) {
 
715
                DBG("Remove proc_entry: " PROC_USBXPP_SUMMARY "\n");
708
716
                remove_proc_entry(PROC_USBXPP_SUMMARY, xbus->proc_xbus_dir);
709
 
                xbus->proc_xbus_dir = NULL;
710
717
        }
711
718
#endif
712
719
        xusb->present = 0;