File: /usr/src/linux/drivers/char/ppdev.c
1 /*
2 * linux/drivers/char/ppdev.c
3 *
4 * This is the code behind /dev/parport* -- it allows a user-space
5 * application to use the parport subsystem.
6 *
7 * Copyright (C) 1998-2000 Tim Waugh <tim@cyberelk.demon.co.uk>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 * A /dev/parportx device node represents an arbitrary device
15 * on port 'x'. The following operations are possible:
16 *
17 * open do nothing, set up default IEEE 1284 protocol to be COMPAT
18 * close release port and unregister device (if necessary)
19 * ioctl
20 * EXCL register device exclusively (may fail)
21 * CLAIM (register device first time) parport_claim_or_block
22 * RELEASE parport_release
23 * SETMODE set the IEEE 1284 protocol to use for read/write
24 * SETPHASE set the IEEE 1284 phase of a particular mode. Not to be
25 * confused with ioctl(fd, SETPHASER, &stun). ;-)
26 * DATADIR data_forward / data_reverse
27 * WDATA write_data
28 * RDATA read_data
29 * WCONTROL write_control
30 * RCONTROL read_control
31 * FCONTROL frob_control
32 * RSTATUS read_status
33 * NEGOT parport_negotiate
34 * YIELD parport_yield_blocking
35 * WCTLONIRQ on interrupt, set control lines
36 * CLRIRQ clear (and return) interrupt count
37 * SETTIME sets device timeout (struct timeval)
38 * GETTIME gets device timeout (struct timeval)
39 * GETMODES gets hardware supported modes (unsigned int)
40 * GETMODE gets the current IEEE1284 mode
41 * GETPHASE gets the current IEEE1284 phase
42 * GETFLAGS gets current (user-visible) flags
43 * SETFLAGS sets current (user-visible) flags
44 * read/write read or write in current IEEE 1284 protocol
45 * select wait for interrupt (in readfds)
46 *
47 * Changes:
48 * Added SETTIME/GETTIME ioctl, Fred Barnes, 1999.
49 *
50 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> 2000/08/25
51 * - On error, copy_from_user and copy_to_user do not return -EFAULT,
52 * They return the positive number of bytes *not* copied due to address
53 * space errors.
54 *
55 * Added GETMODES/GETMODE/GETPHASE ioctls, Fred Barnes <frmb2@ukc.ac.uk>, 03/01/2001.
56 * Added GETFLAGS/SETFLAGS ioctls, Fred Barnes, 04/2001
57 */
58
59 #include <linux/module.h>
60 #include <linux/init.h>
61 #include <linux/sched.h>
62 #include <linux/devfs_fs_kernel.h>
63 #include <linux/ioctl.h>
64 #include <linux/parport.h>
65 #include <linux/ctype.h>
66 #include <linux/poll.h>
67 #include <asm/uaccess.h>
68 #include <linux/ppdev.h>
69 #include <linux/smp_lock.h>
70
71 #define PP_VERSION "ppdev: user-space parallel port driver"
72 #define CHRDEV "ppdev"
73
74 struct pp_struct {
75 struct pardevice * pdev;
76 wait_queue_head_t irq_wait;
77 atomic_t irqc;
78 unsigned int flags;
79 int irqresponse;
80 unsigned char irqctl;
81 struct ieee1284_info state;
82 struct ieee1284_info saved_state;
83 };
84
85 /* pp_struct.flags bitfields */
86 #define PP_CLAIMED (1<<0)
87 #define PP_EXCL (1<<1)
88
89 /* Other constants */
90 #define PP_INTERRUPT_TIMEOUT (10 * HZ) /* 10s */
91 #define PP_BUFFER_SIZE 1024
92 #define PARDEVICE_MAX 8
93
94 /* ROUND_UP macro from fs/select.c */
95 #define ROUND_UP(x,y) (((x)+(y)-1)/(y))
96
97 static inline void pp_enable_irq (struct pp_struct *pp)
98 {
99 struct parport *port = pp->pdev->port;
100 port->ops->enable_irq (port);
101 }
102
103 static ssize_t pp_read (struct file * file, char * buf, size_t count,
104 loff_t * ppos)
105 {
106 unsigned int minor = MINOR (file->f_dentry->d_inode->i_rdev);
107 struct pp_struct *pp = file->private_data;
108 char * kbuffer;
109 ssize_t bytes_read = 0;
110 ssize_t got = 0;
111 struct parport *pport;
112 int mode;
113
114 if (!(pp->flags & PP_CLAIMED)) {
115 /* Don't have the port claimed */
116 printk (KERN_DEBUG CHRDEV "%x: claim the port first\n",
117 minor);
118 return -EINVAL;
119 }
120
121 kbuffer = kmalloc(min_t(size_t, count, PP_BUFFER_SIZE), GFP_KERNEL);
122 if (!kbuffer) {
123 return -ENOMEM;
124 }
125 pport = pp->pdev->port;
126 mode = pport->ieee1284.mode & ~(IEEE1284_DEVICEID | IEEE1284_ADDR);
127
128 while (bytes_read < count) {
129 ssize_t need = min_t(unsigned long, count - bytes_read, PP_BUFFER_SIZE);
130
131 if (mode == IEEE1284_MODE_EPP) {
132 /* various specials for EPP mode */
133 int flags = 0;
134 size_t (*fn)(struct parport *, void *, size_t, int);
135
136 if (pp->flags & PP_W91284PIC) {
137 flags |= PARPORT_W91284PIC;
138 }
139 if (pp->flags & PP_FASTREAD) {
140 flags |= PARPORT_EPP_FAST;
141 }
142 if (pport->ieee1284.mode & IEEE1284_ADDR) {
143 fn = pport->ops->epp_read_addr;
144 } else {
145 fn = pport->ops->epp_read_data;
146 }
147 got = (*fn)(pport, kbuffer, need, flags);
148 } else {
149 got = parport_read (pport, kbuffer, need);
150 }
151
152 if (got <= 0) {
153 if (!bytes_read) {
154 bytes_read = got;
155 }
156 break;
157 }
158
159 if (copy_to_user (buf + bytes_read, kbuffer, got)) {
160 bytes_read = -EFAULT;
161 break;
162 }
163
164 bytes_read += got;
165
166 if (signal_pending (current)) {
167 if (!bytes_read) {
168 bytes_read = -EINTR;
169 }
170 break;
171 }
172
173 if (current->need_resched) {
174 schedule ();
175 }
176 }
177
178 kfree (kbuffer);
179 pp_enable_irq (pp);
180 return bytes_read;
181 }
182
183 static ssize_t pp_write (struct file * file, const char * buf, size_t count,
184 loff_t * ppos)
185 {
186 unsigned int minor = MINOR (file->f_dentry->d_inode->i_rdev);
187 struct pp_struct *pp = file->private_data;
188 char * kbuffer;
189 ssize_t bytes_written = 0;
190 ssize_t wrote;
191 int mode;
192 struct parport *pport;
193
194 if (!(pp->flags & PP_CLAIMED)) {
195 /* Don't have the port claimed */
196 printk (KERN_DEBUG CHRDEV "%x: claim the port first\n",
197 minor);
198 return -EINVAL;
199 }
200
201 kbuffer = kmalloc(min_t(size_t, count, PP_BUFFER_SIZE), GFP_KERNEL);
202 if (!kbuffer) {
203 return -ENOMEM;
204 }
205 pport = pp->pdev->port;
206 mode = pport->ieee1284.mode & ~(IEEE1284_DEVICEID | IEEE1284_ADDR);
207
208 while (bytes_written < count) {
209 ssize_t n = min_t(unsigned long, count - bytes_written, PP_BUFFER_SIZE);
210
211 if (copy_from_user (kbuffer, buf + bytes_written, n)) {
212 bytes_written = -EFAULT;
213 break;
214 }
215
216 if ((pp->flags & PP_FASTWRITE) && (mode == IEEE1284_MODE_EPP)) {
217 /* do a fast EPP write */
218 if (pport->ieee1284.mode & IEEE1284_ADDR) {
219 wrote = pport->ops->epp_write_addr (pport,
220 kbuffer, n, PARPORT_EPP_FAST);
221 } else {
222 wrote = pport->ops->epp_write_data (pport,
223 kbuffer, n, PARPORT_EPP_FAST);
224 }
225 } else {
226 wrote = parport_write (pp->pdev->port, kbuffer, n);
227 }
228
229 if (wrote <= 0) {
230 if (!bytes_written) {
231 bytes_written = wrote;
232 }
233 break;
234 }
235
236 bytes_written += wrote;
237
238 if (signal_pending (current)) {
239 if (!bytes_written) {
240 bytes_written = -EINTR;
241 }
242 break;
243 }
244
245 if (current->need_resched) {
246 schedule ();
247 }
248 }
249
250 kfree (kbuffer);
251 pp_enable_irq (pp);
252 return bytes_written;
253 }
254
255 static void pp_irq (int irq, void * private, struct pt_regs * unused)
256 {
257 struct pp_struct * pp = (struct pp_struct *) private;
258
259 if (pp->irqresponse) {
260 parport_write_control (pp->pdev->port, pp->irqctl);
261 pp->irqresponse = 0;
262 }
263
264 atomic_inc (&pp->irqc);
265 wake_up_interruptible (&pp->irq_wait);
266 }
267
268 static int register_device (int minor, struct pp_struct *pp)
269 {
270 struct parport *port;
271 struct pardevice * pdev = NULL;
272 char *name;
273 int fl;
274
275 name = kmalloc (strlen (CHRDEV) + 3, GFP_KERNEL);
276 if (name == NULL)
277 return -ENOMEM;
278
279 sprintf (name, CHRDEV "%x", minor);
280
281 port = parport_find_number (minor);
282 if (!port) {
283 printk (KERN_WARNING "%s: no associated port!\n", name);
284 kfree (name);
285 return -ENXIO;
286 }
287
288 fl = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
289 pdev = parport_register_device (port, name, NULL,
290 NULL, pp_irq, fl, pp);
291 parport_put_port (port);
292
293 if (!pdev) {
294 printk (KERN_WARNING "%s: failed to register device!\n", name);
295 kfree (name);
296 return -ENXIO;
297 }
298
299 pp->pdev = pdev;
300 printk (KERN_DEBUG "%s: registered pardevice\n", name);
301 return 0;
302 }
303
304 static enum ieee1284_phase init_phase (int mode)
305 {
306 switch (mode & ~(IEEE1284_DEVICEID
307 | IEEE1284_ADDR)) {
308 case IEEE1284_MODE_NIBBLE:
309 case IEEE1284_MODE_BYTE:
310 return IEEE1284_PH_REV_IDLE;
311 }
312 return IEEE1284_PH_FWD_IDLE;
313 }
314
315 static int pp_ioctl(struct inode *inode, struct file *file,
316 unsigned int cmd, unsigned long arg)
317 {
318 unsigned int minor = MINOR(inode->i_rdev);
319 struct pp_struct *pp = file->private_data;
320 struct parport * port;
321
322 /* First handle the cases that don't take arguments. */
323 switch (cmd) {
324 case PPCLAIM:
325 {
326 struct ieee1284_info *info;
327
328 if (pp->flags & PP_CLAIMED) {
329 printk (KERN_DEBUG CHRDEV
330 "%x: you've already got it!\n", minor);
331 return -EINVAL;
332 }
333
334 /* Deferred device registration. */
335 if (!pp->pdev) {
336 int err = register_device (minor, pp);
337 if (err) {
338 return err;
339 }
340 }
341
342 parport_claim_or_block (pp->pdev);
343 pp->flags |= PP_CLAIMED;
344
345 /* For interrupt-reporting to work, we need to be
346 * informed of each interrupt. */
347 pp_enable_irq (pp);
348
349 /* We may need to fix up the state machine. */
350 info = &pp->pdev->port->ieee1284;
351 pp->saved_state.mode = info->mode;
352 pp->saved_state.phase = info->phase;
353 info->mode = pp->state.mode;
354 info->phase = pp->state.phase;
355
356 return 0;
357 }
358 case PPEXCL:
359 if (pp->pdev) {
360 printk (KERN_DEBUG CHRDEV "%x: too late for PPEXCL; "
361 "already registered\n", minor);
362 if (pp->flags & PP_EXCL)
363 /* But it's not really an error. */
364 return 0;
365 /* There's no chance of making the driver happy. */
366 return -EINVAL;
367 }
368
369 /* Just remember to register the device exclusively
370 * when we finally do the registration. */
371 pp->flags |= PP_EXCL;
372 return 0;
373 case PPSETMODE:
374 {
375 int mode;
376 if (copy_from_user (&mode, (int *) arg, sizeof (mode)))
377 return -EFAULT;
378 /* FIXME: validate mode */
379 pp->state.mode = mode;
380 pp->state.phase = init_phase (mode);
381
382 if (pp->flags & PP_CLAIMED) {
383 pp->pdev->port->ieee1284.mode = mode;
384 pp->pdev->port->ieee1284.phase = pp->state.phase;
385 }
386
387 return 0;
388 }
389 case PPGETMODE:
390 {
391 int mode;
392
393 if (pp->flags & PP_CLAIMED) {
394 mode = pp->pdev->port->ieee1284.mode;
395 } else {
396 mode = pp->state.mode;
397 }
398 if (copy_to_user ((int *)arg, &mode, sizeof (mode))) {
399 return -EFAULT;
400 }
401 return 0;
402 }
403 case PPSETPHASE:
404 {
405 int phase;
406 if (copy_from_user (&phase, (int *) arg, sizeof (phase))) {
407 return -EFAULT;
408 }
409 /* FIXME: validate phase */
410 pp->state.phase = phase;
411
412 if (pp->flags & PP_CLAIMED) {
413 pp->pdev->port->ieee1284.phase = phase;
414 }
415
416 return 0;
417 }
418 case PPGETPHASE:
419 {
420 int phase;
421
422 if (pp->flags & PP_CLAIMED) {
423 phase = pp->pdev->port->ieee1284.phase;
424 } else {
425 phase = pp->state.phase;
426 }
427 if (copy_to_user ((int *)arg, &phase, sizeof (phase))) {
428 return -EFAULT;
429 }
430 return 0;
431 }
432 case PPGETMODES:
433 {
434 unsigned int modes;
435
436 modes = pp->pdev->port->modes;
437 if (copy_to_user ((unsigned int *)arg, &modes, sizeof (port->modes))) {
438 return -EFAULT;
439 }
440 return 0;
441 }
442 case PPSETFLAGS:
443 {
444 int uflags;
445
446 if (copy_from_user (&uflags, (int *)arg, sizeof (uflags))) {
447 return -EFAULT;
448 }
449 pp->flags &= ~PP_FLAGMASK;
450 pp->flags |= (uflags & PP_FLAGMASK);
451 return 0;
452 }
453 case PPGETFLAGS:
454 {
455 int uflags;
456
457 uflags = pp->flags & PP_FLAGMASK;
458 if (copy_to_user ((int *)arg, &uflags, sizeof (uflags))) {
459 return -EFAULT;
460 }
461 return 0;
462 }
463 } /* end switch() */
464
465 /* Everything else requires the port to be claimed, so check
466 * that now. */
467 if ((pp->flags & PP_CLAIMED) == 0) {
468 printk (KERN_DEBUG CHRDEV "%x: claim the port first\n",
469 minor);
470 return -EINVAL;
471 }
472
473 port = pp->pdev->port;
474 switch (cmd) {
475 struct ieee1284_info *info;
476 unsigned char reg;
477 unsigned char mask;
478 int mode;
479 int ret;
480 struct timeval par_timeout;
481 long to_jiffies;
482
483 case PPRSTATUS:
484 reg = parport_read_status (port);
485 if (copy_to_user ((unsigned char *) arg, ®, sizeof (reg)))
486 return -EFAULT;
487 return 0;
488 case PPRDATA:
489 reg = parport_read_data (port);
490 if (copy_to_user ((unsigned char *) arg, ®, sizeof (reg)))
491 return -EFAULT;
492 return 0;
493 case PPRCONTROL:
494 reg = parport_read_control (port);
495 if (copy_to_user ((unsigned char *) arg, ®, sizeof (reg)))
496 return -EFAULT;
497 return 0;
498 case PPYIELD:
499 parport_yield_blocking (pp->pdev);
500 return 0;
501
502 case PPRELEASE:
503 /* Save the state machine's state. */
504 info = &pp->pdev->port->ieee1284;
505 pp->state.mode = info->mode;
506 pp->state.phase = info->phase;
507 info->mode = pp->saved_state.mode;
508 info->phase = pp->saved_state.phase;
509 parport_release (pp->pdev);
510 pp->flags &= ~PP_CLAIMED;
511 return 0;
512
513 case PPWCONTROL:
514 if (copy_from_user (®, (unsigned char *) arg, sizeof (reg)))
515 return -EFAULT;
516 parport_write_control (port, reg);
517 return 0;
518
519 case PPWDATA:
520 if (copy_from_user (®, (unsigned char *) arg, sizeof (reg)))
521 return -EFAULT;
522 parport_write_data (port, reg);
523 return 0;
524
525 case PPFCONTROL:
526 if (copy_from_user (&mask, (unsigned char *) arg,
527 sizeof (mask)))
528 return -EFAULT;
529 if (copy_from_user (®, 1 + (unsigned char *) arg,
530 sizeof (reg)))
531 return -EFAULT;
532 parport_frob_control (port, mask, reg);
533 return 0;
534
535 case PPDATADIR:
536 if (copy_from_user (&mode, (int *) arg, sizeof (mode)))
537 return -EFAULT;
538 if (mode)
539 port->ops->data_reverse (port);
540 else
541 port->ops->data_forward (port);
542 return 0;
543
544 case PPNEGOT:
545 if (copy_from_user (&mode, (int *) arg, sizeof (mode)))
546 return -EFAULT;
547 switch ((ret = parport_negotiate (port, mode))) {
548 case 0: break;
549 case -1: /* handshake failed, peripheral not IEEE 1284 */
550 ret = -EIO;
551 break;
552 case 1: /* handshake succeeded, peripheral rejected mode */
553 ret = -ENXIO;
554 break;
555 }
556 pp_enable_irq (pp);
557 return ret;
558
559 case PPWCTLONIRQ:
560 if (copy_from_user (®, (unsigned char *) arg,
561 sizeof (reg)))
562 return -EFAULT;
563
564 /* Remember what to set the control lines to, for next
565 * time we get an interrupt. */
566 pp->irqctl = reg;
567 pp->irqresponse = 1;
568 return 0;
569
570 case PPCLRIRQ:
571 ret = atomic_read (&pp->irqc);
572 if (copy_to_user ((int *) arg, &ret, sizeof (ret)))
573 return -EFAULT;
574 atomic_sub (ret, &pp->irqc);
575 return 0;
576
577 case PPSETTIME:
578 if (copy_from_user (&par_timeout, (struct timeval *)arg,
579 sizeof(struct timeval))) {
580 return -EFAULT;
581 }
582 /* Convert to jiffies, place in pp->pdev->timeout */
583 if ((par_timeout.tv_sec < 0) || (par_timeout.tv_usec < 0)) {
584 return -EINVAL;
585 }
586 to_jiffies = ROUND_UP(par_timeout.tv_usec, 1000000/HZ);
587 to_jiffies += par_timeout.tv_sec * (long)HZ;
588 if (to_jiffies <= 0) {
589 return -EINVAL;
590 }
591 pp->pdev->timeout = to_jiffies;
592 return 0;
593
594 case PPGETTIME:
595 to_jiffies = pp->pdev->timeout;
596 par_timeout.tv_sec = to_jiffies / HZ;
597 par_timeout.tv_usec = (to_jiffies % (long)HZ) * (1000000/HZ);
598 if (copy_to_user ((struct timeval *)arg, &par_timeout,
599 sizeof(struct timeval))) {
600 return -EFAULT;
601 }
602 return 0;
603
604 default:
605 printk (KERN_DEBUG CHRDEV "%x: What? (cmd=0x%x)\n", minor,
606 cmd);
607 return -EINVAL;
608 }
609
610 /* Keep the compiler happy */
611 return 0;
612 }
613
614 static int pp_open (struct inode * inode, struct file * file)
615 {
616 unsigned int minor = MINOR (inode->i_rdev);
617 struct pp_struct *pp;
618
619 if (minor >= PARPORT_MAX)
620 return -ENXIO;
621
622 pp = kmalloc (sizeof (struct pp_struct), GFP_KERNEL);
623 if (!pp)
624 return -ENOMEM;
625
626 pp->state.mode = IEEE1284_MODE_COMPAT;
627 pp->state.phase = init_phase (pp->state.mode);
628 pp->flags = 0;
629 pp->irqresponse = 0;
630 atomic_set (&pp->irqc, 0);
631 init_waitqueue_head (&pp->irq_wait);
632
633 /* Defer the actual device registration until the first claim.
634 * That way, we know whether or not the driver wants to have
635 * exclusive access to the port (PPEXCL).
636 */
637 pp->pdev = NULL;
638 file->private_data = pp;
639
640 return 0;
641 }
642
643 static int pp_release (struct inode * inode, struct file * file)
644 {
645 unsigned int minor = MINOR (inode->i_rdev);
646 struct pp_struct *pp = file->private_data;
647 int compat_negot;
648
649 lock_kernel();
650 compat_negot = 0;
651 if (!(pp->flags & PP_CLAIMED) && pp->pdev &&
652 (pp->state.mode != IEEE1284_MODE_COMPAT)) {
653 struct ieee1284_info *info;
654
655 /* parport released, but not in compatability mode */
656 parport_claim_or_block (pp->pdev);
657 pp->flags |= PP_CLAIMED;
658 info = &pp->pdev->port->ieee1284;
659 pp->saved_state.mode = info->mode;
660 pp->saved_state.phase = info->phase;
661 info->mode = pp->state.mode;
662 info->phase = pp->state.phase;
663 compat_negot = 1;
664 } else if ((pp->flags & PP_CLAIMED) && pp->pdev &&
665 (pp->pdev->port->ieee1284.mode != IEEE1284_MODE_COMPAT)) {
666 compat_negot = 2;
667 }
668 if (compat_negot) {
669 parport_negotiate (pp->pdev->port, IEEE1284_MODE_COMPAT);
670 printk (KERN_DEBUG CHRDEV
671 "%x: negotiated back to compatibility mode because "
672 "user-space forgot\n", minor);
673 }
674
675 if (pp->flags & PP_CLAIMED) {
676 struct ieee1284_info *info;
677
678 info = &pp->pdev->port->ieee1284;
679 pp->state.mode = info->mode;
680 pp->state.phase = info->phase;
681 info->mode = pp->saved_state.mode;
682 info->phase = pp->saved_state.phase;
683 parport_release (pp->pdev);
684 if (compat_negot != 1) {
685 printk (KERN_DEBUG CHRDEV "%x: released pardevice "
686 "because user-space forgot\n", minor);
687 }
688 }
689
690 if (pp->pdev) {
691 const char *name = pp->pdev->name;
692 parport_unregister_device (pp->pdev);
693 kfree (name);
694 pp->pdev = NULL;
695 printk (KERN_DEBUG CHRDEV "%x: unregistered pardevice\n",
696 minor);
697 }
698 unlock_kernel();
699
700 kfree (pp);
701
702 return 0;
703 }
704
705 /* No kernel lock held - fine */
706 static unsigned int pp_poll (struct file * file, poll_table * wait)
707 {
708 struct pp_struct *pp = file->private_data;
709 unsigned int mask = 0;
710
711 poll_wait (file, &pp->irq_wait, wait);
712 if (atomic_read (&pp->irqc))
713 mask |= POLLIN | POLLRDNORM;
714
715 return mask;
716 }
717
718 static struct file_operations pp_fops = {
719 owner: THIS_MODULE,
720 llseek: no_llseek,
721 read: pp_read,
722 write: pp_write,
723 poll: pp_poll,
724 ioctl: pp_ioctl,
725 open: pp_open,
726 release: pp_release,
727 };
728
729 static devfs_handle_t devfs_handle;
730
731 static int __init ppdev_init (void)
732 {
733 if (devfs_register_chrdev (PP_MAJOR, CHRDEV, &pp_fops)) {
734 printk (KERN_WARNING CHRDEV ": unable to get major %d\n",
735 PP_MAJOR);
736 return -EIO;
737 }
738 devfs_handle = devfs_mk_dir (NULL, "parports", NULL);
739 devfs_register_series (devfs_handle, "%u", PARPORT_MAX,
740 DEVFS_FL_DEFAULT, PP_MAJOR, 0,
741 S_IFCHR | S_IRUGO | S_IWUGO,
742 &pp_fops, NULL);
743
744 printk (KERN_INFO PP_VERSION "\n");
745 return 0;
746 }
747
748 static void __exit ppdev_cleanup (void)
749 {
750 /* Clean up all parport stuff */
751 devfs_unregister (devfs_handle);
752 devfs_unregister_chrdev (PP_MAJOR, CHRDEV);
753 }
754
755 module_init(ppdev_init);
756 module_exit(ppdev_cleanup);
757
758 MODULE_LICENSE("GPL");
759
760 EXPORT_NO_SYMBOLS;
761