Lines Matching refs:pp
108 static inline void pp_enable_irq(struct pp_struct *pp) in pp_enable_irq() argument
110 struct parport *port = pp->pdev->port; in pp_enable_irq()
119 struct pp_struct *pp = file->private_data; in pp_read() local
125 if (!(pp->flags & PP_CLAIMED)) { in pp_read()
138 pport = pp->pdev->port; in pp_read()
141 parport_set_timeout(pp->pdev, in pp_read()
144 pp->default_inactivity); in pp_read()
154 if (pp->flags & PP_W91284PIC) in pp_read()
156 if (pp->flags & PP_FASTREAD) in pp_read()
183 parport_set_timeout(pp->pdev, pp->default_inactivity); in pp_read()
189 pp_enable_irq(pp); in pp_read()
197 struct pp_struct *pp = file->private_data; in pp_write() local
204 if (!(pp->flags & PP_CLAIMED)) { in pp_write()
214 pport = pp->pdev->port; in pp_write()
217 parport_set_timeout(pp->pdev, in pp_write()
220 pp->default_inactivity); in pp_write()
230 if ((pp->flags & PP_FASTWRITE) && (mode == IEEE1284_MODE_EPP)) { in pp_write()
240 wrote = parport_write(pp->pdev->port, kbuffer, n); in pp_write()
263 parport_set_timeout(pp->pdev, pp->default_inactivity); in pp_write()
266 pp_enable_irq(pp); in pp_write()
272 struct pp_struct *pp = private; in pp_irq() local
274 if (pp->irqresponse) { in pp_irq()
275 parport_write_control(pp->pdev->port, pp->irqctl); in pp_irq()
276 pp->irqresponse = 0; in pp_irq()
279 atomic_inc(&pp->irqc); in pp_irq()
280 wake_up_interruptible(&pp->irq_wait); in pp_irq()
283 static int register_device(int minor, struct pp_struct *pp) in register_device() argument
311 ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0; in register_device()
312 ppdev_cb.private = pp; in register_device()
322 pp->pdev = pdev; in register_device()
323 pp->index = index; in register_device()
362 struct pp_struct *pp = file->private_data; in pp_do_ioctl() local
378 if (pp->flags & PP_CLAIMED) { in pp_do_ioctl()
379 dev_dbg(&pp->pdev->dev, "you've already got it!\n"); in pp_do_ioctl()
384 if (!pp->pdev) { in pp_do_ioctl()
385 int err = register_device(minor, pp); in pp_do_ioctl()
391 ret = parport_claim_or_block(pp->pdev); in pp_do_ioctl()
395 pp->flags |= PP_CLAIMED; in pp_do_ioctl()
399 pp_enable_irq(pp); in pp_do_ioctl()
402 info = &pp->pdev->port->ieee1284; in pp_do_ioctl()
403 pp->saved_state.mode = info->mode; in pp_do_ioctl()
404 pp->saved_state.phase = info->phase; in pp_do_ioctl()
405 info->mode = pp->state.mode; in pp_do_ioctl()
406 info->phase = pp->state.phase; in pp_do_ioctl()
407 pp->default_inactivity = parport_set_timeout(pp->pdev, 0); in pp_do_ioctl()
408 parport_set_timeout(pp->pdev, pp->default_inactivity); in pp_do_ioctl()
413 if (pp->pdev) { in pp_do_ioctl()
414 dev_dbg(&pp->pdev->dev, in pp_do_ioctl()
416 if (pp->flags & PP_EXCL) in pp_do_ioctl()
425 pp->flags |= PP_EXCL; in pp_do_ioctl()
434 pp->state.mode = mode; in pp_do_ioctl()
435 pp->state.phase = init_phase(mode); in pp_do_ioctl()
437 if (pp->flags & PP_CLAIMED) { in pp_do_ioctl()
438 pp->pdev->port->ieee1284.mode = mode; in pp_do_ioctl()
439 pp->pdev->port->ieee1284.phase = pp->state.phase; in pp_do_ioctl()
448 if (pp->flags & PP_CLAIMED) in pp_do_ioctl()
449 mode = pp->pdev->port->ieee1284.mode; in pp_do_ioctl()
451 mode = pp->state.mode; in pp_do_ioctl()
465 pp->state.phase = phase; in pp_do_ioctl()
467 if (pp->flags & PP_CLAIMED) in pp_do_ioctl()
468 pp->pdev->port->ieee1284.phase = phase; in pp_do_ioctl()
476 if (pp->flags & PP_CLAIMED) in pp_do_ioctl()
477 phase = pp->pdev->port->ieee1284.phase; in pp_do_ioctl()
479 phase = pp->state.phase; in pp_do_ioctl()
504 pp->flags &= ~PP_FLAGMASK; in pp_do_ioctl()
505 pp->flags |= (uflags & PP_FLAGMASK); in pp_do_ioctl()
512 uflags = pp->flags & PP_FLAGMASK; in pp_do_ioctl()
521 if ((pp->flags & PP_CLAIMED) == 0) { in pp_do_ioctl()
526 port = pp->pdev->port; in pp_do_ioctl()
544 parport_yield_blocking(pp->pdev); in pp_do_ioctl()
549 info = &pp->pdev->port->ieee1284; in pp_do_ioctl()
550 pp->state.mode = info->mode; in pp_do_ioctl()
551 pp->state.phase = info->phase; in pp_do_ioctl()
552 info->mode = pp->saved_state.mode; in pp_do_ioctl()
553 info->phase = pp->saved_state.phase; in pp_do_ioctl()
554 parport_release(pp->pdev); in pp_do_ioctl()
555 pp->flags &= ~PP_CLAIMED; in pp_do_ioctl()
601 pp_enable_irq(pp); in pp_do_ioctl()
610 pp->irqctl = reg; in pp_do_ioctl()
611 pp->irqresponse = 1; in pp_do_ioctl()
615 ret = atomic_read(&pp->irqc); in pp_do_ioctl()
618 atomic_sub(ret, &pp->irqc); in pp_do_ioctl()
628 return pp_set_timeout(pp->pdev, time32[0], time32[1]); in pp_do_ioctl()
640 return pp_set_timeout(pp->pdev, time64[0], time64[1]); in pp_do_ioctl()
643 jiffies_to_timespec64(pp->pdev->timeout, &ts); in pp_do_ioctl()
653 jiffies_to_timespec64(pp->pdev->timeout, &ts); in pp_do_ioctl()
666 dev_dbg(&pp->pdev->dev, "What? (cmd=0x%x)\n", cmd); in pp_do_ioctl()
687 struct pp_struct *pp; in pp_open() local
692 pp = kmalloc(sizeof(struct pp_struct), GFP_KERNEL); in pp_open()
693 if (!pp) in pp_open()
696 pp->state.mode = IEEE1284_MODE_COMPAT; in pp_open()
697 pp->state.phase = init_phase(pp->state.mode); in pp_open()
698 pp->flags = 0; in pp_open()
699 pp->irqresponse = 0; in pp_open()
700 atomic_set(&pp->irqc, 0); in pp_open()
701 init_waitqueue_head(&pp->irq_wait); in pp_open()
707 pp->pdev = NULL; in pp_open()
708 file->private_data = pp; in pp_open()
716 struct pp_struct *pp = file->private_data; in pp_release() local
720 if (!(pp->flags & PP_CLAIMED) && pp->pdev && in pp_release()
721 (pp->state.mode != IEEE1284_MODE_COMPAT)) { in pp_release()
725 parport_claim_or_block(pp->pdev); in pp_release()
726 pp->flags |= PP_CLAIMED; in pp_release()
727 info = &pp->pdev->port->ieee1284; in pp_release()
728 pp->saved_state.mode = info->mode; in pp_release()
729 pp->saved_state.phase = info->phase; in pp_release()
730 info->mode = pp->state.mode; in pp_release()
731 info->phase = pp->state.phase; in pp_release()
733 } else if ((pp->flags & PP_CLAIMED) && pp->pdev && in pp_release()
734 (pp->pdev->port->ieee1284.mode != IEEE1284_MODE_COMPAT)) { in pp_release()
738 parport_negotiate(pp->pdev->port, IEEE1284_MODE_COMPAT); in pp_release()
739 dev_dbg(&pp->pdev->dev, in pp_release()
743 if ((pp->flags & PP_CLAIMED) && pp->pdev) { in pp_release()
746 info = &pp->pdev->port->ieee1284; in pp_release()
747 pp->state.mode = info->mode; in pp_release()
748 pp->state.phase = info->phase; in pp_release()
749 info->mode = pp->saved_state.mode; in pp_release()
750 info->phase = pp->saved_state.phase; in pp_release()
751 parport_release(pp->pdev); in pp_release()
758 if (pp->pdev) { in pp_release()
759 parport_unregister_device(pp->pdev); in pp_release()
760 ida_free(&ida_index, pp->index); in pp_release()
761 pp->pdev = NULL; in pp_release()
765 kfree(pp); in pp_release()
773 struct pp_struct *pp = file->private_data; in pp_poll() local
776 poll_wait(file, &pp->irq_wait, wait); in pp_poll()
777 if (atomic_read(&pp->irqc)) in pp_poll()