Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+514 -1024
+12
Documentation/pcmcia/driver-changes.txt
··· 1 1 This file details changes in 2.6 which affect PCMCIA card driver authors: 2 + * pcmcia_loop_config() and autoconfiguration (as of 2.6.36) 3 + If struct pcmcia_device *p_dev->config_flags is set accordingly, 4 + pcmcia_loop_config() now sets up certain configuration values 5 + automatically, though the driver may still override the settings 6 + in the callback function. The following autoconfiguration options 7 + are provided at the moment: 8 + CONF_AUTO_CHECK_VCC : check for matching Vcc 9 + CONF_AUTO_SET_VPP : set Vpp 10 + CONF_AUTO_AUDIO : auto-enable audio line, if required 11 + CONF_AUTO_SET_IO : set ioport resources (->resource[0,1]) 12 + CONF_AUTO_SET_IOMEM : set first iomem resource (->resource[2]) 13 + 2 14 * pcmcia_request_configuration -> pcmcia_enable_device (as of 2.6.36) 3 15 pcmcia_request_configuration() got renamed to pcmcia_enable_device(), 4 16 as it mirrors pcmcia_disable_device(). Configuration settings are now
+26 -55
drivers/ata/pata_pcmcia.c
··· 167 167 }; 168 168 169 169 170 - struct pcmcia_config_check { 171 - unsigned long ctl_base; 172 - int is_kme; 173 - }; 174 - 175 - static int pcmcia_check_one_config(struct pcmcia_device *pdev, 176 - cistpl_cftable_entry_t *cfg, 177 - cistpl_cftable_entry_t *dflt, 178 - void *priv_data) 170 + static int pcmcia_check_one_config(struct pcmcia_device *pdev, void *priv_data) 179 171 { 180 - struct pcmcia_config_check *stk = priv_data; 172 + int *is_kme = priv_data; 181 173 182 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 183 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 184 - pdev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 185 - pdev->resource[0]->start = io->win[0].base; 186 - if (!(io->flags & CISTPL_IO_16BIT)) { 187 - pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 188 - pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 189 - } 190 - if (io->nwin == 2) { 191 - pdev->resource[0]->end = 8; 192 - pdev->resource[1]->start = io->win[1].base; 193 - pdev->resource[1]->end = (stk->is_kme) ? 2 : 1; 194 - if (pcmcia_request_io(pdev) != 0) 195 - return -ENODEV; 196 - stk->ctl_base = pdev->resource[1]->start; 197 - } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { 198 - pdev->resource[0]->end = io->win[0].len; 199 - pdev->resource[1]->end = 0; 200 - if (pcmcia_request_io(pdev) != 0) 201 - return -ENODEV; 202 - stk->ctl_base = pdev->resource[0]->start + 0x0e; 203 - } else 204 - return -ENODEV; 205 - /* If we've got this far, we're done */ 206 - return 0; 174 + if (!(pdev->resource[0]->flags & IO_DATA_PATH_WIDTH_8)) { 175 + pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 176 + pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 207 177 } 208 - return -ENODEV; 178 + pdev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH; 179 + pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 180 + 181 + if (pdev->resource[1]->end) { 182 + pdev->resource[0]->end = 8; 183 + pdev->resource[1]->end = (*is_kme) ? 2 : 1; 184 + } else { 185 + if (pdev->resource[0]->end < 16) 186 + return -ENODEV; 187 + } 188 + 189 + return pcmcia_request_io(pdev); 209 190 } 210 191 211 192 /** ··· 201 220 { 202 221 struct ata_host *host; 203 222 struct ata_port *ap; 204 - struct pcmcia_config_check *stk = NULL; 205 223 int is_kme = 0, ret = -ENOMEM, p; 206 224 unsigned long io_base, ctl_base; 207 225 void __iomem *io_addr, *ctl_addr; ··· 208 228 struct ata_port_operations *ops = &pcmcia_port_ops; 209 229 210 230 /* Set up attributes in order to probe card and get resources */ 211 - pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 212 - pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 213 - pdev->config_flags |= CONF_ENABLE_IRQ; 214 - pdev->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC; 231 + pdev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO | 232 + CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC; 215 233 216 234 /* See if we have a manufacturer identifier. Use it to set is_kme for 217 235 vendor quirks */ ··· 217 239 ((pdev->card_id == PRODID_KME_KXLC005_A) || 218 240 (pdev->card_id == PRODID_KME_KXLC005_B))); 219 241 220 - /* Allocate resoure probing structures */ 221 - 222 - stk = kzalloc(sizeof(*stk), GFP_KERNEL); 223 - if (!stk) 224 - goto out1; 225 - stk->is_kme = is_kme; 226 - io_base = ctl_base = 0; 227 - 228 - if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) { 242 + if (pcmcia_loop_config(pdev, pcmcia_check_one_config, &is_kme)) { 229 243 pdev->config_flags &= ~CONF_AUTO_CHECK_VCC; 230 - if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) 244 + if (pcmcia_loop_config(pdev, pcmcia_check_one_config, &is_kme)) 231 245 goto failed; /* No suitable config found */ 232 246 } 233 247 io_base = pdev->resource[0]->start; 234 - ctl_base = stk->ctl_base; 248 + if (pdev->resource[1]->end) 249 + ctl_base = pdev->resource[1]->start; 250 + else 251 + ctl_base = pdev->resource[0]->start + 0x0e; 252 + 235 253 if (!pdev->irq) 236 254 goto failed; 237 255 ··· 284 310 goto failed; 285 311 286 312 pdev->priv = host; 287 - kfree(stk); 288 313 return 0; 289 314 290 315 failed: 291 - kfree(stk); 292 316 pcmcia_disable_device(pdev); 293 - out1: 294 317 return ret; 295 318 } 296 319
+27 -26
drivers/bluetooth/bt3c_cs.c
··· 656 656 info->p_dev = link; 657 657 link->priv = info; 658 658 659 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 660 - link->resource[0]->end = 8; 661 - 662 - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP; 659 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP | 660 + CONF_AUTO_SET_IO; 663 661 664 662 return bt3c_config(link); 665 663 } ··· 671 673 kfree(info); 672 674 } 673 675 674 - static int bt3c_check_config(struct pcmcia_device *p_dev, 675 - cistpl_cftable_entry_t *cf, 676 - cistpl_cftable_entry_t *dflt, 677 - void *priv_data) 676 + static int bt3c_check_config(struct pcmcia_device *p_dev, void *priv_data) 678 677 { 679 - unsigned long try = (unsigned long) priv_data; 680 - p_dev->io_lines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 678 + int *try = priv_data; 681 679 682 - if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && 683 - (cf->io.win[0].base != 0)) { 684 - p_dev->resource[0]->start = cf->io.win[0].base; 685 - if (!pcmcia_request_io(p_dev)) 686 - return 0; 687 - } 688 - return -ENODEV; 680 + if (try == 0) 681 + p_dev->io_lines = 16; 682 + 683 + if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0)) 684 + return -EINVAL; 685 + 686 + p_dev->resource[0]->end = 8; 687 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 688 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 689 + 690 + return pcmcia_request_io(p_dev); 689 691 } 690 692 691 693 static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev, 692 - cistpl_cftable_entry_t *cf, 693 - cistpl_cftable_entry_t *dflt, 694 694 void *priv_data) 695 695 { 696 696 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 697 697 int j; 698 698 699 - if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 700 - for (j = 0; j < 5; j++) { 701 - p_dev->resource[0]->start = base[j]; 702 - p_dev->io_lines = base[j] ? 16 : 3; 703 - if (!pcmcia_request_io(p_dev)) 704 - return 0; 705 - } 699 + if (p_dev->io_lines > 3) 700 + return -ENODEV; 701 + 702 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 703 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 704 + p_dev->resource[0]->end = 8; 705 + 706 + for (j = 0; j < 5; j++) { 707 + p_dev->resource[0]->start = base[j]; 708 + p_dev->io_lines = base[j] ? 16 : 3; 709 + if (!pcmcia_request_io(p_dev)) 710 + return 0; 706 711 } 707 712 return -ENODEV; 708 713 }
+26 -25
drivers/bluetooth/btuart_cs.c
··· 585 585 info->p_dev = link; 586 586 link->priv = info; 587 587 588 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 589 - link->resource[0]->end = 8; 590 - 591 - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP; 588 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP | 589 + CONF_AUTO_SET_IO; 592 590 593 591 return btuart_config(link); 594 592 } ··· 600 602 kfree(info); 601 603 } 602 604 603 - static int btuart_check_config(struct pcmcia_device *p_dev, 604 - cistpl_cftable_entry_t *cf, 605 - cistpl_cftable_entry_t *dflt, 606 - void *priv_data) 605 + static int btuart_check_config(struct pcmcia_device *p_dev, void *priv_data) 607 606 { 608 607 int *try = priv_data; 609 - p_dev->io_lines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 610 608 611 - if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && 612 - (cf->io.win[0].base != 0)) { 613 - p_dev->resource[0]->start = cf->io.win[0].base; 614 - if (!pcmcia_request_io(p_dev)) 615 - return 0; 616 - } 617 - return -ENODEV; 609 + if (try == 0) 610 + p_dev->io_lines = 16; 611 + 612 + if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0)) 613 + return -EINVAL; 614 + 615 + p_dev->resource[0]->end = 8; 616 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 617 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 618 + 619 + return pcmcia_request_io(p_dev); 618 620 } 619 621 620 622 static int btuart_check_config_notpicky(struct pcmcia_device *p_dev, 621 - cistpl_cftable_entry_t *cf, 622 - cistpl_cftable_entry_t *dflt, 623 623 void *priv_data) 624 624 { 625 625 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 626 626 int j; 627 627 628 - if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 629 - for (j = 0; j < 5; j++) { 630 - p_dev->resource[0]->start = base[j]; 631 - p_dev->io_lines = base[j] ? 16 : 3; 632 - if (!pcmcia_request_io(p_dev)) 633 - return 0; 634 - } 628 + if (p_dev->io_lines > 3) 629 + return -ENODEV; 630 + 631 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 632 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 633 + p_dev->resource[0]->end = 8; 634 + 635 + for (j = 0; j < 5; j++) { 636 + p_dev->resource[0]->start = base[j]; 637 + p_dev->io_lines = base[j] ? 16 : 3; 638 + if (!pcmcia_request_io(p_dev)) 639 + return 0; 635 640 } 636 641 return -ENODEV; 637 642 }
+6 -12
drivers/bluetooth/dtl1_cs.c
··· 571 571 info->p_dev = link; 572 572 link->priv = info; 573 573 574 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 575 - link->resource[0]->end = 8; 576 - 577 - link->config_flags |= CONF_ENABLE_IRQ; 574 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 578 575 579 576 return dtl1_config(link); 580 577 } ··· 586 589 kfree(info); 587 590 } 588 591 589 - static int dtl1_confcheck(struct pcmcia_device *p_dev, 590 - cistpl_cftable_entry_t *cf, 591 - cistpl_cftable_entry_t *dflt, 592 - void *priv_data) 592 + static int dtl1_confcheck(struct pcmcia_device *p_dev, void *priv_data) 593 593 { 594 - if ((cf->io.nwin != 1) || (cf->io.win[0].len <= 8)) 594 + if ((p_dev->resource[1]->end) || (p_dev->resource[1]->end < 8)) 595 595 return -ENODEV; 596 596 597 - p_dev->resource[0]->start = cf->io.win[0].base; 598 - p_dev->resource[0]->end = cf->io.win[0].len; /*yo */ 599 - p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 597 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 598 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 599 + 600 600 return pcmcia_request_io(p_dev); 601 601 } 602 602
+3 -12
drivers/char/pcmcia/cm4000_cs.c
··· 1741 1741 1742 1742 /*==== Interface to PCMCIA Layer =======================================*/ 1743 1743 1744 - static int cm4000_config_check(struct pcmcia_device *p_dev, 1745 - cistpl_cftable_entry_t *cfg, 1746 - cistpl_cftable_entry_t *dflt, 1747 - void *priv_data) 1744 + static int cm4000_config_check(struct pcmcia_device *p_dev, void *priv_data) 1748 1745 { 1749 - if (!cfg->io.nwin) 1750 - return -ENODEV; 1751 - 1752 - p_dev->resource[0]->start = cfg->io.win[0].base; 1753 - p_dev->resource[0]->end = cfg->io.win[0].len; 1754 - p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags); 1755 - p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; 1756 - 1757 1746 return pcmcia_request_io(p_dev); 1758 1747 } 1759 1748 1760 1749 static int cm4000_config(struct pcmcia_device * link, int devno) 1761 1750 { 1762 1751 struct cm4000_dev *dev; 1752 + 1753 + link->config_flags |= CONF_AUTO_SET_IO; 1763 1754 1764 1755 /* read the config-tuples */ 1765 1756 if (pcmcia_loop_config(link, cm4000_config_check, NULL))
+4 -18
drivers/char/pcmcia/cm4040_cs.c
··· 515 515 return; 516 516 } 517 517 518 - static int cm4040_config_check(struct pcmcia_device *p_dev, 519 - cistpl_cftable_entry_t *cfg, 520 - cistpl_cftable_entry_t *dflt, 521 - void *priv_data) 518 + static int cm4040_config_check(struct pcmcia_device *p_dev, void *priv_data) 522 519 { 523 - int rc; 524 - if (!cfg->io.nwin) 525 - return -ENODEV; 526 - 527 - /* Get the IOaddr */ 528 - p_dev->resource[0]->start = cfg->io.win[0].base; 529 - p_dev->resource[0]->end = cfg->io.win[0].len; 530 - p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags); 531 - p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; 532 - rc = pcmcia_request_io(p_dev); 533 - 534 - dev_printk(KERN_INFO, &p_dev->dev, 535 - "pcmcia_request_io returned 0x%x\n", rc); 536 - return rc; 520 + return pcmcia_request_io(p_dev); 537 521 } 538 522 539 523 ··· 525 541 { 526 542 struct reader_dev *dev; 527 543 int fail_rc; 544 + 545 + link->config_flags |= CONF_AUTO_SET_IO; 528 546 529 547 if (pcmcia_loop_config(link, cm4040_config_check, NULL)) 530 548 goto cs_release;
+7 -19
drivers/char/pcmcia/ipwireless/main.c
··· 75 75 schedule_work(&ipw->work_reboot); 76 76 } 77 77 78 - static int ipwireless_probe(struct pcmcia_device *p_dev, 79 - cistpl_cftable_entry_t *cfg, 80 - cistpl_cftable_entry_t *dflt, 81 - void *priv_data) 78 + static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) 82 79 { 83 80 struct ipw_dev *ipw = priv_data; 84 81 struct resource *io_resource; 85 82 int ret; 86 83 84 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 87 85 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 88 - p_dev->resource[0]->start = cfg->io.win[0].base; 89 - p_dev->resource[0]->end = cfg->io.win[0].len; 90 86 91 87 /* 0x40 causes it to generate level mode interrupts. */ 92 88 /* 0x04 enables IREQ pin. */ 93 - p_dev->config_index = cfg->index | 0x44; 89 + p_dev->config_index |= 0x44; 94 90 p_dev->io_lines = 16; 95 91 ret = pcmcia_request_io(p_dev); 96 92 if (ret) ··· 96 100 resource_size(p_dev->resource[0]), 97 101 IPWIRELESS_PCCARD_NAME); 98 102 99 - if (cfg->mem.nwin == 0) 100 - return 0; 101 - 102 103 p_dev->resource[2]->flags |= 103 104 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE; 104 - p_dev->resource[2]->start = cfg->mem.win[0].host_addr; 105 - p_dev->resource[2]->end = cfg->mem.win[0].len; 106 - if (p_dev->resource[2]->end < 0x1000) 107 - p_dev->resource[2]->end = 0x1000; 108 105 109 106 ret = pcmcia_request_window(p_dev, p_dev->resource[2], 0); 110 107 if (ret != 0) 111 108 goto exit1; 112 109 113 - ret = pcmcia_map_mem_page(p_dev, p_dev->resource[2], 114 - cfg->mem.win[0].card_addr); 110 + ret = pcmcia_map_mem_page(p_dev, p_dev->resource[2], p_dev->card_addr); 115 111 if (ret != 0) 116 112 goto exit2; 117 113 118 - ipw->is_v2_card = cfg->mem.win[0].len == 0x100; 114 + ipw->is_v2_card = resource_size(p_dev->resource[2]) == 0x100; 119 115 120 116 ipw->attr_memory = ioremap(p_dev->resource[2]->start, 121 117 resource_size(p_dev->resource[2])); ··· 153 165 int ret = 0; 154 166 155 167 ipw->is_v2_card = 0; 168 + link->config_flags |= CONF_AUTO_SET_IO | CONF_AUTO_SET_IOMEM | 169 + CONF_ENABLE_IRQ; 156 170 157 171 ret = pcmcia_loop_config(link, ipwireless_probe, ipw); 158 172 if (ret != 0) 159 173 return ret; 160 - 161 - link->config_flags |= CONF_ENABLE_IRQ; 162 174 163 175 INIT_WORK(&ipw->work_reboot, signalled_reboot_work); 164 176
+25 -57
drivers/ide/ide-cs.c
··· 96 96 info->p_dev = link; 97 97 link->priv = info; 98 98 99 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 100 - link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 101 - link->config_flags |= CONF_ENABLE_IRQ; 102 - link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC; 99 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO | 100 + CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC; 103 101 104 102 return ide_config(link); 105 103 } /* ide_attach */ ··· 192 194 193 195 ======================================================================*/ 194 196 195 - struct pcmcia_config_check { 196 - unsigned long ctl_base; 197 - int is_kme; 198 - }; 199 - 200 - static int pcmcia_check_one_config(struct pcmcia_device *pdev, 201 - cistpl_cftable_entry_t *cfg, 202 - cistpl_cftable_entry_t *dflt, 203 - void *priv_data) 197 + static int pcmcia_check_one_config(struct pcmcia_device *pdev, void *priv_data) 204 198 { 205 - struct pcmcia_config_check *stk = priv_data; 199 + int *is_kme = priv_data; 206 200 207 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 208 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 209 - pdev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 210 - pdev->config_index = cfg->index; 211 - pdev->resource[0]->start = io->win[0].base; 212 - if (!(io->flags & CISTPL_IO_16BIT)) { 213 - pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 214 - pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 215 - } 216 - if (io->nwin == 2) { 217 - pdev->resource[0]->end = 8; 218 - pdev->resource[1]->start = io->win[1].base; 219 - pdev->resource[1]->end = (stk->is_kme) ? 2 : 1; 220 - if (pcmcia_request_io(pdev) != 0) 221 - return -ENODEV; 222 - stk->ctl_base = pdev->resource[1]->start; 223 - } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { 224 - pdev->resource[0]->end = io->win[0].len; 225 - pdev->resource[1]->end = 0; 226 - if (pcmcia_request_io(pdev) != 0) 227 - return -ENODEV; 228 - stk->ctl_base = pdev->resource[0]->start + 0x0e; 229 - } else 230 - return -ENODEV; 231 - /* If we've got this far, we're done */ 232 - return 0; 201 + if (!(pdev->resource[0]->flags & IO_DATA_PATH_WIDTH_8)) { 202 + pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 203 + pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 233 204 } 234 - return -ENODEV; 205 + pdev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH; 206 + pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 207 + 208 + if (pdev->resource[1]->end) { 209 + pdev->resource[0]->end = 8; 210 + pdev->resource[1]->end = (*is_kme) ? 2 : 1; 211 + } else { 212 + if (pdev->resource[0]->end < 16) 213 + return -ENODEV; 214 + } 215 + 216 + return pcmcia_request_io(pdev); 235 217 } 236 218 237 219 static int ide_config(struct pcmcia_device *link) 238 220 { 239 221 ide_info_t *info = link->priv; 240 - struct pcmcia_config_check *stk = NULL; 241 222 int ret = 0, is_kme = 0; 242 223 unsigned long io_base, ctl_base; 243 224 struct ide_host *host; ··· 227 250 ((link->card_id == PRODID_KME_KXLC005_A) || 228 251 (link->card_id == PRODID_KME_KXLC005_B))); 229 252 230 - stk = kzalloc(sizeof(*stk), GFP_KERNEL); 231 - if (!stk) 232 - goto err_mem; 233 - stk->is_kme = is_kme; 234 - io_base = ctl_base = 0; 235 - 236 - if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) { 253 + if (pcmcia_loop_config(link, pcmcia_check_one_config, &is_kme)) { 237 254 link->config_flags &= ~CONF_AUTO_CHECK_VCC; 238 - if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) 255 + if (pcmcia_loop_config(link, pcmcia_check_one_config, &is_kme)) 239 256 goto failed; /* No suitable config found */ 240 257 } 241 258 io_base = link->resource[0]->start; 242 - ctl_base = stk->ctl_base; 259 + if (link->resource[1]->end) 260 + ctl_base = link->resource[1]->start; 261 + else 262 + ctl_base = link->resource[0]->start + 0x0e; 243 263 244 264 if (!link->irq) 245 265 goto failed; ··· 268 294 'a' + host->ports[0]->index * 2, 269 295 link->vpp / 10, link->vpp % 10); 270 296 271 - kfree(stk); 272 297 return 0; 273 298 274 - err_mem: 275 - printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n"); 276 - goto failed; 277 - 278 299 failed: 279 - kfree(stk); 280 300 ide_release(link); 281 301 return -ENODEV; 282 302 } /* ide_config */
+5 -14
drivers/isdn/hardware/avm/avm_cs.c
··· 72 72 73 73 static int avmcs_probe(struct pcmcia_device *p_dev) 74 74 { 75 - 76 - /* The io structure describes IO port mapping */ 77 - p_dev->resource[0]->end = 16; 78 - p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 79 - 80 75 /* General socket configuration */ 81 - p_dev->config_flags |= CONF_ENABLE_IRQ; 76 + p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 82 77 p_dev->config_index = 1; 83 78 p_dev->config_regs = PRESENT_OPTION; 84 79 ··· 102 107 103 108 ======================================================================*/ 104 109 105 - static int avmcs_configcheck(struct pcmcia_device *p_dev, 106 - cistpl_cftable_entry_t *cf, 107 - cistpl_cftable_entry_t *dflt, 108 - void *priv_data) 110 + static int avmcs_configcheck(struct pcmcia_device *p_dev, void *priv_data) 109 111 { 110 - if (cf->io.nwin <= 0) 111 - return -ENODEV; 112 + p_dev->resource[0]->end = 16; 113 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 114 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 112 115 113 - p_dev->resource[0]->start = cf->io.win[0].base; 114 - p_dev->resource[0]->end = cf->io.win[0].len; 115 116 return pcmcia_request_io(p_dev); 116 117 } 117 118
+6 -16
drivers/isdn/hisax/avma1_cs.c
··· 76 76 { 77 77 dev_dbg(&p_dev->dev, "avma1cs_attach()\n"); 78 78 79 - /* The io structure describes IO port mapping */ 80 - p_dev->resource[0]->end = 16; 81 - p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 82 - p_dev->resource[1]->end = 16; 83 - p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_16; 84 - 85 79 /* General socket configuration */ 86 - p_dev->config_flags |= CONF_ENABLE_IRQ; 80 + p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 87 81 p_dev->config_index = 1; 88 82 p_dev->config_regs = PRESENT_OPTION; 89 83 ··· 108 114 109 115 ======================================================================*/ 110 116 111 - static int avma1cs_configcheck(struct pcmcia_device *p_dev, 112 - cistpl_cftable_entry_t *cf, 113 - cistpl_cftable_entry_t *dflt, 114 - void *priv_data) 117 + static int avma1cs_configcheck(struct pcmcia_device *p_dev, void *priv_data) 115 118 { 116 - if (cf->io.nwin <= 0) 117 - return -ENODEV; 118 - 119 - p_dev->resource[0]->start = cf->io.win[0].base; 120 - p_dev->resource[0]->end = cf->io.win[0].len; 119 + p_dev->resource[0]->end = 16; 120 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 121 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 121 122 p_dev->io_lines = 5; 123 + 122 124 return pcmcia_request_io(p_dev); 123 125 } 124 126
+7 -16
drivers/isdn/hisax/elsa_cs.c
··· 118 118 119 119 local->cardnr = -1; 120 120 121 - /* 122 - General socket configuration defaults can go here. In this 123 - client, we assume very little, and rely on the CIS for almost 124 - everything. In most clients, many details (i.e., number, sizes, 125 - and attributes of IO windows) are fixed by the nature of the 126 - device, and can be hard-wired here. 127 - */ 128 - link->resource[0]->end = 8; 129 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 130 - 131 121 return elsa_cs_config(link); 132 122 } /* elsa_cs_attach */ 133 123 ··· 150 160 151 161 ======================================================================*/ 152 162 153 - static int elsa_cs_configcheck(struct pcmcia_device *p_dev, 154 - cistpl_cftable_entry_t *cf, 155 - cistpl_cftable_entry_t *dflt, 156 - void *priv_data) 163 + static int elsa_cs_configcheck(struct pcmcia_device *p_dev, void *priv_data) 157 164 { 158 165 int j; 159 166 160 167 p_dev->io_lines = 3; 168 + p_dev->resource[0]->end = 8; 169 + p_dev->resource[0]->flags &= IO_DATA_PATH_WIDTH; 170 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 161 171 162 - if ((cf->io.nwin > 0) && cf->io.win[0].base) { 172 + if ((p_dev->resource[0]->end) && p_dev->resource[0]->start) { 163 173 printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n"); 164 - p_dev->resource[0]->start = cf->io.win[0].base; 165 174 if (!pcmcia_request_io(p_dev)) 166 175 return 0; 167 176 } else { ··· 182 193 183 194 dev_dbg(&link->dev, "elsa_config(0x%p)\n", link); 184 195 dev = link->priv; 196 + 197 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 185 198 186 199 i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL); 187 200 if (i != 0)
+6 -30
drivers/isdn/hisax/sedlbauer_cs.c
··· 128 128 /* from old sedl_cs 129 129 */ 130 130 /* The io structure describes IO port mapping */ 131 - link->resource[0]->end = 8; 132 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 133 131 134 132 return sedlbauer_config(link); 135 133 } /* sedlbauer_attach */ ··· 159 161 device available to the system. 160 162 161 163 ======================================================================*/ 162 - static int sedlbauer_config_check(struct pcmcia_device *p_dev, 163 - cistpl_cftable_entry_t *cfg, 164 - cistpl_cftable_entry_t *dflt, 165 - void *priv_data) 164 + static int sedlbauer_config_check(struct pcmcia_device *p_dev, void *priv_data) 166 165 { 167 - if (cfg->index == 0) 168 - return -ENODEV; 166 + if (p_dev->config_index == 0) 167 + return -EINVAL; 169 168 170 - /* IO window settings */ 171 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 172 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 173 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 174 - p_dev->resource[0]->start = io->win[0].base; 175 - p_dev->resource[0]->end = io->win[0].len; 176 - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 177 - p_dev->resource[0]->flags |= 178 - pcmcia_io_cfg_data_width(io->flags); 179 - if (io->nwin > 1) { 180 - p_dev->resource[1]->flags = p_dev->resource[0]->flags; 181 - p_dev->resource[1]->start = io->win[1].base; 182 - p_dev->resource[1]->end = io->win[1].len; 183 - } 184 - /* This reserves IO space but doesn't actually enable it */ 185 - p_dev->io_lines = 3; 186 - if (pcmcia_request_io(p_dev) != 0) 187 - return -ENODEV; 188 - } 189 - 190 - return 0; 169 + p_dev->io_lines = 3; 170 + return pcmcia_request_io(p_dev); 191 171 } 192 172 193 173 ··· 178 202 dev_dbg(&link->dev, "sedlbauer_config(0x%p)\n", link); 179 203 180 204 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC | 181 - CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO; 205 + CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_SET_IO; 182 206 183 207 /* 184 208 In this loop, we scan the CIS for configuration table entries,
+6 -10
drivers/isdn/hisax/teles_cs.c
··· 105 105 and attributes of IO windows) are fixed by the nature of the 106 106 device, and can be hard-wired here. 107 107 */ 108 - link->resource[0]->end = 96; 109 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 110 - 111 - link->config_flags |= CONF_ENABLE_IRQ; 108 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 112 109 113 110 return teles_cs_config(link); 114 111 } /* teles_attach */ ··· 139 142 140 143 ======================================================================*/ 141 144 142 - static int teles_cs_configcheck(struct pcmcia_device *p_dev, 143 - cistpl_cftable_entry_t *cf, 144 - cistpl_cftable_entry_t *dflt, 145 - void *priv_data) 145 + static int teles_cs_configcheck(struct pcmcia_device *p_dev, void *priv_data) 146 146 { 147 147 int j; 148 148 149 149 p_dev->io_lines = 5; 150 + p_dev->resource[0]->end = 96; 151 + p_dev->resource[0]->flags &= IO_DATA_PATH_WIDTH; 152 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 150 153 151 - if ((cf->io.nwin > 0) && cf->io.win[0].base) { 154 + if ((p_dev->resource[0]->end) && p_dev->resource[0]->start) { 152 155 printk(KERN_INFO "(teles_cs: looks like the 96 model)\n"); 153 - p_dev->resource[0]->start = cf->io.win[0].base; 154 156 if (!pcmcia_request_io(p_dev)) 155 157 return 0; 156 158 } else {
+7 -25
drivers/net/pcmcia/axnet_cs.c
··· 284 284 } 285 285 } 286 286 287 - static int axnet_configcheck(struct pcmcia_device *p_dev, 288 - cistpl_cftable_entry_t *cfg, 289 - cistpl_cftable_entry_t *dflt, 290 - void *priv_data) 287 + static int axnet_configcheck(struct pcmcia_device *p_dev, void *priv_data) 291 288 { 292 - int i; 293 - cistpl_io_t *io = &cfg->io; 294 - 295 - if (cfg->index == 0 || cfg->io.nwin == 0) 296 - return -ENODEV; 289 + if (p_dev->config_index == 0) 290 + return -EINVAL; 297 291 298 292 p_dev->config_index = 0x05; 299 - /* For multifunction cards, by convention, we configure the 300 - network function with window 0, and serial with window 1 */ 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); 293 + if (p_dev->resource[0]->end + p_dev->resource[1]->end < 32) 294 + return -ENODEV; 313 295 314 - return -ENODEV; 296 + return try_io_port(p_dev); 315 297 } 316 298 317 299 static int axnet_config(struct pcmcia_device *link) ··· 306 324 307 325 /* don't trust the CIS on this; Linksys got it wrong */ 308 326 link->config_regs = 0x63; 327 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 309 328 ret = pcmcia_loop_config(link, axnet_configcheck, NULL); 310 329 if (ret != 0) 311 330 goto failed; ··· 314 331 if (!link->irq) 315 332 goto failed; 316 333 317 - link->config_flags |= CONF_ENABLE_IRQ; 318 334 if (resource_size(link->resource[1]) == 8) 319 335 link->config_flags |= CONF_ENABLE_SPKR; 320 336
+1 -4
drivers/net/pcmcia/fmvj18x_cs.c
··· 319 319 return ret; /* RequestIO failed */ 320 320 } 321 321 322 - static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, 323 - cistpl_cftable_entry_t *cfg, 324 - cistpl_cftable_entry_t *dflt, 325 - void *priv_data) 322 + static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, void *priv_data) 326 323 { 327 324 return 0; /* strange, but that's what the code did already before... */ 328 325 }
+9 -29
drivers/net/pcmcia/pcnet_cs.c
··· 259 259 info->p_dev = link; 260 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 264 dev->netdev_ops = &pcnet_netdev_ops; 265 265 ··· 500 500 } 501 501 } 502 502 503 - static int pcnet_confcheck(struct pcmcia_device *p_dev, 504 - cistpl_cftable_entry_t *cfg, 505 - cistpl_cftable_entry_t *dflt, 506 - void *priv_data) 503 + static int pcnet_confcheck(struct pcmcia_device *p_dev, void *priv_data) 507 504 { 508 505 int *priv = priv_data; 509 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; 509 + 510 + if (p_dev->config_index == 0) 514 511 return -EINVAL; 515 512 516 - /* For multifunction cards, by convention, we configure the 517 - network function with window 0, and serial with window 1 */ 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 - } 513 + if (p_dev->resource[0]->end + p_dev->resource[1]->end < 32) 514 + return -EINVAL; 525 515 526 - *priv &= ((cfg->mem.nwin == 1) && 527 - (cfg->mem.win[0].len >= 0x4000)) ? 0x10 : ~0x10; 528 - 529 - p_dev->resource[0]->start = io->win[i].base; 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 516 + if (try) 534 517 p_dev->io_lines = 16; 535 - if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32) 536 - return try_io_port(p_dev); 537 - 538 - return -EINVAL; 518 + return try_io_port(p_dev); 539 519 } 540 520 541 521 static hw_info_t *pcnet_try_config(struct pcmcia_device *link,
+19 -20
drivers/net/pcmcia/smc91c92_cs.c
··· 323 323 link->priv = dev; 324 324 325 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 327 /* The SMC91c92-specific entries in the device structure. */ 331 328 dev->netdev_ops = &smc_netdev_ops; ··· 414 417 return 0; 415 418 } 416 419 417 - static int mhz_mfc_config_check(struct pcmcia_device *p_dev, 418 - cistpl_cftable_entry_t *cf, 419 - cistpl_cftable_entry_t *dflt, 420 - void *priv_data) 420 + static int mhz_mfc_config_check(struct pcmcia_device *p_dev, void *priv_data) 421 421 { 422 422 int k; 423 - p_dev->resource[1]->start = cf->io.win[0].base; 423 + p_dev->io_lines = 16; 424 + p_dev->resource[1]->start = p_dev->resource[0]->start; 425 + p_dev->resource[1]->end = 8; 426 + p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH; 427 + p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 428 + p_dev->resource[0]->end = 16; 429 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 430 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 424 431 for (k = 0; k < 0x400; k += 0x10) { 425 432 if (k & 0x80) 426 433 continue; 427 434 p_dev->resource[0]->start = k ^ 0x300; 428 - p_dev->io_lines = 16; 429 435 if (!pcmcia_request_io(p_dev)) 430 436 return 0; 431 437 } ··· 442 442 unsigned int offset; 443 443 int i; 444 444 445 - link->config_flags |= CONF_ENABLE_SPKR; 446 - link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 447 - link->resource[1]->end = 8; 445 + link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ | 446 + CONF_AUTO_SET_IO; 448 447 449 448 /* The Megahertz combo cards have modem-like CIS entries, so 450 449 we have to explicitly try a bunch of port combinations. */ ··· 585 586 586 587 /*====================================================================*/ 587 588 588 - static int smc_configcheck(struct pcmcia_device *p_dev, 589 - cistpl_cftable_entry_t *cf, 590 - cistpl_cftable_entry_t *dflt, 591 - void *priv_data) 589 + static int smc_configcheck(struct pcmcia_device *p_dev, void *priv_data) 592 590 { 593 - p_dev->resource[0]->start = cf->io.win[0].base; 594 - p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 591 + p_dev->resource[0]->end = 16; 592 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 593 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 594 + 595 595 return pcmcia_request_io(p_dev); 596 596 } 597 597 ··· 599 601 struct net_device *dev = link->priv; 600 602 int i; 601 603 602 - link->resource[0]->end = 16; 604 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 605 + 603 606 i = pcmcia_loop_config(link, smc_configcheck, NULL); 604 607 if (!i) 605 608 dev->base_addr = link->resource[0]->start; ··· 633 634 static const unsigned int com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; 634 635 int i, j; 635 636 636 - link->config_flags |= CONF_ENABLE_SPKR; 637 + link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ; 637 638 link->resource[0]->end = 64; 638 639 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 639 640 link->resource[1]->end = 8;
+38 -31
drivers/net/pcmcia/xirc2ps_cs.c
··· 528 528 link->priv = dev; 529 529 530 530 /* General socket configuration */ 531 - link->config_flags |= CONF_ENABLE_IRQ; 532 531 link->config_index = 1; 533 532 534 533 /* Fill in card specific entries */ ··· 664 665 } 665 666 666 667 static int 667 - xirc2ps_config_modem(struct pcmcia_device *p_dev, 668 - cistpl_cftable_entry_t *cf, 669 - cistpl_cftable_entry_t *dflt, 670 - void *priv_data) 668 + xirc2ps_config_modem(struct pcmcia_device *p_dev, void *priv_data) 671 669 { 672 670 unsigned int ioaddr; 673 671 674 - if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 675 - for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 676 - p_dev->resource[1]->start = cf->io.win[0].base; 677 - p_dev->resource[0]->start = ioaddr; 678 - if (!pcmcia_request_io(p_dev)) 679 - return 0; 680 - } 672 + if ((p_dev->resource[0]->start & 0xf) == 8) 673 + return -ENODEV; 674 + 675 + p_dev->resource[0]->end = 16; 676 + p_dev->resource[1]->end = 8; 677 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 678 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 679 + p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH; 680 + p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 681 + p_dev->io_lines = 10; 682 + 683 + p_dev->resource[1]->start = p_dev->resource[0]->start; 684 + for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 685 + p_dev->resource[0]->start = ioaddr; 686 + if (!pcmcia_request_io(p_dev)) 687 + return 0; 681 688 } 682 689 return -ENODEV; 683 690 } 684 691 685 692 static int 686 - xirc2ps_config_check(struct pcmcia_device *p_dev, 687 - cistpl_cftable_entry_t *cf, 688 - cistpl_cftable_entry_t *dflt, 689 - void *priv_data) 693 + xirc2ps_config_check(struct pcmcia_device *p_dev, void *priv_data) 690 694 { 691 695 int *pass = priv_data; 696 + resource_size_t tmp = p_dev->resource[1]->start; 692 697 693 - if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 694 - p_dev->resource[1]->start = cf->io.win[0].base; 695 - p_dev->resource[0]->start = p_dev->resource[1]->start 696 - + (*pass ? (cf->index & 0x20 ? -24:8) 697 - : (cf->index & 0x20 ? 8:-24)); 698 - if (!pcmcia_request_io(p_dev)) 699 - return 0; 700 - } 701 - return -ENODEV; 698 + tmp += (*pass ? (p_dev->config_index & 0x20 ? -24 : 8) 699 + : (p_dev->config_index & 0x20 ? 8 : -24)); 702 700 701 + if ((p_dev->resource[0]->start & 0xf) == 8) 702 + return -ENODEV; 703 + 704 + p_dev->resource[0]->end = 18; 705 + p_dev->resource[1]->end = 8; 706 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 707 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 708 + p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH; 709 + p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 710 + p_dev->io_lines = 10; 711 + 712 + p_dev->resource[1]->start = p_dev->resource[0]->start; 713 + p_dev->resource[0]->start = tmp; 714 + return pcmcia_request_io(p_dev); 703 715 } 704 716 705 717 ··· 813 803 goto failure; 814 804 } 815 805 816 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 817 - link->io_lines = 10; 818 806 if (local->modem) { 819 807 int pass; 808 + link->config_flags |= CONF_AUTO_SET_IO; 820 809 821 - link->resource[1]->end = 8; 822 - link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 823 810 if (local->dingo) { 824 811 /* Take the Modem IO port from the CIS and scan for a free 825 812 * Ethernet port */ 826 - link->resource[0]->end = 16; /* no Mako stuff anymore */ 827 813 if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL)) 828 814 goto port_found; 829 815 } else { 830 - link->resource[0]->end = 18; 831 816 /* We do 2 passes here: The first one uses the regular mapping and 832 817 * the second tries again, thereby considering that the 32 ports are 833 818 * mirrored every 32 bytes. Actually we use a mirrored port for ··· 838 833 } 839 834 printk(KNOT_XIRC "no ports available\n"); 840 835 } else { 836 + link->io_lines = 10; 841 837 link->resource[0]->end = 16; 838 + link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 842 839 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 843 840 link->resource[0]->start = ioaddr; 844 841 if (!(err = pcmcia_request_io(link)))
+5 -29
drivers/net/wireless/airo_cs.c
··· 137 137 138 138 ======================================================================*/ 139 139 140 - static int airo_cs_config_check(struct pcmcia_device *p_dev, 141 - cistpl_cftable_entry_t *cfg, 142 - cistpl_cftable_entry_t *dflt, 143 - void *priv_data) 140 + static int airo_cs_config_check(struct pcmcia_device *p_dev, void *priv_data) 144 141 { 145 - if (cfg->index == 0) 146 - return -ENODEV; 142 + if (p_dev->config_index == 0) 143 + return -EINVAL; 147 144 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 - 168 - /* If we got this far, we're cool! */ 169 - return 0; 145 + return pcmcia_request_io(p_dev); 170 146 } 171 147 172 148 ··· 156 180 dev_dbg(&link->dev, "airo_config\n"); 157 181 158 182 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP | 159 - CONF_AUTO_AUDIO; 183 + CONF_AUTO_AUDIO | CONF_AUTO_SET_IO; 160 184 161 185 /* 162 186 * In this loop, we scan the CIS for configuration table
+4 -24
drivers/net/wireless/atmel_cs.c
··· 154 154 return 0; 155 155 } 156 156 157 - static int atmel_config_check(struct pcmcia_device *p_dev, 158 - cistpl_cftable_entry_t *cfg, 159 - cistpl_cftable_entry_t *dflt, 160 - void *priv_data) 157 + static int atmel_config_check(struct pcmcia_device *p_dev, void *priv_data) 161 158 { 162 - if (cfg->index == 0) 163 - return -ENODEV; 159 + if (p_dev->config_index == 0) 160 + return -EINVAL; 164 161 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 - 181 - /* This reserves IO space but doesn't actually enable it */ 182 162 return pcmcia_request_io(p_dev); 183 163 } 184 164 ··· 174 194 dev_dbg(&link->dev, "atmel_config\n"); 175 195 176 196 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP | 177 - CONF_AUTO_AUDIO; 197 + CONF_AUTO_AUDIO | CONF_AUTO_SET_IO; 178 198 179 199 /* 180 200 In this loop, we scan the CIS for configuration table entries,
+4 -39
drivers/net/wireless/hostap/hostap_cs.c
··· 469 469 /* run after a CARD_INSERTION event is received to configure the PCMCIA 470 470 * socket and make the device available to the system */ 471 471 472 - static int prism2_config_check(struct pcmcia_device *p_dev, 473 - cistpl_cftable_entry_t *cfg, 474 - cistpl_cftable_entry_t *dflt, 475 - void *priv_data) 472 + static int prism2_config_check(struct pcmcia_device *p_dev, void *priv_data) 476 473 { 477 - if (cfg->index == 0) 478 - return -ENODEV; 474 + if (p_dev->config_index == 0) 475 + return -EINVAL; 479 476 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 - 511 - /* This reserves IO space but doesn't actually enable it */ 512 477 return pcmcia_request_io(p_dev); 513 478 } 514 479 ··· 496 531 497 532 /* Look for an appropriate configuration table entry in the CIS */ 498 533 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | 499 - CONF_AUTO_CHECK_VCC; 534 + CONF_AUTO_CHECK_VCC | CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; 500 535 if (ignore_cis_vcc) 501 536 link->config_flags &= ~CONF_AUTO_CHECK_VCC; 502 537 ret = pcmcia_loop_config(link, prism2_config_check, NULL);
+5 -11
drivers/net/wireless/libertas/if_cs.c
··· 794 794 * insertion event. 795 795 */ 796 796 797 - static int if_cs_ioprobe(struct pcmcia_device *p_dev, 798 - cistpl_cftable_entry_t *cfg, 799 - cistpl_cftable_entry_t *dflt, 800 - void *priv_data) 797 + static int if_cs_ioprobe(struct pcmcia_device *p_dev, void *priv_data) 801 798 { 799 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 802 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? */ 807 - p_dev->config_flags |= CONF_ENABLE_IRQ; 808 - 809 - /* IO window settings */ 810 - if (cfg->io.nwin != 1) { 802 + if (p_dev->resource[1]->end) { 811 803 lbs_pr_err("wrong CIS (check number of IO windows)\n"); 812 804 return -ENODEV; 813 805 } ··· 824 832 } 825 833 card->p_dev = p_dev; 826 834 p_dev->priv = card; 835 + 836 + p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 827 837 828 838 if (pcmcia_loop_config(p_dev, if_cs_ioprobe, NULL)) { 829 839 lbs_pr_err("error in pcmcia_loop_config\n");
+6 -35
drivers/net/wireless/orinoco/orinoco_cs.c
··· 142 142 * device available to the system. 143 143 */ 144 144 145 - static int orinoco_cs_config_check(struct pcmcia_device *p_dev, 146 - cistpl_cftable_entry_t *cfg, 147 - cistpl_cftable_entry_t *dflt, 148 - void *priv_data) 145 + static int orinoco_cs_config_check(struct pcmcia_device *p_dev, void *priv_data) 149 146 { 150 - if (cfg->index == 0) 151 - goto next_entry; 147 + if (p_dev->config_index == 0) 148 + return -EINVAL; 152 149 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 - 178 - next_entry: 179 - pcmcia_disable_device(p_dev); 180 - return -ENODEV; 150 + return pcmcia_request_io(p_dev); 181 151 }; 182 152 183 153 static int ··· 172 202 * and most client drivers will only use the CIS to fill in 173 203 * implementation-defined details. 174 204 */ 175 - link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC; 205 + link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC | 206 + CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; 176 207 if (ignore_cis_vcc) 177 208 link->config_flags &= ~CONF_AUTO_CHECK_VCC; 178 209 ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL);
+5 -40
drivers/net/wireless/orinoco/spectrum_cs.c
··· 205 205 */ 206 206 207 207 static int spectrum_cs_config_check(struct pcmcia_device *p_dev, 208 - cistpl_cftable_entry_t *cfg, 209 - cistpl_cftable_entry_t *dflt, 210 208 void *priv_data) 211 209 { 212 - if (cfg->index == 0) 213 - goto next_entry; 210 + if (p_dev->config_index == 0) 211 + return -EINVAL; 214 212 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 - 247 - next_entry: 248 - pcmcia_disable_device(p_dev); 249 - return -ENODEV; 213 + return pcmcia_request_io(p_dev); 250 214 }; 251 215 252 216 static int ··· 235 271 * and most client drivers will only use the CIS to fill in 236 272 * implementation-defined details. 237 273 */ 238 - link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC; 274 + link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC | 275 + CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; 239 276 if (ignore_cis_vcc) 240 277 link->config_flags &= ~CONF_AUTO_CHECK_VCC; 241 278 ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL);
+11 -23
drivers/parport/parport_cs.c
··· 100 100 link->priv = info; 101 101 info->p_dev = link; 102 102 103 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 104 - link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 105 - link->config_flags |= CONF_ENABLE_IRQ; 103 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 106 104 107 105 return parport_config(link); 108 106 } /* parport_attach */ ··· 131 133 132 134 ======================================================================*/ 133 135 134 - static int parport_config_check(struct pcmcia_device *p_dev, 135 - cistpl_cftable_entry_t *cfg, 136 - cistpl_cftable_entry_t *dflt, 137 - void *priv_data) 136 + static int parport_config_check(struct pcmcia_device *p_dev, void *priv_data) 138 137 { 139 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 140 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 141 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 142 - if (epp_mode) 143 - p_dev->config_index |= FORCE_EPP_MODE; 144 - p_dev->resource[0]->start = io->win[0].base; 145 - p_dev->resource[0]->end = io->win[0].len; 146 - if (io->nwin == 2) { 147 - p_dev->resource[1]->start = io->win[1].base; 148 - p_dev->resource[1]->end = io->win[1].len; 149 - } 150 - if (pcmcia_request_io(p_dev) != 0) 151 - return -ENODEV; 152 - return 0; 153 - } 154 - return -ENODEV; 138 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 139 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 140 + p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH; 141 + p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 142 + 143 + return pcmcia_request_io(p_dev); 155 144 } 156 145 157 146 static int parport_config(struct pcmcia_device *link) ··· 148 163 int ret; 149 164 150 165 dev_dbg(&link->dev, "parport_config\n"); 166 + 167 + if (epp_mode) 168 + link->config_index |= FORCE_EPP_MODE; 151 169 152 170 ret = pcmcia_loop_config(link, parport_config_check, NULL); 153 171 if (ret)
+67 -11
drivers/pcmcia/pcmcia_cis.c
··· 6 6 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 7 7 * 8 8 * Copyright (C) 1999 David A. Hinds 9 - * Copyright (C) 2004-2009 Dominik Brodowski 9 + * Copyright (C) 2004-2010 Dominik Brodowski 10 10 * 11 11 * This program is free software; you can redistribute it and/or modify 12 12 * it under the terms of the GNU General Public License version 2 as ··· 125 125 return ret; 126 126 } 127 127 128 + 129 + /** 130 + * pcmcia_io_cfg_data_width() - convert cfgtable to data path width parameter 131 + */ 132 + static int pcmcia_io_cfg_data_width(unsigned int flags) 133 + { 134 + if (!(flags & CISTPL_IO_8BIT)) 135 + return IO_DATA_PATH_WIDTH_16; 136 + if (!(flags & CISTPL_IO_16BIT)) 137 + return IO_DATA_PATH_WIDTH_8; 138 + return IO_DATA_PATH_WIDTH_AUTO; 139 + } 140 + 141 + 128 142 struct pcmcia_cfg_mem { 129 143 struct pcmcia_device *p_dev; 144 + int (*conf_check) (struct pcmcia_device *p_dev, void *priv_data); 130 145 void *priv_data; 131 - int (*conf_check) (struct pcmcia_device *p_dev, 132 - cistpl_cftable_entry_t *cfg, 133 - cistpl_cftable_entry_t *dflt, 134 - void *priv_data); 135 146 cisparse_t parse; 136 147 cistpl_cftable_entry_t dflt; 137 148 }; ··· 195 184 if ((flags & CONF_AUTO_AUDIO) && (cfg->flags & CISTPL_CFTABLE_AUDIO)) 196 185 p_dev->config_flags |= CONF_ENABLE_SPKR; 197 186 198 - return cfg_mem->conf_check(cfg_mem->p_dev, cfg, &cfg_mem->dflt, 199 - cfg_mem->priv_data); 187 + 188 + /* IO window settings? */ 189 + if (flags & CONF_AUTO_SET_IO) { 190 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 191 + int i = 0; 192 + 193 + p_dev->resource[0]->start = p_dev->resource[0]->end = 0; 194 + p_dev->resource[1]->start = p_dev->resource[1]->end = 0; 195 + if (io->nwin == 0) 196 + return -ENODEV; 197 + 198 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 199 + p_dev->resource[0]->flags |= 200 + pcmcia_io_cfg_data_width(io->flags); 201 + if (io->nwin > 1) { 202 + /* For multifunction cards, by convention, we 203 + * configure the network function with window 0, 204 + * and serial with window 1 */ 205 + i = (io->win[1].len > io->win[0].len); 206 + p_dev->resource[1]->flags = p_dev->resource[0]->flags; 207 + p_dev->resource[1]->start = io->win[1-i].base; 208 + p_dev->resource[1]->end = io->win[1-i].len; 209 + } 210 + p_dev->resource[0]->start = io->win[i].base; 211 + p_dev->resource[0]->end = io->win[i].len; 212 + p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 213 + } 214 + 215 + /* MEM window settings? */ 216 + if (flags & CONF_AUTO_SET_IOMEM) { 217 + /* so far, we only set one memory window */ 218 + cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; 219 + 220 + p_dev->resource[2]->start = p_dev->resource[2]->end = 0; 221 + if (mem->nwin == 0) 222 + return -ENODEV; 223 + 224 + p_dev->resource[2]->start = mem->win[0].host_addr; 225 + p_dev->resource[2]->end = mem->win[0].len; 226 + if (p_dev->resource[2]->end < 0x1000) 227 + p_dev->resource[2]->end = 0x1000; 228 + p_dev->card_addr = mem->win[0].card_addr; 229 + } 230 + 231 + dev_dbg(&p_dev->dev, 232 + "checking configuration %x: %pr %pr %pr (%d lines)\n", 233 + p_dev->config_index, p_dev->resource[0], p_dev->resource[1], 234 + p_dev->resource[2], p_dev->io_lines); 235 + 236 + return cfg_mem->conf_check(p_dev, cfg_mem->priv_data); 200 237 } 201 238 202 239 /** 203 240 * pcmcia_loop_config() - loop over configuration options 204 241 * @p_dev: the struct pcmcia_device which we need to loop for. 205 242 * @conf_check: function to call for each configuration option. 206 - * It gets passed the struct pcmcia_device, the CIS data 207 - * describing the configuration option, and private data 243 + * It gets passed the struct pcmcia_device and private data 208 244 * being passed to pcmcia_loop_config() 209 245 * @priv_data: private data to be passed to the conf_check function. 210 246 * ··· 261 203 */ 262 204 int pcmcia_loop_config(struct pcmcia_device *p_dev, 263 205 int (*conf_check) (struct pcmcia_device *p_dev, 264 - cistpl_cftable_entry_t *cfg, 265 - cistpl_cftable_entry_t *dflt, 266 206 void *priv_data), 267 207 void *priv_data) 268 208 {
+16 -18
drivers/scsi/pcmcia/aha152x_stub.c
··· 99 99 info->p_dev = link; 100 100 link->priv = info; 101 101 102 - link->resource[0]->end = 0x20; 103 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 104 - link->config_flags |= CONF_ENABLE_IRQ; 102 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 105 103 link->config_regs = PRESENT_OPTION; 106 104 107 105 return aha152x_config_cs(link); ··· 119 121 120 122 /*====================================================================*/ 121 123 122 - static int aha152x_config_check(struct pcmcia_device *p_dev, 123 - cistpl_cftable_entry_t *cfg, 124 - cistpl_cftable_entry_t *dflt, 125 - void *priv_data) 124 + static int aha152x_config_check(struct pcmcia_device *p_dev, void *priv_data) 126 125 { 127 126 p_dev->io_lines = 10; 127 + 128 128 /* For New Media T&J, look for a SCSI window */ 129 - if (cfg->io.win[0].len >= 0x20) 130 - p_dev->resource[0]->start = cfg->io.win[0].base; 131 - else if ((cfg->io.nwin > 1) && 132 - (cfg->io.win[1].len >= 0x20)) 133 - p_dev->resource[0]->start = cfg->io.win[1].base; 134 - if ((cfg->io.nwin > 0) && 135 - (p_dev->resource[0]->start < 0xffff)) { 136 - if (!pcmcia_request_io(p_dev)) 137 - return 0; 138 - } 139 - return -EINVAL; 129 + if ((p_dev->resource[0]->end < 0x20) && 130 + (p_dev->resource[1]->end >= 0x20)) 131 + p_dev->resource[0]->start = p_dev->resource[1]->start; 132 + 133 + if (p_dev->resource[0]->start >= 0xffff) 134 + return -EINVAL; 135 + 136 + p_dev->resource[1]->start = p_dev->resource[1]->end = 0; 137 + p_dev->resource[0]->end = 0x20; 138 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 139 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 140 + 141 + return pcmcia_request_io(p_dev); 140 142 } 141 143 142 144 static int aha152x_config_cs(struct pcmcia_device *link)
+5 -8
drivers/scsi/pcmcia/fdomain_stub.c
··· 82 82 83 83 info->p_dev = link; 84 84 link->priv = info; 85 - link->resource[0]->end = 0x10; 86 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 87 - link->config_flags |= CONF_ENABLE_IRQ; 85 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 88 86 link->config_regs = PRESENT_OPTION; 89 87 90 88 return fdomain_config(link); ··· 101 103 102 104 /*====================================================================*/ 103 105 104 - static int fdomain_config_check(struct pcmcia_device *p_dev, 105 - cistpl_cftable_entry_t *cfg, 106 - cistpl_cftable_entry_t *dflt, 107 - void *priv_data) 106 + static int fdomain_config_check(struct pcmcia_device *p_dev, void *priv_data) 108 107 { 109 108 p_dev->io_lines = 10; 110 - p_dev->resource[0]->start = cfg->io.win[0].base; 109 + p_dev->resource[0]->end = 0x10; 110 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 111 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 111 112 return pcmcia_request_io(p_dev); 112 113 } 113 114
+9 -38
drivers/scsi/pcmcia/nsp_cs.c
··· 1556 1556 1557 1557 nsp_dbg(NSP_DEBUG_INIT, "info=0x%p", info); 1558 1558 1559 - /* The io structure describes IO port mapping */ 1560 - link->resource[0]->end = 0x10; 1561 - link->resource[0]->flags = IO_DATA_PATH_WIDTH_AUTO; 1562 - 1563 - /* General socket configuration */ 1564 - link->config_flags |= CONF_ENABLE_IRQ; 1565 - 1566 1559 ret = nsp_cs_config(link); 1567 1560 1568 1561 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); ··· 1587 1594 ethernet device available to the system. 1588 1595 ======================================================================*/ 1589 1596 1590 - static int nsp_cs_config_check(struct pcmcia_device *p_dev, 1591 - cistpl_cftable_entry_t *cfg, 1592 - cistpl_cftable_entry_t *dflt, 1593 - void *priv_data) 1597 + static int nsp_cs_config_check(struct pcmcia_device *p_dev, void *priv_data) 1594 1598 { 1595 1599 nsp_hw_data *data = priv_data; 1596 1600 1597 - if (cfg->index == 0) 1601 + if (p_dev->config_index == 0) 1598 1602 return -ENODEV; 1599 1603 1600 - /* IO window settings */ 1601 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 1602 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 1603 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 1604 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 1605 - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 1606 - p_dev->resource[0]->flags |= 1607 - pcmcia_io_cfg_data_width(io->flags); 1608 - p_dev->resource[0]->start = io->win[0].base; 1609 - p_dev->resource[0]->end = io->win[0].len; 1610 - if (io->nwin > 1) { 1611 - p_dev->resource[1]->flags = p_dev->resource[0]->flags; 1612 - p_dev->resource[1]->start = io->win[1].base; 1613 - p_dev->resource[1]->end = io->win[1].len; 1614 - } 1615 - /* This reserves IO space but doesn't actually enable it */ 1616 - if (pcmcia_request_io(p_dev) != 0) 1617 - goto next_entry; 1618 - } 1604 + /* This reserves IO space but doesn't actually enable it */ 1605 + if (pcmcia_request_io(p_dev) != 0) 1606 + goto next_entry; 1619 1607 1620 - if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { 1621 - cistpl_mem_t *mem = 1622 - (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; 1608 + if (resource_size(p_dev->resource[2])) { 1623 1609 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 | 1624 1610 WIN_MEMORY_TYPE_CM | 1625 1611 WIN_ENABLE); 1626 - p_dev->resource[2]->start = mem->win[0].host_addr; 1627 - p_dev->resource[2]->end = mem->win[0].len; 1628 1612 if (p_dev->resource[2]->end < 0x1000) 1629 1613 p_dev->resource[2]->end = 0x1000; 1630 1614 if (pcmcia_request_window(p_dev, p_dev->resource[2], 0) != 0) 1631 1615 goto next_entry; 1632 1616 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2], 1633 - mem->win[0].card_addr) != 0) 1617 + p_dev->card_addr) != 0) 1634 1618 goto next_entry; 1635 1619 1636 1620 data->MmioAddress = (unsigned long) ··· 1634 1664 nsp_dbg(NSP_DEBUG_INIT, "in"); 1635 1665 1636 1666 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC | 1637 - CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO; 1667 + CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_SET_IOMEM | 1668 + CONF_AUTO_SET_IO; 1638 1669 1639 1670 ret = pcmcia_loop_config(link, nsp_cs_config_check, data); 1640 1671 if (ret)
+4 -9
drivers/scsi/pcmcia/qlogic_stub.c
··· 155 155 return -ENOMEM; 156 156 info->p_dev = link; 157 157 link->priv = info; 158 - link->resource[0]->end = 16; 159 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 160 - link->config_flags |= CONF_ENABLE_IRQ; 158 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 161 159 link->config_regs = PRESENT_OPTION; 162 160 163 161 return qlogic_config(link); ··· 174 176 175 177 /*====================================================================*/ 176 178 177 - static int qlogic_config_check(struct pcmcia_device *p_dev, 178 - cistpl_cftable_entry_t *cfg, 179 - cistpl_cftable_entry_t *dflt, 180 - void *priv_data) 179 + static int qlogic_config_check(struct pcmcia_device *p_dev, void *priv_data) 181 180 { 182 181 p_dev->io_lines = 10; 183 - p_dev->resource[0]->start = cfg->io.win[0].base; 184 - p_dev->resource[0]->end = cfg->io.win[0].len; 182 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 183 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 185 184 186 185 if (p_dev->resource[0]->start == 0) 187 186 return -ENODEV;
+4 -9
drivers/scsi/pcmcia/sym53c500_cs.c
··· 683 683 .shost_attrs = SYM53C500_shost_attrs 684 684 }; 685 685 686 - static int SYM53C500_config_check(struct pcmcia_device *p_dev, 687 - cistpl_cftable_entry_t *cfg, 688 - cistpl_cftable_entry_t *dflt, 689 - void *priv_data) 686 + static int SYM53C500_config_check(struct pcmcia_device *p_dev, void *priv_data) 690 687 { 691 688 p_dev->io_lines = 10; 692 - p_dev->resource[0]->start = cfg->io.win[0].base; 693 - p_dev->resource[0]->end = cfg->io.win[0].len; 689 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 690 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 694 691 695 692 if (p_dev->resource[0]->start == 0) 696 693 return -ENODEV; ··· 854 857 return -ENOMEM; 855 858 info->p_dev = link; 856 859 link->priv = info; 857 - link->resource[0]->end = 16; 858 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 859 - link->config_flags |= CONF_ENABLE_IRQ; 860 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 860 861 861 862 return SYM53C500_config(link); 862 863 } /* SYM53C500_attach */
+67 -65
drivers/serial/serial_cs.c
··· 424 424 return -ENODEV; 425 425 } 426 426 427 - static int simple_config_check(struct pcmcia_device *p_dev, 428 - cistpl_cftable_entry_t *cf, 429 - cistpl_cftable_entry_t *dflt, 430 - void *priv_data) 427 + static int simple_config_check(struct pcmcia_device *p_dev, void *priv_data) 431 428 { 432 429 static const int size_table[2] = { 8, 16 }; 433 430 int *try = priv_data; 434 431 435 - p_dev->io_lines = ((*try & 0x1) == 0) ? 436 - 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 432 + if (p_dev->resource[0]->start == 0) 433 + return -ENODEV; 437 434 438 - if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[(*try >> 1)]) 439 - && (cf->io.win[0].base != 0)) { 440 - p_dev->resource[0]->start = cf->io.win[0].base; 441 - if (!pcmcia_request_io(p_dev)) 442 - return 0; 443 - } 444 - return -EINVAL; 435 + if ((*try & 0x1) == 0) 436 + p_dev->io_lines = 16; 437 + 438 + if (p_dev->resource[0]->end != size_table[(*try >> 1)]) 439 + return -ENODEV; 440 + 441 + p_dev->resource[0]->end = 8; 442 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 443 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 444 + 445 + return pcmcia_request_io(p_dev); 445 446 } 446 447 447 448 static int simple_config_check_notpicky(struct pcmcia_device *p_dev, 448 - cistpl_cftable_entry_t *cf, 449 - cistpl_cftable_entry_t *dflt, 450 449 void *priv_data) 451 450 { 452 451 static const unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 453 452 int j; 454 453 455 - if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 456 - for (j = 0; j < 5; j++) { 457 - p_dev->resource[0]->start = base[j]; 458 - p_dev->io_lines = base[j] ? 16 : 3; 459 - if (!pcmcia_request_io(p_dev)) 460 - return 0; 461 - } 454 + if (p_dev->io_lines > 3) 455 + return -ENODEV; 456 + 457 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 458 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 459 + p_dev->resource[0]->end = 8; 460 + 461 + for (j = 0; j < 5; j++) { 462 + p_dev->resource[0]->start = base[j]; 463 + p_dev->io_lines = base[j] ? 16 : 3; 464 + if (!pcmcia_request_io(p_dev)) 465 + return 0; 462 466 } 463 467 return -ENODEV; 464 468 } ··· 472 468 struct serial_info *info = link->priv; 473 469 int i = -ENODEV, try; 474 470 475 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 476 - link->resource[0]->end = 8; 477 - 478 471 /* First pass: look for a config entry that looks normal. 479 472 * Two tries: without IO aliases, then with aliases */ 480 - link->config_flags |= CONF_AUTO_SET_VPP; 473 + link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_SET_IO; 481 474 for (try = 0; try < 4; try++) 482 475 if (!pcmcia_loop_config(link, simple_config_check, &try)) 483 476 goto found_port; ··· 504 503 return setup_serial(link, info, link->resource[0]->start, link->irq); 505 504 } 506 505 507 - static int multi_config_check(struct pcmcia_device *p_dev, 508 - cistpl_cftable_entry_t *cf, 509 - cistpl_cftable_entry_t *dflt, 510 - void *priv_data) 506 + static int multi_config_check(struct pcmcia_device *p_dev, void *priv_data) 511 507 { 512 - int *base2 = priv_data; 508 + int *multi = priv_data; 509 + 510 + if (p_dev->resource[1]->end) 511 + return -EINVAL; 513 512 514 513 /* The quad port cards have bad CIS's, so just look for a 515 514 window larger than 8 ports and assume it will be right */ 516 - if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { 517 - p_dev->resource[0]->start = cf->io.win[0].base; 518 - p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 519 - if (!pcmcia_request_io(p_dev)) { 520 - *base2 = p_dev->resource[0]->start + 8; 521 - return 0; 522 - } 523 - } 524 - return -ENODEV; 515 + if (p_dev->resource[0]->end <= 8) 516 + return -EINVAL; 517 + 518 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 519 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 520 + p_dev->resource[0]->end = *multi * 8; 521 + 522 + if (pcmcia_request_io(p_dev)) 523 + return -ENODEV; 524 + return 0; 525 525 } 526 526 527 527 static int multi_config_check_notpicky(struct pcmcia_device *p_dev, 528 - cistpl_cftable_entry_t *cf, 529 - cistpl_cftable_entry_t *dflt, 530 528 void *priv_data) 531 529 { 532 530 int *base2 = priv_data; 533 531 534 - if (cf->io.nwin == 2) { 535 - p_dev->resource[0]->start = cf->io.win[0].base; 536 - p_dev->resource[1]->start = cf->io.win[1].base; 537 - p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 538 - if (!pcmcia_request_io(p_dev)) { 539 - *base2 = p_dev->resource[1]->start; 540 - return 0; 541 - } 542 - } 543 - return -ENODEV; 532 + if (!p_dev->resource[0]->end || !p_dev->resource[1]->end) 533 + return -ENODEV; 534 + 535 + p_dev->resource[0]->end = p_dev->resource[1]->end = 8; 536 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 537 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 538 + 539 + if (pcmcia_request_io(p_dev)) 540 + return -ENODEV; 541 + 542 + *base2 = p_dev->resource[0]->start + 8; 543 + return 0; 544 544 } 545 545 546 546 static int multi_config(struct pcmcia_device *link) ··· 549 547 struct serial_info *info = link->priv; 550 548 int i, base2 = 0; 551 549 550 + link->config_flags |= CONF_AUTO_SET_IO; 552 551 /* First, look for a generic full-sized window */ 553 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 554 - link->resource[0]->end = info->multi * 8; 555 - if (pcmcia_loop_config(link, multi_config_check, &base2)) { 552 + if (!pcmcia_loop_config(link, multi_config_check, &info->multi)) 553 + base2 = link->resource[0]->start + 8; 554 + else { 556 555 /* If that didn't work, look for two windows */ 557 - link->resource[0]->end = link->resource[1]->end = 8; 558 556 info->multi = 2; 559 557 if (pcmcia_loop_config(link, multi_config_check_notpicky, 560 558 &base2)) { ··· 589 587 link->config_index == 3) { 590 588 err = setup_serial(link, info, base2, 591 589 link->irq); 592 - base2 = link->resource[0]->start;; 590 + base2 = link->resource[0]->start; 593 591 } else { 594 592 err = setup_serial(link, info, link->resource[0]->start, 595 593 link->irq); ··· 613 611 return 0; 614 612 } 615 613 616 - static int serial_check_for_multi(struct pcmcia_device *p_dev, 617 - cistpl_cftable_entry_t *cf, 618 - cistpl_cftable_entry_t *dflt, 619 - void *priv_data) 614 + static int serial_check_for_multi(struct pcmcia_device *p_dev, void *priv_data) 620 615 { 621 616 struct serial_info *info = p_dev->priv; 622 617 623 - if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 624 - info->multi = cf->io.win[0].len >> 3; 618 + if (!p_dev->resource[0]->end) 619 + return -EINVAL; 625 620 626 - if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) && 627 - (cf->io.win[1].len == 8)) 621 + if ((!p_dev->resource[1]->end) && (p_dev->resource[0]->end % 8 == 0)) 622 + info->multi = p_dev->resource[0]->end >> 3; 623 + 624 + if ((p_dev->resource[1]->end) && (p_dev->resource[0]->end == 8) 625 + && (p_dev->resource[1]->end == 8)) 628 626 info->multi = 2; 629 627 630 628 return 0; /* break */
+5 -26
drivers/staging/comedi/drivers/cb_das16_cs.c
··· 710 710 711 711 712 712 static int das16cs_pcmcia_config_loop(struct pcmcia_device *p_dev, 713 - cistpl_cftable_entry_t *cfg, 714 - cistpl_cftable_entry_t *dflt, 715 713 void *priv_data) 716 714 { 717 - if (cfg->index == 0) 715 + if (p_dev->config_index == 0) 718 716 return -EINVAL; 719 717 720 - /* Do we need to allocate an interrupt? */ 721 - p_dev->config_flags |= CONF_ENABLE_IRQ; 722 - 723 - /* IO window settings */ 724 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 725 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 726 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 727 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 728 - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 729 - p_dev->resource[0]->flags |= 730 - pcmcia_io_cfg_data_width(io->flags); 731 - p_dev->resource[0]->start = io->win[0].base; 732 - p_dev->resource[0]->end = io->win[0].len; 733 - if (io->nwin > 1) { 734 - p_dev->resource[1]->flags = p_dev->resource[0]->flags; 735 - p_dev->resource[1]->start = io->win[1].base; 736 - p_dev->resource[1]->end = io->win[1].len; 737 - } 738 - /* This reserves IO space but doesn't actually enable it */ 739 - return pcmcia_request_io(p_dev); 740 - } 741 - 742 - return 0; 718 + return pcmcia_request_io(p_dev); 743 719 } 744 720 745 721 static void das16cs_pcmcia_config(struct pcmcia_device *link) ··· 723 747 int ret; 724 748 725 749 dev_dbg(&link->dev, "das16cs_pcmcia_config\n"); 750 + 751 + /* Do we need to allocate an interrupt? */ 752 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 726 753 727 754 ret = pcmcia_loop_config(link, das16cs_pcmcia_config_loop, NULL); 728 755 if (ret) {
+5 -26
drivers/staging/comedi/drivers/das08_cs.c
··· 192 192 193 193 194 194 static int das08_pcmcia_config_loop(struct pcmcia_device *p_dev, 195 - cistpl_cftable_entry_t *cfg, 196 - cistpl_cftable_entry_t *dflt, 197 195 void *priv_data) 198 196 { 199 - if (cfg->index == 0) 200 - return -ENODEV; 197 + if (p_dev->config_index == 0) 198 + return -EINVAL; 201 199 202 - /* Do we need to allocate an interrupt? */ 203 - p_dev->config_flags |= CONF_ENABLE_IRQ; 204 - 205 - /* IO window settings */ 206 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 207 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 208 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 209 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 210 - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 211 - p_dev->resource[0]->flags |= 212 - pcmcia_io_cfg_data_width(io->flags); 213 - p_dev->resource[0]->start = io->win[0].base; 214 - p_dev->resource[0]->end = io->win[0].len; 215 - if (io->nwin > 1) { 216 - p_dev->resource[1]->flags = p_dev->resource[0]->flags; 217 - p_dev->resource[1]->start = io->win[1].base; 218 - p_dev->resource[1]->end = io->win[1].len; 219 - } 220 - /* This reserves IO space but doesn't actually enable it */ 221 - return pcmcia_request_io(p_dev); 222 - } 223 - return 0; 200 + return pcmcia_request_io(p_dev); 224 201 } 225 202 226 203 ··· 214 237 int ret; 215 238 216 239 dev_dbg(&link->dev, "das08_pcmcia_config\n"); 240 + 241 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 217 242 218 243 ret = pcmcia_loop_config(link, das08_pcmcia_config_loop, NULL); 219 244 if (ret) {
+5 -27
drivers/staging/comedi/drivers/ni_daq_700.c
··· 530 530 ======================================================================*/ 531 531 532 532 static int dio700_pcmcia_config_loop(struct pcmcia_device *p_dev, 533 - cistpl_cftable_entry_t *cfg, 534 - cistpl_cftable_entry_t *dflt, 535 533 void *priv_data) 536 534 { 537 - if (cfg->index == 0) 538 - return -ENODEV; 535 + if (p_dev->config_index == 0) 536 + return -EINVAL; 539 537 540 - /* IO window settings */ 541 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 542 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 543 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 544 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 545 - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 546 - p_dev->resource[0]->flags |= 547 - pcmcia_io_cfg_data_width(io->flags); 548 - p_dev->resource[0]->start = io->win[0].base; 549 - p_dev->resource[0]->end = io->win[0].len; 550 - if (io->nwin > 1) { 551 - p_dev->resource[1]->flags = p_dev->resource[0]->flags; 552 - p_dev->resource[1]->start = io->win[1].base; 553 - p_dev->resource[1]->end = io->win[1].len; 554 - } 555 - /* This reserves IO space but doesn't actually enable it */ 556 - if (pcmcia_request_io(p_dev) != 0) 557 - return -ENODEV; 558 - } 559 - 560 - /* If we got this far, we're cool! */ 561 - return 0; 538 + return pcmcia_request_io(p_dev); 562 539 } 563 540 564 541 static void dio700_config(struct pcmcia_device *link) ··· 547 570 548 571 dev_dbg(&link->dev, "dio700_config\n"); 549 572 550 - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO; 573 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO | 574 + CONF_AUTO_SET_IO; 551 575 552 576 ret = pcmcia_loop_config(link, dio700_pcmcia_config_loop, NULL); 553 577 if (ret) {
+5 -27
drivers/staging/comedi/drivers/ni_daq_dio24.c
··· 282 282 ======================================================================*/ 283 283 284 284 static int dio24_pcmcia_config_loop(struct pcmcia_device *p_dev, 285 - cistpl_cftable_entry_t *cfg, 286 - cistpl_cftable_entry_t *dflt, 287 285 void *priv_data) 288 286 { 289 - if (cfg->index == 0) 290 - return -ENODEV; 287 + if (p_dev->config_index == 0) 288 + return -EINVAL; 291 289 292 - /* IO window settings */ 293 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 294 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 295 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 296 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 297 - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 298 - p_dev->resource[0]->flags |= 299 - pcmcia_io_cfg_data_width(io->flags); 300 - p_dev->resource[0]->start = io->win[0].base; 301 - p_dev->resource[0]->end = io->win[0].len; 302 - if (io->nwin > 1) { 303 - p_dev->resource[1]->flags = p_dev->resource[0]->flags; 304 - p_dev->resource[1]->start = io->win[1].base; 305 - p_dev->resource[1]->end = io->win[1].len; 306 - } 307 - /* This reserves IO space but doesn't actually enable it */ 308 - if (pcmcia_request_io(p_dev) != 0) 309 - return -ENODEV; 310 - } 311 - 312 - /* If we got this far, we're cool! */ 313 - return 0; 290 + return pcmcia_request_io(p_dev); 314 291 } 315 292 316 293 static void dio24_config(struct pcmcia_device *link) ··· 298 321 299 322 dev_dbg(&link->dev, "dio24_config\n"); 300 323 301 - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO; 324 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO | 325 + CONF_AUTO_SET_IO; 302 326 303 327 ret = pcmcia_loop_config(link, dio24_pcmcia_config_loop, NULL); 304 328 if (ret) {
+4 -28
drivers/staging/comedi/drivers/ni_labpc_cs.c
··· 261 261 ======================================================================*/ 262 262 263 263 static int labpc_pcmcia_config_loop(struct pcmcia_device *p_dev, 264 - cistpl_cftable_entry_t *cfg, 265 - cistpl_cftable_entry_t *dflt, 266 264 void *priv_data) 267 265 { 268 - if (cfg->index == 0) 269 - return -ENODEV; 266 + if (p_dev->config_index == 0) 267 + return -EINVAL; 270 268 271 - /* IO window settings */ 272 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 273 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 274 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 275 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 276 - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 277 - p_dev->resource[0]->flags |= 278 - pcmcia_io_cfg_data_width(io->flags); 279 - p_dev->resource[0]->start = io->win[0].base; 280 - p_dev->resource[0]->end = io->win[0].len; 281 - if (io->nwin > 1) { 282 - p_dev->resource[1]->flags = p_dev->resource[0]->flags; 283 - p_dev->resource[1]->start = io->win[1].base; 284 - p_dev->resource[1]->end = io->win[1].len; 285 - } 286 - /* This reserves IO space but doesn't actually enable it */ 287 - if (pcmcia_request_io(p_dev) != 0) 288 - return -ENODEV; 289 - } 290 - 291 - /* If we got this far, we're cool! */ 292 - return 0; 269 + return pcmcia_request_io(p_dev); 293 270 } 294 271 295 272 ··· 277 300 dev_dbg(&link->dev, "labpc_config\n"); 278 301 279 302 link->config_flags |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ | 280 - CONF_AUTO_AUDIO; 303 + CONF_AUTO_AUDIO | CONF_AUTO_SET_IO; 281 304 282 305 ret = pcmcia_loop_config(link, labpc_pcmcia_config_loop, NULL); 283 306 if (ret) { ··· 293 316 the I/O windows and the interrupt mapping, and putting the 294 317 card and host interface into "Memory and IO" mode. 295 318 */ 296 - p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ; 297 319 ret = pcmcia_enable_device(link); 298 320 if (ret) 299 321 goto failed;
+4 -10
drivers/staging/comedi/drivers/ni_mio_cs.c
··· 262 262 263 263 static int cs_attach(struct pcmcia_device *link) 264 264 { 265 - link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 266 - link->resource[0]->end = 16; 267 - link->config_flags |= CONF_ENABLE_IRQ; 268 - 269 265 cur_dev = link; 270 266 271 267 mio_cs_config(link); ··· 295 299 } 296 300 297 301 298 - static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, 299 - cistpl_cftable_entry_t *cfg, 300 - cistpl_cftable_entry_t *dflt, 301 - void *priv_data) 302 + static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data) 302 303 { 303 304 int base, ret; 304 305 305 - p_dev->resource[0]->end = cfg->io.win[0].len; 306 - p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; 306 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 307 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 307 308 308 309 for (base = 0x000; base < 0x400; base += 0x20) { 309 310 p_dev->resource[0]->start = base; ··· 317 324 int ret; 318 325 319 326 DPRINTK("mio_cs_config(link=%p)\n", link); 327 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 320 328 321 329 ret = pcmcia_loop_config(link, mio_pcmcia_config_loop, NULL); 322 330 if (ret) {
+5 -27
drivers/staging/comedi/drivers/quatech_daqp_cs.c
··· 1068 1068 ======================================================================*/ 1069 1069 1070 1070 1071 - static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev, 1072 - cistpl_cftable_entry_t *cfg, 1073 - cistpl_cftable_entry_t *dflt, 1074 - void *priv_data) 1071 + static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data) 1075 1072 { 1076 - if (cfg->index == 0) 1077 - return -ENODEV; 1073 + if (p_dev->config_index == 0) 1074 + return -EINVAL; 1078 1075 1079 - /* Do we need to allocate an interrupt? */ 1080 - p_dev->config_flags |= CONF_ENABLE_IRQ; 1081 - 1082 - /* IO window settings */ 1083 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 1084 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 1085 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 1086 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 1087 - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 1088 - p_dev->resource[0]->flags |= 1089 - pcmcia_io_cfg_data_width(io->flags); 1090 - p_dev->resource[0]->start = io->win[0].base; 1091 - p_dev->resource[0]->end = io->win[0].len; 1092 - if (io->nwin > 1) { 1093 - p_dev->resource[1]->flags = p_dev->resource[0]->flags; 1094 - p_dev->resource[1]->start = io->win[1].base; 1095 - p_dev->resource[1]->end = io->win[1].len; 1096 - } 1097 - } 1098 - 1099 - /* This reserves IO space but doesn't actually enable it */ 1100 1076 return pcmcia_request_io(p_dev); 1101 1077 } 1102 1078 ··· 1081 1105 int ret; 1082 1106 1083 1107 dev_dbg(&link->dev, "daqp_cs_config\n"); 1108 + 1109 + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 1084 1110 1085 1111 ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop, NULL); 1086 1112 if (ret) {
+11 -21
drivers/telephony/ixj_pcmcia.c
··· 31 31 { 32 32 dev_dbg(&p_dev->dev, "ixj_attach()\n"); 33 33 /* Create new ixj device */ 34 - p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 35 - p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 36 34 p_dev->priv = kzalloc(sizeof(struct ixj_info_t), GFP_KERNEL); 37 35 if (!p_dev->priv) { 38 36 return -ENOMEM; ··· 107 109 return; 108 110 } 109 111 110 - static int ixj_config_check(struct pcmcia_device *p_dev, 111 - cistpl_cftable_entry_t *cfg, 112 - cistpl_cftable_entry_t *dflt, 113 - void *priv_data) 112 + static int ixj_config_check(struct pcmcia_device *p_dev, void *priv_data) 114 113 { 115 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 116 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 117 - p_dev->resource[0]->start = io->win[0].base; 118 - p_dev->resource[0]->end = io->win[0].len; 119 - p_dev->io_lines = 3; 120 - if (io->nwin == 2) { 121 - p_dev->resource[1]->start = io->win[1].base; 122 - p_dev->resource[1]->end = io->win[1].len; 123 - } 124 - if (!pcmcia_request_io(p_dev)) 125 - return 0; 126 - } 127 - return -ENODEV; 114 + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; 115 + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 116 + p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH; 117 + p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 118 + p_dev->io_lines = 3; 119 + 120 + return pcmcia_request_io(p_dev); 128 121 } 129 122 130 123 static int ixj_config(struct pcmcia_device * link) 131 124 { 132 125 IXJ *j; 133 126 ixj_info_t *info; 134 - cistpl_cftable_entry_t dflt = { 0 }; 135 127 136 128 info = link->priv; 137 129 dev_dbg(&link->dev, "ixj_config\n"); 138 130 139 - if (pcmcia_loop_config(link, ixj_config_check, &dflt)) 131 + link->config_flags = CONF_AUTO_SET_IO; 132 + 133 + if (pcmcia_loop_config(link, ixj_config_check, NULL)) 140 134 goto failed; 141 135 142 136 if (pcmcia_enable_device(link))
+5 -21
drivers/usb/host/sl811_cs.c
··· 131 131 platform_device_unregister(&platform_dev); 132 132 } 133 133 134 - static int sl811_cs_config_check(struct pcmcia_device *p_dev, 135 - cistpl_cftable_entry_t *cfg, 136 - cistpl_cftable_entry_t *dflt, 137 - void *priv_data) 134 + static int sl811_cs_config_check(struct pcmcia_device *p_dev, void *priv_data) 138 135 { 139 - if (cfg->index == 0) 140 - return -ENODEV; 136 + if (p_dev->config_index == 0) 137 + return -EINVAL; 141 138 142 - /* IO window settings */ 143 - p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 144 - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 145 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 146 - p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 147 - 148 - p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 149 - p_dev->resource[0]->start = io->win[0].base; 150 - p_dev->resource[0]->end = io->win[0].len; 151 - 152 - return pcmcia_request_io(p_dev); 153 - } 154 - pcmcia_disable_device(p_dev); 155 - return -ENODEV; 139 + return pcmcia_request_io(p_dev); 156 140 } 157 141 158 142 ··· 148 164 dev_dbg(&link->dev, "sl811_cs_config\n"); 149 165 150 166 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP | 151 - CONF_AUTO_CHECK_VCC; 167 + CONF_AUTO_CHECK_VCC | CONF_AUTO_SET_IO; 152 168 153 169 if (pcmcia_loop_config(link, sl811_cs_config_check, NULL)) 154 170 goto failed;
+10 -20
include/pcmcia/ds.h
··· 93 93 /* device setup */ 94 94 unsigned int irq; 95 95 struct resource *resource[PCMCIA_NUM_RESOURCES]; 96 + resource_size_t card_addr; /* for the 1st IOMEM resource */ 96 97 unsigned int vpp; 97 98 98 99 unsigned int config_flags; /* CONF_ENABLE_ flags below */ ··· 176 175 /* loop CIS entries for valid configuration */ 177 176 int pcmcia_loop_config(struct pcmcia_device *p_dev, 178 177 int (*conf_check) (struct pcmcia_device *p_dev, 179 - cistpl_cftable_entry_t *cf, 180 - cistpl_cftable_entry_t *dflt, 181 178 void *priv_data), 182 179 void *priv_data); 183 180 ··· 224 225 #define IO_DATA_PATH_WIDTH_16 0x08 225 226 #define IO_DATA_PATH_WIDTH_AUTO 0x10 226 227 227 - /* convert flag found in cfgtable to data path width parameter */ 228 - static inline int pcmcia_io_cfg_data_width(unsigned int flags) 229 - { 230 - if (!(flags & CISTPL_IO_8BIT)) 231 - return IO_DATA_PATH_WIDTH_16; 232 - if (!(flags & CISTPL_IO_16BIT)) 233 - return IO_DATA_PATH_WIDTH_8; 234 - return IO_DATA_PATH_WIDTH_AUTO; 235 - } 236 - 237 228 /* IO memory */ 238 229 #define WIN_MEMORY_TYPE_CM 0x00 /* default */ 239 230 #define WIN_MEMORY_TYPE_AM 0x20 /* MAP_ATTRIB */ ··· 253 264 #define PRESENT_IOSIZE 0x200 254 265 255 266 /* flags to be passed to pcmcia_enable_device() */ 256 - #define CONF_ENABLE_IRQ 0x01 257 - #define CONF_ENABLE_SPKR 0x02 258 - #define CONF_ENABLE_PULSE_IRQ 0x04 259 - #define CONF_ENABLE_ESR 0x08 267 + #define CONF_ENABLE_IRQ 0x0001 268 + #define CONF_ENABLE_SPKR 0x0002 269 + #define CONF_ENABLE_PULSE_IRQ 0x0004 270 + #define CONF_ENABLE_ESR 0x0008 260 271 261 272 /* flags used by pcmcia_loop_config() autoconfiguration */ 262 - #define CONF_AUTO_CHECK_VCC 0x10 /* check for matching Vcc? */ 263 - #define CONF_AUTO_SET_VPP 0x20 /* set Vpp? */ 264 - #define CONF_AUTO_AUDIO 0x40 /* enable audio line? */ 265 - 273 + #define CONF_AUTO_CHECK_VCC 0x0100 /* check for matching Vcc? */ 274 + #define CONF_AUTO_SET_VPP 0x0200 /* set Vpp? */ 275 + #define CONF_AUTO_AUDIO 0x0400 /* enable audio line? */ 276 + #define CONF_AUTO_SET_IO 0x0800 /* set ->resource[0,1] */ 277 + #define CONF_AUTO_SET_IOMEM 0x1000 /* set ->resource[2] */ 266 278 267 279 #endif /* __KERNEL__ */ 268 280