1 /*****************************************************************************/
2 /*
3  *      auerbuf.h  --  Auerswald PBX/System Telephone urb list storage.
4  *
5  *      Copyright (C) 2002  Wolfgang M�es (wolfgang@iksw-muees.de)
6  *
7  *      This program is free software; you can redistribute it and/or modify
8  *      it under the terms of the GNU General Public License as published by
9  *      the Free Software Foundation; either version 2 of the License, or
10  *      (at your option) any later version.
11  *
12  *      This program is distributed in the hope that it will be useful,
13  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *      GNU General Public License for more details.
16  *
17  *      You should have received a copy of the GNU General Public License
18  *      along with this program; if not, write to the Free Software
19  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21  /*****************************************************************************/
22 
23 /* This module assembles together an URB, an usb_ctrlrequest struct for sending of
24  * control messages, and a data buffer.
25  * These items (auerbuf) are collected in a list (auerbufctl) and are used
26  * for serialized usb data transfer.
27  */
28 
29 #ifndef AUERBUF_H
30 #define AUERBUF_H
31 
32 #include <linux/usb.h>
33 
34 /* buffer element */
35 struct auerbufctl;			/* forward */
36 struct auerbuf {
37 	unsigned char *bufp;		/* reference to allocated data buffer */
38 	unsigned int len;		/* number of characters in data buffer */
39 	unsigned int retries;		/* for urb retries */
40 	struct usb_ctrlrequest *dr;	/* for setup data in control messages */
41 	struct urb *urbp;		/* USB urb */
42 	struct auerbufctl *list;	/* pointer to list */
43 	struct list_head buff_list;	/* reference to next buffer in list */
44 };
45 
46 /* buffer list control block */
47 struct auerbufctl {
48 	spinlock_t lock;		/* protection in interrupt */
49 	struct list_head free_buff_list;/* free buffers */
50 	struct list_head rec_buff_list;	/* buffers with received data */
51 };
52 
53 /* Function prototypes */
54 void auerbuf_free(struct auerbuf *bp);
55 
56 void auerbuf_free_list(struct list_head *q);
57 
58 void auerbuf_init(struct auerbufctl *bcp);
59 
60 void auerbuf_free_buffers(struct auerbufctl *bcp);
61 
62 int auerbuf_setup(struct auerbufctl *bcp, unsigned int numElements,
63 		  unsigned int bufsize);
64 
65 struct auerbuf *auerbuf_getbuf(struct auerbufctl *bcp);
66 
67 void auerbuf_releasebuf(struct auerbuf *bp);
68 
69 #endif	/* AUERBUF_H */
70