Lines Matching full:minor
209 static int lp_reset(int minor) in lp_reset() argument
212 lp_claim_parport_or_block(&lp_table[minor]); in lp_reset()
213 w_ctr(minor, LP_PSELECP); in lp_reset()
215 w_ctr(minor, LP_PSELECP | LP_PINITP); in lp_reset()
216 retval = r_str(minor); in lp_reset()
217 lp_release_parport(&lp_table[minor]); in lp_reset()
221 static void lp_error(int minor) in lp_error() argument
226 if (LP_F(minor) & LP_ABORT) in lp_error()
229 polling = lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE; in lp_error()
231 lp_release_parport(&lp_table[minor]); in lp_error()
232 prepare_to_wait(&lp_table[minor].waitq, &wait, TASK_INTERRUPTIBLE); in lp_error()
234 finish_wait(&lp_table[minor].waitq, &wait); in lp_error()
236 lp_claim_parport_or_block(&lp_table[minor]); in lp_error()
238 parport_yield_blocking(lp_table[minor].dev); in lp_error()
241 static int lp_check_status(int minor) in lp_check_status() argument
244 unsigned int last = lp_table[minor].last_error; in lp_check_status()
245 unsigned char status = r_str(minor); in lp_check_status()
246 if ((status & LP_PERRORP) && !(LP_F(minor) & LP_CAREFUL)) in lp_check_status()
252 printk(KERN_INFO "lp%d out of paper\n", minor); in lp_check_status()
258 printk(KERN_INFO "lp%d off-line\n", minor); in lp_check_status()
264 printk(KERN_INFO "lp%d on fire\n", minor); in lp_check_status()
272 lp_table[minor].last_error = last; in lp_check_status()
275 lp_error(minor); in lp_check_status()
280 static int lp_wait_ready(int minor, int nonblock) in lp_wait_ready() argument
285 if (lp_table[minor].current_mode != IEEE1284_MODE_COMPAT) { in lp_wait_ready()
290 error = lp_check_status(minor); in lp_wait_ready()
291 if (error && (nonblock || (LP_F(minor) & LP_ABORT))) in lp_wait_ready()
304 unsigned int minor = iminor(file_inode(file)); in lp_write() local
305 struct parport *port = lp_table[minor].dev->port; in lp_write()
306 char *kbuf = lp_table[minor].lp_buffer; in lp_write()
311 (LP_F(minor) & LP_ABORT)); in lp_write()
314 if (time_after(jiffies, lp_table[minor].lastcall + LP_TIME(minor))) in lp_write()
315 lp_table[minor].runchars = 0; in lp_write()
317 lp_table[minor].lastcall = jiffies; in lp_write()
324 if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) in lp_write()
334 lp_claim_parport_or_block(&lp_table[minor]); in lp_write()
336 lp_table[minor].current_mode = lp_negotiate(port, in lp_write()
337 lp_table[minor].best_mode); in lp_write()
339 parport_set_timeout(lp_table[minor].dev, in lp_write()
341 : lp_table[minor].timeout)); in lp_write()
343 if ((retv = lp_wait_ready(minor, nonblock)) == 0) in lp_write()
365 parport_negotiate(lp_table[minor].dev->port, in lp_write()
367 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; in lp_write()
369 error = lp_wait_ready(minor, nonblock); in lp_write()
381 parport_yield_blocking(lp_table[minor].dev); in lp_write()
382 lp_table[minor].current_mode in lp_write()
384 lp_table[minor].best_mode); in lp_write()
403 &lp_table[minor].bits)) { in lp_write()
404 printk(KERN_INFO "lp%d releasing parport\n", minor); in lp_write()
405 parport_negotiate(lp_table[minor].dev->port, in lp_write()
407 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; in lp_write()
408 lp_release_parport(&lp_table[minor]); in lp_write()
411 mutex_unlock(&lp_table[minor].port_mutex); in lp_write()
423 unsigned int minor=iminor(file_inode(file)); in lp_read() local
424 struct parport *port = lp_table[minor].dev->port; in lp_read()
426 char *kbuf = lp_table[minor].lp_buffer; in lp_read()
428 (LP_F(minor) & LP_ABORT)); in lp_read()
433 if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) in lp_read()
436 lp_claim_parport_or_block(&lp_table[minor]); in lp_read()
438 parport_set_timeout(lp_table[minor].dev, in lp_read()
440 : lp_table[minor].timeout)); in lp_read()
442 parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); in lp_read()
443 if (parport_negotiate(lp_table[minor].dev->port, in lp_read()
462 if (lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE) { in lp_read()
463 parport_negotiate(lp_table[minor].dev->port, in lp_read()
465 lp_error(minor); in lp_read()
466 if (parport_negotiate(lp_table[minor].dev->port, in lp_read()
472 prepare_to_wait(&lp_table[minor].waitq, &wait, TASK_INTERRUPTIBLE); in lp_read()
474 finish_wait(&lp_table[minor].waitq, &wait); in lp_read()
484 parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); in lp_read()
486 lp_release_parport(&lp_table[minor]); in lp_read()
491 mutex_unlock(&lp_table[minor].port_mutex); in lp_read()
500 unsigned int minor = iminor(inode); in lp_open() local
504 if (minor >= LP_NO) { in lp_open()
508 if ((LP_F(minor) & LP_EXIST) == 0) { in lp_open()
512 if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) { in lp_open()
521 if ((LP_F(minor) & LP_ABORTOPEN) && !(file->f_flags & O_NONBLOCK)) { in lp_open()
523 lp_claim_parport_or_block(&lp_table[minor]); in lp_open()
524 status = r_str(minor); in lp_open()
525 lp_release_parport(&lp_table[minor]); in lp_open()
527 printk(KERN_INFO "lp%d out of paper\n", minor); in lp_open()
528 LP_F(minor) &= ~LP_BUSY; in lp_open()
532 printk(KERN_INFO "lp%d off-line\n", minor); in lp_open()
533 LP_F(minor) &= ~LP_BUSY; in lp_open()
537 printk(KERN_ERR "lp%d printer error\n", minor); in lp_open()
538 LP_F(minor) &= ~LP_BUSY; in lp_open()
543 lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); in lp_open()
544 if (!lp_table[minor].lp_buffer) { in lp_open()
545 LP_F(minor) &= ~LP_BUSY; in lp_open()
550 lp_claim_parport_or_block(&lp_table[minor]); in lp_open()
551 if ((lp_table[minor].dev->port->modes & PARPORT_MODE_ECP) && in lp_open()
552 !parport_negotiate(lp_table[minor].dev->port, in lp_open()
554 printk(KERN_INFO "lp%d: ECP mode\n", minor); in lp_open()
555 lp_table[minor].best_mode = IEEE1284_MODE_ECP; in lp_open()
557 lp_table[minor].best_mode = IEEE1284_MODE_COMPAT; in lp_open()
560 parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); in lp_open()
561 lp_release_parport(&lp_table[minor]); in lp_open()
562 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; in lp_open()
570 unsigned int minor = iminor(inode); in lp_release() local
572 lp_claim_parport_or_block(&lp_table[minor]); in lp_release()
573 parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); in lp_release()
574 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; in lp_release()
575 lp_release_parport(&lp_table[minor]); in lp_release()
576 kfree(lp_table[minor].lp_buffer); in lp_release()
577 lp_table[minor].lp_buffer = NULL; in lp_release()
578 LP_F(minor) &= ~LP_BUSY; in lp_release()
582 static int lp_do_ioctl(unsigned int minor, unsigned int cmd, in lp_do_ioctl() argument
589 printk(KERN_DEBUG "lp%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); in lp_do_ioctl()
591 if (minor >= LP_NO) in lp_do_ioctl()
593 if ((LP_F(minor) & LP_EXIST) == 0) in lp_do_ioctl()
599 LP_TIME(minor) = arg * HZ/100; in lp_do_ioctl()
602 LP_CHAR(minor) = arg; in lp_do_ioctl()
606 LP_F(minor) |= LP_ABORT; in lp_do_ioctl()
608 LP_F(minor) &= ~LP_ABORT; in lp_do_ioctl()
612 LP_F(minor) |= LP_ABORTOPEN; in lp_do_ioctl()
614 LP_F(minor) &= ~LP_ABORTOPEN; in lp_do_ioctl()
618 LP_F(minor) |= LP_CAREFUL; in lp_do_ioctl()
620 LP_F(minor) &= ~LP_CAREFUL; in lp_do_ioctl()
623 LP_WAIT(minor) = arg; in lp_do_ioctl()
628 if (copy_to_user(argp, &LP_IRQ(minor), in lp_do_ioctl()
633 if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) in lp_do_ioctl()
635 lp_claim_parport_or_block(&lp_table[minor]); in lp_do_ioctl()
636 status = r_str(minor); in lp_do_ioctl()
637 lp_release_parport(&lp_table[minor]); in lp_do_ioctl()
638 mutex_unlock(&lp_table[minor].port_mutex); in lp_do_ioctl()
644 lp_reset(minor); in lp_do_ioctl()
648 if (copy_to_user(argp, &LP_STAT(minor), in lp_do_ioctl()
652 memset(&LP_STAT(minor), 0, in lp_do_ioctl()
657 status = LP_F(minor); in lp_do_ioctl()
668 static int lp_set_timeout(unsigned int minor, s64 tv_sec, long tv_usec) in lp_set_timeout() argument
696 lp_table[minor].timeout = to_jiffies; in lp_set_timeout()
700 static int lp_set_timeout32(unsigned int minor, void __user *arg) in lp_set_timeout32() argument
707 return lp_set_timeout(minor, karg[0], karg[1]); in lp_set_timeout32()
710 static int lp_set_timeout64(unsigned int minor, void __user *arg) in lp_set_timeout64() argument
721 return lp_set_timeout(minor, karg[0], karg[1]); in lp_set_timeout64()
727 unsigned int minor; in lp_ioctl() local
730 minor = iminor(file_inode(file)); in lp_ioctl()
735 ret = lp_set_timeout32(minor, (void __user *)arg); in lp_ioctl()
740 ret = lp_set_timeout64(minor, (void __user *)arg); in lp_ioctl()
743 ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg); in lp_ioctl()
755 unsigned int minor; in lp_compat_ioctl() local
758 minor = iminor(file_inode(file)); in lp_compat_ioctl()
763 ret = lp_set_timeout32(minor, (void __user *)arg); in lp_compat_ioctl()
768 ret = lp_set_timeout64(minor, (void __user *)arg); in lp_compat_ioctl()
777 ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg)); in lp_compat_ioctl()