aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_artop.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-05-04 06:43:58 -0400
committerJeff Garzik <jeff@garzik.org>2007-05-11 18:09:18 -0400
commit1626aeb881236c8cb022b5e4ca594146a951d669 (patch)
tree30f3457e4b5d76e62ee192fcc0d52b0ee8a829df /drivers/ata/pata_artop.c
parent920a4b1038e442700a1cfac77ea7e20bd615a2c3 (diff)
libata: clean up SFF init mess
The intention of using port_mask in SFF init helpers was to eventually support exoctic configurations such as combination of legacy and native port on the same controller. This never became actually necessary and the related code always has been subtly broken one way or the other. Now that new init model is in place, there is no reason to make common helpers capable of handling all corner cases. Exotic cases can simply dealt within LLDs as necessary. This patch removes port_mask handling in SFF init helpers. SFF init helpers don't take n_ports argument and interpret it into port_mask anymore. All information is carried via port_info. n_ports argument is dropped and always two ports are allocated. LLD can tell SFF to skip certain port by marking it dummy. Note that SFF code has been treating unuvailable ports this way for a long time until recent breakage fix from Linus and is consistent with how other drivers handle with unavailable ports. This fixes 1-port legacy host handling still broken after the recent native mode fix and simplifies SFF init logic. The following changes are made... * ata_pci_init_native_host() and ata_init_legacy_host() both now try to initialized whatever they can and mark failed ports dummy. They return 0 if any port is successfully initialized. * ata_pci_prepare_native_host() and ata_pci_init_one() now doesn't take n_ports argument. All info should be specified via port_info array. Always two ports are allocated. * ata_pci_init_bmdma() exported to be used by LLDs in exotic cases. * port_info handling in all LLDs are standardized - all port_info arrays are const stack variable named ppi. Unless the second port is different from the first, its port_info is specified as NULL (tells libata that it's identical to the last non-NULL port_info). * pata_hpt37x/hpt3x2n: don't modify static variable directly. Make an on-stack copy instead as ata_piix does. * pata_uli: It has 4 ports instead of 2. Don't use ata_pci_prepare_native_host(). Allocate the host explicitly and use init helpers. It's simple enough. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_artop.c')
-rw-r--r--drivers/ata/pata_artop.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index ef51940c3adb..9861059dd673 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -414,7 +414,7 @@ static const struct ata_port_operations artop6260_ops = {
414static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 414static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
415{ 415{
416 static int printed_version; 416 static int printed_version;
417 static struct ata_port_info info_6210 = { 417 static const struct ata_port_info info_6210 = {
418 .sht = &artop_sht, 418 .sht = &artop_sht,
419 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 419 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
420 .pio_mask = 0x1f, /* pio0-4 */ 420 .pio_mask = 0x1f, /* pio0-4 */
@@ -422,7 +422,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
422 .udma_mask = ATA_UDMA2, 422 .udma_mask = ATA_UDMA2,
423 .port_ops = &artop6210_ops, 423 .port_ops = &artop6210_ops,
424 }; 424 };
425 static struct ata_port_info info_626x = { 425 static const struct ata_port_info info_626x = {
426 .sht = &artop_sht, 426 .sht = &artop_sht,
427 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 427 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
428 .pio_mask = 0x1f, /* pio0-4 */ 428 .pio_mask = 0x1f, /* pio0-4 */
@@ -430,7 +430,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
430 .udma_mask = ATA_UDMA4, 430 .udma_mask = ATA_UDMA4,
431 .port_ops = &artop6260_ops, 431 .port_ops = &artop6260_ops,
432 }; 432 };
433 static struct ata_port_info info_626x_fast = { 433 static const struct ata_port_info info_626x_fast = {
434 .sht = &artop_sht, 434 .sht = &artop_sht,
435 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 435 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
436 .pio_mask = 0x1f, /* pio0-4 */ 436 .pio_mask = 0x1f, /* pio0-4 */
@@ -438,32 +438,30 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
438 .udma_mask = ATA_UDMA5, 438 .udma_mask = ATA_UDMA5,
439 .port_ops = &artop6260_ops, 439 .port_ops = &artop6260_ops,
440 }; 440 };
441 struct ata_port_info *port_info[2]; 441 const struct ata_port_info *ppi[] = { NULL, NULL };
442 struct ata_port_info *info = NULL;
443 int ports = 2;
444 442
445 if (!printed_version++) 443 if (!printed_version++)
446 dev_printk(KERN_DEBUG, &pdev->dev, 444 dev_printk(KERN_DEBUG, &pdev->dev,
447 "version " DRV_VERSION "\n"); 445 "version " DRV_VERSION "\n");
448 446
449 if (id->driver_data == 0) { /* 6210 variant */ 447 if (id->driver_data == 0) { /* 6210 variant */
450 info = &info_6210; 448 ppi[0] = &info_6210;
449 ppi[1] = &ata_dummy_port_info;
451 /* BIOS may have left us in UDMA, clear it before libata probe */ 450 /* BIOS may have left us in UDMA, clear it before libata probe */
452 pci_write_config_byte(pdev, 0x54, 0); 451 pci_write_config_byte(pdev, 0x54, 0);
453 /* For the moment (also lacks dsc) */ 452 /* For the moment (also lacks dsc) */
454 printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); 453 printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n");
455 printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); 454 printk(KERN_WARNING "Secondary ATA ports will not be activated.\n");
456 ports = 1;
457 } 455 }
458 else if (id->driver_data == 1) /* 6260 */ 456 else if (id->driver_data == 1) /* 6260 */
459 info = &info_626x; 457 ppi[0] = &info_626x;
460 else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ 458 else if (id->driver_data == 2) { /* 6260 or 6260 + fast */
461 unsigned long io = pci_resource_start(pdev, 4); 459 unsigned long io = pci_resource_start(pdev, 4);
462 u8 reg; 460 u8 reg;
463 461
464 info = &info_626x; 462 ppi[0] = &info_626x;
465 if (inb(io) & 0x10) 463 if (inb(io) & 0x10)
466 info = &info_626x_fast; 464 ppi[0] = &info_626x_fast;
467 /* Mac systems come up with some registers not set as we 465 /* Mac systems come up with some registers not set as we
468 will need them */ 466 will need them */
469 467
@@ -484,10 +482,9 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
484 482
485 } 483 }
486 484
487 BUG_ON(info == NULL); 485 BUG_ON(ppi[0] == NULL);
488 486
489 port_info[0] = port_info[1] = info; 487 return ata_pci_init_one(pdev, ppi);
490 return ata_pci_init_one(pdev, port_info, ports);
491} 488}
492 489
493static const struct pci_device_id artop_pci_tbl[] = { 490static const struct pci_device_id artop_pci_tbl[] = {