Lines Matching refs:port

2  * Parallel-port resource manager code.
56 /* What you can do to a port that's gone away.. */
149 * iterates through all the drivers registered with the bus and sends the port
151 * know about the new port that just registered with the bus and decide if it
152 * wants to use this new port.
156 struct parport *port = _port;
160 drv->match_port(port);
164 /* Call attach(port) for each registered driver. */
165 static void attach_driver_chain(struct parport *port)
171 drv->attach(port);
178 bus_for_each_drv(&parport_bus_type, NULL, port, driver_check);
183 struct parport *port = _port;
187 drv->detach(port);
191 /* Call detach(port) for each registered driver. */
192 static void detach_driver_chain(struct parport *port)
197 drv->detach(port);
204 bus_for_each_drv(&parport_bus_type, NULL, port, driver_detach);
221 * port to which it wants to register its device.
235 * if the device is a parallel port.
246 * parport_register_driver - register a parallel port device driver
251 * This can be called by a parallel port device driver in order
262 * The driver's attach() function may block. The port that
266 * parport_register_device() on that port will do this for you.
268 * The driver's detach() function may block. The port that
294 * check if bus has any parallel port registered, if
323 * parport_unregister_driver - deregister a parallel port device driver
327 * This should be called by a parallel port device driver that
332 * be called, and for each port that attach() was called for, the
351 struct parport *port = to_parport_dev(dev);
354 list_del(&port->full_list);
357 kfree(port->probe_info[d].class_name);
358 kfree(port->probe_info[d].mfr);
359 kfree(port->probe_info[d].model);
360 kfree(port->probe_info[d].cmdset);
361 kfree(port->probe_info[d].description);
364 kfree(port->name);
365 kfree(port);
369 * parport_get_port - increment a port's reference count
370 * @port: the port
376 struct parport *parport_get_port(struct parport *port)
378 struct device *dev = get_device(&port->bus_dev);
384 void parport_del_port(struct parport *port)
386 device_unregister(&port->bus_dev);
391 * parport_put_port - decrement a port's reference count
392 * @port: the port
395 * once the port is no longer needed. When the reference count reaches
396 * zero (port is no longer used), free_port is called.
399 void parport_put_port(struct parport *port)
401 put_device(&port->bus_dev);
406 * parport_register_port - register a parallel port
410 * @ops: pointer to the port driver's port operations structure
412 * When a parallel port (lowlevel) driver finds a port that
413 * should be made available to parallel port device drivers, it
415 * @dma parameters are for the convenience of port drivers, and
419 * and represents the port. They should not be tampered with
422 * If there are parallel port device drivers in the system that
424 * they are not told about the port at this time; that is done by
514 * parport_announce_port - tell device drivers about a parallel port
515 * @port: parallel port to announce
517 * After a port driver has registered a parallel port with
522 * functions will be called, with @port as the parameter.
525 void parport_announce_port(struct parport *port)
530 /* Analyse the IEEE1284.3 topology of the port. */
531 parport_daisy_init(port);
534 if (!port->dev)
535 pr_warn("%s: fix this legacy no-device port driver!\n",
536 port->name);
538 parport_proc_register(port);
541 list_add_tail(&port->list, &portlist);
543 struct parport *slave = port->slaves[i-1];
549 /* Let drivers know that new port(s) has arrived. */
550 attach_driver_chain(port);
552 struct parport *slave = port->slaves[i-1];
561 * parport_remove_port - deregister a parallel port
562 * @port: parallel port to deregister
564 * When a parallel port driver is forcibly unloaded, or a
565 * parallel port becomes inaccessible, the port driver must call
569 * The parport structure associated with the port has its
574 * parport_register_driver() are notified that the port is no
576 * with @port as the parameter.
579 void parport_remove_port(struct parport *port)
586 detach_driver_chain(port);
589 /* Forget the IEEE1284.3 topology of the port. */
590 parport_daisy_fini(port);
592 struct parport *slave = port->slaves[i-1];
600 port->ops = &dead_ops;
602 list_del_init(&port->list);
604 struct parport *slave = port->slaves[i-1];
612 parport_proc_unregister(port);
615 struct parport *slave = port->slaves[i-1];
631 * parport_register_dev_model - register a device on a parallel port
632 * @port: port to which the device is attached
637 * This function, called by parallel port device drivers,
638 * declares that a device is connected to a port, and tells the
643 * has claimed access to the port but another device driver wants
645 * return zero if it is willing for the system to release the port
647 * the port it should return non-zero, and no action will be taken.
648 * It is good manners for the driver to try to release the port at
652 * port; it is done automatically. This function may not block, as
657 * the port is available to be claimed for exclusive access; that
660 * claim the port it should do so; otherwise, it need not take
663 * be explicitly invited to claim the port in this way, @wakeup can
667 * arrives from the parallel port. Note that if a device driver
670 * representing the port.
672 * The parallel port (lowlevel) driver is the one that has called
682 * The %PARPORT_DEV_EXCL flag is for preventing port sharing, and
683 * so should only be used when sharing the port with other device
688 * the device on the port, or %NULL if there is not enough memory
693 parport_register_dev_model(struct parport *port, const char *name,
700 if (port->physport->flags & PARPORT_FLAG_EXCL) {
702 pr_err("%s: no more devices allowed\n", port->name);
709 port->name, name);
715 if (port->physport->devices) {
723 port->name, name);
728 if (!try_module_get(port->ops->owner))
731 parport_get_port(port);
746 par_dev->port = port;
756 par_dev->dev.parent = &port->bus_dev;
776 spin_lock(&port->physport->pardevice_lock);
779 if (port->physport->devices) {
780 spin_unlock(&port->physport->pardevice_lock);
782 port->name, name);
787 port->flags |= PARPORT_FLAG_EXCL;
790 par_dev->next = port->physport->devices;
796 if (port->physport->devices)
797 port->physport->devices->prev = par_dev;
798 port->physport->devices = par_dev;
799 spin_unlock(&port->physport->pardevice_lock);
810 port->ops->init_state(par_dev, par_dev->state);
811 if (!test_and_set_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags)) {
812 port->proc_device = par_dev;
826 parport_put_port(port);
827 module_put(port->ops->owner);
834 * parport_unregister_device - deregister a device on a parallel port
842 struct parport *port;
851 port = dev->port->physport;
853 if (port->proc_device == dev) {
854 port->proc_device = NULL;
855 clear_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags);
859 if (port->cad == dev) {
860 printk(KERN_DEBUG "%s: %s forgot to release port\n",
861 port->name, dev->name);
865 spin_lock(&port->pardevice_lock);
871 port->devices = dev->next;
874 port->flags &= ~PARPORT_FLAG_EXCL;
876 spin_unlock(&port->pardevice_lock);
882 spin_lock_irq(&port->waitlist_lock);
883 if (dev->waitprev || dev->waitnext || port->waithead == dev) {
887 port->waithead = dev->waitnext;
891 port->waittail = dev->waitprev;
893 spin_unlock_irq(&port->waitlist_lock);
898 module_put(port->ops->owner);
899 parport_put_port(port);
904 * parport_find_number - find a parallel port by number
905 * @number: parallel port number
907 * This returns the parallel port with the specified number, or
911 * away the reference to the port that parport_find_number()
917 struct parport *port, *result = NULL;
923 list_for_each_entry(port, &portlist, list) {
924 if (port->number == number) {
925 result = parport_get_port(port);
935 * parport_find_base - find a parallel port by base address
938 * This returns the parallel port with the specified base
942 * away the reference to the port that parport_find_base()
948 struct parport *port, *result = NULL;
954 list_for_each_entry(port, &portlist, list) {
955 if (port->base == base) {
956 result = parport_get_port(port);
966 * parport_claim - claim access to a parallel port device
967 * @dev: pointer to structure representing a device on the port
971 * the port it returns zero and the port is available to use. It
972 * may fail (returning non-zero) if the port is in use by another
974 * the port.
980 struct parport *port = dev->port->physport;
983 if (port->cad == dev) {
984 pr_info("%s: %s already owner\n", dev->port->name, dev->name);
989 write_lock_irqsave(&port->cad_lock, flags);
990 oldcad = port->cad;
995 port->ops->save_state(port, dev->state);
999 if (port->cad != oldcad) {
1004 pr_warn("%s: %s released port when preempted!\n",
1005 port->name, oldcad->name);
1006 if (port->cad)
1016 spin_lock_irq(&port->waitlist_lock);
1020 port->waithead = dev->waitnext;
1024 port->waittail = dev->waitprev;
1025 spin_unlock_irq(&port->waitlist_lock);
1030 port->cad = dev;
1033 /* If it's a mux port, select it. */
1034 if (dev->port->muxport >= 0) {
1036 port->muxsel = dev->port->muxport;
1042 if (!parport_daisy_select(port, dev->daisy,
1044 port->daisy = dev->daisy;
1049 port->ops->restore_state(port, dev->state);
1050 write_unlock_irqrestore(&port->cad_lock, flags);
1056 * If this is the first time we tried to claim the port, register an
1063 spin_lock(&port->waitlist_lock);
1067 dev->waitprev = port->waittail;
1068 if (port->waittail) {
1069 port->waittail->waitnext = dev;
1070 port->waittail = dev;
1072 port->waithead = port->waittail = dev;
1074 spin_unlock(&port->waitlist_lock);
1076 write_unlock_irqrestore(&port->cad_lock, flags);
1082 * parport_claim_or_block - claim access to a parallel port device
1083 * @dev: pointer to structure representing a device on the port
1086 * to wait for the port to be free. A return value of 1
1101 /* Try to claim the port. If this fails, we need to sleep. */
1119 * gave us the port and we would deadlock if we slept.
1136 if (dev->port->physport->cad != dev)
1137 printk(KERN_DEBUG "%s: exiting parport_claim_or_block but %s owns port!\n",
1138 dev->name, dev->port->physport->cad ?
1139 dev->port->physport->cad->name : "nobody");
1148 * parport_release - give up access to a parallel port device
1149 * @dev: pointer to structure representing parallel port device
1152 * the port claimed. Similarly, if the port is already claimed
1158 struct parport *port = dev->port->physport;
1163 write_lock_irqsave(&port->cad_lock, flags);
1164 if (port->cad != dev) {
1165 write_unlock_irqrestore(&port->cad_lock, flags);
1167 port->name, dev->name);
1172 /* If this is on a mux port, deselect it. */
1173 if (dev->port->muxport >= 0) {
1175 port->muxsel = -1;
1180 parport_daisy_deselect_all(port);
1181 port->daisy = -1;
1185 port->cad = NULL;
1186 write_unlock_irqrestore(&port->cad_lock, flags);
1189 port->ops->save_state(port, dev->state);
1196 for (pd = port->waithead; pd; pd = pd->waitnext) {
1204 if (dev->port->cad) /* racy but no matter */
1208 port->name, pd->name);
1217 for (pd = port->devices; !port->cad && pd; pd = pd->next) {
1226 struct parport *port = dev_id;
1228 parport_generic_irq(port);