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);
368 * parport_get_port - increment a port's reference count
369 * @port: the port
375 struct parport *parport_get_port(struct parport *port)
377 struct device *dev = get_device(&port->bus_dev);
383 void parport_del_port(struct parport *port)
385 device_unregister(&port->bus_dev);
390 * parport_put_port - decrement a port's reference count
391 * @port: the port
394 * once the port is no longer needed. When the reference count reaches
395 * zero (port is no longer used), free_port is called.
398 void parport_put_port(struct parport *port)
400 put_device(&port->bus_dev);
405 * parport_register_port - register a parallel port
409 * @ops: pointer to the port driver's port operations structure
411 * When a parallel port (lowlevel) driver finds a port that
412 * should be made available to parallel port device drivers, it
414 * @dma parameters are for the convenience of port drivers, and
418 * and represents the port. They should not be tampered with
421 * If there are parallel port device drivers in the system that
423 * they are not told about the port at this time; that is done by
502 * parport_announce_port - tell device drivers about a parallel port
503 * @port: parallel port to announce
505 * After a port driver has registered a parallel port with
510 * functions will be called, with @port as the parameter.
513 void parport_announce_port(struct parport *port)
518 /* Analyse the IEEE1284.3 topology of the port. */
519 parport_daisy_init(port);
522 if (!port->dev)
523 pr_warn("%s: fix this legacy no-device port driver!\n",
524 port->name);
526 parport_proc_register(port);
529 list_add_tail(&port->list, &portlist);
531 struct parport *slave = port->slaves[i-1];
537 /* Let drivers know that new port(s) has arrived. */
538 attach_driver_chain(port);
540 struct parport *slave = port->slaves[i-1];
549 * parport_remove_port - deregister a parallel port
550 * @port: parallel port to deregister
552 * When a parallel port driver is forcibly unloaded, or a
553 * parallel port becomes inaccessible, the port driver must call
557 * The parport structure associated with the port has its
562 * parport_register_driver() are notified that the port is no
564 * with @port as the parameter.
567 void parport_remove_port(struct parport *port)
574 detach_driver_chain(port);
577 /* Forget the IEEE1284.3 topology of the port. */
578 parport_daisy_fini(port);
580 struct parport *slave = port->slaves[i-1];
588 port->ops = &dead_ops;
590 list_del_init(&port->list);
592 struct parport *slave = port->slaves[i-1];
600 parport_proc_unregister(port);
603 struct parport *slave = port->slaves[i-1];
619 * parport_register_dev_model - register a device on a parallel port
620 * @port: port to which the device is attached
625 * This function, called by parallel port device drivers,
626 * declares that a device is connected to a port, and tells the
631 * has claimed access to the port but another device driver wants
633 * return zero if it is willing for the system to release the port
635 * the port it should return non-zero, and no action will be taken.
636 * It is good manners for the driver to try to release the port at
640 * port; it is done automatically. This function may not block, as
645 * the port is available to be claimed for exclusive access; that
648 * claim the port it should do so; otherwise, it need not take
651 * be explicitly invited to claim the port in this way, @wakeup can
655 * arrives from the parallel port. Note that if a device driver
658 * representing the port.
660 * The parallel port (lowlevel) driver is the one that has called
670 * The %PARPORT_DEV_EXCL flag is for preventing port sharing, and
671 * so should only be used when sharing the port with other device
676 * the device on the port, or %NULL if there is not enough memory
681 parport_register_dev_model(struct parport *port, const char *name,
688 if (port->physport->flags & PARPORT_FLAG_EXCL) {
690 pr_err("%s: no more devices allowed\n", port->name);
697 port->name, name);
703 if (port->physport->devices) {
711 port->name, name);
716 if (!try_module_get(port->ops->owner))
719 parport_get_port(port);
734 par_dev->port = port;
744 par_dev->dev.parent = &port->bus_dev;
764 spin_lock(&port->physport->pardevice_lock);
767 if (port->physport->devices) {
768 spin_unlock(&port->physport->pardevice_lock);
770 port->name, name);
775 port->flags |= PARPORT_FLAG_EXCL;
778 par_dev->next = port->physport->devices;
784 if (port->physport->devices)
785 port->physport->devices->prev = par_dev;
786 port->physport->devices = par_dev;
787 spin_unlock(&port->physport->pardevice_lock);
798 port->ops->init_state(par_dev, par_dev->state);
799 if (!test_and_set_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags)) {
800 port->proc_device = par_dev;
814 parport_put_port(port);
815 module_put(port->ops->owner);
822 * parport_unregister_device - deregister a device on a parallel port
830 struct parport *port;
839 port = dev->port->physport;
841 if (port->proc_device == dev) {
842 port->proc_device = NULL;
843 clear_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags);
847 if (port->cad == dev) {
848 printk(KERN_DEBUG "%s: %s forgot to release port\n",
849 port->name, dev->name);
853 spin_lock(&port->pardevice_lock);
859 port->devices = dev->next;
862 port->flags &= ~PARPORT_FLAG_EXCL;
864 spin_unlock(&port->pardevice_lock);
870 spin_lock_irq(&port->waitlist_lock);
871 if (dev->waitprev || dev->waitnext || port->waithead == dev) {
875 port->waithead = dev->waitnext;
879 port->waittail = dev->waitprev;
881 spin_unlock_irq(&port->waitlist_lock);
886 module_put(port->ops->owner);
887 parport_put_port(port);
892 * parport_find_number - find a parallel port by number
893 * @number: parallel port number
895 * This returns the parallel port with the specified number, or
899 * away the reference to the port that parport_find_number()
905 struct parport *port, *result = NULL;
911 list_for_each_entry(port, &portlist, list) {
912 if (port->number == number) {
913 result = parport_get_port(port);
923 * parport_find_base - find a parallel port by base address
926 * This returns the parallel port with the specified base
930 * away the reference to the port that parport_find_base()
936 struct parport *port, *result = NULL;
942 list_for_each_entry(port, &portlist, list) {
943 if (port->base == base) {
944 result = parport_get_port(port);
954 * parport_claim - claim access to a parallel port device
955 * @dev: pointer to structure representing a device on the port
959 * the port it returns zero and the port is available to use. It
960 * may fail (returning non-zero) if the port is in use by another
962 * the port.
968 struct parport *port = dev->port->physport;
971 if (port->cad == dev) {
972 pr_info("%s: %s already owner\n", dev->port->name, dev->name);
977 write_lock_irqsave(&port->cad_lock, flags);
978 oldcad = port->cad;
983 port->ops->save_state(port, dev->state);
987 if (port->cad != oldcad) {
992 pr_warn("%s: %s released port when preempted!\n",
993 port->name, oldcad->name);
994 if (port->cad)
1004 spin_lock_irq(&port->waitlist_lock);
1008 port->waithead = dev->waitnext;
1012 port->waittail = dev->waitprev;
1013 spin_unlock_irq(&port->waitlist_lock);
1018 port->cad = dev;
1021 /* If it's a mux port, select it. */
1022 if (dev->port->muxport >= 0) {
1024 port->muxsel = dev->port->muxport;
1030 if (!parport_daisy_select(port, dev->daisy,
1032 port->daisy = dev->daisy;
1037 port->ops->restore_state(port, dev->state);
1038 write_unlock_irqrestore(&port->cad_lock, flags);
1044 * If this is the first time we tried to claim the port, register an
1051 spin_lock(&port->waitlist_lock);
1055 dev->waitprev = port->waittail;
1056 if (port->waittail) {
1057 port->waittail->waitnext = dev;
1058 port->waittail = dev;
1060 port->waithead = port->waittail = dev;
1062 spin_unlock(&port->waitlist_lock);
1064 write_unlock_irqrestore(&port->cad_lock, flags);
1070 * parport_claim_or_block - claim access to a parallel port device
1071 * @dev: pointer to structure representing a device on the port
1074 * to wait for the port to be free. A return value of 1
1089 /* Try to claim the port. If this fails, we need to sleep. */
1107 * gave us the port and we would deadlock if we slept.
1124 if (dev->port->physport->cad != dev)
1125 printk(KERN_DEBUG "%s: exiting parport_claim_or_block but %s owns port!\n",
1126 dev->name, dev->port->physport->cad ?
1127 dev->port->physport->cad->name : "nobody");
1136 * parport_release - give up access to a parallel port device
1137 * @dev: pointer to structure representing parallel port device
1140 * the port claimed. Similarly, if the port is already claimed
1146 struct parport *port = dev->port->physport;
1151 write_lock_irqsave(&port->cad_lock, flags);
1152 if (port->cad != dev) {
1153 write_unlock_irqrestore(&port->cad_lock, flags);
1155 port->name, dev->name);
1160 /* If this is on a mux port, deselect it. */
1161 if (dev->port->muxport >= 0) {
1163 port->muxsel = -1;
1168 parport_daisy_deselect_all(port);
1169 port->daisy = -1;
1173 port->cad = NULL;
1174 write_unlock_irqrestore(&port->cad_lock, flags);
1177 port->ops->save_state(port, dev->state);
1184 for (pd = port->waithead; pd; pd = pd->waitnext) {
1192 if (dev->port->cad) /* racy but no matter */
1196 port->name, pd->name);
1205 for (pd = port->devices; !port->cad && pd; pd = pd->next) {
1214 struct parport *port = dev_id;
1216 parport_generic_irq(port);