aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parport/daisy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/parport/daisy.c')
-rw-r--r--drivers/parport/daisy.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c
index 075c7eb5c85d..9ee67321b630 100644
--- a/drivers/parport/daisy.c
+++ b/drivers/parport/daisy.c
@@ -144,9 +144,9 @@ again:
144 add_dev (numdevs++, port, -1); 144 add_dev (numdevs++, port, -1);
145 145
146 /* Find out the legacy device's IEEE 1284 device ID. */ 146 /* Find out the legacy device's IEEE 1284 device ID. */
147 deviceid = kmalloc (1000, GFP_KERNEL); 147 deviceid = kmalloc (1024, GFP_KERNEL);
148 if (deviceid) { 148 if (deviceid) {
149 if (parport_device_id (numdevs - 1, deviceid, 1000) > 2) 149 if (parport_device_id (numdevs - 1, deviceid, 1024) > 2)
150 detected++; 150 detected++;
151 151
152 kfree (deviceid); 152 kfree (deviceid);
@@ -252,7 +252,7 @@ struct pardevice *parport_open (int devnum, const char *name,
252 selected = port->daisy; 252 selected = port->daisy;
253 parport_release (dev); 253 parport_release (dev);
254 254
255 if (selected != port->daisy) { 255 if (selected != daisy) {
256 /* No corresponding device. */ 256 /* No corresponding device. */
257 parport_unregister_device (dev); 257 parport_unregister_device (dev);
258 return NULL; 258 return NULL;
@@ -344,9 +344,9 @@ static int cpp_daisy (struct parport *port, int cmd)
344 PARPORT_CONTROL_STROBE, 344 PARPORT_CONTROL_STROBE,
345 PARPORT_CONTROL_STROBE); 345 PARPORT_CONTROL_STROBE);
346 udelay (1); 346 udelay (1);
347 s = parport_read_status (port);
347 parport_frob_control (port, PARPORT_CONTROL_STROBE, 0); 348 parport_frob_control (port, PARPORT_CONTROL_STROBE, 0);
348 udelay (1); 349 udelay (1);
349 s = parport_read_status (port);
350 parport_write_data (port, 0xff); udelay (2); 350 parport_write_data (port, 0xff); udelay (2);
351 351
352 return s; 352 return s;
@@ -395,15 +395,15 @@ int parport_daisy_select (struct parport *port, int daisy, int mode)
395 case IEEE1284_MODE_EPP: 395 case IEEE1284_MODE_EPP:
396 case IEEE1284_MODE_EPPSL: 396 case IEEE1284_MODE_EPPSL:
397 case IEEE1284_MODE_EPPSWE: 397 case IEEE1284_MODE_EPPSWE:
398 return (cpp_daisy (port, 0x20 + daisy) & 398 return !(cpp_daisy (port, 0x20 + daisy) &
399 PARPORT_STATUS_ERROR); 399 PARPORT_STATUS_ERROR);
400 400
401 // For these modes we should switch to ECP mode: 401 // For these modes we should switch to ECP mode:
402 case IEEE1284_MODE_ECP: 402 case IEEE1284_MODE_ECP:
403 case IEEE1284_MODE_ECPRLE: 403 case IEEE1284_MODE_ECPRLE:
404 case IEEE1284_MODE_ECPSWE: 404 case IEEE1284_MODE_ECPSWE:
405 return (cpp_daisy (port, 0xd0 + daisy) & 405 return !(cpp_daisy (port, 0xd0 + daisy) &
406 PARPORT_STATUS_ERROR); 406 PARPORT_STATUS_ERROR);
407 407
408 // Nothing was told for BECP in Daisy chain specification. 408 // Nothing was told for BECP in Daisy chain specification.
409 // May be it's wise to use ECP? 409 // May be it's wise to use ECP?
@@ -413,8 +413,8 @@ int parport_daisy_select (struct parport *port, int daisy, int mode)
413 case IEEE1284_MODE_BYTE: 413 case IEEE1284_MODE_BYTE:
414 case IEEE1284_MODE_COMPAT: 414 case IEEE1284_MODE_COMPAT:
415 default: 415 default:
416 return (cpp_daisy (port, 0xe0 + daisy) & 416 return !(cpp_daisy (port, 0xe0 + daisy) &
417 PARPORT_STATUS_ERROR); 417 PARPORT_STATUS_ERROR);
418 } 418 }
419} 419}
420 420
@@ -436,7 +436,7 @@ static int select_port (struct parport *port)
436 436
437static int assign_addrs (struct parport *port) 437static int assign_addrs (struct parport *port)
438{ 438{
439 unsigned char s, last_dev; 439 unsigned char s;
440 unsigned char daisy; 440 unsigned char daisy;
441 int thisdev = numdevs; 441 int thisdev = numdevs;
442 int detected; 442 int detected;
@@ -472,10 +472,13 @@ static int assign_addrs (struct parport *port)
472 } 472 }
473 473
474 parport_write_data (port, 0x78); udelay (2); 474 parport_write_data (port, 0x78); udelay (2);
475 last_dev = 0; /* We've just been speaking to a device, so we 475 s = parport_read_status (port);
476 know there must be at least _one_ out there. */
477 476
478 for (daisy = 0; daisy < 4; daisy++) { 477 for (daisy = 0;
478 (s & (PARPORT_STATUS_PAPEROUT|PARPORT_STATUS_SELECT))
479 == (PARPORT_STATUS_PAPEROUT|PARPORT_STATUS_SELECT)
480 && daisy < 4;
481 ++daisy) {
479 parport_write_data (port, daisy); 482 parport_write_data (port, daisy);
480 udelay (2); 483 udelay (2);
481 parport_frob_control (port, 484 parport_frob_control (port,
@@ -485,14 +488,18 @@ static int assign_addrs (struct parport *port)
485 parport_frob_control (port, PARPORT_CONTROL_STROBE, 0); 488 parport_frob_control (port, PARPORT_CONTROL_STROBE, 0);
486 udelay (1); 489 udelay (1);
487 490
488 if (last_dev) 491 add_dev (numdevs++, port, daisy);
489 /* No more devices. */
490 break;
491 492
492 last_dev = !(parport_read_status (port) 493 /* See if this device thought it was the last in the
493 & PARPORT_STATUS_BUSY); 494 * chain. */
495 if (!(s & PARPORT_STATUS_BUSY))
496 break;
494 497
495 add_dev (numdevs++, port, daisy); 498 /* We are seeing pass through status now. We see
499 last_dev from next device or if last_dev does not
500 work status lines from some non-daisy chain
501 device. */
502 s = parport_read_status (port);
496 } 503 }
497 504
498 parport_write_data (port, 0xff); udelay (2); 505 parport_write_data (port, 0xff); udelay (2);
@@ -501,11 +508,11 @@ static int assign_addrs (struct parport *port)
501 detected); 508 detected);
502 509
503 /* Ask the new devices to introduce themselves. */ 510 /* Ask the new devices to introduce themselves. */
504 deviceid = kmalloc (1000, GFP_KERNEL); 511 deviceid = kmalloc (1024, GFP_KERNEL);
505 if (!deviceid) return 0; 512 if (!deviceid) return 0;
506 513
507 for (daisy = 0; thisdev < numdevs; thisdev++, daisy++) 514 for (daisy = 0; thisdev < numdevs; thisdev++, daisy++)
508 parport_device_id (thisdev, deviceid, 1000); 515 parport_device_id (thisdev, deviceid, 1024);
509 516
510 kfree (deviceid); 517 kfree (deviceid);
511 return detected; 518 return detected;