1 /*****************************************************************************/
4 * ezusb.c -- Firmware download miscdevice for Anchorchips EZUSB microcontrollers.
7 * Thomas Sailer (sailer@ife.ee.ethz.ch)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * 0.1 26.05.99 Created
25 * 0.2 23.07.99 Removed EZUSB_INTERRUPT. Interrupt pipes may be polled with
27 * Implemented EZUSB_SETINTERFACE, more sanity checks for EZUSB_BULK.
28 * Preliminary ISO support
29 * 0.3 01.09.99 Async Bulk and ISO support
34 /*****************************************************************************/
36 #include <linux/config.h>
37 #include <linux/module.h>
38 #include <linux/socket.h>
39 #include <linux/miscdevice.h>
40 #include <linux/list.h>
41 #include <linux/vmalloc.h>
42 #include <linux/slab.h>
43 #include <linux/spinlock.h>
44 #include <asm/uaccess.h>
49 /* --------------------------------------------------------------------- */
54 struct semaphore mutex
;
55 struct usb_device
*usbdev
;
56 struct list_head async_pending
;
57 struct list_head async_completed
;
58 wait_queue_head_t wait
;
63 struct list_head asynclist
;
70 struct usb_isoc_desc
*iso
;
73 unsigned numframes
; /* 0 means bulk, > 0 means iso */
74 struct ezusb_asynccompleted completed
;
77 /* --------------------------------------------------------------------- */
79 extern inline unsigned ld2(unsigned int x
)
104 /* --------------------------------------------------------------------- */
106 extern __inline__
void async_removelist(struct async
*as
)
108 struct ezusb
*ez
= as
->ez
;
111 spin_lock_irqsave(&ez
->lock
, flags
);
112 list_del(&as
->asynclist
);
113 INIT_LIST_HEAD(&as
->asynclist
);
114 spin_unlock_irqrestore(&ez
->lock
, flags
);
117 extern __inline__
void async_newpending(struct async
*as
)
119 struct ezusb
*ez
= as
->ez
;
122 spin_lock_irqsave(&ez
->lock
, flags
);
123 list_add_tail(&as
->asynclist
, &ez
->async_pending
);
124 spin_unlock_irqrestore(&ez
->lock
, flags
);
127 extern __inline__
void async_movetocompleted(struct async
*as
)
129 struct ezusb
*ez
= as
->ez
;
132 spin_lock_irqsave(&ez
->lock
, flags
);
133 list_del(&as
->asynclist
);
134 list_add_tail(&as
->asynclist
, &ez
->async_completed
);
135 spin_unlock_irqrestore(&ez
->lock
, flags
);
138 extern __inline__
struct async
*async_getcompleted(struct ezusb
*ez
)
141 struct async
*as
= NULL
;
143 spin_lock_irqsave(&ez
->lock
, flags
);
144 if (!list_empty(&ez
->async_completed
)) {
145 as
= list_entry(ez
->async_completed
.next
, struct async
, asynclist
);
146 list_del(&as
->asynclist
);
147 INIT_LIST_HEAD(&as
->asynclist
);
149 spin_unlock_irqrestore(&ez
->lock
, flags
);
153 extern __inline__
struct async
*async_getpending(struct ezusb
*ez
, void *context
)
159 spin_lock_irqsave(&ez
->lock
, flags
);
160 for (p
= ez
->async_pending
.next
; p
!= &ez
->async_pending
; ) {
161 as
= list_entry(p
, struct async
, asynclist
);
163 if (as
->completed
.context
!= context
)
165 list_del(&as
->asynclist
);
166 INIT_LIST_HEAD(&as
->asynclist
);
167 spin_unlock_irqrestore(&ez
->lock
, flags
);
170 spin_unlock_irqrestore(&ez
->lock
, flags
);
174 /* --------------------------------------------------------------------- */
176 static int async_completed(int status
, void *__buffer
, int rval
, void *dev_id
)
178 struct async
*as
= (struct async
*)dev_id
;
179 struct ezusb
*ez
= as
->ez
;
182 printk(KERN_DEBUG
"ezusb: async_completed: status %d rval %d\n", status
, rval
);
183 as
->completed
.length
= rval
;
184 if (as
->numframes
> 0) {
185 as
->completed
.status
= USB_ST_NOERROR
;
186 for (cnt
= 0; cnt
< as
->numframes
; cnt
++) {
187 as
->completed
.isostat
[cnt
].status
= as
->desc
.iso
->frames
[cnt
].frame_status
;
188 as
->completed
.isostat
[cnt
].length
= as
->desc
.iso
->frames
[cnt
].frame_length
;
191 as
->completed
.status
= status
;
192 spin_lock(&ez
->lock
);
193 list_del(&as
->asynclist
);
194 list_add_tail(&as
->asynclist
, &ez
->async_completed
);
195 spin_unlock(&ez
->lock
);
200 static void remove_async(struct async
*as
)
202 if (as
->data
&& as
->dataorder
)
203 free_pages((unsigned long)as
->data
, as
->dataorder
);
205 usb_free_isoc(as
->desc
.iso
);
209 static void kill_async(struct async
*as
)
211 struct ezusb
*ez
= as
->ez
;
215 usb_kill_isoc(as
->desc
.iso
);
217 usb_terminate_bulk(ez
->usbdev
, as
->desc
.bulk
);
218 as
->completed
.status
= USB_ST_REMOVED
;
219 async_movetocompleted(as
);
222 static void destroy_all_async(struct ezusb
*ez
)
227 spin_lock_irqsave(&ez
->lock
, flags
);
228 if (!list_empty(&ez
->async_pending
)) {
229 as
= list_entry(ez
->async_pending
.next
, struct async
, asynclist
);
230 list_del(&as
->asynclist
);
231 INIT_LIST_HEAD(&as
->asynclist
);
232 spin_unlock_irqrestore(&ez
->lock
, flags
);
234 spin_lock_irqsave(&ez
->lock
, flags
);
236 spin_unlock_irqrestore(&ez
->lock
, flags
);
237 while ((as
= async_getcompleted(ez
)))
241 /* --------------------------------------------------------------------- */
243 static loff_t
ezusb_llseek(struct file
*file
, loff_t offset
, int origin
)
245 struct ezusb
*ez
= (struct ezusb
*)file
->private_data
;
249 offset
+= file
->f_pos
;
255 if (offset
< 0 || offset
>= 0x10000)
257 return (file
->f_pos
= offset
);
260 static ssize_t
ezusb_read(struct file
*file
, char *buf
, size_t sz
, loff_t
*ppos
)
262 struct ezusb
*ez
= (struct ezusb
*)file
->private_data
;
263 unsigned pos
= *ppos
;
270 if (*ppos
< 0 || *ppos
>= 0x10000)
277 while (sz
> 0 && pos
< 0x10000) {
281 if (pos
+ len
> 0x10000)
283 dr
.requesttype
= 0xc0;
288 i
= ez
->usbdev
->bus
->op
->control_msg(ez
->usbdev
, usb_rcvctrlpipe(ez
->usbdev
, 0), &dr
, b
, len
);
291 printk(KERN_WARNING
"ezusb: upload failed pos %u len %u ret %d\n", dr
.value
, dr
.length
, i
);
297 if (copy_to_user(buf
, b
, len
)) {
314 static ssize_t
ezusb_write(struct file
*file
, const char *buf
, size_t sz
, loff_t
*ppos
)
316 struct ezusb
*ez
= (struct ezusb
*)file
->private_data
;
317 unsigned pos
= *ppos
;
324 if (*ppos
< 0 || *ppos
>= 0x10000)
331 while (sz
> 0 && pos
< 0x10000) {
335 if (pos
+ len
> 0x10000)
337 if (copy_from_user(b
, buf
, len
)) {
344 dr
.requesttype
= 0x40;
349 i
= ez
->usbdev
->bus
->op
->control_msg(ez
->usbdev
, usb_sndctrlpipe(ez
->usbdev
, 0), &dr
, b
, len
);
352 printk(KERN_WARNING
"ezusb: download failed pos %u len %u ret %d\n", dr
.value
, dr
.length
, i
);
368 static int ezusb_open(struct inode
*inode
, struct file
*file
)
370 struct ezusb
*ez
= &ezusb
[0];
373 while (!ez
->usbdev
) {
375 if (!(file
->f_flags
& O_NONBLOCK
)) {
378 schedule_timeout(HZ
/2);
379 if (signal_pending(current
))
385 file
->private_data
= ez
;
390 static int ezusb_release(struct inode
*inode
, struct file
*file
)
392 struct ezusb
*ez
= (struct ezusb
*)file
->private_data
;
395 destroy_all_async(ez
);
401 static int ezusb_control(struct usb_device
*usbdev
, unsigned char requesttype
,
402 unsigned char request
, unsigned short value
,
403 unsigned short index
, unsigned short length
,
406 unsigned char *tbuf
= NULL
;
410 if (length
> PAGE_SIZE
)
412 /* __range_ok is broken;
413 with unsigned short size, it gave
414 addl %si,%edx ; sbbl %ecx,%ecx; cmpl %edx,12(%eax); sbbl $0,%ecx
416 if (requesttype
& 0x80) {
417 pipe
= usb_rcvctrlpipe(usbdev
, 0);
418 if (length
> 0 && !access_ok(VERIFY_WRITE
, data
, (unsigned int)length
))
421 pipe
= usb_sndctrlpipe(usbdev
, 0);
423 if (!(tbuf
= (unsigned char *)__get_free_page(GFP_KERNEL
)))
425 if (!(requesttype
& 0x80)) {
426 if (copy_from_user(tbuf
, data
, length
)) {
427 free_page((unsigned long)tbuf
);
432 i
= usb_control_msg(usbdev
, pipe
, request
, requesttype
, value
, index
, tbuf
, length
);
435 free_page((unsigned long)tbuf
);
436 printk(KERN_WARNING
"ezusb: EZUSB_CONTROL failed rqt %u rq %u len %u ret %d\n",
437 requesttype
, request
, length
, i
);
440 if (requesttype
& 0x80 && length
> 0 && copy_to_user(data
, tbuf
, length
))
443 free_page((unsigned long)tbuf
);
447 static int ezusb_bulk(struct usb_device
*usbdev
, unsigned int ep
, unsigned int length
, void *data
)
449 unsigned char *tbuf
= NULL
;
451 unsigned long len2
= 0;
454 if (length
> PAGE_SIZE
)
456 if ((ep
& ~0x80) >= 16)
459 pipe
= usb_rcvbulkpipe(usbdev
, ep
& 0x7f);
460 if (length
> 0 && !access_ok(VERIFY_WRITE
, data
, length
))
463 pipe
= usb_sndbulkpipe(usbdev
, ep
& 0x7f);
464 if (!usb_maxpacket(usbdev
, pipe
, !(ep
& 0x80)))
467 if (!(tbuf
= (unsigned char *)__get_free_page(GFP_KERNEL
)))
470 if (copy_from_user(tbuf
, data
, length
)) {
471 free_page((unsigned long)tbuf
);
476 ret
= usbdev
->bus
->op
->bulk_msg(usbdev
, pipe
, tbuf
, length
, &len2
);
479 free_page((unsigned long)tbuf
);
480 printk(KERN_WARNING
"ezusb: EZUSB_BULK failed ep 0x%x len %u ret %d\n",
487 if (ep
& 0x80 && len2
> 0 && copy_to_user(data
, tbuf
, len2
))
490 free_page((unsigned long)tbuf
);
494 static int ezusb_resetep(struct usb_device
*usbdev
, unsigned int ep
)
496 if ((ep
& ~0x80) >= 16)
498 usb_settoggle(usbdev
, ep
& 0xf, !(ep
& 0x80), 0);
502 static int ezusb_setinterface(struct usb_device
*usbdev
, unsigned int interface
, unsigned int altsetting
)
504 if (usb_set_interface(usbdev
, interface
, altsetting
) < 0)
509 static int ezusb_setconfiguration(struct usb_device
*usbdev
, unsigned int config
)
511 if (usb_set_configuration(usbdev
, config
) < 0)
516 static int ezusb_requestbulk(struct ezusb
*ez
, struct ezusb_asyncbulk
*ab
)
518 struct async
*as
= NULL
;
521 if (ab
->len
> PAGE_SIZE
)
523 if ((ab
->ep
& ~0x80) >= 16)
526 pipe
= usb_rcvbulkpipe(ez
->usbdev
, ab
->ep
& 0x7f);
527 if (ab
->len
> 0 && !access_ok(VERIFY_WRITE
, ab
->data
, ab
->len
))
530 pipe
= usb_sndbulkpipe(ez
->usbdev
, ab
->ep
& 0x7f);
531 if (!usb_maxpacket(ez
->usbdev
, pipe
, !(ab
->ep
& 0x80)))
533 if (!(as
= kmalloc(sizeof(struct async
), GFP_KERNEL
)))
535 INIT_LIST_HEAD(&as
->asynclist
);
537 as
->userdata
= ab
->data
;
541 as
->datalen
= ab
->len
;
542 as
->completed
.context
= ab
->context
;
545 if (!(as
->data
= (unsigned char *)__get_free_page(GFP_KERNEL
))) {
549 if (!(ab
->ep
& 0x80)) {
550 if (copy_from_user(as
->data
, ab
->data
, ab
->len
))
552 as
->datalen
= 0; /* no need to copy back at completion */
555 async_newpending(as
);
556 if (!(as
->desc
.bulk
= usb_request_bulk(ez
->usbdev
, pipe
, async_completed
, as
->data
, ab
->len
, as
))) {
557 async_removelist(as
);
565 free_page((unsigned long)as
->data
);
573 free_page((unsigned long)as
->data
);
579 static int ezusb_requestiso(struct ezusb
*ez
, struct ezusb_asynciso
*ai
, unsigned char *cmd
)
582 unsigned int maxpkt
, pipe
;
583 unsigned int dsize
, order
, assize
, j
;
586 if ((ai
->ep
& ~0x80) >= 16 || ai
->framecnt
< 1 || ai
->framecnt
> 128)
589 pipe
= usb_rcvisocpipe(ez
->usbdev
, ai
->ep
& 0x7f);
591 pipe
= usb_sndisocpipe(ez
->usbdev
, ai
->ep
& 0x7f);
592 if (!(maxpkt
= usb_maxpacket(ez
->usbdev
, pipe
, !(ai
->ep
& 0x80))))
594 dsize
= maxpkt
* ai
->framecnt
;
597 order
= ld2(dsize
>> PAGE_SHIFT
);
598 if (dsize
> (PAGE_SIZE
<< order
))
601 if (dsize
> 0 && !access_ok(VERIFY_WRITE
, ai
->data
, dsize
))
603 assize
= sizeof(struct async
) + ai
->framecnt
* sizeof(struct ezusb_isoframestat
);
604 if (!(as
= kmalloc(assize
, GFP_KERNEL
)))
606 memset(as
, 0, assize
);
607 INIT_LIST_HEAD(&as
->asynclist
);
609 as
->userdata
= ai
->data
;
610 as
->numframes
= ai
->framecnt
;
612 as
->dataorder
= order
;
614 as
->completed
.context
= ai
->context
;
617 if (!(as
->data
= (unsigned char *)__get_free_pages(GFP_KERNEL
, order
))) {
621 if (!(ai
->ep
& 0x80)) {
622 if (copy_from_user(as
->data
, ai
->data
, dsize
))
624 as
->datalen
= 0; /* no need to copy back at completion */
627 if ((i
= usb_init_isoc(ez
->usbdev
, pipe
, ai
->framecnt
, as
, &as
->desc
.iso
))) {
628 printk(KERN_DEBUG
"ezusb: usb_init_isoc error %d\n", i
);
631 as
->desc
.iso
->start_type
= START_ABSOLUTE
;
632 as
->desc
.iso
->start_frame
= ai
->startframe
;
633 as
->desc
.iso
->callback_frames
= 0;
634 as
->desc
.iso
->callback_fn
= async_completed
;
635 as
->desc
.iso
->data
= as
->data
;
636 as
->desc
.iso
->buf_size
= dsize
;
637 for (j
= 0; j
< ai
->framecnt
; j
++) {
638 if (get_user(i
, (int *)(cmd
+ j
* sizeof(struct ezusb_isoframestat
)))) {
639 usb_free_isoc(as
->desc
.iso
);
645 as
->desc
.iso
->frames
[j
].frame_length
= i
;
647 async_newpending(as
);
648 if ((i
= usb_run_isoc(as
->desc
.iso
, NULL
))) {
649 printk(KERN_DEBUG
"ezusb: usb_run_isoc error %d\n", i
);
650 async_removelist(as
);
658 usb_free_isoc(as
->desc
.iso
);
660 free_page((unsigned long)as
->data
);
668 usb_free_isoc(as
->desc
.iso
);
670 free_page((unsigned long)as
->data
);
676 static int ezusb_terminateasync(struct ezusb
*ez
, void *context
)
681 while ((as
= async_getpending(ez
, context
))) {
688 static int ezusb_asynccompl(struct async
*as
, void *arg
)
690 if (as
->datalen
> 0) {
691 if (copy_to_user(as
->userdata
, as
->data
, as
->datalen
)) {
696 if (copy_to_user(arg
, &as
->completed
,
697 sizeof(struct ezusb_asynccompleted
) +
698 as
->numframes
* sizeof(struct ezusb_isoframestat
))) {
706 static int ezusb_ioctl(struct inode
*inode
, struct file
*file
, unsigned int cmd
, unsigned long arg
)
708 struct ezusb
*ez
= (struct ezusb
*)file
->private_data
;
709 DECLARE_WAITQUEUE(wait
, current
);
710 struct usb_proc_ctrltransfer pctrl
;
711 struct usb_proc_bulktransfer pbulk
;
712 struct usb_proc_setinterface psetintf
;
713 struct ezusb_ctrltransfer ctrl
;
714 struct ezusb_bulktransfer bulk
;
715 struct ezusb_setinterface setintf
;
716 struct ezusb_asyncbulk abulk
;
717 struct ezusb_asynciso aiso
;
720 unsigned int ep
, cfg
;
729 case USB_PROC_CONTROL
:
730 if (copy_from_user(&pctrl
, (void *)arg
, sizeof(pctrl
))) {
734 ret
= ezusb_control(ez
->usbdev
, pctrl
.requesttype
, pctrl
.request
,
735 pctrl
.value
, pctrl
.index
, pctrl
.length
, pctrl
.data
);
739 if (copy_from_user(&pbulk
, (void *)arg
, sizeof(pbulk
))) {
743 ret
= ezusb_bulk(ez
->usbdev
, pbulk
.ep
, pbulk
.len
, pbulk
.data
);
746 case USB_PROC_RESETEP
:
747 if (get_user(ep
, (unsigned int *)arg
)) {
751 ret
= ezusb_resetep(ez
->usbdev
, ep
);
754 case USB_PROC_SETINTERFACE
:
755 if (copy_from_user(&psetintf
, (void *)arg
, sizeof(psetintf
))) {
759 ret
= ezusb_setinterface(ez
->usbdev
, psetintf
.interface
, psetintf
.altsetting
);
762 case USB_PROC_SETCONFIGURATION
:
763 if (get_user(cfg
, (unsigned int *)arg
)) {
767 ret
= ezusb_setconfiguration(ez
->usbdev
, cfg
);
771 if (copy_from_user(&ctrl
, (void *)arg
, sizeof(ctrl
))) {
775 if (ctrl
.dlen
!= ctrl
.length
) {
779 ret
= ezusb_control(ez
->usbdev
, ctrl
.requesttype
, ctrl
.request
,
780 ctrl
.value
, ctrl
.index
, ctrl
.length
, ctrl
.data
);
784 if (copy_from_user(&bulk
, (void *)arg
, sizeof(bulk
))) {
788 ret
= ezusb_bulk(ez
->usbdev
, bulk
.ep
, bulk
.len
, bulk
.data
);
792 if (get_user(ep
, (unsigned int *)arg
)) {
796 ret
= ezusb_resetep(ez
->usbdev
, ep
);
799 case EZUSB_SETINTERFACE
:
800 if (copy_from_user(&setintf
, (void *)arg
, sizeof(setintf
))) {
804 ret
= ezusb_setinterface(ez
->usbdev
, setintf
.interface
, setintf
.altsetting
);
807 case EZUSB_SETCONFIGURATION
:
808 if (get_user(cfg
, (unsigned int *)arg
)) {
812 ret
= ezusb_setconfiguration(ez
->usbdev
, cfg
);
815 case EZUSB_ASYNCCOMPLETED
:
816 current
->state
= TASK_INTERRUPTIBLE
;
817 add_wait_queue(&ez
->wait
, &wait
);
821 if ((as
= async_getcompleted(ez
)))
823 if (signal_pending(current
))
829 remove_wait_queue(&ez
->wait
, &wait
);
830 current
->state
= TASK_RUNNING
;
832 ret
= ezusb_asynccompl(as
, (void *)arg
);
835 if (signal_pending(current
)) {
842 case EZUSB_ASYNCCOMPLETEDNB
:
843 if ((as
= async_getcompleted(ez
))) {
844 ret
= ezusb_asynccompl(as
, (void *)arg
);
850 case EZUSB_REQUESTBULK
:
851 if (copy_from_user(&abulk
, (void *)arg
, sizeof(abulk
))) {
855 ret
= ezusb_requestbulk(ez
, &abulk
);
858 case EZUSB_REQUESTISO
:
859 if (copy_from_user(&aiso
, (void *)arg
, sizeof(aiso
))) {
863 ret
= ezusb_requestiso(ez
, &aiso
, ((unsigned char *)arg
)+sizeof(aiso
));
866 case EZUSB_TERMINATEASYNC
:
867 if (get_user(context
, (void **)arg
)) {
871 ret
= ezusb_terminateasync(ez
, context
);
874 case EZUSB_GETFRAMENUMBER
:
875 i
= usb_get_current_frame_number(ez
->usbdev
);
876 ret
= put_user(i
, (int *)arg
);
887 static struct file_operations ezusb_fops
= {
900 NULL
, /* check_media_change */
901 NULL
, /* revalidate */
905 static struct miscdevice ezusb_misc
= {
906 192, "ezusb", &ezusb_fops
909 /* --------------------------------------------------------------------- */
911 static int ezusb_probe(struct usb_device
*usbdev
)
913 struct ezusb
*ez
= &ezusb
[0];
914 struct usb_interface_descriptor
*interface
;
915 struct usb_endpoint_descriptor
*endpoint
;
918 #define KERN_DEBUG ""
919 printk(KERN_DEBUG
"ezusb: probe: vendor id 0x%x, device id 0x%x\n",
920 usbdev
->descriptor
.idVendor
, usbdev
->descriptor
.idProduct
);
922 /* the 1234:5678 is just a self assigned test ID */
923 if ((usbdev
->descriptor
.idVendor
!= 0x0547 || usbdev
->descriptor
.idProduct
!= 0x2131) &&
924 (usbdev
->descriptor
.idVendor
!= 0x1234 || usbdev
->descriptor
.idProduct
!= 0x5678))
927 /* We don't handle multiple configurations */
928 if (usbdev
->descriptor
.bNumConfigurations
!= 1)
931 /* We don't handle multiple interfaces */
932 if (usbdev
->config
[0].bNumInterfaces
!= 1)
938 printk(KERN_INFO
"ezusb: device already used\n");
942 usbdev
->private = ez
;
943 if (usb_set_configuration(usbdev
, usbdev
->config
[0].bConfigurationValue
) < 0) {
944 printk(KERN_ERR
"ezusb: set_configuration failed\n");
947 interface
= &usbdev
->config
[0].interface
[0].altsetting
[1];
948 if (usb_set_interface(usbdev
, 0, 1) < 0) {
949 printk(KERN_ERR
"ezusb: set_interface failed\n");
959 usbdev
->private = NULL
;
963 static void ezusb_disconnect(struct usb_device
*usbdev
)
965 struct ezusb
*ez
= (struct ezusb
*)usbdev
->private;
968 destroy_all_async(ez
);
972 usbdev
->private = NULL
;
976 static struct usb_driver ezusb_driver
= {
983 /* --------------------------------------------------------------------- */
989 /* initialize struct */
990 for (u
= 0; u
< NREZUSB
; u
++) {
991 init_MUTEX(&ezusb
[u
].mutex
);
992 ezusb
[u
].usbdev
= NULL
;
993 INIT_LIST_HEAD(&ezusb
[u
].async_pending
);
994 INIT_LIST_HEAD(&ezusb
[u
].async_completed
);
995 init_waitqueue_head(&ezusb
[u
].wait
);
996 spin_lock_init(&ezusb
[u
].lock
);
998 /* register misc device */
999 if (misc_register(&ezusb_misc
)) {
1000 printk(KERN_WARNING
"ezusb: cannot register minor %d\n", ezusb_misc
.minor
);
1003 usb_register(&ezusb_driver
);
1004 printk(KERN_INFO
"ezusb: Anchorchip firmware download driver registered\n");
1008 void ezusb_cleanup(void)
1010 usb_deregister(&ezusb_driver
);
1011 misc_deregister(&ezusb_misc
);
1014 /* --------------------------------------------------------------------- */
1020 int init_module(void)
1022 ezusb_misc
.minor
= minor
;
1023 return ezusb_init();
1026 void cleanup_module(void)
1033 /* --------------------------------------------------------------------- */