Lines Matching +full:parallel +full:- +full:in
2 * Parallel-port resource manager code.
13 * Any part of this program may be used in documents licensed under
48 /* list of all allocated ports, sorted by ->number */
108 return dev->type == &parport_device_type; in is_parport()
116 return -ENODEV; in parport_probe()
118 drv = to_parport_driver(dev->driver); in parport_probe()
119 if (!drv->probe) { in parport_probe()
123 if (strcmp(par_dev->name, drv->name)) in parport_probe()
124 return -ENODEV; in parport_probe()
128 return drv->probe(to_pardevice(dev)); in parport_probe()
157 if (drv->match_port) in driver_check()
158 drv->match_port(port); in driver_check()
168 * call the driver_check function of the drivers registered in in attach_driver_chain()
180 if (drv->detach) in driver_detach()
181 drv->detach(port); in driver_detach()
191 * call the detach function of the drivers registered in in detach_driver_chain()
220 drv->match_port(to_parport_dev(dev)); in port_check()
226 * if the device is a parallel port.
237 * __parport_register_driver - register a parallel port device driver
242 * This can be called by a parallel port device driver in order
243 * to receive notifications about ports being found in the
276 drv->driver.name = drv->name; in __parport_register_driver()
277 drv->driver.bus = &parport_bus_type; in __parport_register_driver()
278 drv->driver.owner = owner; in __parport_register_driver()
279 drv->driver.mod_name = mod_name; in __parport_register_driver()
280 ret = driver_register(&drv->driver); in __parport_register_driver()
285 * check if bus has any parallel port registered, if in __parport_register_driver()
294 if (drv->match_port) in __parport_register_driver()
307 if (is_parport(dev) && drv->detach) in port_detach()
308 drv->detach(to_parport_dev(dev)); in port_detach()
314 * parport_unregister_driver - deregister a parallel port device driver
318 * This should be called by a parallel port device driver that
334 driver_unregister(&drv->driver); in parport_unregister_driver()
345 list_del(&port->full_list); in free_port()
348 kfree(port->probe_info[d].class_name); in free_port()
349 kfree(port->probe_info[d].mfr); in free_port()
350 kfree(port->probe_info[d].model); in free_port()
351 kfree(port->probe_info[d].cmdset); in free_port()
352 kfree(port->probe_info[d].description); in free_port()
359 * parport_get_port - increment a port's reference count
368 struct device *dev = get_device(&port->bus_dev); in parport_get_port()
376 device_unregister(&port->bus_dev); in parport_del_port()
381 * parport_put_port - decrement a port's reference count
391 put_device(&port->bus_dev); in parport_put_port()
396 * parport_register_port - register a parallel port
402 * When a parallel port (lowlevel) driver finds a port that
403 * should be made available to parallel port device drivers, it
412 * If there are parallel port device drivers in the system that
438 tmp->base = base; in parport_register_port()
439 tmp->irq = irq; in parport_register_port()
440 tmp->dma = dma; in parport_register_port()
441 tmp->muxport = tmp->daisy = tmp->muxsel = -1; in parport_register_port()
442 INIT_LIST_HEAD(&tmp->list); in parport_register_port()
443 tmp->ops = ops; in parport_register_port()
444 tmp->physport = tmp; in parport_register_port()
445 rwlock_init(&tmp->cad_lock); in parport_register_port()
446 spin_lock_init(&tmp->waitlist_lock); in parport_register_port()
447 spin_lock_init(&tmp->pardevice_lock); in parport_register_port()
448 tmp->ieee1284.mode = IEEE1284_MODE_COMPAT; in parport_register_port()
449 tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_register_port()
450 sema_init(&tmp->ieee1284.irq, 0); in parport_register_port()
451 tmp->spintime = parport_default_spintime; in parport_register_port()
452 atomic_set(&tmp->ref_count, 1); in parport_register_port()
461 if (p->number != num++) in parport_register_port()
464 tmp->portnum = tmp->number = num; in parport_register_port()
465 list_add_tail(&tmp->full_list, l); in parport_register_port()
471 dev_set_name(&tmp->bus_dev, "parport%d", tmp->portnum); in parport_register_port()
472 tmp->bus_dev.bus = &parport_bus_type; in parport_register_port()
473 tmp->bus_dev.release = free_port; in parport_register_port()
474 tmp->bus_dev.type = &parport_device_type; in parport_register_port()
476 tmp->name = dev_name(&tmp->bus_dev); in parport_register_port()
480 tmp->probe_info[device].class = PARPORT_CLASS_LEGACY; in parport_register_port()
482 ret = device_register(&tmp->bus_dev); in parport_register_port()
484 put_device(&tmp->bus_dev); in parport_register_port()
493 * parport_announce_port - tell device drivers about a parallel port
494 * @port: parallel port to announce
496 * After a port driver has registered a parallel port with
499 * parport_announce_port() in order to notify all device drivers
513 if (!port->dev) in parport_announce_port()
514 pr_warn("%s: fix this legacy no-device port driver!\n", in parport_announce_port()
515 port->name); in parport_announce_port()
520 list_add_tail(&port->list, &portlist); in parport_announce_port()
522 struct parport *slave = port->slaves[i-1]; in parport_announce_port()
524 list_add_tail(&slave->list, &portlist); in parport_announce_port()
531 struct parport *slave = port->slaves[i-1]; in parport_announce_port()
540 * parport_remove_port - deregister a parallel port
541 * @port: parallel port to deregister
543 * When a parallel port driver is forcibly unloaded, or a
544 * parallel port becomes inaccessible, the port driver must call
545 * this function in order to deal with device drivers that still
571 struct parport *slave = port->slaves[i-1]; in parport_remove_port()
579 port->ops = &dead_ops; in parport_remove_port()
581 list_del_init(&port->list); in parport_remove_port()
583 struct parport *slave = port->slaves[i-1]; in parport_remove_port()
585 list_del_init(&slave->list); in parport_remove_port()
594 struct parport *slave = port->slaves[i-1]; in parport_remove_port()
605 kfree_const(par_dev->name); in free_pardevice()
610 * parport_register_dev_model - register a device on a parallel port
616 * This function, called by parallel port device drivers,
626 * the port it should return non-zero, and no action will be taken.
635 * The wake-up ("kick") callback function, @wakeup, is called when
638 * inside the wake-up callback function. If the driver wants to
642 * be explicitly invited to claim the port in this way, @wakeup can
646 * arrives from the parallel port. Note that if a device driver
651 * The parallel port (lowlevel) driver is the one that has called
654 * acknowledge the interrupt (for PC-style ports there is nothing
679 if (port->physport->flags & PARPORT_FLAG_EXCL) { in parport_register_dev_model()
681 pr_err("%s: no more devices allowed\n", port->name); in parport_register_dev_model()
685 if (par_dev_cb->flags & PARPORT_DEV_LURK) { in parport_register_dev_model()
686 if (!par_dev_cb->preempt || !par_dev_cb->wakeup) { in parport_register_dev_model()
688 port->name, name); in parport_register_dev_model()
693 if (par_dev_cb->flags & PARPORT_DEV_EXCL) { in parport_register_dev_model()
694 if (port->physport->devices) { in parport_register_dev_model()
702 port->name, name); in parport_register_dev_model()
707 if (!try_module_get(port->ops->owner)) in parport_register_dev_model()
716 par_dev->state = kzalloc(sizeof(*par_dev->state), GFP_KERNEL); in parport_register_dev_model()
717 if (!par_dev->state) in parport_register_dev_model()
724 par_dev->name = devname; in parport_register_dev_model()
725 par_dev->port = port; in parport_register_dev_model()
726 par_dev->daisy = -1; in parport_register_dev_model()
727 par_dev->preempt = par_dev_cb->preempt; in parport_register_dev_model()
728 par_dev->wakeup = par_dev_cb->wakeup; in parport_register_dev_model()
729 par_dev->private = par_dev_cb->private; in parport_register_dev_model()
730 par_dev->flags = par_dev_cb->flags; in parport_register_dev_model()
731 par_dev->irq_func = par_dev_cb->irq_func; in parport_register_dev_model()
732 par_dev->waiting = 0; in parport_register_dev_model()
733 par_dev->timeout = 5 * HZ; in parport_register_dev_model()
735 par_dev->dev.parent = &port->bus_dev; in parport_register_dev_model()
736 par_dev->dev.bus = &parport_bus_type; in parport_register_dev_model()
737 ret = dev_set_name(&par_dev->dev, "%s.%d", devname, id); in parport_register_dev_model()
740 par_dev->dev.release = free_pardevice; in parport_register_dev_model()
741 par_dev->devmodel = true; in parport_register_dev_model()
742 ret = device_register(&par_dev->dev); in parport_register_dev_model()
744 kfree(par_dev->state); in parport_register_dev_model()
745 put_device(&par_dev->dev); in parport_register_dev_model()
750 par_dev->prev = NULL; in parport_register_dev_model()
753 * to clear irq on the local CPU. -arca in parport_register_dev_model()
755 spin_lock(&port->physport->pardevice_lock); in parport_register_dev_model()
757 if (par_dev_cb->flags & PARPORT_DEV_EXCL) { in parport_register_dev_model()
758 if (port->physport->devices) { in parport_register_dev_model()
759 spin_unlock(&port->physport->pardevice_lock); in parport_register_dev_model()
761 port->name, name); in parport_register_dev_model()
762 kfree(par_dev->state); in parport_register_dev_model()
763 device_unregister(&par_dev->dev); in parport_register_dev_model()
766 port->flags |= PARPORT_FLAG_EXCL; in parport_register_dev_model()
769 par_dev->next = port->physport->devices; in parport_register_dev_model()
771 * Make sure that tmp->next is written before it's in parport_register_dev_model()
775 if (port->physport->devices) in parport_register_dev_model()
776 port->physport->devices->prev = par_dev; in parport_register_dev_model()
777 port->physport->devices = par_dev; in parport_register_dev_model()
778 spin_unlock(&port->physport->pardevice_lock); in parport_register_dev_model()
780 init_waitqueue_head(&par_dev->wait_q); in parport_register_dev_model()
781 par_dev->timeslice = parport_default_timeslice; in parport_register_dev_model()
782 par_dev->waitnext = NULL; in parport_register_dev_model()
783 par_dev->waitprev = NULL; in parport_register_dev_model()
787 * pardevice fields. -arca in parport_register_dev_model()
789 port->ops->init_state(par_dev, par_dev->state); in parport_register_dev_model()
790 if (!test_and_set_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags)) { in parport_register_dev_model()
791 port->proc_device = par_dev; in parport_register_dev_model()
800 kfree(par_dev->state); in parport_register_dev_model()
802 if (!par_dev->devmodel) in parport_register_dev_model()
806 module_put(port->ops->owner); in parport_register_dev_model()
813 * parport_unregister_device - deregister a device on a parallel port
830 port = dev->port->physport; in parport_unregister_device()
832 if (port->proc_device == dev) { in parport_unregister_device()
833 port->proc_device = NULL; in parport_unregister_device()
834 clear_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags); in parport_unregister_device()
838 if (port->cad == dev) { in parport_unregister_device()
840 port->name, dev->name); in parport_unregister_device()
844 spin_lock(&port->pardevice_lock); in parport_unregister_device()
845 if (dev->next) in parport_unregister_device()
846 dev->next->prev = dev->prev; in parport_unregister_device()
847 if (dev->prev) in parport_unregister_device()
848 dev->prev->next = dev->next; in parport_unregister_device()
850 port->devices = dev->next; in parport_unregister_device()
852 if (dev->flags & PARPORT_DEV_EXCL) in parport_unregister_device()
853 port->flags &= ~PARPORT_FLAG_EXCL; in parport_unregister_device()
855 spin_unlock(&port->pardevice_lock); in parport_unregister_device()
858 * Make sure we haven't left any pointers around in the wait in parport_unregister_device()
861 spin_lock_irq(&port->waitlist_lock); in parport_unregister_device()
862 if (dev->waitprev || dev->waitnext || port->waithead == dev) { in parport_unregister_device()
863 if (dev->waitprev) in parport_unregister_device()
864 dev->waitprev->waitnext = dev->waitnext; in parport_unregister_device()
866 port->waithead = dev->waitnext; in parport_unregister_device()
867 if (dev->waitnext) in parport_unregister_device()
868 dev->waitnext->waitprev = dev->waitprev; in parport_unregister_device()
870 port->waittail = dev->waitprev; in parport_unregister_device()
872 spin_unlock_irq(&port->waitlist_lock); in parport_unregister_device()
874 kfree(dev->state); in parport_unregister_device()
875 device_unregister(&dev->dev); in parport_unregister_device()
877 module_put(port->ops->owner); in parport_unregister_device()
883 * parport_find_number - find a parallel port by number
884 * @number: parallel port number
886 * This returns the parallel port with the specified number, or
903 if (port->number == number) { in parport_find_number()
914 * parport_find_base - find a parallel port by base address
917 * This returns the parallel port with the specified base
934 if (port->base == base) { in parport_find_base()
945 * parport_claim - claim access to a parallel port device
949 * context. If parport_claim() succeeds in claiming access to
951 * may fail (returning non-zero) if the port is in use by another
959 struct parport *port = dev->port->physport; in parport_claim()
962 if (port->cad == dev) { in parport_claim()
963 pr_info("%s: %s already owner\n", dev->port->name, dev->name); in parport_claim()
968 write_lock_irqsave(&port->cad_lock, flags); in parport_claim()
969 oldcad = port->cad; in parport_claim()
971 if (oldcad->preempt) { in parport_claim()
972 if (oldcad->preempt(oldcad->private)) in parport_claim()
974 port->ops->save_state(port, dev->state); in parport_claim()
978 if (port->cad != oldcad) { in parport_claim()
981 * get here, but just in case.. in parport_claim()
984 port->name, oldcad->name); in parport_claim()
985 if (port->cad) in parport_claim()
991 if (dev->waiting & 1) { in parport_claim()
992 dev->waiting = 0; in parport_claim()
995 spin_lock_irq(&port->waitlist_lock); in parport_claim()
996 if (dev->waitprev) in parport_claim()
997 dev->waitprev->waitnext = dev->waitnext; in parport_claim()
999 port->waithead = dev->waitnext; in parport_claim()
1000 if (dev->waitnext) in parport_claim()
1001 dev->waitnext->waitprev = dev->waitprev; in parport_claim()
1003 port->waittail = dev->waitprev; in parport_claim()
1004 spin_unlock_irq(&port->waitlist_lock); in parport_claim()
1005 dev->waitprev = dev->waitnext = NULL; in parport_claim()
1009 port->cad = dev; in parport_claim()
1013 if (dev->port->muxport >= 0) { in parport_claim()
1015 port->muxsel = dev->port->muxport; in parport_claim()
1019 if (dev->daisy >= 0) { in parport_claim()
1021 if (!parport_daisy_select(port, dev->daisy, in parport_claim()
1023 port->daisy = dev->daisy; in parport_claim()
1028 port->ops->restore_state(port, dev->state); in parport_claim()
1029 write_unlock_irqrestore(&port->cad_lock, flags); in parport_claim()
1030 dev->time = jiffies; in parport_claim()
1036 * interest. This is only allowed for devices sleeping in in parport_claim()
1041 if (dev->waiting & 2 || dev->wakeup) { in parport_claim()
1042 spin_lock(&port->waitlist_lock); in parport_claim()
1043 if (test_and_set_bit(0, &dev->waiting) == 0) { in parport_claim()
1045 dev->waitnext = NULL; in parport_claim()
1046 dev->waitprev = port->waittail; in parport_claim()
1047 if (port->waittail) { in parport_claim()
1048 port->waittail->waitnext = dev; in parport_claim()
1049 port->waittail = dev; in parport_claim()
1051 port->waithead = port->waittail = dev; in parport_claim()
1053 spin_unlock(&port->waitlist_lock); in parport_claim()
1055 write_unlock_irqrestore(&port->cad_lock, flags); in parport_claim()
1056 return -EAGAIN; in parport_claim()
1061 * parport_claim_or_block - claim access to a parallel port device
1078 dev->waiting = 2; in parport_claim_or_block()
1082 if (r == -EAGAIN) { in parport_claim_or_block()
1084 printk(KERN_DEBUG "%s: parport_claim() returned -EAGAIN\n", in parport_claim_or_block()
1085 dev->name); in parport_claim_or_block()
1088 * FIXME!!! Use the proper locking for dev->waiting, in parport_claim_or_block()
1097 * If dev->waiting is clear now, an interrupt in parport_claim_or_block()
1100 if (dev->waiting) { in parport_claim_or_block()
1101 wait_event_interruptible(dev->wait_q, in parport_claim_or_block()
1102 !dev->waiting); in parport_claim_or_block()
1104 return -EINTR; in parport_claim_or_block()
1109 printk(KERN_DEBUG "%s: didn't sleep in parport_claim_or_block()\n", in parport_claim_or_block()
1110 dev->name); in parport_claim_or_block()
1115 if (dev->port->physport->cad != dev) in parport_claim_or_block()
1117 dev->name, dev->port->physport->cad ? in parport_claim_or_block()
1118 dev->port->physport->cad->name : "nobody"); in parport_claim_or_block()
1121 dev->waiting = 0; in parport_claim_or_block()
1127 * parport_release - give up access to a parallel port device
1128 * @dev: pointer to structure representing parallel port device
1137 struct parport *port = dev->port->physport; in parport_release()
1142 write_lock_irqsave(&port->cad_lock, flags); in parport_release()
1143 if (port->cad != dev) { in parport_release()
1144 write_unlock_irqrestore(&port->cad_lock, flags); in parport_release()
1146 port->name, dev->name); in parport_release()
1152 if (dev->port->muxport >= 0) { in parport_release()
1154 port->muxsel = -1; in parport_release()
1158 if (dev->daisy >= 0) { in parport_release()
1160 port->daisy = -1; in parport_release()
1164 port->cad = NULL; in parport_release()
1165 write_unlock_irqrestore(&port->cad_lock, flags); in parport_release()
1168 port->ops->save_state(port, dev->state); in parport_release()
1175 for (pd = port->waithead; pd; pd = pd->waitnext) { in parport_release()
1176 if (pd->waiting & 2) { /* sleeping in claim_or_block */ in parport_release()
1178 if (waitqueue_active(&pd->wait_q)) in parport_release()
1179 wake_up_interruptible(&pd->wait_q); in parport_release()
1181 } else if (pd->wakeup) { in parport_release()
1182 pd->wakeup(pd->private); in parport_release()
1183 if (dev->port->cad) /* racy but no matter */ in parport_release()
1187 port->name, pd->name); in parport_release()
1193 * interested in being woken up. (Note: no locking required) in parport_release()
1196 for (pd = port->devices; !port->cad && pd; pd = pd->next) { in parport_release()
1197 if (pd->wakeup && pd != dev) in parport_release()
1198 pd->wakeup(pd->private); in parport_release()
1213 MODULE_DESCRIPTION("Parallel-port resource manager");