diff options
Diffstat (limited to 'drivers/scsi/pcmcia/aha152x_stub.c')
-rw-r--r-- | drivers/scsi/pcmcia/aha152x_stub.c | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 2dd0dc9a9aed..165ff884f48e 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c | |||
@@ -140,44 +140,41 @@ static void aha152x_detach(struct pcmcia_device *link) | |||
140 | #define CS_CHECK(fn, ret) \ | 140 | #define CS_CHECK(fn, ret) \ |
141 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 141 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
142 | 142 | ||
143 | static int aha152x_config_check(struct pcmcia_device *p_dev, | ||
144 | cistpl_cftable_entry_t *cfg, | ||
145 | cistpl_cftable_entry_t *dflt, | ||
146 | unsigned int vcc, | ||
147 | void *priv_data) | ||
148 | { | ||
149 | /* For New Media T&J, look for a SCSI window */ | ||
150 | if (cfg->io.win[0].len >= 0x20) | ||
151 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
152 | else if ((cfg->io.nwin > 1) && | ||
153 | (cfg->io.win[1].len >= 0x20)) | ||
154 | p_dev->io.BasePort1 = cfg->io.win[1].base; | ||
155 | if ((cfg->io.nwin > 0) && | ||
156 | (p_dev->io.BasePort1 < 0xffff)) { | ||
157 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
158 | return 0; | ||
159 | } | ||
160 | return -EINVAL; | ||
161 | } | ||
162 | |||
143 | static int aha152x_config_cs(struct pcmcia_device *link) | 163 | static int aha152x_config_cs(struct pcmcia_device *link) |
144 | { | 164 | { |
145 | scsi_info_t *info = link->priv; | 165 | scsi_info_t *info = link->priv; |
146 | struct aha152x_setup s; | 166 | struct aha152x_setup s; |
147 | tuple_t tuple; | 167 | int last_ret, last_fn; |
148 | cisparse_t parse; | ||
149 | int i, last_ret, last_fn; | ||
150 | u_char tuple_data[64]; | ||
151 | struct Scsi_Host *host; | 168 | struct Scsi_Host *host; |
152 | 169 | ||
153 | DEBUG(0, "aha152x_config(0x%p)\n", link); | 170 | DEBUG(0, "aha152x_config(0x%p)\n", link); |
154 | 171 | ||
155 | tuple.TupleData = tuple_data; | 172 | last_ret = pcmcia_loop_config(link, aha152x_config_check, NULL); |
156 | tuple.TupleDataMax = 64; | 173 | if (last_ret) { |
157 | tuple.TupleOffset = 0; | 174 | cs_error(link, RequestIO, last_ret); |
158 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 175 | goto failed; |
159 | tuple.Attributes = 0; | ||
160 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
161 | while (1) { | ||
162 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
163 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
164 | goto next_entry; | ||
165 | /* For New Media T&J, look for a SCSI window */ | ||
166 | if (parse.cftable_entry.io.win[0].len >= 0x20) | ||
167 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
168 | else if ((parse.cftable_entry.io.nwin > 1) && | ||
169 | (parse.cftable_entry.io.win[1].len >= 0x20)) | ||
170 | link->io.BasePort1 = parse.cftable_entry.io.win[1].base; | ||
171 | if ((parse.cftable_entry.io.nwin > 0) && | ||
172 | (link->io.BasePort1 < 0xffff)) { | ||
173 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
174 | i = pcmcia_request_io(link, &link->io); | ||
175 | if (i == CS_SUCCESS) break; | ||
176 | } | ||
177 | next_entry: | ||
178 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
179 | } | 176 | } |
180 | 177 | ||
181 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 178 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
182 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 179 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
183 | 180 | ||
@@ -208,6 +205,7 @@ static int aha152x_config_cs(struct pcmcia_device *link) | |||
208 | 205 | ||
209 | cs_failed: | 206 | cs_failed: |
210 | cs_error(link, last_fn, last_ret); | 207 | cs_error(link, last_fn, last_ret); |
208 | failed: | ||
211 | aha152x_release_cs(link); | 209 | aha152x_release_cs(link); |
212 | return -ENODEV; | 210 | return -ENODEV; |
213 | } | 211 | } |