22 #include <linux/module.h>
23 #include <linux/parport.h>
25 #include <linux/slab.h>
26 #include <linux/sched.h>
28 #include <asm/current.h>
29 #include <asm/uaccess.h>
34 #define DPRINTK(stuff...) printk(stuff)
36 #define DPRINTK(stuff...)
39 static struct daisydev {
40 struct daisydev *
next;
47 static int numdevs = 0;
58 struct daisydev *newdev, **
p;
62 newdev->daisy = daisy;
64 spin_lock(&topology_lock);
65 for (p = &topology; *p && (*p)->devnum<
devnum; p = &(*p)->next)
69 spin_unlock(&topology_lock);
96 static const char *
th[] = {
"th",
"st",
"nd",
"rd",
"th" };
107 if (port->
muxport < 0 && mux_present(port) &&
109 ((num_ports = num_mux_ports(port)) == 2 || num_ports == 4)) {
113 "%s: 1st (default) port of %d-way multiplexor\n",
114 port->
name, num_ports);
115 for (i = 1; i < num_ports; i++) {
117 struct parport *extra = clone_parport(port, i);
127 "%s: %d%s port of %d-way multiplexor on %s\n",
128 extra->
name, i + 1, th[i + 1], num_ports,
142 detected += assign_addrs(port);
145 add_dev(numdevs++, port, -1);
156 if (!detected && !last_try) {
179 spin_lock(&topology_lock);
182 struct daisydev *
dev = *
p;
183 if (dev->port != port) {
194 if (!topology) numdevs = 0;
195 spin_unlock(&topology_lock);
215 struct daisydev *p = topology;
220 spin_lock(&topology_lock);
221 while (p && p->devnum != devnum)
225 spin_unlock(&topology_lock);
231 spin_unlock(&topology_lock);
244 selected = port->
daisy;
247 if (selected != daisy) {
271 static int cpp_daisy(
struct parport *port,
int cmd)
319 static int cpp_mux(
struct parport *port,
int cmd)
350 cpp_daisy(port, 0x30);
361 return !(cpp_daisy(port, 0x20 + daisy) &
368 return !(cpp_daisy(port, 0xd0 + daisy) &
379 return !(cpp_daisy(port, 0xe0 + daisy) &
384 static int mux_present(
struct parport *port)
386 return cpp_mux(port, 0x51) == 3;
389 static int num_mux_ports(
struct parport *port)
391 return cpp_mux(port, 0x58);
394 static int select_port(
struct parport *port)
397 return cpp_mux(port, 0x60 + muxport) == muxport;
400 static int assign_addrs(
struct parport *port)
404 int thisdev = numdevs;
454 add_dev(numdevs++, port, daisy);
469 detected = numdevs - thisdev;
475 if (!deviceid)
return 0;
477 for (daisy = 0; thisdev < numdevs; thisdev++, daisy++)