aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-07-30 07:13:46 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2010-09-29 11:20:24 -0400
commit00990e7ce0b0e596fe41d9c64d6933ea70084003 (patch)
tree189e0dd92860feba84231c66955749574cac5d6d /drivers/net
parent440eed43e2a95bb842488755683716814da10f2b (diff)
pcmcia: use autoconfiguration feature for ioports and iomem
When CONF_AUTO_SET_IO or CONF_AUTO_SET_IOMEM are set, the corresponding fields in struct pcmcia_device *p_dev->resource[0,1,2] are set accordinly. Drivers wishing to override certain settings may do so in the callback function, but they no longer need to parse the CIS entries stored in cistpl_cftable_entry_t themselves. CC: netdev@vger.kernel.org CC: linux-wireless@vger.kernel.org CC: linux-ide@vger.kernel.org CC: linux-usb@vger.kernel.org CC: laforge@gnumonks.org CC: linux-mtd@lists.infradead.org CC: linux-bluetooth@vger.kernel.org CC: alsa-devel@alsa-project.org CC: linux-serial@vger.kernel.org CC: Jiri Kosina <jkosina@suse.cz> CC: linux-scsi@vger.kernel.org Tested-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/pcmcia/axnet_cs.c32
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c5
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c38
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c39
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c69
-rw-r--r--drivers/net/wireless/airo_cs.c34
-rw-r--r--drivers/net/wireless/atmel_cs.c28
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c43
-rw-r--r--drivers/net/wireless/libertas/if_cs.c16
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c41
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c45
11 files changed, 103 insertions, 287 deletions
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 17f1040e255e..9d9d997f2e59 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -284,34 +284,16 @@ static int try_io_port(struct pcmcia_device *link)
284 } 284 }
285} 285}
286 286
287static int axnet_configcheck(struct pcmcia_device *p_dev, 287static int axnet_configcheck(struct pcmcia_device *p_dev, void *priv_data)
288 cistpl_cftable_entry_t *cfg,
289 cistpl_cftable_entry_t *dflt,
290 void *priv_data)
291{ 288{
292 int i; 289 if (p_dev->config_index == 0)
293 cistpl_io_t *io = &cfg->io; 290 return -EINVAL;
294
295 if (cfg->index == 0 || cfg->io.nwin == 0)
296 return -ENODEV;
297 291
298 p_dev->config_index = 0x05; 292 p_dev->config_index = 0x05;
299 /* For multifunction cards, by convention, we configure the 293 if (p_dev->resource[0]->end + p_dev->resource[1]->end < 32)
300 network function with window 0, and serial with window 1 */ 294 return -ENODEV;
301 if (io->nwin > 1) {
302 i = (io->win[1].len > io->win[0].len);
303 p_dev->resource[1]->start = io->win[1-i].base;
304 p_dev->resource[1]->end = io->win[1-i].len;
305 } else {
306 i = p_dev->resource[1]->end = 0;
307 }
308 p_dev->resource[0]->start = io->win[i].base;
309 p_dev->resource[0]->end = io->win[i].len;
310 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
311 if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32)
312 return try_io_port(p_dev);
313 295
314 return -ENODEV; 296 return try_io_port(p_dev);
315} 297}
316 298
317static int axnet_config(struct pcmcia_device *link) 299static int axnet_config(struct pcmcia_device *link)
@@ -324,6 +306,7 @@ static int axnet_config(struct pcmcia_device *link)
324 306
325 /* don't trust the CIS on this; Linksys got it wrong */ 307 /* don't trust the CIS on this; Linksys got it wrong */
326 link->config_regs = 0x63; 308 link->config_regs = 0x63;
309 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
327 ret = pcmcia_loop_config(link, axnet_configcheck, NULL); 310 ret = pcmcia_loop_config(link, axnet_configcheck, NULL);
328 if (ret != 0) 311 if (ret != 0)
329 goto failed; 312 goto failed;
@@ -331,7 +314,6 @@ static int axnet_config(struct pcmcia_device *link)
331 if (!link->irq) 314 if (!link->irq)
332 goto failed; 315 goto failed;
333 316
334 link->config_flags |= CONF_ENABLE_IRQ;
335 if (resource_size(link->resource[1]) == 8) 317 if (resource_size(link->resource[1]) == 8)
336 link->config_flags |= CONF_ENABLE_SPKR; 318 link->config_flags |= CONF_ENABLE_SPKR;
337 319
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index c1479e3bfab4..792ab38d979c 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -319,10 +319,7 @@ static int ungermann_try_io_port(struct pcmcia_device *link)
319 return ret; /* RequestIO failed */ 319 return ret; /* RequestIO failed */
320} 320}
321 321
322static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, 322static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
323 cistpl_cftable_entry_t *cfg,
324 cistpl_cftable_entry_t *dflt,
325 void *priv_data)
326{ 323{
327 return 0; /* strange, but that's what the code did already before... */ 324 return 0; /* strange, but that's what the code did already before... */
328} 325}
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 12b028c6abc9..ffe2587b9145 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -259,7 +259,7 @@ static int pcnet_probe(struct pcmcia_device *link)
259 info->p_dev = link; 259 info->p_dev = link;
260 link->priv = dev; 260 link->priv = dev;
261 261
262 link->config_flags |= CONF_ENABLE_IRQ; 262 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
263 263
264 dev->netdev_ops = &pcnet_netdev_ops; 264 dev->netdev_ops = &pcnet_netdev_ops;
265 265
@@ -500,42 +500,22 @@ static int try_io_port(struct pcmcia_device *link)
500 } 500 }
501} 501}
502 502
503static int pcnet_confcheck(struct pcmcia_device *p_dev, 503static int pcnet_confcheck(struct pcmcia_device *p_dev, void *priv_data)
504 cistpl_cftable_entry_t *cfg,
505 cistpl_cftable_entry_t *dflt,
506 void *priv_data)
507{ 504{
508 int *priv = priv_data; 505 int *priv = priv_data;
509 int try = (*priv & 0x1); 506 int try = (*priv & 0x1);
510 int i;
511 cistpl_io_t *io = &cfg->io;
512 507
513 if (cfg->index == 0 || cfg->io.nwin == 0) 508 *priv &= (p_dev->resource[2]->end >= 0x4000) ? 0x10 : ~0x10;
514 return -EINVAL;
515 509
516 /* For multifunction cards, by convention, we configure the 510 if (p_dev->config_index == 0)
517 network function with window 0, and serial with window 1 */ 511 return -EINVAL;
518 if (io->nwin > 1) {
519 i = (io->win[1].len > io->win[0].len);
520 p_dev->resource[1]->start = io->win[1-i].base;
521 p_dev->resource[1]->end = io->win[1-i].len;
522 } else {
523 i = p_dev->resource[1]->end = 0;
524 }
525 512
526 *priv &= ((cfg->mem.nwin == 1) && 513 if (p_dev->resource[0]->end + p_dev->resource[1]->end < 32)
527 (cfg->mem.win[0].len >= 0x4000)) ? 0x10 : ~0x10; 514 return -EINVAL;
528 515
529 p_dev->resource[0]->start = io->win[i].base; 516 if (try)
530 p_dev->resource[0]->end = io->win[i].len;
531 if (!try)
532 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
533 else
534 p_dev->io_lines = 16; 517 p_dev->io_lines = 16;
535 if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32) 518 return try_io_port(p_dev);
536 return try_io_port(p_dev);
537
538 return -EINVAL;
539} 519}
540 520
541static hw_info_t *pcnet_try_config(struct pcmcia_device *link, 521static hw_info_t *pcnet_try_config(struct pcmcia_device *link,
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index e127d2b546dd..a8cef28507de 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -323,9 +323,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
323 link->priv = dev; 323 link->priv = dev;
324 324
325 spin_lock_init(&smc->lock); 325 spin_lock_init(&smc->lock);
326 link->resource[0]->end = 16;
327 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
328 link->config_flags |= CONF_ENABLE_IRQ;
329 326
330 /* The SMC91c92-specific entries in the device structure. */ 327 /* The SMC91c92-specific entries in the device structure. */
331 dev->netdev_ops = &smc_netdev_ops; 328 dev->netdev_ops = &smc_netdev_ops;
@@ -417,18 +414,21 @@ static int mhz_3288_power(struct pcmcia_device *link)
417 return 0; 414 return 0;
418} 415}
419 416
420static int mhz_mfc_config_check(struct pcmcia_device *p_dev, 417static int mhz_mfc_config_check(struct pcmcia_device *p_dev, void *priv_data)
421 cistpl_cftable_entry_t *cf,
422 cistpl_cftable_entry_t *dflt,
423 void *priv_data)
424{ 418{
425 int k; 419 int k;
426 p_dev->resource[1]->start = cf->io.win[0].base; 420 p_dev->io_lines = 16;
421 p_dev->resource[1]->start = p_dev->resource[0]->start;
422 p_dev->resource[1]->end = 8;
423 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
424 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
425 p_dev->resource[0]->end = 16;
426 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
427 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
427 for (k = 0; k < 0x400; k += 0x10) { 428 for (k = 0; k < 0x400; k += 0x10) {
428 if (k & 0x80) 429 if (k & 0x80)
429 continue; 430 continue;
430 p_dev->resource[0]->start = k ^ 0x300; 431 p_dev->resource[0]->start = k ^ 0x300;
431 p_dev->io_lines = 16;
432 if (!pcmcia_request_io(p_dev)) 432 if (!pcmcia_request_io(p_dev))
433 return 0; 433 return 0;
434 } 434 }
@@ -442,9 +442,8 @@ static int mhz_mfc_config(struct pcmcia_device *link)
442 unsigned int offset; 442 unsigned int offset;
443 int i; 443 int i;
444 444
445 link->config_flags |= CONF_ENABLE_SPKR; 445 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ |
446 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 446 CONF_AUTO_SET_IO;
447 link->resource[1]->end = 8;
448 447
449 /* The Megahertz combo cards have modem-like CIS entries, so 448 /* The Megahertz combo cards have modem-like CIS entries, so
450 we have to explicitly try a bunch of port combinations. */ 449 we have to explicitly try a bunch of port combinations. */
@@ -586,13 +585,12 @@ static int mot_setup(struct pcmcia_device *link)
586 585
587/*====================================================================*/ 586/*====================================================================*/
588 587
589static int smc_configcheck(struct pcmcia_device *p_dev, 588static int smc_configcheck(struct pcmcia_device *p_dev, void *priv_data)
590 cistpl_cftable_entry_t *cf,
591 cistpl_cftable_entry_t *dflt,
592 void *priv_data)
593{ 589{
594 p_dev->resource[0]->start = cf->io.win[0].base; 590 p_dev->resource[0]->end = 16;
595 p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 591 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
592 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
593
596 return pcmcia_request_io(p_dev); 594 return pcmcia_request_io(p_dev);
597} 595}
598 596
@@ -601,7 +599,8 @@ static int smc_config(struct pcmcia_device *link)
601 struct net_device *dev = link->priv; 599 struct net_device *dev = link->priv;
602 int i; 600 int i;
603 601
604 link->resource[0]->end = 16; 602 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
603
605 i = pcmcia_loop_config(link, smc_configcheck, NULL); 604 i = pcmcia_loop_config(link, smc_configcheck, NULL);
606 if (!i) 605 if (!i)
607 dev->base_addr = link->resource[0]->start; 606 dev->base_addr = link->resource[0]->start;
@@ -634,7 +633,7 @@ static int osi_config(struct pcmcia_device *link)
634 static const unsigned int com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; 633 static const unsigned int com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
635 int i, j; 634 int i, j;
636 635
637 link->config_flags |= CONF_ENABLE_SPKR; 636 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ;
638 link->resource[0]->end = 64; 637 link->resource[0]->end = 64;
639 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 638 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
640 link->resource[1]->end = 8; 639 link->resource[1]->end = 8;
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 2bc2eb89c4cd..cecc07454e9e 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -528,7 +528,6 @@ xirc2ps_probe(struct pcmcia_device *link)
528 link->priv = dev; 528 link->priv = dev;
529 529
530 /* General socket configuration */ 530 /* General socket configuration */
531 link->config_flags |= CONF_ENABLE_IRQ;
532 link->config_index = 1; 531 link->config_index = 1;
533 532
534 /* Fill in card specific entries */ 533 /* Fill in card specific entries */
@@ -665,42 +664,53 @@ has_ce2_string(struct pcmcia_device * p_dev)
665} 664}
666 665
667static int 666static int
668xirc2ps_config_modem(struct pcmcia_device *p_dev, 667xirc2ps_config_modem(struct pcmcia_device *p_dev, void *priv_data)
669 cistpl_cftable_entry_t *cf,
670 cistpl_cftable_entry_t *dflt,
671 void *priv_data)
672{ 668{
673 unsigned int ioaddr; 669 unsigned int ioaddr;
674 670
675 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 671 if ((p_dev->resource[0]->start & 0xf) == 8)
676 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 672 return -ENODEV;
677 p_dev->resource[1]->start = cf->io.win[0].base; 673
678 p_dev->resource[0]->start = ioaddr; 674 p_dev->resource[0]->end = 16;
679 if (!pcmcia_request_io(p_dev)) 675 p_dev->resource[1]->end = 8;
680 return 0; 676 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
681 } 677 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
678 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
679 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
680 p_dev->io_lines = 10;
681
682 p_dev->resource[1]->start = p_dev->resource[0]->start;
683 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
684 p_dev->resource[0]->start = ioaddr;
685 if (!pcmcia_request_io(p_dev))
686 return 0;
682 } 687 }
683 return -ENODEV; 688 return -ENODEV;
684} 689}
685 690
686static int 691static int
687xirc2ps_config_check(struct pcmcia_device *p_dev, 692xirc2ps_config_check(struct pcmcia_device *p_dev, void *priv_data)
688 cistpl_cftable_entry_t *cf,
689 cistpl_cftable_entry_t *dflt,
690 void *priv_data)
691{ 693{
692 int *pass = priv_data; 694 int *pass = priv_data;
695 resource_size_t tmp = p_dev->resource[1]->start;
693 696
694 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 697 tmp += (*pass ? (p_dev->config_index & 0x20 ? -24 : 8)
695 p_dev->resource[1]->start = cf->io.win[0].base; 698 : (p_dev->config_index & 0x20 ? 8 : -24));
696 p_dev->resource[0]->start = p_dev->resource[1]->start 699
697 + (*pass ? (cf->index & 0x20 ? -24:8) 700 if ((p_dev->resource[0]->start & 0xf) == 8)
698 : (cf->index & 0x20 ? 8:-24)); 701 return -ENODEV;
699 if (!pcmcia_request_io(p_dev)) 702
700 return 0; 703 p_dev->resource[0]->end = 18;
701 } 704 p_dev->resource[1]->end = 8;
702 return -ENODEV; 705 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
706 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
707 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
708 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
709 p_dev->io_lines = 10;
703 710
711 p_dev->resource[1]->start = p_dev->resource[0]->start;
712 p_dev->resource[0]->start = tmp;
713 return pcmcia_request_io(p_dev);
704} 714}
705 715
706 716
@@ -803,21 +813,16 @@ xirc2ps_config(struct pcmcia_device * link)
803 goto failure; 813 goto failure;
804 } 814 }
805 815
806 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
807 link->io_lines = 10;
808 if (local->modem) { 816 if (local->modem) {
809 int pass; 817 int pass;
818 link->config_flags |= CONF_AUTO_SET_IO;
810 819
811 link->resource[1]->end = 8;
812 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
813 if (local->dingo) { 820 if (local->dingo) {
814 /* Take the Modem IO port from the CIS and scan for a free 821 /* Take the Modem IO port from the CIS and scan for a free
815 * Ethernet port */ 822 * Ethernet port */
816 link->resource[0]->end = 16; /* no Mako stuff anymore */
817 if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL)) 823 if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL))
818 goto port_found; 824 goto port_found;
819 } else { 825 } else {
820 link->resource[0]->end = 18;
821 /* We do 2 passes here: The first one uses the regular mapping and 826 /* We do 2 passes here: The first one uses the regular mapping and
822 * the second tries again, thereby considering that the 32 ports are 827 * the second tries again, thereby considering that the 32 ports are
823 * mirrored every 32 bytes. Actually we use a mirrored port for 828 * mirrored every 32 bytes. Actually we use a mirrored port for
@@ -833,7 +838,9 @@ xirc2ps_config(struct pcmcia_device * link)
833 } 838 }
834 printk(KNOT_XIRC "no ports available\n"); 839 printk(KNOT_XIRC "no ports available\n");
835 } else { 840 } else {
841 link->io_lines = 10;
836 link->resource[0]->end = 16; 842 link->resource[0]->end = 16;
843 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
837 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 844 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
838 link->resource[0]->start = ioaddr; 845 link->resource[0]->start = ioaddr;
839 if (!(err = pcmcia_request_io(link))) 846 if (!(err = pcmcia_request_io(link)))
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 63bf662e9c7f..77682f27772b 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -137,36 +137,12 @@ static void airo_detach(struct pcmcia_device *link)
137 137
138 ======================================================================*/ 138 ======================================================================*/
139 139
140static int airo_cs_config_check(struct pcmcia_device *p_dev, 140static int airo_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
141 cistpl_cftable_entry_t *cfg,
142 cistpl_cftable_entry_t *dflt,
143 void *priv_data)
144{ 141{
145 if (cfg->index == 0) 142 if (p_dev->config_index == 0)
146 return -ENODEV; 143 return -EINVAL;
147
148 /* IO window settings */
149 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
150 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
151 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
152 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
153 p_dev->resource[0]->flags |=
154 pcmcia_io_cfg_data_width(io->flags);
155 p_dev->resource[0]->start = io->win[0].base;
156 p_dev->resource[0]->end = io->win[0].len;
157 if (io->nwin > 1) {
158 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
159 p_dev->resource[1]->start = io->win[1].base;
160 p_dev->resource[1]->end = io->win[1].len;
161 }
162 }
163
164 /* This reserves IO space but doesn't actually enable it */
165 if (pcmcia_request_io(p_dev) != 0)
166 return -ENODEV;
167 144
168 /* If we got this far, we're cool! */ 145 return pcmcia_request_io(p_dev);
169 return 0;
170} 146}
171 147
172 148
@@ -180,7 +156,7 @@ static int airo_config(struct pcmcia_device *link)
180 dev_dbg(&link->dev, "airo_config\n"); 156 dev_dbg(&link->dev, "airo_config\n");
181 157
182 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP | 158 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
183 CONF_AUTO_AUDIO; 159 CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
184 160
185 /* 161 /*
186 * In this loop, we scan the CIS for configuration table 162 * In this loop, we scan the CIS for configuration table
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 812decd3fbe9..202938022112 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -154,31 +154,11 @@ static int card_present(void *arg)
154 return 0; 154 return 0;
155} 155}
156 156
157static int atmel_config_check(struct pcmcia_device *p_dev, 157static int atmel_config_check(struct pcmcia_device *p_dev, void *priv_data)
158 cistpl_cftable_entry_t *cfg,
159 cistpl_cftable_entry_t *dflt,
160 void *priv_data)
161{ 158{
162 if (cfg->index == 0) 159 if (p_dev->config_index == 0)
163 return -ENODEV; 160 return -EINVAL;
164
165 /* IO window settings */
166 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
167 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
168 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
169 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
170 p_dev->resource[0]->flags |=
171 pcmcia_io_cfg_data_width(io->flags);
172 p_dev->resource[0]->start = io->win[0].base;
173 p_dev->resource[0]->end = io->win[0].len;
174 if (io->nwin > 1) {
175 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
176 p_dev->resource[1]->start = io->win[1].base;
177 p_dev->resource[1]->end = io->win[1].len;
178 }
179 }
180 161
181 /* This reserves IO space but doesn't actually enable it */
182 return pcmcia_request_io(p_dev); 162 return pcmcia_request_io(p_dev);
183} 163}
184 164
@@ -194,7 +174,7 @@ static int atmel_config(struct pcmcia_device *link)
194 dev_dbg(&link->dev, "atmel_config\n"); 174 dev_dbg(&link->dev, "atmel_config\n");
195 175
196 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP | 176 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
197 CONF_AUTO_AUDIO; 177 CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
198 178
199 /* 179 /*
200 In this loop, we scan the CIS for configuration table entries, 180 In this loop, we scan the CIS for configuration table entries,
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index d4f19af1757f..e57b20134d39 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -469,46 +469,11 @@ static void prism2_detach(struct pcmcia_device *link)
469/* run after a CARD_INSERTION event is received to configure the PCMCIA 469/* run after a CARD_INSERTION event is received to configure the PCMCIA
470 * socket and make the device available to the system */ 470 * socket and make the device available to the system */
471 471
472static int prism2_config_check(struct pcmcia_device *p_dev, 472static int prism2_config_check(struct pcmcia_device *p_dev, void *priv_data)
473 cistpl_cftable_entry_t *cfg,
474 cistpl_cftable_entry_t *dflt,
475 void *priv_data)
476{ 473{
477 if (cfg->index == 0) 474 if (p_dev->config_index == 0)
478 return -ENODEV; 475 return -EINVAL;
479
480 PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
481 "(default 0x%02X)\n", cfg->index, dflt->index);
482
483 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
484 p_dev->vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
485 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
486 p_dev->vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
487
488 /* Do we need to allocate an interrupt? */
489 p_dev->config_flags |= CONF_ENABLE_IRQ;
490
491 /* IO window settings */
492 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
493 "dflt->io.nwin=%d\n",
494 cfg->io.nwin, dflt->io.nwin);
495 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
496 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
497 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
498 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
499 p_dev->resource[0]->flags |=
500 pcmcia_io_cfg_data_width(io->flags);
501 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
502 p_dev->resource[0]->start = io->win[0].base;
503 p_dev->resource[0]->end = io->win[0].len;
504 if (io->nwin > 1) {
505 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
506 p_dev->resource[1]->start = io->win[1].base;
507 p_dev->resource[1]->end = io->win[1].len;
508 }
509 }
510 476
511 /* This reserves IO space but doesn't actually enable it */
512 return pcmcia_request_io(p_dev); 477 return pcmcia_request_io(p_dev);
513} 478}
514 479
@@ -531,7 +496,7 @@ static int prism2_config(struct pcmcia_device *link)
531 496
532 /* Look for an appropriate configuration table entry in the CIS */ 497 /* Look for an appropriate configuration table entry in the CIS */
533 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | 498 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO |
534 CONF_AUTO_CHECK_VCC; 499 CONF_AUTO_CHECK_VCC | CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
535 if (ignore_cis_vcc) 500 if (ignore_cis_vcc)
536 link->config_flags &= ~CONF_AUTO_CHECK_VCC; 501 link->config_flags &= ~CONF_AUTO_CHECK_VCC;
537 ret = pcmcia_loop_config(link, prism2_config_check, NULL); 502 ret = pcmcia_loop_config(link, prism2_config_check, NULL);
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 031f3e6da3c9..2c6f28ac5197 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -794,20 +794,12 @@ static void if_cs_release(struct pcmcia_device *p_dev)
794 * insertion event. 794 * insertion event.
795 */ 795 */
796 796
797static int if_cs_ioprobe(struct pcmcia_device *p_dev, 797static int if_cs_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
798 cistpl_cftable_entry_t *cfg,
799 cistpl_cftable_entry_t *dflt,
800 void *priv_data)
801{ 798{
799 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
802 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 800 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
803 p_dev->resource[0]->start = cfg->io.win[0].base;
804 p_dev->resource[0]->end = cfg->io.win[0].len;
805 801
806 /* Do we need to allocate an interrupt? */ 802 if (p_dev->resource[1]->end) {
807 p_dev->config_flags |= CONF_ENABLE_IRQ;
808
809 /* IO window settings */
810 if (cfg->io.nwin != 1) {
811 lbs_pr_err("wrong CIS (check number of IO windows)\n"); 803 lbs_pr_err("wrong CIS (check number of IO windows)\n");
812 return -ENODEV; 804 return -ENODEV;
813 } 805 }
@@ -833,6 +825,8 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
833 card->p_dev = p_dev; 825 card->p_dev = p_dev;
834 p_dev->priv = card; 826 p_dev->priv = card;
835 827
828 p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
829
836 if (pcmcia_loop_config(p_dev, if_cs_ioprobe, NULL)) { 830 if (pcmcia_loop_config(p_dev, if_cs_ioprobe, NULL)) {
837 lbs_pr_err("error in pcmcia_loop_config\n"); 831 lbs_pr_err("error in pcmcia_loop_config\n");
838 goto out1; 832 goto out1;
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index b92173827b55..263dfe9e0e30 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -142,42 +142,12 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
142 * device available to the system. 142 * device available to the system.
143 */ 143 */
144 144
145static int orinoco_cs_config_check(struct pcmcia_device *p_dev, 145static int orinoco_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
146 cistpl_cftable_entry_t *cfg,
147 cistpl_cftable_entry_t *dflt,
148 void *priv_data)
149{ 146{
150 if (cfg->index == 0) 147 if (p_dev->config_index == 0)
151 goto next_entry; 148 return -EINVAL;
152
153 /* Do we need to allocate an interrupt? */
154 p_dev->config_flags |= CONF_ENABLE_IRQ;
155
156 /* IO window settings */
157 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
158 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
159 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
160 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
161 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
162 p_dev->resource[0]->flags |=
163 pcmcia_io_cfg_data_width(io->flags);
164 p_dev->resource[0]->start = io->win[0].base;
165 p_dev->resource[0]->end = io->win[0].len;
166 if (io->nwin > 1) {
167 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
168 p_dev->resource[1]->start = io->win[1].base;
169 p_dev->resource[1]->end = io->win[1].len;
170 }
171
172 /* This reserves IO space but doesn't actually enable it */
173 if (pcmcia_request_io(p_dev) != 0)
174 goto next_entry;
175 }
176 return 0;
177 149
178next_entry: 150 return pcmcia_request_io(p_dev);
179 pcmcia_disable_device(p_dev);
180 return -ENODEV;
181}; 151};
182 152
183static int 153static int
@@ -202,7 +172,8 @@ orinoco_cs_config(struct pcmcia_device *link)
202 * and most client drivers will only use the CIS to fill in 172 * and most client drivers will only use the CIS to fill in
203 * implementation-defined details. 173 * implementation-defined details.
204 */ 174 */
205 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC; 175 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC |
176 CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
206 if (ignore_cis_vcc) 177 if (ignore_cis_vcc)
207 link->config_flags &= ~CONF_AUTO_CHECK_VCC; 178 link->config_flags &= ~CONF_AUTO_CHECK_VCC;
208 ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL); 179 ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL);
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index f462c78856e9..78446507873f 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -205,48 +205,12 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
205 */ 205 */
206 206
207static int spectrum_cs_config_check(struct pcmcia_device *p_dev, 207static int spectrum_cs_config_check(struct pcmcia_device *p_dev,
208 cistpl_cftable_entry_t *cfg,
209 cistpl_cftable_entry_t *dflt,
210 void *priv_data) 208 void *priv_data)
211{ 209{
212 if (cfg->index == 0) 210 if (p_dev->config_index == 0)
213 goto next_entry; 211 return -EINVAL;
214
215 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
216 p_dev->vpp =
217 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
218 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
219 p_dev->vpp =
220 dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
221
222 /* Do we need to allocate an interrupt? */
223 p_dev->config_flags |= CONF_ENABLE_IRQ;
224
225 /* IO window settings */
226 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
227 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
228 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
229 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
230 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
231 p_dev->resource[0]->flags |=
232 pcmcia_io_cfg_data_width(io->flags);
233 p_dev->resource[0]->start = io->win[0].base;
234 p_dev->resource[0]->end = io->win[0].len;
235 if (io->nwin > 1) {
236 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
237 p_dev->resource[1]->start = io->win[1].base;
238 p_dev->resource[1]->end = io->win[1].len;
239 }
240
241 /* This reserves IO space but doesn't actually enable it */
242 if (pcmcia_request_io(p_dev) != 0)
243 goto next_entry;
244 }
245 return 0;
246 212
247next_entry: 213 return pcmcia_request_io(p_dev);
248 pcmcia_disable_device(p_dev);
249 return -ENODEV;
250}; 214};
251 215
252static int 216static int
@@ -271,7 +235,8 @@ spectrum_cs_config(struct pcmcia_device *link)
271 * and most client drivers will only use the CIS to fill in 235 * and most client drivers will only use the CIS to fill in
272 * implementation-defined details. 236 * implementation-defined details.
273 */ 237 */
274 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC; 238 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC |
239 CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
275 if (ignore_cis_vcc) 240 if (ignore_cis_vcc)
276 link->config_flags &= ~CONF_AUTO_CHECK_VCC; 241 link->config_flags &= ~CONF_AUTO_CHECK_VCC;
277 ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL); 242 ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL);