1 /*****************************************************************************/
2 
3 /*
4  *	uss720.c  --  USS720 USB Parport Cable.
5  *
6  *	Copyright (C) 1999
7  *	    Thomas Sailer (sailer@ife.ee.ethz.ch)
8  *
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.
13  *
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.
18  *
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.
22  *
23  *  Based on parport_pc.c
24  *
25  *  History:
26  *   0.1  04.08.99  Created
27  *   0.2  07.08.99  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.99  fixing merge errors
33  *   0.4  13.08.99  Added Vendor/Product ID of Brad Hard's cable
34  *   0.5  20.09.99  usb_control_msg wrapper used
35  *        Nov01.00  usb_device_table support by Adam J. Richter
36  *        08.04.01  Identify version on module load.  gb
37  *
38  */
39 
40 /*****************************************************************************/
41 
42 #include <linux/module.h>
43 #include <linux/socket.h>
44 #include <linux/parport.h>
45 #include <linux/init.h>
46 #include <linux/usb.h>
47 
48 /*
49  * Version Information
50  */
51 #define DRIVER_VERSION "v0.5"
52 #define DRIVER_AUTHOR "Thomas M. Sailer, sailer@ife.ee.ethz.ch"
53 #define DRIVER_DESC "USB Parport Cable driver for Cables using the Lucent Technologies USS720 Chip"
54 
55 /* --------------------------------------------------------------------- */
56 
57 struct parport_uss720_private {
58 	struct usb_device *usbdev;
59 	void *irqhandle;
60 	unsigned int irqpipe;
61 	unsigned char reg[7];  /* USB registers */
62 };
63 
64 /* --------------------------------------------------------------------- */
65 
get_1284_register(struct parport * pp,unsigned char reg,unsigned char * val)66 static int get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val)
67 {
68 	struct parport_uss720_private *priv = pp->private_data;
69 	struct usb_device *usbdev = priv->usbdev;
70 	static const unsigned char regindex[9] = {
71 		4, 0, 1, 5, 5, 0, 2, 3, 6
72 	};
73 	int ret;
74 
75 	if (!usbdev)
76 		return -1;
77 	ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev,0), 3, 0xc0, ((unsigned int)reg) << 8, 0, priv->reg, 7, HZ);
78 	if (ret != 7) {
79 		printk(KERN_DEBUG "uss720: get_1284_register(%d) failed, status 0x%x expected 7\n",
80 		       (unsigned int)reg, ret);
81 		ret = -1;
82 	} else {
83 #if 0
84 		printk(KERN_DEBUG "uss720: get_1284_register(%d) return %02x %02x %02x %02x %02x %02x %02x\n",
85 		       (unsigned int)reg, (unsigned int)priv->reg[0], (unsigned int)priv->reg[1],
86 		       (unsigned int)priv->reg[2], (unsigned int)priv->reg[3], (unsigned int)priv->reg[4],
87 		       (unsigned int)priv->reg[5], (unsigned int)priv->reg[6]);
88 #endif
89 		/* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */
90 		if (priv->reg[2] & priv->reg[1] & 0x10)
91 			parport_generic_irq(0, pp, NULL);
92 		ret = 0;
93 	}
94 	if (val)
95 		*val = priv->reg[(reg >= 9) ? 0 : regindex[reg]];
96 	return ret;
97 }
98 
set_1284_register(struct parport * pp,unsigned char reg,unsigned char val)99 static int set_1284_register(struct parport *pp, unsigned char reg, unsigned char val)
100 {
101 	struct parport_uss720_private *priv = pp->private_data;
102 	struct usb_device *usbdev = priv->usbdev;
103 	int ret;
104 
105 	if (!usbdev)
106 		return -1;
107 	ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev,0), 4, 0x40, (((unsigned int)reg) << 8) | val, 0, NULL, 0, HZ);
108 	if (ret) {
109 		printk(KERN_DEBUG "uss720: set_1284_register(%u,0x%02x) failed, status 0x%x\n",
110 		       (unsigned int)reg, (unsigned int)val, ret);
111 	} else {
112 #if 0
113 		printk(KERN_DEBUG "uss720: set_1284_register(%u,0x%02x)\n",
114 		       (unsigned int)reg, (unsigned int)val);
115 #endif
116 	}
117 	return ret;
118 }
119 
120 /* --------------------------------------------------------------------- */
121 
122 /* ECR modes */
123 #define ECR_SPP 00
124 #define ECR_PS2 01
125 #define ECR_PPF 02
126 #define ECR_ECP 03
127 #define ECR_EPP 04
128 
129 /* Safely change the mode bits in the ECR */
change_mode(struct parport * pp,int m)130 static int change_mode(struct parport *pp, int m)
131 {
132 	struct parport_uss720_private *priv = pp->private_data;
133 	int mode;
134 
135 	if (get_1284_register(pp, 6, NULL))
136 		return -EIO;
137 	/* Bits <7:5> contain the mode. */
138 	mode = (priv->reg[2] >> 5) & 0x7;
139 	if (mode == m)
140 		return 0;
141 	/* We have to go through mode 000 or 001 */
142 	if (mode > ECR_PS2 && m > ECR_PS2)
143 		if (change_mode(pp, ECR_PS2))
144 			return -EIO;
145 
146 	if (m <= ECR_PS2 && !(priv->reg[1] & 0x20)) {
147 		/* This mode resets the FIFO, so we may
148 		 * have to wait for it to drain first. */
149 		long expire = jiffies + pp->physport->cad->timeout;
150 		switch (mode) {
151 		case ECR_PPF: /* Parallel Port FIFO mode */
152 		case ECR_ECP: /* ECP Parallel Port mode */
153 			/* Poll slowly. */
154 			for (;;) {
155 				if (get_1284_register(pp, 6, NULL))
156 					return -EIO;
157 				if (priv->reg[2] & 0x01)
158 					break;
159 				if (time_after_eq (jiffies, expire))
160 					/* The FIFO is stuck. */
161 					return -EBUSY;
162 				set_current_state(TASK_INTERRUPTIBLE);
163 				schedule_timeout((HZ + 99) / 100);
164 				if (signal_pending (current))
165 					break;
166 			}
167 		}
168 	}
169 	/* Set the mode. */
170 	if (set_1284_register(pp, 6, m << 5))
171 		return -EIO;
172 	return 0;
173 }
174 
175 /*
176  * Clear TIMEOUT BIT in EPP MODE
177  */
clear_epp_timeout(struct parport * pp)178 static int clear_epp_timeout(struct parport *pp)
179 {
180 	unsigned char stat;
181 
182 	if (get_1284_register(pp, 1, &stat))
183 		return 1;
184 	return stat & 1;
185 }
186 
187 /*
188  * Access functions.
189  */
190 #if 0
191 static int uss720_irq(int usbstatus, void *buffer, int len, void *dev_id)
192 {
193 	struct parport *pp = (struct parport *)dev_id;
194 	struct parport_uss720_private *priv = pp->private_data;
195 
196 	if (usbstatus != USB_ST_NOERROR || len < 4 || !buffer)
197 		return 1;
198 	memcpy(priv->reg, buffer, 4);
199 	/* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */
200 	if (priv->reg[2] & priv->reg[1] & 0x10)
201 		parport_generic_irq(0, pp, NULL);
202 	return 1;
203 }
204 #endif
205 
parport_uss720_write_data(struct parport * pp,unsigned char d)206 static void parport_uss720_write_data(struct parport *pp, unsigned char d)
207 {
208 	set_1284_register(pp, 0, d);
209 }
210 
parport_uss720_read_data(struct parport * pp)211 static unsigned char parport_uss720_read_data(struct parport *pp)
212 {
213 	unsigned char ret;
214 
215 	if (get_1284_register(pp, 0, &ret))
216 		return 0;
217 	return ret;
218 }
219 
parport_uss720_write_control(struct parport * pp,unsigned char d)220 static void parport_uss720_write_control(struct parport *pp, unsigned char d)
221 {
222 	struct parport_uss720_private *priv = pp->private_data;
223 
224 	d = (d & 0xf) | (priv->reg[1] & 0xf0);
225 	if (set_1284_register(pp, 2, d))
226 		return;
227 	priv->reg[1] = d;
228 }
229 
parport_uss720_read_control(struct parport * pp)230 static unsigned char parport_uss720_read_control(struct parport *pp)
231 {
232 	struct parport_uss720_private *priv = pp->private_data;
233 	return priv->reg[1] & 0xf; /* Use soft copy */
234 }
235 
parport_uss720_frob_control(struct parport * pp,unsigned char mask,unsigned char val)236 static unsigned char parport_uss720_frob_control(struct parport *pp, unsigned char mask, unsigned char val)
237 {
238 	struct parport_uss720_private *priv = pp->private_data;
239 	unsigned char d;
240 
241 	mask &= 0x0f;
242 	val &= 0x0f;
243 	d = (priv->reg[1] & (~mask)) ^ val;
244 	if (set_1284_register(pp, 2, d))
245 		return 0;
246 	priv->reg[1] = d;
247 	return d & 0xf;
248 }
249 
parport_uss720_read_status(struct parport * pp)250 static unsigned char parport_uss720_read_status(struct parport *pp)
251 {
252 	unsigned char ret;
253 
254 	if (get_1284_register(pp, 1, &ret))
255 		return 0;
256 	return ret & 0xf8;
257 }
258 
parport_uss720_disable_irq(struct parport * pp)259 static void parport_uss720_disable_irq(struct parport *pp)
260 {
261 	struct parport_uss720_private *priv = pp->private_data;
262 	unsigned char d;
263 
264 	d = priv->reg[1] & ~0x10;
265 	if (set_1284_register(pp, 2, d))
266 		return;
267 	priv->reg[1] = d;
268 }
269 
parport_uss720_enable_irq(struct parport * pp)270 static void parport_uss720_enable_irq(struct parport *pp)
271 {
272 	struct parport_uss720_private *priv = pp->private_data;
273 	unsigned char d;
274 
275 	d = priv->reg[1] | 0x10;
276 	if (set_1284_register(pp, 2, d))
277 		return;
278 	priv->reg[1] = d;
279 }
280 
parport_uss720_data_forward(struct parport * pp)281 static void parport_uss720_data_forward (struct parport *pp)
282 {
283 	struct parport_uss720_private *priv = pp->private_data;
284 	unsigned char d;
285 
286 	d = priv->reg[1] & ~0x20;
287 	if (set_1284_register(pp, 2, d))
288 		return;
289 	priv->reg[1] = d;
290 }
291 
parport_uss720_data_reverse(struct parport * pp)292 static void parport_uss720_data_reverse (struct parport *pp)
293 {
294 	struct parport_uss720_private *priv = pp->private_data;
295 	unsigned char d;
296 
297 	d = priv->reg[1] | 0x20;
298 	if (set_1284_register(pp, 2, d))
299 		return;
300 	priv->reg[1] = d;
301 }
302 
parport_uss720_init_state(struct pardevice * dev,struct parport_state * s)303 static void parport_uss720_init_state(struct pardevice *dev, struct parport_state *s)
304 {
305 	s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0);
306 	s->u.pc.ecr = 0x24;
307 }
308 
parport_uss720_save_state(struct parport * pp,struct parport_state * s)309 static void parport_uss720_save_state(struct parport *pp, struct parport_state *s)
310 {
311 	struct parport_uss720_private *priv = pp->private_data;
312 
313 	if (get_1284_register(pp, 2, NULL))
314 		return;
315 	s->u.pc.ctr = priv->reg[1];
316 	s->u.pc.ecr = priv->reg[2];
317 }
318 
parport_uss720_restore_state(struct parport * pp,struct parport_state * s)319 static void parport_uss720_restore_state(struct parport *pp, struct parport_state *s)
320 {
321 	set_1284_register(pp, 2, s->u.pc.ctr);
322 	set_1284_register(pp, 6, s->u.pc.ecr);
323 	get_1284_register(pp, 2, NULL);
324 }
325 
parport_uss720_epp_read_data(struct parport * pp,void * buf,size_t length,int flags)326 static size_t parport_uss720_epp_read_data(struct parport *pp, void *buf, size_t length, int flags)
327 {
328 	struct parport_uss720_private *priv = pp->private_data;
329 	size_t got = 0;
330 	char *buff = buf;
331 
332 	if (change_mode(pp, ECR_EPP))
333 		return 0;
334 	for (; got < length; got++) {
335 		if (get_1284_register(pp, 4, buff))
336 			break;
337 		buff++;
338 		if (priv->reg[0] & 0x01) {
339 			clear_epp_timeout(pp);
340 			break;
341 		}
342 	}
343 	change_mode(pp, ECR_PS2);
344 	return got;
345 }
346 
parport_uss720_epp_write_data(struct parport * pp,const void * buf,size_t length,int flags)347 static size_t parport_uss720_epp_write_data(struct parport *pp, const void *buf, size_t length, int flags)
348 {
349 #if 0
350 	struct parport_uss720_private *priv = pp->private_data;
351 	size_t written = 0;
352 	const char *buff = buf;
353 
354 	if (change_mode(pp, ECR_EPP))
355 		return 0;
356 	for (; written < length; written++) {
357 		if (set_1284_register(pp, 4, *buff))
358 			break;
359 		buff++;
360 		if (get_1284_register(pp, 1, NULL))
361 			break;
362 		if (priv->reg[0] & 0x01) {
363 			clear_epp_timeout(pp);
364 			break;
365 		}
366 	}
367 	change_mode(pp, ECR_PS2);
368 	return written;
369 #else
370 	struct parport_uss720_private *priv = pp->private_data;
371 	struct usb_device *usbdev = priv->usbdev;
372 	int rlen;
373 	int i;
374 
375 	if (!usbdev)
376 		return 0;
377 	if (change_mode(pp, ECR_EPP))
378 		return 0;
379 	i = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 1), (void *)buf, length, &rlen, HZ*20);
380 	if (i)
381 		printk(KERN_ERR "uss720: sendbulk ep 1 buf %p len %Zu rlen %u\n", buf, length, rlen);
382 	change_mode(pp, ECR_PS2);
383 	return rlen;
384 #endif
385 }
386 
parport_uss720_epp_read_addr(struct parport * pp,void * buf,size_t length,int flags)387 static size_t parport_uss720_epp_read_addr(struct parport *pp, void *buf, size_t length, int flags)
388 {
389 	struct parport_uss720_private *priv = pp->private_data;
390 	size_t got = 0;
391 	char *buff = buf;
392 
393 	if (change_mode(pp, ECR_EPP))
394 		return 0;
395 	for (; got < length; got++) {
396 		if (get_1284_register(pp, 3, buff))
397 			break;
398 		buff++;
399 		if (priv->reg[0] & 0x01) {
400 			clear_epp_timeout(pp);
401 			break;
402 		}
403 	}
404 	change_mode(pp, ECR_PS2);
405 	return got;
406 }
407 
parport_uss720_epp_write_addr(struct parport * pp,const void * buf,size_t length,int flags)408 static size_t parport_uss720_epp_write_addr(struct parport *pp, const void *buf, size_t length, int flags)
409 {
410 	struct parport_uss720_private *priv = pp->private_data;
411 	size_t written = 0;
412 	const char *buff = buf;
413 
414 	if (change_mode(pp, ECR_EPP))
415 		return 0;
416 	for (; written < length; written++) {
417 		if (set_1284_register(pp, 3, *buff))
418 			break;
419 		buff++;
420 		if (get_1284_register(pp, 1, NULL))
421 			break;
422 		if (priv->reg[0] & 0x01) {
423 			clear_epp_timeout(pp);
424 			break;
425 		}
426 	}
427 	change_mode(pp, ECR_PS2);
428 	return written;
429 }
430 
parport_uss720_ecp_write_data(struct parport * pp,const void * buffer,size_t len,int flags)431 static size_t parport_uss720_ecp_write_data(struct parport *pp, const void *buffer, size_t len, int flags)
432 {
433 	struct parport_uss720_private *priv = pp->private_data;
434 	struct usb_device *usbdev = priv->usbdev;
435 	int rlen;
436 	int i;
437 
438 	if (!usbdev)
439 		return 0;
440 	if (change_mode(pp, ECR_ECP))
441 		return 0;
442 	i = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 1), (void *)buffer, len, &rlen, HZ*20);
443 	if (i)
444 		printk(KERN_ERR "uss720: sendbulk ep 1 buf %p len %Zu rlen %u\n", buffer, len, rlen);
445 	change_mode(pp, ECR_PS2);
446 	return rlen;
447 }
448 
parport_uss720_ecp_read_data(struct parport * pp,void * buffer,size_t len,int flags)449 static size_t parport_uss720_ecp_read_data(struct parport *pp, void *buffer, size_t len, int flags)
450 {
451 	struct parport_uss720_private *priv = pp->private_data;
452 	struct usb_device *usbdev = priv->usbdev;
453 	int rlen;
454 	int i;
455 
456 	if (!usbdev)
457 		return 0;
458 	if (change_mode(pp, ECR_ECP))
459 		return 0;
460 	i = usb_bulk_msg(usbdev, usb_rcvbulkpipe(usbdev, 2), buffer, len, &rlen, HZ*20);
461 	if (i)
462 		printk(KERN_ERR "uss720: recvbulk ep 2 buf %p len %Zu rlen %u\n", buffer, len, rlen);
463 	change_mode(pp, ECR_PS2);
464 	return rlen;
465 }
466 
parport_uss720_ecp_write_addr(struct parport * pp,const void * buffer,size_t len,int flags)467 static size_t parport_uss720_ecp_write_addr(struct parport *pp, const void *buffer, size_t len, int flags)
468 {
469 	size_t written = 0;
470 	const char *buff = buffer;
471 
472 	if (change_mode(pp, ECR_ECP))
473 		return 0;
474 	for (; written < len; written++) {
475 		if (set_1284_register(pp, 5, *buff))
476 			break;
477 		buff++;
478 	}
479 	change_mode(pp, ECR_PS2);
480 	return written;
481 }
482 
parport_uss720_write_compat(struct parport * pp,const void * buffer,size_t len,int flags)483 static size_t parport_uss720_write_compat(struct parport *pp, const void *buffer, size_t len, int flags)
484 {
485 	struct parport_uss720_private *priv = pp->private_data;
486 	struct usb_device *usbdev = priv->usbdev;
487 	int rlen;
488 	int i;
489 
490 	if (!usbdev)
491 		return 0;
492 	if (change_mode(pp, ECR_PPF))
493 		return 0;
494 	i = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 1), (void *)buffer, len, &rlen, HZ*20);
495 	if (i)
496 		printk(KERN_ERR "uss720: sendbulk ep 1 buf %p len %Zu rlen %u\n", buffer, len, rlen);
497 	change_mode(pp, ECR_PS2);
498 	return rlen;
499 }
500 
parport_uss720_inc_use_count(void)501 void parport_uss720_inc_use_count(void)
502 {
503 	MOD_INC_USE_COUNT;
504 }
505 
parport_uss720_dec_use_count(void)506 void parport_uss720_dec_use_count(void)
507 {
508 	MOD_DEC_USE_COUNT;
509 }
510 
511 /* --------------------------------------------------------------------- */
512 
513 static struct parport_operations parport_uss720_ops =
514 {
515 	parport_uss720_write_data,
516 	parport_uss720_read_data,
517 
518 	parport_uss720_write_control,
519 	parport_uss720_read_control,
520 	parport_uss720_frob_control,
521 
522 	parport_uss720_read_status,
523 
524 	parport_uss720_enable_irq,
525 	parport_uss720_disable_irq,
526 
527 	parport_uss720_data_forward,
528 	parport_uss720_data_reverse,
529 
530 	parport_uss720_init_state,
531 	parport_uss720_save_state,
532 	parport_uss720_restore_state,
533 
534 	parport_uss720_inc_use_count,
535 	parport_uss720_dec_use_count,
536 
537 	parport_uss720_epp_write_data,
538 	parport_uss720_epp_read_data,
539 	parport_uss720_epp_write_addr,
540 	parport_uss720_epp_read_addr,
541 
542 	parport_uss720_ecp_write_data,
543 	parport_uss720_ecp_read_data,
544 	parport_uss720_ecp_write_addr,
545 
546 	parport_uss720_write_compat,
547 	parport_ieee1284_read_nibble,
548 	parport_ieee1284_read_byte,
549 };
550 
551 /* --------------------------------------------------------------------- */
552 
uss720_probe(struct usb_device * usbdev,unsigned int ifnum,const struct usb_device_id * id)553 static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
554 			   const struct usb_device_id *id)
555 {
556 	struct usb_interface_descriptor *interface;
557 	struct usb_endpoint_descriptor *endpoint;
558 	struct parport_uss720_private *priv;
559 	struct parport *pp;
560 	int i;
561 
562 	printk(KERN_DEBUG "uss720: probe: vendor id 0x%x, device id 0x%x\n",
563 	       usbdev->descriptor.idVendor, usbdev->descriptor.idProduct);
564 
565 	/* our known interfaces have 3 alternate settings */
566 	if (usbdev->actconfig->interface[ifnum].num_altsetting != 3)
567 		return NULL;
568 
569 	i = usb_set_interface(usbdev, ifnum, 2);
570 	printk(KERN_DEBUG "uss720: set inteface result %d\n", i);
571 
572 	interface = &usbdev->actconfig->interface[ifnum].altsetting[2];
573 
574 	/*
575 	 * Allocate parport interface
576 	 */
577 	printk(KERN_INFO "uss720: (C) 1999 by Thomas Sailer, <sailer@ife.ee.ethz.ch>\n");
578 
579 	if (!(priv = kmalloc(sizeof(struct parport_uss720_private), GFP_KERNEL)))
580 		return NULL;
581 	if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) {
582 		printk(KERN_WARNING "usb-uss720: could not register parport\n");
583 		goto probe_abort;
584 	}
585 
586 	pp->private_data = priv;
587 	priv->usbdev = usbdev;
588 	pp->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_TRISTATE | PARPORT_MODE_EPP | PARPORT_MODE_ECP | PARPORT_MODE_COMPAT;
589 
590 	/* set the USS720 control register to manual mode, no ECP compression, enable all ints */
591 	set_1284_register(pp, 7, 0x00);
592 	set_1284_register(pp, 6, 0x30);  /* PS/2 mode */
593 	set_1284_register(pp, 2, 0x0c);
594 	/* debugging */
595 	get_1284_register(pp, 0, NULL);
596 	printk("uss720: reg: %02x %02x %02x %02x %02x %02x %02x\n",
597 	       priv->reg[0], priv->reg[1], priv->reg[2], priv->reg[3], priv->reg[4], priv->reg[5], priv->reg[6]);
598 
599 	endpoint = &interface->endpoint[2];
600 	printk(KERN_DEBUG "uss720: epaddr %d interval %d\n", endpoint->bEndpointAddress, endpoint->bInterval);
601 #if 0
602 	priv->irqpipe = usb_rcvctrlpipe(usbdev, endpoint->bEndpointAddress);
603 	i = usb_request_irq(usbdev, priv->irqpipe,
604 				  uss720_irq, endpoint->bInterval,
605 				  pp, &priv->irqhandle);
606 	if (i) {
607 		printk (KERN_WARNING "usb-uss720: usb_request_irq failed (0x%x)\n", i);
608 		goto probe_abort_port;
609 	}
610 #endif
611 	parport_proc_register(pp);
612 	parport_announce_port(pp);
613 
614 	MOD_INC_USE_COUNT;
615 	return pp;
616 
617 #if 0
618 probe_abort_port:
619 	parport_unregister_port(pp);
620 #endif
621 probe_abort:
622 	kfree(priv);
623 	return NULL;
624 }
625 
uss720_disconnect(struct usb_device * usbdev,void * ptr)626 static void uss720_disconnect(struct usb_device *usbdev, void *ptr)
627 {
628 	struct parport *pp = (struct parport *)ptr;
629 	struct parport_uss720_private *priv = pp->private_data;
630 
631 #if 0
632 	usb_release_irq(usbdev, priv->irqhandle, priv->irqpipe);
633 #endif
634 	priv->usbdev = NULL;
635 	parport_proc_unregister(pp);
636 	parport_unregister_port(pp);
637 	kfree(priv);
638 	MOD_DEC_USE_COUNT;
639 }
640 
641 /* table of cables that work through this driver */
642 static struct usb_device_id uss720_table [] = {
643 	{ USB_DEVICE(0x047e, 0x1001) },
644 	{ USB_DEVICE(0x0557, 0x2001) },
645 	{ USB_DEVICE(0x0729, 0x1284) },
646 	{ USB_DEVICE(0x1293, 0x0002) },
647 	{ }						/* Terminating entry */
648 };
649 
650 MODULE_DEVICE_TABLE (usb, uss720_table);
651 
652 
653 static struct usb_driver uss720_driver = {
654 	name:		"uss720",
655 	probe:		uss720_probe,
656 	disconnect:	uss720_disconnect,
657 	id_table:	uss720_table,
658 };
659 
660 /* --------------------------------------------------------------------- */
661 
662 MODULE_AUTHOR( DRIVER_AUTHOR );
663 MODULE_DESCRIPTION( DRIVER_DESC );
664 MODULE_LICENSE("GPL");
665 
uss720_init(void)666 static int __init uss720_init(void)
667 {
668 	if (usb_register(&uss720_driver) < 0)
669 		return -1;
670 
671 	info(DRIVER_VERSION ":" DRIVER_DESC);
672 	return 0;
673 }
674 
uss720_cleanup(void)675 static void __exit uss720_cleanup(void)
676 {
677 	usb_deregister(&uss720_driver);
678 }
679 
680 module_init(uss720_init);
681 module_exit(uss720_cleanup);
682 
683 /* --------------------------------------------------------------------- */
684