| .. | .. |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | #undef DEBUG |
|---|
| 32 | 32 | |
|---|
| 33 | | -#ifdef DEBUG |
|---|
| 34 | | -#define DPRINTK(stuff...) printk(stuff) |
|---|
| 35 | | -#else |
|---|
| 36 | | -#define DPRINTK(stuff...) |
|---|
| 37 | | -#endif |
|---|
| 38 | | - |
|---|
| 39 | 33 | static struct daisydev { |
|---|
| 40 | 34 | struct daisydev *next; |
|---|
| 41 | 35 | struct parport *port; |
|---|
| .. | .. |
|---|
| 45 | 39 | static DEFINE_SPINLOCK(topology_lock); |
|---|
| 46 | 40 | |
|---|
| 47 | 41 | static int numdevs; |
|---|
| 42 | +static bool daisy_init_done; |
|---|
| 48 | 43 | |
|---|
| 49 | 44 | /* Forward-declaration of lower-level functions. */ |
|---|
| 50 | 45 | static int mux_present(struct parport *port); |
|---|
| .. | .. |
|---|
| 87 | 82 | return extra; |
|---|
| 88 | 83 | } |
|---|
| 89 | 84 | |
|---|
| 85 | +static int daisy_drv_probe(struct pardevice *par_dev) |
|---|
| 86 | +{ |
|---|
| 87 | + struct device_driver *drv = par_dev->dev.driver; |
|---|
| 88 | + |
|---|
| 89 | + if (strcmp(drv->name, "daisy_drv")) |
|---|
| 90 | + return -ENODEV; |
|---|
| 91 | + if (strcmp(par_dev->name, daisy_dev_name)) |
|---|
| 92 | + return -ENODEV; |
|---|
| 93 | + |
|---|
| 94 | + return 0; |
|---|
| 95 | +} |
|---|
| 96 | + |
|---|
| 97 | +static struct parport_driver daisy_driver = { |
|---|
| 98 | + .name = "daisy_drv", |
|---|
| 99 | + .probe = daisy_drv_probe, |
|---|
| 100 | + .devmodel = true, |
|---|
| 101 | +}; |
|---|
| 102 | + |
|---|
| 90 | 103 | /* Discover the IEEE1284.3 topology on a port -- muxes and daisy chains. |
|---|
| 91 | 104 | * Return value is number of devices actually detected. */ |
|---|
| 92 | 105 | int parport_daisy_init(struct parport *port) |
|---|
| .. | .. |
|---|
| 97 | 110 | int num_ports; |
|---|
| 98 | 111 | int i; |
|---|
| 99 | 112 | int last_try = 0; |
|---|
| 113 | + |
|---|
| 114 | + if (!daisy_init_done) { |
|---|
| 115 | + /* |
|---|
| 116 | + * flag should be marked true first as |
|---|
| 117 | + * parport_register_driver() might try to load the low |
|---|
| 118 | + * level driver which will lead to announcing new ports |
|---|
| 119 | + * and which will again come back here at |
|---|
| 120 | + * parport_daisy_init() |
|---|
| 121 | + */ |
|---|
| 122 | + daisy_init_done = true; |
|---|
| 123 | + i = parport_register_driver(&daisy_driver); |
|---|
| 124 | + if (i) { |
|---|
| 125 | + pr_err("daisy registration failed\n"); |
|---|
| 126 | + daisy_init_done = false; |
|---|
| 127 | + return i; |
|---|
| 128 | + } |
|---|
| 129 | + } |
|---|
| 100 | 130 | |
|---|
| 101 | 131 | again: |
|---|
| 102 | 132 | /* Because this is called before any other devices exist, |
|---|
| .. | .. |
|---|
| 109 | 139 | ((num_ports = num_mux_ports(port)) == 2 || num_ports == 4)) { |
|---|
| 110 | 140 | /* Leave original as port zero. */ |
|---|
| 111 | 141 | port->muxport = 0; |
|---|
| 112 | | - printk(KERN_INFO |
|---|
| 113 | | - "%s: 1st (default) port of %d-way multiplexor\n", |
|---|
| 142 | + pr_info("%s: 1st (default) port of %d-way multiplexor\n", |
|---|
| 114 | 143 | port->name, num_ports); |
|---|
| 115 | 144 | for (i = 1; i < num_ports; i++) { |
|---|
| 116 | 145 | /* Clone the port. */ |
|---|
| .. | .. |
|---|
| 123 | 152 | continue; |
|---|
| 124 | 153 | } |
|---|
| 125 | 154 | |
|---|
| 126 | | - printk(KERN_INFO |
|---|
| 127 | | - "%s: %d%s port of %d-way multiplexor on %s\n", |
|---|
| 155 | + pr_info("%s: %d%s port of %d-way multiplexor on %s\n", |
|---|
| 128 | 156 | extra->name, i + 1, th[i + 1], num_ports, |
|---|
| 129 | 157 | port->name); |
|---|
| 130 | 158 | |
|---|
| .. | .. |
|---|
| 213 | 241 | struct pardevice *parport_open(int devnum, const char *name) |
|---|
| 214 | 242 | { |
|---|
| 215 | 243 | struct daisydev *p = topology; |
|---|
| 244 | + struct pardev_cb par_cb; |
|---|
| 216 | 245 | struct parport *port; |
|---|
| 217 | 246 | struct pardevice *dev; |
|---|
| 218 | 247 | int daisy; |
|---|
| 219 | 248 | |
|---|
| 249 | + memset(&par_cb, 0, sizeof(par_cb)); |
|---|
| 220 | 250 | spin_lock(&topology_lock); |
|---|
| 221 | 251 | while (p && p->devnum != devnum) |
|---|
| 222 | 252 | p = p->next; |
|---|
| .. | .. |
|---|
| 230 | 260 | port = parport_get_port(p->port); |
|---|
| 231 | 261 | spin_unlock(&topology_lock); |
|---|
| 232 | 262 | |
|---|
| 233 | | - dev = parport_register_device(port, name, NULL, NULL, NULL, 0, NULL); |
|---|
| 263 | + dev = parport_register_dev_model(port, name, &par_cb, devnum); |
|---|
| 234 | 264 | parport_put_port(port); |
|---|
| 235 | 265 | if (!dev) |
|---|
| 236 | 266 | return NULL; |
|---|
| .. | .. |
|---|
| 285 | 315 | | PARPORT_STATUS_PAPEROUT |
|---|
| 286 | 316 | | PARPORT_STATUS_SELECT |
|---|
| 287 | 317 | | PARPORT_STATUS_ERROR)) { |
|---|
| 288 | | - DPRINTK(KERN_DEBUG "%s: cpp_daisy: aa5500ff(%02x)\n", |
|---|
| 289 | | - port->name, s); |
|---|
| 318 | + pr_debug("%s: cpp_daisy: aa5500ff(%02x)\n", port->name, s); |
|---|
| 290 | 319 | return -ENXIO; |
|---|
| 291 | 320 | } |
|---|
| 292 | 321 | |
|---|
| .. | .. |
|---|
| 296 | 325 | | PARPORT_STATUS_SELECT |
|---|
| 297 | 326 | | PARPORT_STATUS_ERROR); |
|---|
| 298 | 327 | if (s != (PARPORT_STATUS_SELECT | PARPORT_STATUS_ERROR)) { |
|---|
| 299 | | - DPRINTK(KERN_DEBUG "%s: cpp_daisy: aa5500ff87(%02x)\n", |
|---|
| 300 | | - port->name, s); |
|---|
| 328 | + pr_debug("%s: cpp_daisy: aa5500ff87(%02x)\n", port->name, s); |
|---|
| 301 | 329 | return -ENXIO; |
|---|
| 302 | 330 | } |
|---|
| 303 | 331 | |
|---|
| .. | .. |
|---|
| 332 | 360 | |
|---|
| 333 | 361 | s = parport_read_status(port); |
|---|
| 334 | 362 | if (!(s & PARPORT_STATUS_ACK)) { |
|---|
| 335 | | - DPRINTK(KERN_DEBUG "%s: cpp_mux: aa55f00f52ad%02x(%02x)\n", |
|---|
| 363 | + pr_debug("%s: cpp_mux: aa55f00f52ad%02x(%02x)\n", |
|---|
| 336 | 364 | port->name, cmd, s); |
|---|
| 337 | 365 | return -EIO; |
|---|
| 338 | 366 | } |
|---|
| .. | .. |
|---|
| 418 | 446 | | PARPORT_STATUS_PAPEROUT |
|---|
| 419 | 447 | | PARPORT_STATUS_SELECT |
|---|
| 420 | 448 | | PARPORT_STATUS_ERROR)) { |
|---|
| 421 | | - DPRINTK(KERN_DEBUG "%s: assign_addrs: aa5500ff(%02x)\n", |
|---|
| 422 | | - port->name, s); |
|---|
| 449 | + pr_debug("%s: assign_addrs: aa5500ff(%02x)\n", port->name, s); |
|---|
| 423 | 450 | return 0; |
|---|
| 424 | 451 | } |
|---|
| 425 | 452 | |
|---|
| .. | .. |
|---|
| 429 | 456 | | PARPORT_STATUS_SELECT |
|---|
| 430 | 457 | | PARPORT_STATUS_ERROR); |
|---|
| 431 | 458 | if (s != (PARPORT_STATUS_SELECT | PARPORT_STATUS_ERROR)) { |
|---|
| 432 | | - DPRINTK(KERN_DEBUG "%s: assign_addrs: aa5500ff87(%02x)\n", |
|---|
| 433 | | - port->name, s); |
|---|
| 459 | + pr_debug("%s: assign_addrs: aa5500ff87(%02x)\n", port->name, s); |
|---|
| 434 | 460 | return 0; |
|---|
| 435 | 461 | } |
|---|
| 436 | 462 | |
|---|
| .. | .. |
|---|
| 467 | 493 | |
|---|
| 468 | 494 | parport_write_data(port, 0xff); udelay(2); |
|---|
| 469 | 495 | detected = numdevs - thisdev; |
|---|
| 470 | | - DPRINTK(KERN_DEBUG "%s: Found %d daisy-chained devices\n", port->name, |
|---|
| 471 | | - detected); |
|---|
| 496 | + pr_debug("%s: Found %d daisy-chained devices\n", port->name, detected); |
|---|
| 472 | 497 | |
|---|
| 473 | 498 | /* Ask the new devices to introduce themselves. */ |
|---|
| 474 | 499 | deviceid = kmalloc(1024, GFP_KERNEL); |
|---|