int parport_daisy_init(struct parport *port) { int detected = 0; char *deviceid; static const char *th[] = { "th", "st", "nd", "rd", "th" }; int num_ports; int i; int last_try = 0; again: if (port->muxport < 0 && mux_present(port) && ((num_ports = num_mux_ports(port)) == 2 || num_ports == 4)) { port->muxport = 0; printk(KERN_INFO "%s: 1st (default) port of %d-way multiplexor\n", port->name, num_ports); for (i = 1; i < num_ports; i++) { struct parport *extra = clone_parport(port, i); if (!extra) { if (signal_pending(current)) break; schedule(); continue; } printk(KERN_INFO "%s: %d%s port of %d-way multiplexor on %s\n", extra->name, i + 1, th[i + 1], num_ports, port->name); parport_daisy_init(extra); } } if (port->muxport >= 0) select_port(port); parport_daisy_deselect_all(port); detected += assign_addrs(port); add_dev(numdevs++, port, -1); deviceid = kmalloc(1024, GFP_KERNEL); if (deviceid) { if (parport_device_id(numdevs - 1, deviceid, 1024) > 2) detected++; kfree(deviceid); } if (!detected && !last_try) { parport_daisy_fini(port); parport_write_control(port, PARPORT_CONTROL_SELECT); udelay(50); parport_write_control(port, PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT); udelay(50); last_try = 1; goto again; } return detected; }
int parport_daisy_init(struct parport *port) { int detected = 0; char *deviceid; static const char *th[] = { /*0*/"th", "st", "nd", "rd", "th" }; int num_ports; int i; int last_try = 0; again: /* Because this is called before any other devices exist, * we don't have to claim exclusive access. */ /* If mux present on normal port, need to create new * parports for each extra port. */ if (port->muxport < 0 && mux_present(port) && /* don't be fooled: a mux must have 2 or 4 ports. */ ((num_ports = num_mux_ports(port)) == 2 || num_ports == 4)) { /* Leave original as port zero. */ port->muxport = 0; printk(KERN_INFO "%s: 1st (default) port of %d-way multiplexor\n", port->name, num_ports); for (i = 1; i < num_ports; i++) { /* Clone the port. */ struct parport *extra = clone_parport(port, i); if (!extra) { if (signal_pending(current)) break; schedule(); continue; } printk(KERN_INFO "%s: %d%s port of %d-way multiplexor on %s\n", extra->name, i + 1, th[i + 1], num_ports, port->name); /* Analyse that port too. We won't recurse forever because of the 'port->muxport < 0' test above. */ parport_daisy_init(extra); } } if (port->muxport >= 0) select_port(port); parport_daisy_deselect_all(port); detected += assign_addrs(port); /* Count the potential legacy device at the end. */ add_dev(numdevs++, port, -1); /* Find out the legacy device's IEEE 1284 device ID. */ deviceid = kmalloc(1024, GFP_KERNEL); if (deviceid) { if (parport_device_id(numdevs - 1, deviceid, 1024) > 2) detected++; kfree(deviceid); } if (!detected && !last_try) { /* No devices were detected. Perhaps they are in some funny state; let's try to reset them and see if they wake up. */ parport_daisy_fini(port); parport_write_control(port, PARPORT_CONTROL_SELECT); udelay(50); parport_write_control(port, PARPORT_CONTROL_SELECT | PARPORT_CONTROL_INIT); udelay(50); last_try = 1; goto again; } return detected; }