diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-07-29 02:38:55 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-22 19:21:23 -0400 |
commit | 0e6f9d2708409cd8e864cdb94edbe599872a19d1 (patch) | |
tree | 398f993c6a50996483e9b48285f4971fa72e6e4e /drivers/scsi/pcmcia/aha152x_stub.c | |
parent | ed58872aa33e16a0d5352080e47c65fa14e6ad1c (diff) |
pcmcia: use pcmcia_loop_config in scsi pcmcia drivers
Use the config loop helper in scsi pcmcia drivers.
CC: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
CC: linux-scsi@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/scsi/pcmcia/aha152x_stub.c')
-rw-r--r-- | drivers/scsi/pcmcia/aha152x_stub.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 2dd0dc9a9aed..bbcc20f2d9d0 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c | |||
@@ -140,44 +140,40 @@ 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 | void *priv_data) | ||
146 | { | ||
147 | /* For New Media T&J, look for a SCSI window */ | ||
148 | if (cfg->io.win[0].len >= 0x20) | ||
149 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
150 | else if ((cfg->io.nwin > 1) && | ||
151 | (cfg->io.win[1].len >= 0x20)) | ||
152 | p_dev->io.BasePort1 = cfg->io.win[1].base; | ||
153 | if ((cfg->io.nwin > 0) && | ||
154 | (p_dev->io.BasePort1 < 0xffff)) { | ||
155 | p_dev->conf.ConfigIndex = cfg->index; | ||
156 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
157 | return 0; | ||
158 | } | ||
159 | return -EINVAL; | ||
160 | } | ||
161 | |||
143 | static int aha152x_config_cs(struct pcmcia_device *link) | 162 | static int aha152x_config_cs(struct pcmcia_device *link) |
144 | { | 163 | { |
145 | scsi_info_t *info = link->priv; | 164 | scsi_info_t *info = link->priv; |
146 | struct aha152x_setup s; | 165 | struct aha152x_setup s; |
147 | tuple_t tuple; | 166 | 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; | 167 | struct Scsi_Host *host; |
152 | 168 | ||
153 | DEBUG(0, "aha152x_config(0x%p)\n", link); | 169 | DEBUG(0, "aha152x_config(0x%p)\n", link); |
154 | 170 | ||
155 | tuple.TupleData = tuple_data; | 171 | last_ret = pcmcia_loop_config(link, aha152x_config_check, NULL); |
156 | tuple.TupleDataMax = 64; | 172 | if (last_ret) { |
157 | tuple.TupleOffset = 0; | 173 | cs_error(link, RequestIO, last_ret); |
158 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 174 | 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 | } | 175 | } |
180 | 176 | ||
181 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 177 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
182 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 178 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
183 | 179 | ||
@@ -208,6 +204,7 @@ static int aha152x_config_cs(struct pcmcia_device *link) | |||
208 | 204 | ||
209 | cs_failed: | 205 | cs_failed: |
210 | cs_error(link, last_fn, last_ret); | 206 | cs_error(link, last_fn, last_ret); |
207 | failed: | ||
211 | aha152x_release_cs(link); | 208 | aha152x_release_cs(link); |
212 | return -ENODEV; | 209 | return -ENODEV; |
213 | } | 210 | } |