2 * Generic parallel printer driver
4 * Copyright (C) 1992 by Jim Weigand and Linus Torvalds
5 * Copyright (C) 1992,1993 by Michael K. Johnson
6 * - Thanks much to Gunter Windau for pointing out to me where the error
7 * checking ought to be.
8 * Copyright (C) 1993 by Nigel Gamble (added interrupt code)
9 * Copyright (C) 1994 by Alan Cox (Modularised it)
10 * LPCAREFUL, LPABORT, LPGETSTATUS added by Chris Metcalf, metcalf@lcs.mit.edu
11 * Statistics and support for slow printers by Rob Janssen, rob@knoware.nl
12 * "lp=" command line parameters added by Grant Guenther, grant@torque.net
13 * lp_read (Status readback) support added by Carsten Gross,
14 * carsten@sol.wohnheim.uni-ulm.de
15 * Support for parport by Philip Blundell <Philip.Blundell@pobox.com>
16 * Parport sharing hacking by Andrea Arcangeli
17 * Fixed kernel_(to/from)_user memory copy to check for errors
18 * by Riccardo Facchetti <fizban@tin.it>
19 * Redesigned interrupt handling for handle printers with buggy handshake
20 * by Andrea Arcangeli, 11 May 1998
21 * Full efficient handling of printer with buggy irq handshake (now I have
22 * understood the meaning of the strange handshake). This is done sending new
23 * characters if the interrupt is just happened, even if the printer say to
24 * be still BUSY. This is needed at least with Epson Stylus Color. To enable
25 * the new TRUST_IRQ mode read the `LP OPTIMIZATION' section below...
26 * Fixed the irq on the rising edge of the strobe case.
27 * Obsoleted the CAREFUL flag since a printer that doesn' t work with
28 * CAREFUL will block a bit after in lp_check_status().
29 * Andrea Arcangeli, 15 Oct 1998
30 * Obsoleted and removed all the lowlevel stuff implemented in the last
31 * month to use the IEEE1284 functions (that handle the _new_ compatibilty
35 /* This driver should, in theory, work with any parallel port that has an
36 * appropriate low-level driver; all I/O is done through the parport
39 * If this driver is built into the kernel, you can configure it using the
40 * kernel command-line. For example:
42 * lp=parport1,none,parport2 (bind lp0 to parport1, disable lp1 and
43 * bind lp2 to parport2)
45 * lp=auto (assign lp devices to all ports that
46 * have printers attached, as determined
47 * by the IEEE-1284 autoprobe)
49 * lp=reset (reset the printer during
52 * lp=off (disable the printer driver entirely)
54 * If the driver is loaded as a module, similar functionality is available
55 * using module parameters. The equivalent of the above commands would be:
57 * # insmod lp.o parport=1,none,2
59 * # insmod lp.o parport=auto
61 * # insmod lp.o reset=1
64 /* COMPATIBILITY WITH OLD KERNELS
66 * Under Linux 2.0 and previous versions, lp devices were bound to ports at
67 * particular I/O addresses, as follows:
73 * The new driver, by default, binds lp devices to parport devices as it
74 * finds them. This means that if you only have one port, it will be bound
75 * to lp0 regardless of its I/O address. If you need the old behaviour, you
76 * can force it using the parameters described above.
80 * The new interrupt handling code take care of the buggy handshake
81 * of some HP and Epson printer:
83 * ACK _______________ ___________
86 * BUSY _________ _______
89 * I discovered this using the printer scanner that you can find at:
91 * ftp://e-mind.com/pub/linux/pscan/
93 * 11 May 98, Andrea Arcangeli
95 * My printer scanner run on an Epson Stylus Color show that such printer
96 * generates the irq on the _rising_ edge of the STROBE. Now lp handle
99 * 15 Oct 1998, Andrea Arcangeli
101 * The so called `buggy' handshake is really the well documented
102 * compatibility mode IEEE1284 handshake. They changed the well known
103 * Centronics handshake acking in the middle of busy expecting to not
104 * break drivers or legacy application, while they broken linux lp
105 * until I fixed it reverse engineering the protocol by hand some
108 * 14 Dec 1998, Andrea Arcangeli
110 * Copyright (C) 2000 by Tim Waugh (added LPSETTIMEOUT ioctl)
113 #include <linux/module.h>
114 #include <linux/init.h>
116 #include <linux/config.h>
117 #include <linux/errno.h>
118 #include <linux/kernel.h>
119 #include <linux/major.h>
120 #include <linux/sched.h>
121 #include <linux/malloc.h>
122 #include <linux/fcntl.h>
123 #include <linux/delay.h>
124 #include <linux/poll.h>
125 #include <linux/console.h>
127 #include <linux/parport.h>
129 #include <linux/lp.h>
132 #include <asm/uaccess.h>
133 #include <asm/system.h>
135 /* if you have more than 3 printers, remember to increase LP_NO */
138 /* ROUND_UP macro from fs/select.c */
139 #define ROUND_UP(x,y) (((x)+(y)-1)/(y))
141 struct lp_struct lp_table
[LP_NO
];
143 static unsigned int lp_count
= 0;
145 /* Test if printer is ready */
146 #define LP_READY(status) ((status) & LP_PBUSY)
147 /* Test if the printer is not acking the strobe */
148 #define LP_NO_ACKING(status) ((status) & LP_PACK)
149 /* Test if the printer has error conditions */
150 #define LP_NO_ERROR(status) ((status) & LP_PERRORP)
154 /* If you want to see if you can get lp_poll working, define this. */
157 /* --- parport support ----------------------------------------- */
159 static int lp_preempt(void *handle
)
161 struct lp_struct
*lps
= (struct lp_struct
*)handle
;
163 if (!(lps
->flags
& LP_PORT_BUSY
)) {
164 /* Let the port go. */
165 clear_bit (LP_HAVE_PORT_BIT
, &lps
->flags
);
169 /* Don't actually release the port now */
173 static void lp_check_data (struct lp_struct
*lp
)
175 #if !defined(CONFIG_PARPORT_1284) || !defined (SUPPORT_POLL)
178 struct pardevice
*dev
= lp
->dev
;
179 if (!(lp
->flags
& LP_NO_REVERSE
)) {
180 int err
= parport_negotiate (dev
->port
, IEEE1284_MODE_NIBBLE
);
182 lp
->flags
|= LP_NO_REVERSE
;
184 unsigned char s
= parport_read_status (dev
->port
);
185 if (s
& PARPORT_STATUS_ERROR
)
186 lp
->flags
&= ~LP_DATA_AVAIL
;
188 lp
->flags
|= LP_DATA_AVAIL
;
189 if (waitqueue_active (&lp
->dataq
))
190 wake_up_interruptible (&lp
->dataq
);
194 #endif /* IEEE 1284 support */
197 static void lp_parport_release (int minor
)
199 lp_check_data (&lp_table
[minor
]);
200 if (test_and_clear_bit (LP_HAVE_PORT_BIT
, &lp_table
[minor
].flags
))
201 parport_release (lp_table
[minor
].dev
);
203 lp_table
[minor
].flags
&= ~LP_PORT_BUSY
;
206 static void lp_parport_claim (int minor
)
208 if (!test_and_set_bit (LP_HAVE_PORT_BIT
, &lp_table
[minor
].flags
))
209 parport_claim_or_block (lp_table
[minor
].dev
);
211 lp_table
[minor
].flags
|= LP_PORT_BUSY
;
214 /* --- low-level port access ----------------------------------- */
216 #define r_dtr(x) (parport_read_data(lp_table[(x)].dev->port))
217 #define r_str(x) (parport_read_status(lp_table[(x)].dev->port))
218 #define w_ctr(x,y) do { parport_write_control(lp_table[(x)].dev->port, (y)); } while (0)
219 #define w_dtr(x,y) do { parport_write_data(lp_table[(x)].dev->port, (y)); } while (0)
221 static int lp_reset(int minor
)
224 lp_parport_claim (minor
);
225 w_ctr(minor
, LP_PSELECP
);
227 w_ctr(minor
, LP_PSELECP
| LP_PINITP
);
228 retval
= r_str(minor
);
229 lp_parport_release (minor
);
233 static void lp_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
235 struct lp_struct
*lp_dev
= (struct lp_struct
*) dev_id
;
236 if (!(lp_dev
->flags
& LP_PORT_BUSY
))
237 /* We must have the port since we got an interrupt. */
238 lp_check_data (lp_dev
);
239 if (waitqueue_active (&lp_dev
->waitq
))
240 wake_up_interruptible (&lp_dev
->waitq
);
243 static void lp_wakeup (void *handle
)
245 struct lp_struct
*lp_dev
= handle
;
247 if (lp_dev
->flags
& LP_PORT_BUSY
)
250 /* Grab the port if it can help (i.e. reverse mode is possible). */
251 if (!(lp_dev
->flags
& LP_NO_REVERSE
)) {
252 parport_claim (lp_dev
->dev
);
253 set_bit (LP_HAVE_PORT_BIT
, &lp_dev
->flags
);
254 lp_check_data (lp_dev
);
255 if (waitqueue_active (&lp_dev
->waitq
))
256 wake_up_interruptible (&lp_dev
->waitq
);
260 static void lp_error (int minor
)
264 if (LP_F(minor
) & LP_ABORT
)
267 polling
= lp_table
[minor
].dev
->port
->irq
== PARPORT_IRQ_NONE
;
268 if (polling
) lp_parport_release (minor
);
269 interruptible_sleep_on_timeout (&lp_table
[minor
].waitq
,
271 if (polling
) lp_parport_claim (minor
);
272 else parport_yield_blocking (lp_table
[minor
].dev
);
275 static int lp_check_status(int minor
)
278 unsigned int last
= lp_table
[minor
].last_error
;
279 unsigned char status
= r_str(minor
);
280 if ((status
& LP_PERRORP
) && !(LP_F(minor
) & LP_CAREFUL
))
283 else if ((status
& LP_POUTPA
)) {
284 if (last
!= LP_POUTPA
) {
286 printk(KERN_INFO
"lp%d out of paper\n", minor
);
289 } else if (!(status
& LP_PSELECD
)) {
290 if (last
!= LP_PSELECD
) {
292 printk(KERN_INFO
"lp%d off-line\n", minor
);
295 } else if (!(status
& LP_PERRORP
)) {
296 if (last
!= LP_PERRORP
) {
298 printk(KERN_INFO
"lp%d on fire\n", minor
);
302 last
= 0; /* Come here if LP_CAREFUL is set and no
303 errors are reported. */
306 lp_table
[minor
].last_error
= last
;
314 static ssize_t
lp_write(struct file
* file
, const char * buf
,
315 size_t count
, loff_t
*ppos
)
317 unsigned int minor
= MINOR(file
->f_dentry
->d_inode
->i_rdev
);
318 struct parport
*port
= lp_table
[minor
].dev
->port
;
319 char *kbuf
= lp_table
[minor
].lp_buffer
;
322 size_t copy_size
= count
;
326 if (jiffies
-lp_table
[minor
].lastcall
> LP_TIME(minor
))
327 lp_table
[minor
].runchars
= 0;
329 lp_table
[minor
].lastcall
= jiffies
;
332 /* Need to copy the data from user-space. */
333 if (copy_size
> LP_BUFFER_SIZE
)
334 copy_size
= LP_BUFFER_SIZE
;
336 if (copy_from_user (kbuf
, buf
, copy_size
))
339 if (down_interruptible (&lp_table
[minor
].port_mutex
))
342 /* Claim Parport or sleep until it becomes available
344 lp_parport_claim (minor
);
346 /* Go to compatibility mode. */
347 parport_negotiate (port
, IEEE1284_MODE_COMPAT
);
349 old_to
= parport_set_timeout (lp_table
[minor
].dev
,
350 lp_table
[minor
].timeout
);
353 /* Write the data. */
354 written
= parport_write (port
, kbuf
, copy_size
);
356 copy_size
-= written
;
362 if (signal_pending (current
)) {
370 /* incomplete write -> check error ! */
371 int error
= lp_check_status (minor
);
373 if (LP_F(minor
) & LP_ABORT
) {
379 parport_yield_blocking (lp_table
[minor
].dev
);
380 } else if (current
->need_resched
)
385 if (copy_size
> LP_BUFFER_SIZE
)
386 copy_size
= LP_BUFFER_SIZE
;
388 if (copy_from_user(kbuf
, buf
, copy_size
)) {
396 /* Not really necessary, but polite. */
397 parport_set_timeout (lp_table
[minor
].dev
, old_to
);
399 lp_parport_release (minor
);
401 up (&lp_table
[minor
].port_mutex
);
406 #ifdef CONFIG_PARPORT_1284
408 /* Status readback conforming to ieee1284 */
409 static ssize_t
lp_read(struct file
* file
, char * buf
,
410 size_t count
, loff_t
*ppos
)
412 unsigned int minor
=MINOR(file
->f_dentry
->d_inode
->i_rdev
);
413 struct parport
*port
= lp_table
[minor
].dev
->port
;
415 char *kbuf
= lp_table
[minor
].lp_buffer
;
417 if (count
> LP_BUFFER_SIZE
)
418 count
= LP_BUFFER_SIZE
;
420 if (down_interruptible (&lp_table
[minor
].port_mutex
))
423 lp_parport_claim (minor
);
426 retval
= parport_read (port
, kbuf
, count
);
431 if (file
->f_flags
& O_NONBLOCK
)
434 /* Wait for an interrupt. */
435 interruptible_sleep_on_timeout (&lp_table
[minor
].waitq
,
438 if (signal_pending (current
)) {
444 lp_parport_release (minor
);
446 if (retval
> 0 && copy_to_user (buf
, kbuf
, retval
))
449 up (&lp_table
[minor
].port_mutex
);
454 #endif /* IEEE 1284 support */
456 static int lp_open(struct inode
* inode
, struct file
* file
)
458 unsigned int minor
= MINOR(inode
->i_rdev
);
462 if ((LP_F(minor
) & LP_EXIST
) == 0)
464 if (test_and_set_bit(LP_BUSY_BIT_POS
, &LP_F(minor
)))
469 /* If ABORTOPEN is set and the printer is offline or out of paper,
470 we may still want to open it to perform ioctl()s. Therefore we
471 have commandeered O_NONBLOCK, even though it is being used in
472 a non-standard manner. This is strictly a Linux hack, and
473 should most likely only ever be used by the tunelp application. */
474 if ((LP_F(minor
) & LP_ABORTOPEN
) && !(file
->f_flags
& O_NONBLOCK
)) {
476 lp_parport_claim (minor
);
477 status
= r_str(minor
);
478 lp_parport_release (minor
);
479 if (status
& LP_POUTPA
) {
480 printk(KERN_INFO
"lp%d out of paper\n", minor
);
482 LP_F(minor
) &= ~LP_BUSY
;
484 } else if (!(status
& LP_PSELECD
)) {
485 printk(KERN_INFO
"lp%d off-line\n", minor
);
487 LP_F(minor
) &= ~LP_BUSY
;
489 } else if (!(status
& LP_PERRORP
)) {
490 printk(KERN_ERR
"lp%d printer error\n", minor
);
492 LP_F(minor
) &= ~LP_BUSY
;
496 lp_table
[minor
].lp_buffer
= (char *) kmalloc(LP_BUFFER_SIZE
, GFP_KERNEL
);
497 if (!lp_table
[minor
].lp_buffer
) {
499 LP_F(minor
) &= ~LP_BUSY
;
505 static int lp_release(struct inode
* inode
, struct file
* file
)
507 unsigned int minor
= MINOR(inode
->i_rdev
);
509 kfree_s(lp_table
[minor
].lp_buffer
, LP_BUFFER_SIZE
);
510 lp_table
[minor
].lp_buffer
= NULL
;
512 LP_F(minor
) &= ~LP_BUSY
;
516 static int lp_ioctl(struct inode
*inode
, struct file
*file
,
517 unsigned int cmd
, unsigned long arg
)
519 unsigned int minor
= MINOR(inode
->i_rdev
);
524 printk(KERN_DEBUG
"lp%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor
, cmd
, arg
);
528 if ((LP_F(minor
) & LP_EXIST
) == 0)
531 struct timeval par_timeout
;
535 LP_TIME(minor
) = arg
* HZ
/100;
538 LP_CHAR(minor
) = arg
;
542 LP_F(minor
) |= LP_ABORT
;
544 LP_F(minor
) &= ~LP_ABORT
;
548 LP_F(minor
) |= LP_ABORTOPEN
;
550 LP_F(minor
) &= ~LP_ABORTOPEN
;
554 LP_F(minor
) |= LP_CAREFUL
;
556 LP_F(minor
) &= ~LP_CAREFUL
;
559 LP_WAIT(minor
) = arg
;
565 if (copy_to_user((int *) arg
, &LP_IRQ(minor
),
570 lp_parport_claim(minor
);
571 status
= r_str(minor
);
572 lp_parport_release(minor
);
574 if (copy_to_user((int *) arg
, &status
, sizeof(int)))
582 if (copy_to_user((int *) arg
, &LP_STAT(minor
),
583 sizeof(struct lp_stats
)))
586 memset(&LP_STAT(minor
), 0,
587 sizeof(struct lp_stats
));
591 status
= LP_F(minor
);
592 if (copy_to_user((int *) arg
, &status
, sizeof(int)))
597 if (copy_from_user (&par_timeout
,
598 (struct timeval
*) arg
,
599 sizeof (struct timeval
))) {
602 /* Convert to jiffies, place in lp_table */
603 if ((par_timeout
.tv_sec
< 0) ||
604 (par_timeout
.tv_usec
< 0)) {
607 to_jiffies
= ROUND_UP(par_timeout
.tv_usec
, 1000000/HZ
);
608 to_jiffies
+= par_timeout
.tv_sec
* (long) HZ
;
609 if (to_jiffies
<= 0) {
612 lp_table
[minor
].timeout
= to_jiffies
;
621 #ifdef CONFIG_PARPORT_1284
622 static unsigned int lp_poll (struct file
*filp
, struct poll_table_struct
*wait
)
624 unsigned int minor
= MINOR (filp
->f_dentry
->d_inode
->i_rdev
);
625 unsigned int mask
= POLLOUT
| POLLWRNORM
; /* always writable */
627 poll_wait (filp
, &lp_table
[minor
].dataq
, wait
);
629 if (lp_table
[minor
].flags
& LP_DATA_AVAIL
)
630 mask
|= POLLIN
| POLLRDNORM
;
634 #endif /* IEEE 1284 support */
636 static struct file_operations lp_fops
= {
641 #ifdef CONFIG_PARPORT_1284
647 /* --- support for console on the line printer ----------------- */
649 #ifdef CONFIG_LP_CONSOLE
653 /* If the printer is out of paper, we can either lose the messages or
654 * stall until the printer is happy again. Define CONSOLE_LP_STRICT
655 * non-zero to get the latter behaviour. */
656 #define CONSOLE_LP_STRICT 1
658 /* The console_lock must be held when we get here. */
660 static void lp_console_write (struct console
*co
, const char *s
,
663 struct pardevice
*dev
= lp_table
[CONSOLE_LP
].dev
;
664 struct parport
*port
= dev
->port
;
668 if (!(lp_table
[CONSOLE_LP
].flags
& (1<<LP_HAVE_PORT_BIT
))) {
669 if (parport_claim (dev
))
670 /* Nothing we can do. */
672 set_bit (LP_HAVE_PORT_BIT
, &lp_table
[CONSOLE_LP
].flags
);
675 old_to
= parport_set_timeout (dev
, 0);
677 /* Go to compatibility mode. */
678 parport_negotiate (port
, IEEE1284_MODE_COMPAT
);
681 /* Write the data, converting LF->CRLF as we go. */
682 ssize_t canwrite
= count
;
683 char *lf
= strchr (s
, '\n');
688 written
= parport_write (port
, s
, canwrite
);
698 if (lf
&& canwrite
<= 0) {
699 const char *crlf
= "\r\n";
702 /* Dodge the original '\n', and put '\r\n' instead. */
706 written
= parport_write (port
, crlf
, i
);
708 i
-= written
, crlf
+= written
;
709 } while (i
> 0 && (CONSOLE_LP_STRICT
|| written
> 0));
711 } while (count
> 0 && (CONSOLE_LP_STRICT
|| written
> 0));
713 parport_set_timeout (dev
, old_to
);
716 static kdev_t
lp_console_device (struct console
*c
)
718 return MKDEV(LP_MAJOR
, CONSOLE_LP
);
721 static struct console lpcons
= {
735 #endif /* console on line printer */
737 /* --- initialisation code ------------------------------------- */
741 static int parport_nr
[LP_NO
] = { [0 ... LP_NO
-1] = LP_PARPORT_UNSPEC
};
742 static char *parport
[LP_NO
] = { NULL
, };
743 static int reset
= 0;
745 MODULE_PARM(parport
, "1-" __MODULE_STRING(LP_NO
) "s");
746 MODULE_PARM(reset
, "i");
750 static int parport_nr
[LP_NO
] = { [0 ... LP_NO
-1] = LP_PARPORT_UNSPEC
};
751 static int reset
= 0;
753 static int parport_ptr
= 0;
755 void __init
lp_setup(char *str
, int *ints
)
758 if (ints
[0] == 0 || ints
[1] == 0) {
759 /* disable driver on "lp=" or "lp=0" */
760 parport_nr
[0] = LP_PARPORT_OFF
;
762 printk(KERN_WARNING
"warning: 'lp=0x%x' is deprecated, ignored\n", ints
[1]);
764 } else if (!strncmp(str
, "parport", 7)) {
765 int n
= simple_strtoul(str
+7, NULL
, 10);
766 if (parport_ptr
< LP_NO
)
767 parport_nr
[parport_ptr
++] = n
;
769 printk(KERN_INFO
"lp: too many ports, %s ignored.\n",
771 } else if (!strcmp(str
, "auto")) {
772 parport_nr
[0] = LP_PARPORT_AUTO
;
773 } else if (!strcmp(str
, "none")) {
774 parport_nr
[parport_ptr
++] = LP_PARPORT_NONE
;
775 } else if (!strcmp(str
, "reset")) {
782 static int lp_register(int nr
, struct parport
*port
)
784 lp_table
[nr
].dev
= parport_register_device(port
, "lp",
785 lp_preempt
, lp_wakeup
,
788 (void *) &lp_table
[nr
]);
789 if (lp_table
[nr
].dev
== NULL
)
791 lp_table
[nr
].flags
|= LP_EXIST
;
796 printk(KERN_INFO
"lp%d: using %s (%s).\n", nr
, port
->name
,
797 (port
->irq
== PARPORT_IRQ_NONE
)?"polling":"interrupt-driven");
799 #ifdef CONFIG_LP_CONSOLE
801 if (port
->modes
& PARPORT_MODE_SAFEININT
) {
803 register_console (&lpcons
);
804 printk (KERN_INFO
"lp%d: console ready\n", CONSOLE_LP
);
806 printk (KERN_ERR
"lp%d: cannot run console on %s\n",
807 CONSOLE_LP
, port
->name
);
814 static void lp_attach (struct parport
*port
)
818 switch (parport_nr
[0])
820 case LP_PARPORT_UNSPEC
:
821 case LP_PARPORT_AUTO
:
822 if (parport_nr
[0] == LP_PARPORT_AUTO
&&
823 port
->probe_info
[0].class != PARPORT_CLASS_PRINTER
)
826 if (!lp_register(lp_count
, port
))
827 if (++lp_count
== LP_NO
)
833 for (i
= 0; i
< LP_NO
; i
++) {
834 if (port
->number
== parport_nr
[i
]) {
835 if (!lp_register(i
, port
))
844 static void lp_detach (struct parport
*port
)
846 /* Write this some day. */
849 static struct parport_driver lp_driver
= {
856 int __init
lp_init (void)
860 if (parport_nr
[0] == LP_PARPORT_OFF
)
863 for (i
= 0; i
< LP_NO
; i
++) {
864 lp_table
[i
].dev
= NULL
;
865 lp_table
[i
].flags
= 0;
866 lp_table
[i
].chars
= LP_INIT_CHAR
;
867 lp_table
[i
].time
= LP_INIT_TIME
;
868 lp_table
[i
].wait
= LP_INIT_WAIT
;
869 lp_table
[i
].lp_buffer
= NULL
;
871 lp_table
[i
].lastcall
= 0;
872 lp_table
[i
].runchars
= 0;
873 memset (&lp_table
[i
].stats
, 0, sizeof (struct lp_stats
));
875 lp_table
[i
].last_error
= 0;
876 init_waitqueue_head (&lp_table
[i
].waitq
);
877 init_waitqueue_head (&lp_table
[i
].dataq
);
878 init_MUTEX (&lp_table
[i
].port_mutex
);
879 lp_table
[i
].timeout
= 10 * HZ
;
882 if (register_chrdev (LP_MAJOR
, "lp", &lp_fops
)) {
883 printk ("lp: unable to get major %d\n", LP_MAJOR
);
887 if (parport_register_driver (&lp_driver
)) {
888 printk ("lp: unable to register with parport\n");
893 printk (KERN_INFO
"lp: driver loaded but no devices found\n");
894 #ifndef CONFIG_PARPORT_12843
895 if (parport_nr
[0] == LP_PARPORT_AUTO
)
896 printk (KERN_INFO
"lp: (is IEEE 1284.3 support enabled?)\n");
904 int init_module(void)
907 /* The user gave some parameters. Let's see what they were. */
908 if (!strncmp(parport
[0], "auto", 4))
909 parport_nr
[0] = LP_PARPORT_AUTO
;
912 for (n
= 0; n
< LP_NO
&& parport
[n
]; n
++) {
913 if (!strncmp(parport
[n
], "none", 4))
914 parport_nr
[n
] = LP_PARPORT_NONE
;
917 unsigned long r
= simple_strtoul(parport
[n
], &ep
, 0);
918 if (ep
!= parport
[n
])
921 printk(KERN_ERR
"lp: bad port specifier `%s'\n", parport
[n
]);
932 void cleanup_module(void)
936 parport_unregister_driver (&lp_driver
);
938 #ifdef CONFIG_LP_CONSOLE
939 unregister_console (&lpcons
);
942 unregister_chrdev(LP_MAJOR
, "lp");
943 for (offset
= 0; offset
< LP_NO
; offset
++) {
944 if (lp_table
[offset
].dev
== NULL
)
946 if (lp_table
[offset
].flags
& (1<<LP_HAVE_PORT_BIT
))
947 parport_release (lp_table
[offset
].dev
);
948 parport_unregister_device(lp_table
[offset
].dev
);