Lines Matching refs:minor

205 static int lp_reset(int minor)  in lp_reset()  argument
208 lp_claim_parport_or_block (&lp_table[minor]); in lp_reset()
209 w_ctr(minor, LP_PSELECP); in lp_reset()
211 w_ctr(minor, LP_PSELECP | LP_PINITP); in lp_reset()
212 retval = r_str(minor); in lp_reset()
213 lp_release_parport (&lp_table[minor]); in lp_reset()
217 static void lp_error (int minor) in lp_error() argument
222 if (LP_F(minor) & LP_ABORT) in lp_error()
225 polling = lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE; in lp_error()
226 if (polling) lp_release_parport (&lp_table[minor]); in lp_error()
227 prepare_to_wait(&lp_table[minor].waitq, &wait, TASK_INTERRUPTIBLE); in lp_error()
229 finish_wait(&lp_table[minor].waitq, &wait); in lp_error()
230 if (polling) lp_claim_parport_or_block (&lp_table[minor]); in lp_error()
231 else parport_yield_blocking (lp_table[minor].dev); in lp_error()
234 static int lp_check_status(int minor) in lp_check_status() argument
237 unsigned int last = lp_table[minor].last_error; in lp_check_status()
238 unsigned char status = r_str(minor); in lp_check_status()
239 if ((status & LP_PERRORP) && !(LP_F(minor) & LP_CAREFUL)) in lp_check_status()
245 printk(KERN_INFO "lp%d out of paper\n", minor); in lp_check_status()
251 printk(KERN_INFO "lp%d off-line\n", minor); in lp_check_status()
257 printk(KERN_INFO "lp%d on fire\n", minor); in lp_check_status()
265 lp_table[minor].last_error = last; in lp_check_status()
268 lp_error(minor); in lp_check_status()
273 static int lp_wait_ready(int minor, int nonblock) in lp_wait_ready() argument
278 if (lp_table[minor].current_mode != IEEE1284_MODE_COMPAT) { in lp_wait_ready()
283 error = lp_check_status (minor); in lp_wait_ready()
284 if (error && (nonblock || (LP_F(minor) & LP_ABORT))) in lp_wait_ready()
297 unsigned int minor = iminor(file_inode(file)); in lp_write() local
298 struct parport *port = lp_table[minor].dev->port; in lp_write()
299 char *kbuf = lp_table[minor].lp_buffer; in lp_write()
304 (LP_F(minor) & LP_ABORT)); in lp_write()
307 if (time_after(jiffies, lp_table[minor].lastcall + LP_TIME(minor))) in lp_write()
308 lp_table[minor].runchars = 0; in lp_write()
310 lp_table[minor].lastcall = jiffies; in lp_write()
317 if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) in lp_write()
327 lp_claim_parport_or_block (&lp_table[minor]); in lp_write()
329 lp_table[minor].current_mode = lp_negotiate (port, in lp_write()
330 lp_table[minor].best_mode); in lp_write()
332 parport_set_timeout (lp_table[minor].dev, in lp_write()
334 : lp_table[minor].timeout)); in lp_write()
336 if ((retv = lp_wait_ready (minor, nonblock)) == 0) in lp_write()
358 parport_negotiate (lp_table[minor].dev->port, in lp_write()
360 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; in lp_write()
362 error = lp_wait_ready (minor, nonblock); in lp_write()
374 parport_yield_blocking (lp_table[minor].dev); in lp_write()
375 lp_table[minor].current_mode in lp_write()
377 lp_table[minor].best_mode); in lp_write()
396 &lp_table[minor].bits)) { in lp_write()
397 printk(KERN_INFO "lp%d releasing parport\n", minor); in lp_write()
398 parport_negotiate (lp_table[minor].dev->port, in lp_write()
400 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; in lp_write()
401 lp_release_parport (&lp_table[minor]); in lp_write()
404 mutex_unlock(&lp_table[minor].port_mutex); in lp_write()
416 unsigned int minor=iminor(file_inode(file)); in lp_read() local
417 struct parport *port = lp_table[minor].dev->port; in lp_read()
419 char *kbuf = lp_table[minor].lp_buffer; in lp_read()
421 (LP_F(minor) & LP_ABORT)); in lp_read()
426 if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) in lp_read()
429 lp_claim_parport_or_block (&lp_table[minor]); in lp_read()
431 parport_set_timeout (lp_table[minor].dev, in lp_read()
433 : lp_table[minor].timeout)); in lp_read()
435 parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); in lp_read()
436 if (parport_negotiate (lp_table[minor].dev->port, in lp_read()
455 if (lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE) { in lp_read()
456 parport_negotiate (lp_table[minor].dev->port, in lp_read()
458 lp_error (minor); in lp_read()
459 if (parport_negotiate (lp_table[minor].dev->port, in lp_read()
465 prepare_to_wait(&lp_table[minor].waitq, &wait, TASK_INTERRUPTIBLE); in lp_read()
467 finish_wait(&lp_table[minor].waitq, &wait); in lp_read()
477 parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); in lp_read()
479 lp_release_parport (&lp_table[minor]); in lp_read()
484 mutex_unlock(&lp_table[minor].port_mutex); in lp_read()
493 unsigned int minor = iminor(inode); in lp_open() local
497 if (minor >= LP_NO) { in lp_open()
501 if ((LP_F(minor) & LP_EXIST) == 0) { in lp_open()
505 if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) { in lp_open()
514 if ((LP_F(minor) & LP_ABORTOPEN) && !(file->f_flags & O_NONBLOCK)) { in lp_open()
516 lp_claim_parport_or_block (&lp_table[minor]); in lp_open()
517 status = r_str(minor); in lp_open()
518 lp_release_parport (&lp_table[minor]); in lp_open()
520 printk(KERN_INFO "lp%d out of paper\n", minor); in lp_open()
521 LP_F(minor) &= ~LP_BUSY; in lp_open()
525 printk(KERN_INFO "lp%d off-line\n", minor); in lp_open()
526 LP_F(minor) &= ~LP_BUSY; in lp_open()
530 printk(KERN_ERR "lp%d printer error\n", minor); in lp_open()
531 LP_F(minor) &= ~LP_BUSY; in lp_open()
536 lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); in lp_open()
537 if (!lp_table[minor].lp_buffer) { in lp_open()
538 LP_F(minor) &= ~LP_BUSY; in lp_open()
543 lp_claim_parport_or_block (&lp_table[minor]); in lp_open()
544 if ( (lp_table[minor].dev->port->modes & PARPORT_MODE_ECP) && in lp_open()
545 !parport_negotiate (lp_table[minor].dev->port, in lp_open()
547 printk (KERN_INFO "lp%d: ECP mode\n", minor); in lp_open()
548 lp_table[minor].best_mode = IEEE1284_MODE_ECP; in lp_open()
550 lp_table[minor].best_mode = IEEE1284_MODE_COMPAT; in lp_open()
553 parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); in lp_open()
554 lp_release_parport (&lp_table[minor]); in lp_open()
555 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; in lp_open()
563 unsigned int minor = iminor(inode); in lp_release() local
565 lp_claim_parport_or_block (&lp_table[minor]); in lp_release()
566 parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); in lp_release()
567 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; in lp_release()
568 lp_release_parport (&lp_table[minor]); in lp_release()
569 kfree(lp_table[minor].lp_buffer); in lp_release()
570 lp_table[minor].lp_buffer = NULL; in lp_release()
571 LP_F(minor) &= ~LP_BUSY; in lp_release()
575 static int lp_do_ioctl(unsigned int minor, unsigned int cmd, in lp_do_ioctl() argument
582 printk(KERN_DEBUG "lp%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); in lp_do_ioctl()
584 if (minor >= LP_NO) in lp_do_ioctl()
586 if ((LP_F(minor) & LP_EXIST) == 0) in lp_do_ioctl()
592 LP_TIME(minor) = arg * HZ/100; in lp_do_ioctl()
595 LP_CHAR(minor) = arg; in lp_do_ioctl()
599 LP_F(minor) |= LP_ABORT; in lp_do_ioctl()
601 LP_F(minor) &= ~LP_ABORT; in lp_do_ioctl()
605 LP_F(minor) |= LP_ABORTOPEN; in lp_do_ioctl()
607 LP_F(minor) &= ~LP_ABORTOPEN; in lp_do_ioctl()
611 LP_F(minor) |= LP_CAREFUL; in lp_do_ioctl()
613 LP_F(minor) &= ~LP_CAREFUL; in lp_do_ioctl()
616 LP_WAIT(minor) = arg; in lp_do_ioctl()
622 if (copy_to_user(argp, &LP_IRQ(minor), in lp_do_ioctl()
627 if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) in lp_do_ioctl()
629 lp_claim_parport_or_block (&lp_table[minor]); in lp_do_ioctl()
630 status = r_str(minor); in lp_do_ioctl()
631 lp_release_parport (&lp_table[minor]); in lp_do_ioctl()
632 mutex_unlock(&lp_table[minor].port_mutex); in lp_do_ioctl()
638 lp_reset(minor); in lp_do_ioctl()
642 if (copy_to_user(argp, &LP_STAT(minor), in lp_do_ioctl()
646 memset(&LP_STAT(minor), 0, in lp_do_ioctl()
651 status = LP_F(minor); in lp_do_ioctl()
662 static int lp_set_timeout(unsigned int minor, s64 tv_sec, long tv_usec) in lp_set_timeout() argument
690 lp_table[minor].timeout = to_jiffies; in lp_set_timeout()
694 static int lp_set_timeout32(unsigned int minor, void __user *arg) in lp_set_timeout32() argument
701 return lp_set_timeout(minor, karg[0], karg[1]); in lp_set_timeout32()
704 static int lp_set_timeout64(unsigned int minor, void __user *arg) in lp_set_timeout64() argument
715 return lp_set_timeout(minor, karg[0], karg[1]); in lp_set_timeout64()
721 unsigned int minor; in lp_ioctl() local
724 minor = iminor(file_inode(file)); in lp_ioctl()
729 ret = lp_set_timeout32(minor, (void __user *)arg); in lp_ioctl()
734 ret = lp_set_timeout64(minor, (void __user *)arg); in lp_ioctl()
737 ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg); in lp_ioctl()
749 unsigned int minor; in lp_compat_ioctl() local
752 minor = iminor(file_inode(file)); in lp_compat_ioctl()
757 ret = lp_set_timeout32(minor, (void __user *)arg); in lp_compat_ioctl()
762 ret = lp_set_timeout64(minor, (void __user *)arg); in lp_compat_ioctl()
771 ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg)); in lp_compat_ioctl()