aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parport/parport_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/parport/parport_cs.c')
-rw-r--r--drivers/parport/parport_cs.c70
1 files changed, 31 insertions, 39 deletions
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 00e1d9620f7c..b1899e9c1f65 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -149,52 +149,44 @@ static void parport_detach(struct pcmcia_device *link)
149#define CS_CHECK(fn, ret) \ 149#define CS_CHECK(fn, ret) \
150do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 150do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
151 151
152static int parport_config_check(struct pcmcia_device *p_dev,
153 cistpl_cftable_entry_t *cfg,
154 cistpl_cftable_entry_t *dflt,
155 unsigned int vcc,
156 void *priv_data)
157{
158 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
159 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
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 return -ENODEV;
171 return 0;
172 }
173 return -ENODEV;
174}
175
152static int parport_config(struct pcmcia_device *link) 176static int parport_config(struct pcmcia_device *link)
153{ 177{
154 parport_info_t *info = link->priv; 178 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 };
160 struct parport *p; 179 struct parport *p;
161 int last_ret, last_fn; 180 int last_ret, last_fn;
162 181
163 DEBUG(0, "parport_config(0x%p)\n", link); 182 DEBUG(0, "parport_config(0x%p)\n", link);
164 183
165 tuple.TupleData = (cisdata_t *)buf; 184 last_ret = pcmcia_loop_config(link, parport_config_check, NULL);
166 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 185 if (last_ret) {
167 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 186 cs_error(link, RequestIO, last_ret);
168 tuple.Attributes = 0; 187 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 } 188 }
197 189
198 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 190 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
199 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 191 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
200 192