diff options
Diffstat (limited to 'drivers/scsi/pcmcia/qlogic_stub.c')
-rw-r--r-- | drivers/scsi/pcmcia/qlogic_stub.c | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index 67c5a58d17df..aa9b9e0968b6 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c | |||
@@ -195,39 +195,32 @@ static void qlogic_detach(struct pcmcia_device *link) | |||
195 | #define CS_CHECK(fn, ret) \ | 195 | #define CS_CHECK(fn, ret) \ |
196 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 196 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
197 | 197 | ||
198 | static int qlogic_config_check(struct pcmcia_device *p_dev, | ||
199 | cistpl_cftable_entry_t *cfg, | ||
200 | void *priv_data) | ||
201 | { | ||
202 | p_dev->conf.ConfigIndex = cfg->index; | ||
203 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
204 | p_dev->io.NumPorts1 = cfg->io.win[0].len; | ||
205 | |||
206 | if (p_dev->io.BasePort1 == 0) | ||
207 | return -ENODEV; | ||
208 | |||
209 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
210 | } | ||
211 | |||
198 | static int qlogic_config(struct pcmcia_device * link) | 212 | static int qlogic_config(struct pcmcia_device * link) |
199 | { | 213 | { |
200 | scsi_info_t *info = link->priv; | 214 | scsi_info_t *info = link->priv; |
201 | tuple_t tuple; | 215 | int last_ret, last_fn; |
202 | cisparse_t parse; | ||
203 | int i, last_ret, last_fn; | ||
204 | unsigned short tuple_data[32]; | ||
205 | struct Scsi_Host *host; | 216 | struct Scsi_Host *host; |
206 | 217 | ||
207 | DEBUG(0, "qlogic_config(0x%p)\n", link); | 218 | DEBUG(0, "qlogic_config(0x%p)\n", link); |
208 | 219 | ||
209 | info->manf_id = link->manf_id; | 220 | last_ret = pcmcia_loop_config(link, qlogic_config_check, NULL); |
210 | 221 | if (last_ret) { | |
211 | tuple.TupleData = (cisdata_t *) tuple_data; | 222 | cs_error(link, RequestIO, last_ret); |
212 | tuple.TupleDataMax = 64; | 223 | goto failed; |
213 | tuple.TupleOffset = 0; | ||
214 | |||
215 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
216 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
217 | while (1) { | ||
218 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
219 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
220 | goto next_entry; | ||
221 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
222 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
223 | link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; | ||
224 | if (link->io.BasePort1 != 0) { | ||
225 | i = pcmcia_request_io(link, &link->io); | ||
226 | if (i == CS_SUCCESS) | ||
227 | break; | ||
228 | } | ||
229 | next_entry: | ||
230 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
231 | } | 224 | } |
232 | 225 | ||
233 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 226 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
@@ -262,6 +255,7 @@ static int qlogic_config(struct pcmcia_device * link) | |||
262 | cs_failed: | 255 | cs_failed: |
263 | cs_error(link, last_fn, last_ret); | 256 | cs_error(link, last_fn, last_ret); |
264 | pcmcia_disable_device(link); | 257 | pcmcia_disable_device(link); |
258 | failed: | ||
265 | return -ENODEV; | 259 | return -ENODEV; |
266 | 260 | ||
267 | } /* qlogic_config */ | 261 | } /* qlogic_config */ |