diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 16:25:19 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 16:25:19 -0400 |
commit | 7ebe5936c214c656a1625abf9ec3b09e3d1bf34a (patch) | |
tree | de41fcb9d0089099f07abc853cad1be9ffe81eb4 /drivers | |
parent | d92f1a2829dbe29c644569a3b64a021e4d90005d (diff) |
cmd640: manage I/O resources in driver
* Tell IDE layer to not manage resources by setting hwif->mmio flag.
* Use {request,release}_region() for resources management.
* Use driver name for resources management.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/pci/cmd640.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index de1bbdcf2297..1a60d7093605 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -109,6 +109,8 @@ | |||
109 | 109 | ||
110 | #include <asm/io.h> | 110 | #include <asm/io.h> |
111 | 111 | ||
112 | #define DRV_NAME "cmd640" | ||
113 | |||
112 | /* | 114 | /* |
113 | * This flag is set in ide.c by the parameter: ide0=cmd640_vlb | 115 | * This flag is set in ide.c by the parameter: ide0=cmd640_vlb |
114 | */ | 116 | */ |
@@ -686,6 +688,24 @@ static const struct ide_port_info cmd640_port_info __initdata = { | |||
686 | #endif | 688 | #endif |
687 | }; | 689 | }; |
688 | 690 | ||
691 | static int cmd640x_init_one(unsigned long base, unsigned long ctl) | ||
692 | { | ||
693 | if (!request_region(base, 8, DRV_NAME)) { | ||
694 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
695 | DRV_NAME, base, base + 7); | ||
696 | return -EBUSY; | ||
697 | } | ||
698 | |||
699 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
700 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
701 | DRV_NAME, ctl); | ||
702 | release_region(base, 8); | ||
703 | return -EBUSY; | ||
704 | } | ||
705 | |||
706 | return 0; | ||
707 | } | ||
708 | |||
689 | /* | 709 | /* |
690 | * Probe for a cmd640 chipset, and initialize it if found. | 710 | * Probe for a cmd640 chipset, and initialize it if found. |
691 | */ | 711 | */ |
@@ -694,7 +714,7 @@ static int __init cmd640x_init(void) | |||
694 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 714 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
695 | int second_port_toggled = 0; | 715 | int second_port_toggled = 0; |
696 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 716 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
697 | int second_port_cmd640 = 0; | 717 | int second_port_cmd640 = 0, rc; |
698 | const char *bus_type, *port2; | 718 | const char *bus_type, *port2; |
699 | unsigned int index; | 719 | unsigned int index; |
700 | u8 b, cfr; | 720 | u8 b, cfr; |
@@ -738,6 +758,17 @@ static int __init cmd640x_init(void) | |||
738 | return 0; | 758 | return 0; |
739 | } | 759 | } |
740 | 760 | ||
761 | rc = cmd640x_init_one(0x1f0, 0x3f6); | ||
762 | if (rc) | ||
763 | return rc; | ||
764 | |||
765 | rc = cmd640x_init_one(0x170, 0x376); | ||
766 | if (rc) { | ||
767 | release_region(0x3f6, 1); | ||
768 | release_region(0x1f0, 8); | ||
769 | return rc; | ||
770 | } | ||
771 | |||
741 | memset(&hw, 0, sizeof(hw)); | 772 | memset(&hw, 0, sizeof(hw)); |
742 | 773 | ||
743 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | 774 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); |
@@ -756,7 +787,7 @@ static int __init cmd640x_init(void) | |||
756 | */ | 787 | */ |
757 | if (cmd_hwif0) { | 788 | if (cmd_hwif0) { |
758 | ide_init_port_hw(cmd_hwif0, &hw[0]); | 789 | ide_init_port_hw(cmd_hwif0, &hw[0]); |
759 | 790 | cmd_hwif0->mmio = 1; | |
760 | idx[0] = cmd_hwif0->index; | 791 | idx[0] = cmd_hwif0->index; |
761 | } | 792 | } |
762 | 793 | ||
@@ -809,7 +840,7 @@ static int __init cmd640x_init(void) | |||
809 | */ | 840 | */ |
810 | if (second_port_cmd640 && cmd_hwif1) { | 841 | if (second_port_cmd640 && cmd_hwif1) { |
811 | ide_init_port_hw(cmd_hwif1, &hw[1]); | 842 | ide_init_port_hw(cmd_hwif1, &hw[1]); |
812 | 843 | cmd_hwif1->mmio = 1; | |
813 | idx[1] = cmd_hwif1->index; | 844 | idx[1] = cmd_hwif1->index; |
814 | } | 845 | } |
815 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", | 846 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", |