GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / usb / misc / uss720.c
blob78e266721a3fd2a0da6994d3a49793eda67f6e8c
1 /*****************************************************************************/
3 /*
4 * uss720.c -- USS720 USB Parport Cable.
6 * Copyright (C) 1999, 2005, 2010
7 * Thomas Sailer (t.sailer@alumni.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.
23 * Based on parport_pc.c
25 * History:
26 * 0.1 04.08.1999 Created
27 * 0.2 07.08.1999 Some fixes mainly suggested by Tim Waugh
28 * Interrupt handling currently disabled because
29 * usb_request_irq crashes somewhere within ohci.c
30 * for no apparent reason (that is for me, anyway)
31 * ECP currently untested
32 * 0.3 10.08.1999 fixing merge errors
33 * 0.4 13.08.1999 Added Vendor/Product ID of Brad Hard's cable
34 * 0.5 20.09.1999 usb_control_msg wrapper used
35 * Nov01.2000 usb_device_table support by Adam J. Richter
36 * 08.04.2001 Identify version on module load. gb
37 * 0.6 02.09.2005 Fix "scheduling in interrupt" problem by making save/restore
38 * context asynchronous
42 /*****************************************************************************/
44 #include <linux/module.h>
45 #include <linux/socket.h>
46 #include <linux/parport.h>
47 #include <linux/init.h>
48 #include <linux/usb.h>
49 #include <linux/delay.h>
50 #include <linux/completion.h>
51 #include <linux/kref.h>
52 #include <linux/slab.h>
55 * Version Information
57 #define DRIVER_VERSION "v0.6"
58 #define DRIVER_AUTHOR "Thomas M. Sailer, t.sailer@alumni.ethz.ch"
59 #define DRIVER_DESC "USB Parport Cable driver for Cables using the Lucent Technologies USS720 Chip"
61 /* --------------------------------------------------------------------- */
63 struct parport_uss720_private {
64 struct usb_device *usbdev;
65 struct parport *pp;
66 struct kref ref_count;
67 __u8 reg[7]; /* USB registers */
68 struct list_head asynclist;
69 spinlock_t asynclock;
72 struct uss720_async_request {
73 struct parport_uss720_private *priv;
74 struct kref ref_count;
75 struct list_head asynclist;
76 struct completion compl;
77 struct urb *urb;
78 struct usb_ctrlrequest dr;
79 __u8 reg[7];
82 /* --------------------------------------------------------------------- */
84 static void destroy_priv(struct kref *kref)
86 struct parport_uss720_private *priv = container_of(kref, struct parport_uss720_private, ref_count);
88 usb_put_dev(priv->usbdev);
89 kfree(priv);
90 dbg("destroying priv datastructure");
93 static void destroy_async(struct kref *kref)
95 struct uss720_async_request *rq = container_of(kref, struct uss720_async_request, ref_count);
96 struct parport_uss720_private *priv = rq->priv;
97 unsigned long flags;
99 if (likely(rq->urb))
100 usb_free_urb(rq->urb);
101 spin_lock_irqsave(&priv->asynclock, flags);
102 list_del_init(&rq->asynclist);
103 spin_unlock_irqrestore(&priv->asynclock, flags);
104 kfree(rq);
105 kref_put(&priv->ref_count, destroy_priv);
108 /* --------------------------------------------------------------------- */
110 static void async_complete(struct urb *urb)
112 struct uss720_async_request *rq;
113 struct parport *pp;
114 struct parport_uss720_private *priv;
115 int status = urb->status;
117 rq = urb->context;
118 priv = rq->priv;
119 pp = priv->pp;
120 if (status) {
121 err("async_complete: urb error %d", status);
122 } else if (rq->dr.bRequest == 3) {
123 memcpy(priv->reg, rq->reg, sizeof(priv->reg));
124 /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */
125 if (rq->reg[2] & rq->reg[1] & 0x10 && pp)
126 parport_generic_irq(pp);
128 complete(&rq->compl);
129 kref_put(&rq->ref_count, destroy_async);
132 static struct uss720_async_request *submit_async_request(struct parport_uss720_private *priv,
133 __u8 request, __u8 requesttype, __u16 value, __u16 index,
134 gfp_t mem_flags)
136 struct usb_device *usbdev;
137 struct uss720_async_request *rq;
138 unsigned long flags;
139 int ret;
141 if (!priv)
142 return NULL;
143 usbdev = priv->usbdev;
144 if (!usbdev)
145 return NULL;
146 rq = kmalloc(sizeof(struct uss720_async_request), mem_flags);
147 if (!rq) {
148 err("submit_async_request out of memory");
149 return NULL;
151 kref_init(&rq->ref_count);
152 INIT_LIST_HEAD(&rq->asynclist);
153 init_completion(&rq->compl);
154 kref_get(&priv->ref_count);
155 rq->priv = priv;
156 rq->urb = usb_alloc_urb(0, mem_flags);
157 if (!rq->urb) {
158 kref_put(&rq->ref_count, destroy_async);
159 err("submit_async_request out of memory");
160 return NULL;
162 rq->dr.bRequestType = requesttype;
163 rq->dr.bRequest = request;
164 rq->dr.wValue = cpu_to_le16(value);
165 rq->dr.wIndex = cpu_to_le16(index);
166 rq->dr.wLength = cpu_to_le16((request == 3) ? sizeof(rq->reg) : 0);
167 usb_fill_control_urb(rq->urb, usbdev, (requesttype & 0x80) ? usb_rcvctrlpipe(usbdev, 0) : usb_sndctrlpipe(usbdev, 0),
168 (unsigned char *)&rq->dr,
169 (request == 3) ? rq->reg : NULL, (request == 3) ? sizeof(rq->reg) : 0, async_complete, rq);
170 /* rq->urb->transfer_flags |= URB_ASYNC_UNLINK; */
171 spin_lock_irqsave(&priv->asynclock, flags);
172 list_add_tail(&rq->asynclist, &priv->asynclist);
173 spin_unlock_irqrestore(&priv->asynclock, flags);
174 ret = usb_submit_urb(rq->urb, mem_flags);
175 if (!ret) {
176 kref_get(&rq->ref_count);
177 return rq;
179 kref_put(&rq->ref_count, destroy_async);
180 err("submit_async_request submit_urb failed with %d", ret);
181 return NULL;
184 static unsigned int kill_all_async_requests_priv(struct parport_uss720_private *priv)
186 struct uss720_async_request *rq;
187 unsigned long flags;
188 unsigned int ret = 0;
190 spin_lock_irqsave(&priv->asynclock, flags);
191 list_for_each_entry(rq, &priv->asynclist, asynclist) {
192 usb_unlink_urb(rq->urb);
193 ret++;
195 spin_unlock_irqrestore(&priv->asynclock, flags);
196 return ret;
199 /* --------------------------------------------------------------------- */
201 static int get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val, gfp_t mem_flags)
203 struct parport_uss720_private *priv;
204 struct uss720_async_request *rq;
205 static const unsigned char regindex[9] = {
206 4, 0, 1, 5, 5, 0, 2, 3, 6
208 int ret;
210 if (!pp)
211 return -EIO;
212 priv = pp->private_data;
213 rq = submit_async_request(priv, 3, 0xc0, ((unsigned int)reg) << 8, 0, mem_flags);
214 if (!rq) {
215 err("get_1284_register(%u) failed", (unsigned int)reg);
216 return -EIO;
218 if (!val) {
219 kref_put(&rq->ref_count, destroy_async);
220 return 0;
222 if (wait_for_completion_timeout(&rq->compl, HZ)) {
223 ret = rq->urb->status;
224 *val = priv->reg[(reg >= 9) ? 0 : regindex[reg]];
225 if (ret)
226 printk(KERN_WARNING "get_1284_register: "
227 "usb error %d\n", ret);
228 kref_put(&rq->ref_count, destroy_async);
229 return ret;
231 printk(KERN_WARNING "get_1284_register timeout\n");
232 kill_all_async_requests_priv(priv);
233 return -EIO;
236 static int set_1284_register(struct parport *pp, unsigned char reg, unsigned char val, gfp_t mem_flags)
238 struct parport_uss720_private *priv;
239 struct uss720_async_request *rq;
241 if (!pp)
242 return -EIO;
243 priv = pp->private_data;
244 rq = submit_async_request(priv, 4, 0x40, (((unsigned int)reg) << 8) | val, 0, mem_flags);
245 if (!rq) {
246 err("set_1284_register(%u,%u) failed", (unsigned int)reg, (unsigned int)val);
247 return -EIO;
249 kref_put(&rq->ref_count, destroy_async);
250 return 0;
253 /* --------------------------------------------------------------------- */
255 /* ECR modes */
256 #define ECR_SPP 00
257 #define ECR_PS2 01
258 #define ECR_PPF 02
259 #define ECR_ECP 03
260 #define ECR_EPP 04
262 /* Safely change the mode bits in the ECR */
263 static int change_mode(struct parport *pp, int m)
265 struct parport_uss720_private *priv = pp->private_data;
266 int mode;
267 __u8 reg;
269 if (get_1284_register(pp, 6, &reg, GFP_KERNEL))
270 return -EIO;
271 /* Bits <7:5> contain the mode. */
272 mode = (priv->reg[2] >> 5) & 0x7;
273 if (mode == m)
274 return 0;
275 /* We have to go through mode 000 or 001 */
276 if (mode > ECR_PS2 && m > ECR_PS2)
277 if (change_mode(pp, ECR_PS2))
278 return -EIO;
280 if (m <= ECR_PS2 && !(priv->reg[1] & 0x20)) {
281 /* This mode resets the FIFO, so we may
282 * have to wait for it to drain first. */
283 unsigned long expire = jiffies + pp->physport->cad->timeout;
284 switch (mode) {
285 case ECR_PPF: /* Parallel Port FIFO mode */
286 case ECR_ECP: /* ECP Parallel Port mode */
287 /* Poll slowly. */
288 for (;;) {
289 if (get_1284_register(pp, 6, &reg, GFP_KERNEL))
290 return -EIO;
291 if (priv->reg[2] & 0x01)
292 break;
293 if (time_after_eq (jiffies, expire))
294 /* The FIFO is stuck. */
295 return -EBUSY;
296 msleep_interruptible(10);
297 if (signal_pending (current))
298 break;
302 /* Set the mode. */
303 if (set_1284_register(pp, 6, m << 5, GFP_KERNEL))
304 return -EIO;
305 if (get_1284_register(pp, 6, &reg, GFP_KERNEL))
306 return -EIO;
307 return 0;
311 * Clear TIMEOUT BIT in EPP MODE
313 static int clear_epp_timeout(struct parport *pp)
315 unsigned char stat;
317 if (get_1284_register(pp, 1, &stat, GFP_KERNEL))
318 return 1;
319 return stat & 1;
323 * Access functions.
326 static void parport_uss720_write_data(struct parport *pp, unsigned char d)
328 set_1284_register(pp, 0, d, GFP_KERNEL);
331 static unsigned char parport_uss720_read_data(struct parport *pp)
333 unsigned char ret;
335 if (get_1284_register(pp, 0, &ret, GFP_KERNEL))
336 return 0;
337 return ret;
340 static void parport_uss720_write_control(struct parport *pp, unsigned char d)
342 struct parport_uss720_private *priv = pp->private_data;
344 d = (d & 0xf) | (priv->reg[1] & 0xf0);
345 if (set_1284_register(pp, 2, d, GFP_KERNEL))
346 return;
347 priv->reg[1] = d;
350 static unsigned char parport_uss720_read_control(struct parport *pp)
352 struct parport_uss720_private *priv = pp->private_data;
353 return priv->reg[1] & 0xf; /* Use soft copy */
356 static unsigned char parport_uss720_frob_control(struct parport *pp, unsigned char mask, unsigned char val)
358 struct parport_uss720_private *priv = pp->private_data;
359 unsigned char d;
361 mask &= 0x0f;
362 val &= 0x0f;
363 d = (priv->reg[1] & (~mask)) ^ val;
364 if (set_1284_register(pp, 2, d, GFP_KERNEL))
365 return 0;
366 priv->reg[1] = d;
367 return d & 0xf;
370 static unsigned char parport_uss720_read_status(struct parport *pp)
372 unsigned char ret;
374 if (get_1284_register(pp, 1, &ret, GFP_KERNEL))
375 return 0;
376 return ret & 0xf8;
379 static void parport_uss720_disable_irq(struct parport *pp)
381 struct parport_uss720_private *priv = pp->private_data;
382 unsigned char d;
384 d = priv->reg[1] & ~0x10;
385 if (set_1284_register(pp, 2, d, GFP_KERNEL))
386 return;
387 priv->reg[1] = d;
390 static void parport_uss720_enable_irq(struct parport *pp)
392 struct parport_uss720_private *priv = pp->private_data;
393 unsigned char d;
395 d = priv->reg[1] | 0x10;
396 if (set_1284_register(pp, 2, d, GFP_KERNEL))
397 return;
398 priv->reg[1] = d;
401 static void parport_uss720_data_forward (struct parport *pp)
403 struct parport_uss720_private *priv = pp->private_data;
404 unsigned char d;
406 d = priv->reg[1] & ~0x20;
407 if (set_1284_register(pp, 2, d, GFP_KERNEL))
408 return;
409 priv->reg[1] = d;
412 static void parport_uss720_data_reverse (struct parport *pp)
414 struct parport_uss720_private *priv = pp->private_data;
415 unsigned char d;
417 d = priv->reg[1] | 0x20;
418 if (set_1284_register(pp, 2, d, GFP_KERNEL))
419 return;
420 priv->reg[1] = d;
423 static void parport_uss720_init_state(struct pardevice *dev, struct parport_state *s)
425 s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0);
426 s->u.pc.ecr = 0x24;
429 static void parport_uss720_save_state(struct parport *pp, struct parport_state *s)
431 struct parport_uss720_private *priv = pp->private_data;
433 s->u.pc.ctr = priv->reg[1];
434 s->u.pc.ecr = priv->reg[2];
437 static void parport_uss720_restore_state(struct parport *pp, struct parport_state *s)
439 struct parport_uss720_private *priv = pp->private_data;
441 set_1284_register(pp, 2, s->u.pc.ctr, GFP_ATOMIC);
442 set_1284_register(pp, 6, s->u.pc.ecr, GFP_ATOMIC);
443 get_1284_register(pp, 2, NULL, GFP_ATOMIC);
444 priv->reg[1] = s->u.pc.ctr;
445 priv->reg[2] = s->u.pc.ecr;
448 static size_t parport_uss720_epp_read_data(struct parport *pp, void *buf, size_t length, int flags)
450 struct parport_uss720_private *priv = pp->private_data;
451 size_t got = 0;
453 if (change_mode(pp, ECR_EPP))
454 return 0;
455 for (; got < length; got++) {
456 if (get_1284_register(pp, 4, (char *)buf, GFP_KERNEL))
457 break;
458 buf++;
459 if (priv->reg[0] & 0x01) {
460 clear_epp_timeout(pp);
461 break;
464 change_mode(pp, ECR_PS2);
465 return got;
468 static size_t parport_uss720_epp_write_data(struct parport *pp, const void *buf, size_t length, int flags)
470 struct parport_uss720_private *priv = pp->private_data;
471 struct usb_device *usbdev = priv->usbdev;
472 int rlen;
473 int i;
475 if (!usbdev)
476 return 0;
477 if (change_mode(pp, ECR_EPP))
478 return 0;
479 i = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 1), (void *)buf, length, &rlen, 20000);
480 if (i)
481 printk(KERN_ERR "uss720: sendbulk ep 1 buf %p len %Zu rlen %u\n", buf, length, rlen);
482 change_mode(pp, ECR_PS2);
483 return rlen;
486 static size_t parport_uss720_epp_read_addr(struct parport *pp, void *buf, size_t length, int flags)
488 struct parport_uss720_private *priv = pp->private_data;
489 size_t got = 0;
491 if (change_mode(pp, ECR_EPP))
492 return 0;
493 for (; got < length; got++) {
494 if (get_1284_register(pp, 3, (char *)buf, GFP_KERNEL))
495 break;
496 buf++;
497 if (priv->reg[0] & 0x01) {
498 clear_epp_timeout(pp);
499 break;
502 change_mode(pp, ECR_PS2);
503 return got;
506 static size_t parport_uss720_epp_write_addr(struct parport *pp, const void *buf, size_t length, int flags)
508 struct parport_uss720_private *priv = pp->private_data;
509 size_t written = 0;
511 if (change_mode(pp, ECR_EPP))
512 return 0;
513 for (; written < length; written++) {
514 if (set_1284_register(pp, 3, *(char *)buf, GFP_KERNEL))
515 break;
516 buf++;
517 if (get_1284_register(pp, 1, NULL, GFP_KERNEL))
518 break;
519 if (priv->reg[0] & 0x01) {
520 clear_epp_timeout(pp);
521 break;
524 change_mode(pp, ECR_PS2);
525 return written;
528 static size_t parport_uss720_ecp_write_data(struct parport *pp, const void *buffer, size_t len, int flags)
530 struct parport_uss720_private *priv = pp->private_data;
531 struct usb_device *usbdev = priv->usbdev;
532 int rlen;
533 int i;
535 if (!usbdev)
536 return 0;
537 if (change_mode(pp, ECR_ECP))
538 return 0;
539 i = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 1), (void *)buffer, len, &rlen, 20000);
540 if (i)
541 printk(KERN_ERR "uss720: sendbulk ep 1 buf %p len %Zu rlen %u\n", buffer, len, rlen);
542 change_mode(pp, ECR_PS2);
543 return rlen;
546 static size_t parport_uss720_ecp_read_data(struct parport *pp, void *buffer, size_t len, int flags)
548 struct parport_uss720_private *priv = pp->private_data;
549 struct usb_device *usbdev = priv->usbdev;
550 int rlen;
551 int i;
553 if (!usbdev)
554 return 0;
555 if (change_mode(pp, ECR_ECP))
556 return 0;
557 i = usb_bulk_msg(usbdev, usb_rcvbulkpipe(usbdev, 2), buffer, len, &rlen, 20000);
558 if (i)
559 printk(KERN_ERR "uss720: recvbulk ep 2 buf %p len %Zu rlen %u\n", buffer, len, rlen);
560 change_mode(pp, ECR_PS2);
561 return rlen;
564 static size_t parport_uss720_ecp_write_addr(struct parport *pp, const void *buffer, size_t len, int flags)
566 size_t written = 0;
568 if (change_mode(pp, ECR_ECP))
569 return 0;
570 for (; written < len; written++) {
571 if (set_1284_register(pp, 5, *(char *)buffer, GFP_KERNEL))
572 break;
573 buffer++;
575 change_mode(pp, ECR_PS2);
576 return written;
579 static size_t parport_uss720_write_compat(struct parport *pp, const void *buffer, size_t len, int flags)
581 struct parport_uss720_private *priv = pp->private_data;
582 struct usb_device *usbdev = priv->usbdev;
583 int rlen;
584 int i;
586 if (!usbdev)
587 return 0;
588 if (change_mode(pp, ECR_PPF))
589 return 0;
590 i = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 1), (void *)buffer, len, &rlen, 20000);
591 if (i)
592 printk(KERN_ERR "uss720: sendbulk ep 1 buf %p len %Zu rlen %u\n", buffer, len, rlen);
593 change_mode(pp, ECR_PS2);
594 return rlen;
597 /* --------------------------------------------------------------------- */
599 static struct parport_operations parport_uss720_ops =
601 .owner = THIS_MODULE,
602 .write_data = parport_uss720_write_data,
603 .read_data = parport_uss720_read_data,
605 .write_control = parport_uss720_write_control,
606 .read_control = parport_uss720_read_control,
607 .frob_control = parport_uss720_frob_control,
609 .read_status = parport_uss720_read_status,
611 .enable_irq = parport_uss720_enable_irq,
612 .disable_irq = parport_uss720_disable_irq,
614 .data_forward = parport_uss720_data_forward,
615 .data_reverse = parport_uss720_data_reverse,
617 .init_state = parport_uss720_init_state,
618 .save_state = parport_uss720_save_state,
619 .restore_state = parport_uss720_restore_state,
621 .epp_write_data = parport_uss720_epp_write_data,
622 .epp_read_data = parport_uss720_epp_read_data,
623 .epp_write_addr = parport_uss720_epp_write_addr,
624 .epp_read_addr = parport_uss720_epp_read_addr,
626 .ecp_write_data = parport_uss720_ecp_write_data,
627 .ecp_read_data = parport_uss720_ecp_read_data,
628 .ecp_write_addr = parport_uss720_ecp_write_addr,
630 .compat_write_data = parport_uss720_write_compat,
631 .nibble_read_data = parport_ieee1284_read_nibble,
632 .byte_read_data = parport_ieee1284_read_byte,
635 /* --------------------------------------------------------------------- */
637 static int uss720_probe(struct usb_interface *intf,
638 const struct usb_device_id *id)
640 struct usb_device *usbdev = usb_get_dev(interface_to_usbdev(intf));
641 struct usb_host_interface *interface;
642 struct usb_host_endpoint *endpoint;
643 struct parport_uss720_private *priv;
644 struct parport *pp;
645 unsigned char reg;
646 int i;
648 dbg("probe: vendor id 0x%x, device id 0x%x\n",
649 le16_to_cpu(usbdev->descriptor.idVendor),
650 le16_to_cpu(usbdev->descriptor.idProduct));
652 /* our known interfaces have 3 alternate settings */
653 if (intf->num_altsetting != 3) {
654 usb_put_dev(usbdev);
655 return -ENODEV;
657 i = usb_set_interface(usbdev, intf->altsetting->desc.bInterfaceNumber, 2);
658 dbg("set inteface result %d", i);
660 interface = intf->cur_altsetting;
663 * Allocate parport interface
665 if (!(priv = kzalloc(sizeof(struct parport_uss720_private), GFP_KERNEL))) {
666 usb_put_dev(usbdev);
667 return -ENOMEM;
669 priv->pp = NULL;
670 priv->usbdev = usbdev;
671 kref_init(&priv->ref_count);
672 spin_lock_init(&priv->asynclock);
673 INIT_LIST_HEAD(&priv->asynclist);
674 if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) {
675 printk(KERN_WARNING "uss720: could not register parport\n");
676 goto probe_abort;
679 priv->pp = pp;
680 pp->private_data = priv;
681 pp->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_TRISTATE | PARPORT_MODE_EPP | PARPORT_MODE_ECP | PARPORT_MODE_COMPAT;
683 /* set the USS720 control register to manual mode, no ECP compression, enable all ints */
684 set_1284_register(pp, 7, 0x00, GFP_KERNEL);
685 set_1284_register(pp, 6, 0x30, GFP_KERNEL); /* PS/2 mode */
686 set_1284_register(pp, 2, 0x0c, GFP_KERNEL);
687 /* debugging */
688 get_1284_register(pp, 0, &reg, GFP_KERNEL);
689 dbg("reg: %02x %02x %02x %02x %02x %02x %02x",
690 priv->reg[0], priv->reg[1], priv->reg[2], priv->reg[3], priv->reg[4], priv->reg[5], priv->reg[6]);
692 endpoint = &interface->endpoint[2];
693 dbg("epaddr %d interval %d", endpoint->desc.bEndpointAddress, endpoint->desc.bInterval);
694 parport_announce_port(pp);
696 usb_set_intfdata(intf, pp);
697 return 0;
699 probe_abort:
700 kill_all_async_requests_priv(priv);
701 kref_put(&priv->ref_count, destroy_priv);
702 return -ENODEV;
705 static void uss720_disconnect(struct usb_interface *intf)
707 struct parport *pp = usb_get_intfdata(intf);
708 struct parport_uss720_private *priv;
709 struct usb_device *usbdev;
711 dbg("disconnect");
712 usb_set_intfdata(intf, NULL);
713 if (pp) {
714 priv = pp->private_data;
715 usbdev = priv->usbdev;
716 priv->usbdev = NULL;
717 priv->pp = NULL;
718 dbg("parport_remove_port");
719 parport_remove_port(pp);
720 parport_put_port(pp);
721 kill_all_async_requests_priv(priv);
722 kref_put(&priv->ref_count, destroy_priv);
724 dbg("disconnect done");
727 /* table of cables that work through this driver */
728 static const struct usb_device_id uss720_table[] = {
729 { USB_DEVICE(0x047e, 0x1001) },
730 { USB_DEVICE(0x0557, 0x2001) },
731 { USB_DEVICE(0x0729, 0x1284) },
732 { USB_DEVICE(0x1293, 0x0002) },
733 { USB_DEVICE(0x1293, 0x0002) },
734 { USB_DEVICE(0x050d, 0x0002) },
735 { } /* Terminating entry */
738 MODULE_DEVICE_TABLE (usb, uss720_table);
741 static struct usb_driver uss720_driver = {
742 .name = "uss720",
743 .probe = uss720_probe,
744 .disconnect = uss720_disconnect,
745 .id_table = uss720_table,
748 /* --------------------------------------------------------------------- */
750 MODULE_AUTHOR(DRIVER_AUTHOR);
751 MODULE_DESCRIPTION(DRIVER_DESC);
752 MODULE_LICENSE("GPL");
754 static int __init uss720_init(void)
756 int retval;
757 retval = usb_register(&uss720_driver);
758 if (retval)
759 goto out;
761 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
762 DRIVER_DESC "\n");
763 printk(KERN_INFO KBUILD_MODNAME ": NOTE: this is a special purpose "
764 "driver to allow nonstandard\n");
765 printk(KERN_INFO KBUILD_MODNAME ": protocols (eg. bitbang) over "
766 "USS720 usb to parallel cables\n");
767 printk(KERN_INFO KBUILD_MODNAME ": If you just want to connect to a "
768 "printer, use usblp instead\n");
769 out:
770 return retval;
773 static void __exit uss720_cleanup(void)
775 usb_deregister(&uss720_driver);
778 module_init(uss720_init);
779 module_exit(uss720_cleanup);
781 /* --------------------------------------------------------------------- */