Staging: unisys: Remove RETINT macro
[linux/fpc-iii.git] / drivers / staging / ozwpan / ozurbparanoia.c
blobcf6278a198a8b52ac22ae3cd0d940ccdd70cb36b
1 /* -----------------------------------------------------------------------------
2 * Copyright (c) 2011 Ozmo Inc
3 * Released under the GNU General Public License Version 2 (GPLv2).
4 * -----------------------------------------------------------------------------
5 */
6 #include <linux/usb.h>
7 #include "ozdbg.h"
9 #ifdef WANT_URB_PARANOIA
11 #include "ozurbparanoia.h"
13 #define OZ_MAX_URBS 1000
14 struct urb *g_urb_memory[OZ_MAX_URBS];
15 int g_nb_urbs;
16 DEFINE_SPINLOCK(g_urb_mem_lock);
18 void oz_remember_urb(struct urb *urb)
20 unsigned long irq_state;
22 spin_lock_irqsave(&g_urb_mem_lock, irq_state);
23 if (g_nb_urbs < OZ_MAX_URBS) {
24 g_urb_memory[g_nb_urbs++] = urb;
25 oz_dbg(ON, "urb up = %d %p\n", g_nb_urbs, urb);
26 } else {
27 oz_dbg(ON, "ERROR urb buffer full\n");
29 spin_unlock_irqrestore(&g_urb_mem_lock, irq_state);
34 int oz_forget_urb(struct urb *urb)
36 unsigned long irq_state;
37 int i;
38 int rc = -1;
40 spin_lock_irqsave(&g_urb_mem_lock, irq_state);
41 for (i = 0; i < g_nb_urbs; i++) {
42 if (g_urb_memory[i] == urb) {
43 rc = 0;
44 if (--g_nb_urbs > i)
45 memcpy(&g_urb_memory[i], &g_urb_memory[i+1],
46 (g_nb_urbs - i) * sizeof(struct urb *));
47 oz_dbg(ON, "urb down = %d %p\n", g_nb_urbs, urb);
50 spin_unlock_irqrestore(&g_urb_mem_lock, irq_state);
51 return rc;
53 #endif /* #ifdef WANT_URB_PARANOIA */