diff options
Diffstat (limited to 'drivers/ide/pci/it821x.c')
-rw-r--r-- | drivers/ide/pci/it821x.c | 74 |
1 files changed, 44 insertions, 30 deletions
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index cbf647202994..e16a1d113a2a 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -67,6 +67,8 @@ | |||
67 | #include <linux/ide.h> | 67 | #include <linux/ide.h> |
68 | #include <linux/init.h> | 68 | #include <linux/init.h> |
69 | 69 | ||
70 | #define DRV_NAME "it821x" | ||
71 | |||
70 | struct it821x_dev | 72 | struct it821x_dev |
71 | { | 73 | { |
72 | unsigned int smart:1, /* Are we in smart raid mode */ | 74 | unsigned int smart:1, /* Are we in smart raid mode */ |
@@ -534,8 +536,9 @@ static struct ide_dma_ops it821x_pass_through_dma_ops = { | |||
534 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | 536 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) |
535 | { | 537 | { |
536 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 538 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
537 | struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev); | 539 | struct ide_host *host = pci_get_drvdata(dev); |
538 | struct it821x_dev *idev = itdevs[hwif->channel]; | 540 | struct it821x_dev *itdevs = host->host_priv; |
541 | struct it821x_dev *idev = itdevs + hwif->channel; | ||
539 | u8 conf; | 542 | u8 conf; |
540 | 543 | ||
541 | ide_set_hwifdata(hwif, idev); | 544 | ide_set_hwifdata(hwif, idev); |
@@ -568,7 +571,8 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
568 | idev->timing10 = 1; | 571 | idev->timing10 = 1; |
569 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 572 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |
570 | if (idev->smart == 0) | 573 | if (idev->smart == 0) |
571 | printk(KERN_WARNING "it821x: Revision 0x10, workarounds activated.\n"); | 574 | printk(KERN_WARNING DRV_NAME " %s: revision 0x10, " |
575 | "workarounds activated\n", pci_name(dev)); | ||
572 | } | 576 | } |
573 | 577 | ||
574 | if (idev->smart == 0) { | 578 | if (idev->smart == 0) { |
@@ -601,18 +605,20 @@ static void __devinit it8212_disable_raid(struct pci_dev *dev) | |||
601 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); | 605 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); |
602 | } | 606 | } |
603 | 607 | ||
604 | static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const char *name) | 608 | static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev) |
605 | { | 609 | { |
606 | u8 conf; | 610 | u8 conf; |
607 | static char *mode[2] = { "pass through", "smart" }; | 611 | static char *mode[2] = { "pass through", "smart" }; |
608 | 612 | ||
609 | /* Force the card into bypass mode if so requested */ | 613 | /* Force the card into bypass mode if so requested */ |
610 | if (it8212_noraid) { | 614 | if (it8212_noraid) { |
611 | printk(KERN_INFO "it8212: forcing bypass mode.\n"); | 615 | printk(KERN_INFO DRV_NAME " %s: forcing bypass mode\n", |
616 | pci_name(dev)); | ||
612 | it8212_disable_raid(dev); | 617 | it8212_disable_raid(dev); |
613 | } | 618 | } |
614 | pci_read_config_byte(dev, 0x50, &conf); | 619 | pci_read_config_byte(dev, 0x50, &conf); |
615 | printk(KERN_INFO "it821x: controller in %s mode.\n", mode[conf & 1]); | 620 | printk(KERN_INFO DRV_NAME " %s: controller in %s mode\n", |
621 | pci_name(dev), mode[conf & 1]); | ||
616 | return 0; | 622 | return 0; |
617 | } | 623 | } |
618 | 624 | ||
@@ -624,17 +630,12 @@ static const struct ide_port_ops it821x_port_ops = { | |||
624 | .cable_detect = it821x_cable_detect, | 630 | .cable_detect = it821x_cable_detect, |
625 | }; | 631 | }; |
626 | 632 | ||
627 | #define DECLARE_ITE_DEV(name_str) \ | 633 | static const struct ide_port_info it821x_chipset __devinitdata = { |
628 | { \ | 634 | .name = DRV_NAME, |
629 | .name = name_str, \ | 635 | .init_chipset = init_chipset_it821x, |
630 | .init_chipset = init_chipset_it821x, \ | 636 | .init_hwif = init_hwif_it821x, |
631 | .init_hwif = init_hwif_it821x, \ | 637 | .port_ops = &it821x_port_ops, |
632 | .port_ops = &it821x_port_ops, \ | 638 | .pio_mask = ATA_PIO4, |
633 | .pio_mask = ATA_PIO4, \ | ||
634 | } | ||
635 | |||
636 | static const struct ide_port_info it821x_chipsets[] __devinitdata = { | ||
637 | /* 0 */ DECLARE_ITE_DEV("IT8212"), | ||
638 | }; | 639 | }; |
639 | 640 | ||
640 | /** | 641 | /** |
@@ -648,23 +649,29 @@ static const struct ide_port_info it821x_chipsets[] __devinitdata = { | |||
648 | 649 | ||
649 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 650 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
650 | { | 651 | { |
651 | struct it821x_dev *itdevs[2] = { NULL, NULL} , *itdev; | 652 | struct it821x_dev *itdevs; |
652 | unsigned int i; | 653 | int rc; |
653 | |||
654 | for (i = 0; i < 2; i++) { | ||
655 | itdev = kzalloc(sizeof(*itdev), GFP_KERNEL); | ||
656 | if (itdev == NULL) { | ||
657 | kfree(itdevs[0]); | ||
658 | printk(KERN_ERR "it821x: out of memory\n"); | ||
659 | return -ENOMEM; | ||
660 | } | ||
661 | 654 | ||
662 | itdevs[i] = itdev; | 655 | itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL); |
656 | if (itdevs == NULL) { | ||
657 | printk(KERN_ERR DRV_NAME " %s: out of memory\n", pci_name(dev)); | ||
658 | return -ENOMEM; | ||
663 | } | 659 | } |
664 | 660 | ||
665 | pci_set_drvdata(dev, itdevs); | 661 | rc = ide_pci_init_one(dev, &it821x_chipset, itdevs); |
662 | if (rc) | ||
663 | kfree(itdevs); | ||
666 | 664 | ||
667 | return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); | 665 | return rc; |
666 | } | ||
667 | |||
668 | static void __devexit it821x_remove(struct pci_dev *dev) | ||
669 | { | ||
670 | struct ide_host *host = pci_get_drvdata(dev); | ||
671 | struct it821x_dev *itdevs = host->host_priv; | ||
672 | |||
673 | ide_pci_remove(dev); | ||
674 | kfree(itdevs); | ||
668 | } | 675 | } |
669 | 676 | ||
670 | static const struct pci_device_id it821x_pci_tbl[] = { | 677 | static const struct pci_device_id it821x_pci_tbl[] = { |
@@ -679,6 +686,7 @@ static struct pci_driver driver = { | |||
679 | .name = "ITE821x IDE", | 686 | .name = "ITE821x IDE", |
680 | .id_table = it821x_pci_tbl, | 687 | .id_table = it821x_pci_tbl, |
681 | .probe = it821x_init_one, | 688 | .probe = it821x_init_one, |
689 | .remove = it821x_remove, | ||
682 | }; | 690 | }; |
683 | 691 | ||
684 | static int __init it821x_ide_init(void) | 692 | static int __init it821x_ide_init(void) |
@@ -686,7 +694,13 @@ static int __init it821x_ide_init(void) | |||
686 | return ide_pci_register_driver(&driver); | 694 | return ide_pci_register_driver(&driver); |
687 | } | 695 | } |
688 | 696 | ||
697 | static void __exit it821x_ide_exit(void) | ||
698 | { | ||
699 | pci_unregister_driver(&driver); | ||
700 | } | ||
701 | |||
689 | module_init(it821x_ide_init); | 702 | module_init(it821x_ide_init); |
703 | module_exit(it821x_ide_exit); | ||
690 | 704 | ||
691 | module_param_named(noraid, it8212_noraid, int, S_IRUGO); | 705 | module_param_named(noraid, it8212_noraid, int, S_IRUGO); |
692 | MODULE_PARM_DESC(noraid, "Force card into bypass mode"); | 706 | MODULE_PARM_DESC(noraid, "Force card into bypass mode"); |