diff options
-rw-r--r-- | drivers/pci/hotplug/cpcihp_zt5550.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c index e9928024be78..790abadd816c 100644 --- a/drivers/pci/hotplug/cpcihp_zt5550.c +++ b/drivers/pci/hotplug/cpcihp_zt5550.c | |||
@@ -78,11 +78,20 @@ static void __iomem *csr_int_mask; | |||
78 | 78 | ||
79 | static int zt5550_hc_config(struct pci_dev *pdev) | 79 | static int zt5550_hc_config(struct pci_dev *pdev) |
80 | { | 80 | { |
81 | int ret; | ||
82 | |||
81 | /* Since we know that no boards exist with two HC chips, treat it as an error */ | 83 | /* Since we know that no boards exist with two HC chips, treat it as an error */ |
82 | if(hc_dev) { | 84 | if(hc_dev) { |
83 | err("too many host controller devices?"); | 85 | err("too many host controller devices?"); |
84 | return -EBUSY; | 86 | return -EBUSY; |
85 | } | 87 | } |
88 | |||
89 | ret = pci_enable_device(pdev); | ||
90 | if(ret) { | ||
91 | err("cannot enable %s\n", pci_name(pdev)); | ||
92 | return ret; | ||
93 | } | ||
94 | |||
86 | hc_dev = pdev; | 95 | hc_dev = pdev; |
87 | dbg("hc_dev = %p", hc_dev); | 96 | dbg("hc_dev = %p", hc_dev); |
88 | dbg("pci resource start %lx", pci_resource_start(hc_dev, 1)); | 97 | dbg("pci resource start %lx", pci_resource_start(hc_dev, 1)); |
@@ -91,7 +100,8 @@ static int zt5550_hc_config(struct pci_dev *pdev) | |||
91 | if(!request_mem_region(pci_resource_start(hc_dev, 1), | 100 | if(!request_mem_region(pci_resource_start(hc_dev, 1), |
92 | pci_resource_len(hc_dev, 1), MY_NAME)) { | 101 | pci_resource_len(hc_dev, 1), MY_NAME)) { |
93 | err("cannot reserve MMIO region"); | 102 | err("cannot reserve MMIO region"); |
94 | return -ENOMEM; | 103 | ret = -ENOMEM; |
104 | goto exit_disable_device; | ||
95 | } | 105 | } |
96 | 106 | ||
97 | hc_registers = | 107 | hc_registers = |
@@ -99,9 +109,8 @@ static int zt5550_hc_config(struct pci_dev *pdev) | |||
99 | if(!hc_registers) { | 109 | if(!hc_registers) { |
100 | err("cannot remap MMIO region %lx @ %lx", | 110 | err("cannot remap MMIO region %lx @ %lx", |
101 | pci_resource_len(hc_dev, 1), pci_resource_start(hc_dev, 1)); | 111 | pci_resource_len(hc_dev, 1), pci_resource_start(hc_dev, 1)); |
102 | release_mem_region(pci_resource_start(hc_dev, 1), | 112 | ret = -ENODEV; |
103 | pci_resource_len(hc_dev, 1)); | 113 | goto exit_release_region; |
104 | return -ENODEV; | ||
105 | } | 114 | } |
106 | 115 | ||
107 | csr_hc_index = hc_registers + CSR_HCINDEX; | 116 | csr_hc_index = hc_registers + CSR_HCINDEX; |
@@ -124,6 +133,13 @@ static int zt5550_hc_config(struct pci_dev *pdev) | |||
124 | writeb((u8) ALL_DIRECT_INTS_MASK, csr_int_mask); | 133 | writeb((u8) ALL_DIRECT_INTS_MASK, csr_int_mask); |
125 | dbg("disabled timer0, timer1 and ENUM interrupts"); | 134 | dbg("disabled timer0, timer1 and ENUM interrupts"); |
126 | return 0; | 135 | return 0; |
136 | |||
137 | exit_release_region: | ||
138 | release_mem_region(pci_resource_start(hc_dev, 1), | ||
139 | pci_resource_len(hc_dev, 1)); | ||
140 | exit_disable_device: | ||
141 | pci_disable_device(hc_dev); | ||
142 | return ret; | ||
127 | } | 143 | } |
128 | 144 | ||
129 | static int zt5550_hc_cleanup(void) | 145 | static int zt5550_hc_cleanup(void) |
@@ -134,6 +150,7 @@ static int zt5550_hc_cleanup(void) | |||
134 | iounmap(hc_registers); | 150 | iounmap(hc_registers); |
135 | release_mem_region(pci_resource_start(hc_dev, 1), | 151 | release_mem_region(pci_resource_start(hc_dev, 1), |
136 | pci_resource_len(hc_dev, 1)); | 152 | pci_resource_len(hc_dev, 1)); |
153 | pci_disable_device(hc_dev); | ||
137 | return 0; | 154 | return 0; |
138 | } | 155 | } |
139 | 156 | ||