diff options
Diffstat (limited to 'drivers/parport')
-rw-r--r-- | drivers/parport/parport_cs.c | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 00e1d9620f7c..636231739f4b 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c | |||
@@ -149,52 +149,49 @@ static void parport_detach(struct pcmcia_device *link) | |||
149 | #define CS_CHECK(fn, ret) \ | 149 | #define CS_CHECK(fn, ret) \ |
150 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 150 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
151 | 151 | ||
152 | static int parport_config_check(struct pcmcia_device *p_dev, | ||
153 | cistpl_cftable_entry_t *cfg, | ||
154 | void *priv_data) | ||
155 | { | ||
156 | cistpl_cftable_entry_t *dflt = priv_data; | ||
157 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
158 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
159 | p_dev->conf.ConfigIndex = cfg->index; | ||
160 | if (epp_mode) | ||
161 | p_dev->conf.ConfigIndex |= FORCE_EPP_MODE; | ||
162 | p_dev->io.BasePort1 = io->win[0].base; | ||
163 | p_dev->io.NumPorts1 = io->win[0].len; | ||
164 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
165 | if (io->nwin == 2) { | ||
166 | p_dev->io.BasePort2 = io->win[1].base; | ||
167 | p_dev->io.NumPorts2 = io->win[1].len; | ||
168 | } | ||
169 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) | ||
170 | goto next_entry; | ||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | next_entry: | ||
175 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
176 | *dflt = *cfg; | ||
177 | return -ENODEV; | ||
178 | } | ||
179 | |||
152 | static int parport_config(struct pcmcia_device *link) | 180 | static int parport_config(struct pcmcia_device *link) |
153 | { | 181 | { |
154 | parport_info_t *info = link->priv; | 182 | parport_info_t *info = link->priv; |
155 | tuple_t tuple; | ||
156 | u_short buf[128]; | ||
157 | cisparse_t parse; | ||
158 | cistpl_cftable_entry_t *cfg = &parse.cftable_entry; | ||
159 | cistpl_cftable_entry_t dflt = { 0 }; | 183 | cistpl_cftable_entry_t dflt = { 0 }; |
160 | struct parport *p; | 184 | struct parport *p; |
161 | int last_ret, last_fn; | 185 | int last_ret, last_fn; |
162 | 186 | ||
163 | DEBUG(0, "parport_config(0x%p)\n", link); | 187 | DEBUG(0, "parport_config(0x%p)\n", link); |
164 | 188 | ||
165 | tuple.TupleData = (cisdata_t *)buf; | 189 | last_ret = pcmcia_loop_config(link, parport_config_check, &dflt); |
166 | tuple.TupleOffset = 0; tuple.TupleDataMax = 255; | 190 | if (last_ret) { |
167 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 191 | cs_error(link, RequestIO, last_ret); |
168 | tuple.Attributes = 0; | 192 | goto failed; |
169 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
170 | while (1) { | ||
171 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
172 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
173 | goto next_entry; | ||
174 | |||
175 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
176 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
177 | link->conf.ConfigIndex = cfg->index; | ||
178 | if (epp_mode) | ||
179 | link->conf.ConfigIndex |= FORCE_EPP_MODE; | ||
180 | link->io.BasePort1 = io->win[0].base; | ||
181 | link->io.NumPorts1 = io->win[0].len; | ||
182 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
183 | if (io->nwin == 2) { | ||
184 | link->io.BasePort2 = io->win[1].base; | ||
185 | link->io.NumPorts2 = io->win[1].len; | ||
186 | } | ||
187 | if (pcmcia_request_io(link, &link->io) != 0) | ||
188 | goto next_entry; | ||
189 | /* If we've got this far, we're done */ | ||
190 | break; | ||
191 | } | ||
192 | |||
193 | next_entry: | ||
194 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | ||
195 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
196 | } | 193 | } |
197 | 194 | ||
198 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 195 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
199 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 196 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
200 | 197 | ||