diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-02 08:28:43 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-22 19:21:28 -0400 |
commit | b54bf94bf91e4ca2a489eb02bca0424ddb55242a (patch) | |
tree | 4a5383d29173e24dd1fe71ce3ee4d010e60f391c /drivers/net/pcmcia/axnet_cs.c | |
parent | 5fcd4da0090828bd34a1956cb322a483c6bf163c (diff) |
pcmcia: use pcmcia_loop_config in net pcmcia drivers
Use the config loop helper in (some) net pcmcia drivers.
CC: netdev@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/pcmcia/axnet_cs.c')
-rw-r--r-- | drivers/net/pcmcia/axnet_cs.c | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 3f682d49a4e6..04ece0b77d1d 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -284,58 +284,47 @@ static int try_io_port(struct pcmcia_device *link) | |||
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | static int axnet_configcheck(struct pcmcia_device *p_dev, | ||
288 | cistpl_cftable_entry_t *cfg, | ||
289 | void *priv_data) | ||
290 | { | ||
291 | int i; | ||
292 | cistpl_io_t *io = &cfg->io; | ||
293 | |||
294 | if (cfg->index == 0 || cfg->io.nwin == 0) | ||
295 | return -ENODEV; | ||
296 | |||
297 | p_dev->conf.ConfigIndex = 0x05; | ||
298 | /* For multifunction cards, by convention, we configure the | ||
299 | network function with window 0, and serial with window 1 */ | ||
300 | if (io->nwin > 1) { | ||
301 | i = (io->win[1].len > io->win[0].len); | ||
302 | p_dev->io.BasePort2 = io->win[1-i].base; | ||
303 | p_dev->io.NumPorts2 = io->win[1-i].len; | ||
304 | } else { | ||
305 | i = p_dev->io.NumPorts2 = 0; | ||
306 | } | ||
307 | p_dev->io.BasePort1 = io->win[i].base; | ||
308 | p_dev->io.NumPorts1 = io->win[i].len; | ||
309 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
310 | if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) | ||
311 | return try_io_port(p_dev); | ||
312 | |||
313 | return -ENODEV; | ||
314 | } | ||
315 | |||
287 | static int axnet_config(struct pcmcia_device *link) | 316 | static int axnet_config(struct pcmcia_device *link) |
288 | { | 317 | { |
289 | struct net_device *dev = link->priv; | 318 | struct net_device *dev = link->priv; |
290 | axnet_dev_t *info = PRIV(dev); | 319 | axnet_dev_t *info = PRIV(dev); |
291 | tuple_t tuple; | ||
292 | cisparse_t parse; | ||
293 | int i, j, last_ret, last_fn; | 320 | int i, j, last_ret, last_fn; |
294 | u_short buf[64]; | ||
295 | DECLARE_MAC_BUF(mac); | 321 | DECLARE_MAC_BUF(mac); |
296 | 322 | ||
297 | DEBUG(0, "axnet_config(0x%p)\n", link); | 323 | DEBUG(0, "axnet_config(0x%p)\n", link); |
298 | 324 | ||
299 | tuple.Attributes = 0; | ||
300 | tuple.TupleData = (cisdata_t *)buf; | ||
301 | tuple.TupleDataMax = sizeof(buf); | ||
302 | tuple.TupleOffset = 0; | ||
303 | |||
304 | /* don't trust the CIS on this; Linksys got it wrong */ | 325 | /* don't trust the CIS on this; Linksys got it wrong */ |
305 | link->conf.Present = 0x63; | 326 | link->conf.Present = 0x63; |
306 | 327 | last_ret = pcmcia_loop_config(link, axnet_configcheck, NULL); | |
307 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
308 | tuple.Attributes = 0; | ||
309 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
310 | while (last_ret == CS_SUCCESS) { | ||
311 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
312 | cistpl_io_t *io = &(parse.cftable_entry.io); | ||
313 | |||
314 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
315 | pcmcia_parse_tuple(link, &tuple, &parse) != 0 || | ||
316 | cfg->index == 0 || cfg->io.nwin == 0) | ||
317 | goto next_entry; | ||
318 | |||
319 | link->conf.ConfigIndex = 0x05; | ||
320 | /* For multifunction cards, by convention, we configure the | ||
321 | network function with window 0, and serial with window 1 */ | ||
322 | if (io->nwin > 1) { | ||
323 | i = (io->win[1].len > io->win[0].len); | ||
324 | link->io.BasePort2 = io->win[1-i].base; | ||
325 | link->io.NumPorts2 = io->win[1-i].len; | ||
326 | } else { | ||
327 | i = link->io.NumPorts2 = 0; | ||
328 | } | ||
329 | link->io.BasePort1 = io->win[i].base; | ||
330 | link->io.NumPorts1 = io->win[i].len; | ||
331 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
332 | if (link->io.NumPorts1 + link->io.NumPorts2 >= 32) { | ||
333 | last_ret = try_io_port(link); | ||
334 | if (last_ret == CS_SUCCESS) break; | ||
335 | } | ||
336 | next_entry: | ||
337 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
338 | } | ||
339 | if (last_ret != CS_SUCCESS) { | 328 | if (last_ret != CS_SUCCESS) { |
340 | cs_error(link, RequestIO, last_ret); | 329 | cs_error(link, RequestIO, last_ret); |
341 | goto failed; | 330 | goto failed; |