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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (49 commits)
pcmcia: ioctl-internal definitions
pcmcia: cistpl header cleanup
pcmcia: remove unused argument to pcmcia_parse_tuple()
pcmcia: card services header cleanup
pcmcia: device_id header cleanup
pcmcia: encapsulate ioaddr_t
pcmcia: cleanup device driver header file
pcmcia: cleanup socket services header file
pcmcia: merge ds_internal.h into cs_internal.h
pcmcia: cleanup cs_internal.h
pcmcia: cs_internal.h is internal
pcmcia: use dev_printk for cs_error()
pcmcia: remove CS_ error codes alltogether
pcmcia: deprecate CS_BAD_TUPLE
pcmcia: deprecate CS_BAD_ARGS
pcmcia: deprecate CS_BAD_BASE, CS_BAD_IRQ, CS_BAD_OFFSET and CS_BAD_SIZE
pcmcia: deprecate CS_BAD_ATTRIBUTE, CS_BAD_TYPE and CS_BAD_PAGE
pcmcia: deprecate CS_NO_MORE_ITEMS
pcmcia: deprecate CS_IN_USE
pcmcia: deprecate CS_CONFIGURATION_LOCKED
...

Fix trivial conflict in drivers/pcmcia/ds.c manually

+3016 -3301
+6
Documentation/pcmcia/driver-changes.txt
··· 1 1 This file details changes in 2.6 which affect PCMCIA card driver authors: 2 2 3 + * New configuration loop helper (as of 2.6.28) 4 + By calling pcmcia_loop_config(), a driver can iterate over all available 5 + configuration options. During a driver's probe() phase, one doesn't need 6 + to use pcmcia_get_{first,next}_tuple, pcmcia_get_tuple_data and 7 + pcmcia_parse_tuple directly in most if not all cases. 8 + 3 9 * New release helper (as of 2.6.17) 4 10 Instead of calling pcmcia_release_{configuration,io,irq,win}, all that's 5 11 necessary now is calling pcmcia_disable_device. As there is no valid
+74 -92
drivers/ata/pata_pcmcia.c
··· 148 148 #define CS_CHECK(fn, ret) \ 149 149 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 150 150 151 + 152 + struct pcmcia_config_check { 153 + unsigned long ctl_base; 154 + int skip_vcc; 155 + int is_kme; 156 + }; 157 + 158 + static int pcmcia_check_one_config(struct pcmcia_device *pdev, 159 + cistpl_cftable_entry_t *cfg, 160 + cistpl_cftable_entry_t *dflt, 161 + unsigned int vcc, 162 + void *priv_data) 163 + { 164 + struct pcmcia_config_check *stk = priv_data; 165 + 166 + /* Check for matching Vcc, unless we're desperate */ 167 + if (!stk->skip_vcc) { 168 + if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 169 + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) 170 + return -ENODEV; 171 + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { 172 + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) 173 + return -ENODEV; 174 + } 175 + } 176 + 177 + if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 178 + pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 179 + else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) 180 + pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 181 + 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.BasePort1 = io->win[0].base; 185 + pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 186 + if (!(io->flags & CISTPL_IO_16BIT)) 187 + pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 188 + if (io->nwin == 2) { 189 + pdev->io.NumPorts1 = 8; 190 + pdev->io.BasePort2 = io->win[1].base; 191 + pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1; 192 + if (pcmcia_request_io(pdev, &pdev->io) != 0) 193 + return -ENODEV; 194 + stk->ctl_base = pdev->io.BasePort2; 195 + } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { 196 + pdev->io.NumPorts1 = io->win[0].len; 197 + pdev->io.NumPorts2 = 0; 198 + if (pcmcia_request_io(pdev, &pdev->io) != 0) 199 + return -ENODEV; 200 + stk->ctl_base = pdev->io.BasePort1 + 0x0e; 201 + } else 202 + return -ENODEV; 203 + /* If we've got this far, we're done */ 204 + return 0; 205 + } 206 + return -ENODEV; 207 + } 208 + 151 209 /** 152 210 * pcmcia_init_one - attach a PCMCIA interface 153 211 * @pdev: pcmcia device ··· 219 161 struct ata_host *host; 220 162 struct ata_port *ap; 221 163 struct ata_pcmcia_info *info; 222 - tuple_t tuple; 223 - struct { 224 - unsigned short buf[128]; 225 - cisparse_t parse; 226 - config_info_t conf; 227 - cistpl_cftable_entry_t dflt; 228 - } *stk = NULL; 229 - cistpl_cftable_entry_t *cfg; 230 - int pass, last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM, p; 164 + struct pcmcia_config_check *stk = NULL; 165 + int last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM, p; 231 166 unsigned long io_base, ctl_base; 232 167 void __iomem *io_addr, *ctl_addr; 233 168 int n_ports = 1; 234 - 235 169 struct ata_port_operations *ops = &pcmcia_port_ops; 236 170 237 171 info = kzalloc(sizeof(*info), GFP_KERNEL); ··· 243 193 pdev->conf.Attributes = CONF_ENABLE_IRQ; 244 194 pdev->conf.IntType = INT_MEMORY_AND_IO; 245 195 246 - /* Allocate resoure probing structures */ 247 - 248 - stk = kzalloc(sizeof(*stk), GFP_KERNEL); 249 - if (!stk) 250 - goto out1; 251 - 252 - cfg = &stk->parse.cftable_entry; 253 - 254 - /* Tuples we are walking */ 255 - tuple.TupleData = (cisdata_t *)&stk->buf; 256 - tuple.TupleOffset = 0; 257 - tuple.TupleDataMax = 255; 258 - tuple.Attributes = 0; 259 - 260 196 /* See if we have a manufacturer identifier. Use it to set is_kme for 261 197 vendor quirks */ 262 198 is_kme = ((pdev->manf_id == MANFID_KME) && 263 199 ((pdev->card_id == PRODID_KME_KXLC005_A) || 264 200 (pdev->card_id == PRODID_KME_KXLC005_B))); 265 201 266 - /* Not sure if this is right... look up the current Vcc */ 267 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf)); 268 - /* link->conf.Vcc = stk->conf.Vcc; */ 202 + /* Allocate resoure probing structures */ 269 203 270 - pass = io_base = ctl_base = 0; 271 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 272 - tuple.Attributes = 0; 273 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple)); 204 + stk = kzalloc(sizeof(*stk), GFP_KERNEL); 205 + if (!stk) 206 + goto out1; 207 + stk->is_kme = is_kme; 208 + stk->skip_vcc = io_base = ctl_base = 0; 274 209 275 - /* Now munch the resources looking for a suitable set */ 276 - while (1) { 277 - if (pcmcia_get_tuple_data(pdev, &tuple) != 0) 278 - goto next_entry; 279 - if (pcmcia_parse_tuple(pdev, &tuple, &stk->parse) != 0) 280 - goto next_entry; 281 - /* Check for matching Vcc, unless we're desperate */ 282 - if (!pass) { 283 - if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 284 - if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) 285 - goto next_entry; 286 - } else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { 287 - if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) 288 - goto next_entry; 289 - } 290 - } 291 - 292 - if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 293 - pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 294 - else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 295 - pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 296 - 297 - if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { 298 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; 299 - pdev->conf.ConfigIndex = cfg->index; 300 - pdev->io.BasePort1 = io->win[0].base; 301 - pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 302 - if (!(io->flags & CISTPL_IO_16BIT)) 303 - pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 304 - if (io->nwin == 2) { 305 - pdev->io.NumPorts1 = 8; 306 - pdev->io.BasePort2 = io->win[1].base; 307 - pdev->io.NumPorts2 = (is_kme) ? 2 : 1; 308 - if (pcmcia_request_io(pdev, &pdev->io) != 0) 309 - goto next_entry; 310 - io_base = pdev->io.BasePort1; 311 - ctl_base = pdev->io.BasePort2; 312 - } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { 313 - pdev->io.NumPorts1 = io->win[0].len; 314 - pdev->io.NumPorts2 = 0; 315 - if (pcmcia_request_io(pdev, &pdev->io) != 0) 316 - goto next_entry; 317 - io_base = pdev->io.BasePort1; 318 - ctl_base = pdev->io.BasePort1 + 0x0e; 319 - } else 320 - goto next_entry; 321 - /* If we've got this far, we're done */ 322 - break; 323 - } 324 - next_entry: 325 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 326 - memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); 327 - if (pass) { 328 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(pdev, &tuple)); 329 - } else if (pcmcia_get_next_tuple(pdev, &tuple) != 0) { 330 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple)); 331 - memset(&stk->dflt, 0, sizeof(stk->dflt)); 332 - pass++; 333 - } 210 + if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) { 211 + stk->skip_vcc = 1; 212 + if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) 213 + goto failed; /* No suitable config found */ 334 214 } 335 - 215 + io_base = pdev->io.BasePort1; 216 + ctl_base = stk->ctl_base; 336 217 CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq)); 337 218 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf)); 338 219 ··· 365 384 PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), 366 385 PCMCIA_DEVICE_MANF_CARD(0x0032, 0x2904), 367 386 PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ 387 + PCMCIA_DEVICE_MANF_CARD(0x004f, 0x0000), /* Kingston */ 368 388 PCMCIA_DEVICE_MANF_CARD(0x0097, 0x1620), /* TI emulated */ 369 389 PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ 370 390 PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), ··· 386 404 PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591), 387 405 PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728), 388 406 PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), 389 - PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), 390 407 PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), 391 408 PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), 409 + PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), 392 410 PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), 393 411 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), 394 412 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e),
+4 -4
drivers/bluetooth/bluecard_cs.c
··· 901 901 for (n = 0; n < 0x400; n += 0x40) { 902 902 link->io.BasePort1 = n ^ 0x300; 903 903 i = pcmcia_request_io(link, &link->io); 904 - if (i == CS_SUCCESS) 904 + if (i == 0) 905 905 break; 906 906 } 907 907 908 - if (i != CS_SUCCESS) { 908 + if (i != 0) { 909 909 cs_error(link, RequestIO, i); 910 910 goto failed; 911 911 } 912 912 913 913 i = pcmcia_request_irq(link, &link->irq); 914 - if (i != CS_SUCCESS) { 914 + if (i != 0) { 915 915 cs_error(link, RequestIRQ, i); 916 916 link->irq.AssignedIRQ = 0; 917 917 } 918 918 919 919 i = pcmcia_request_configuration(link, &link->conf); 920 - if (i != CS_SUCCESS) { 920 + if (i != 0) { 921 921 cs_error(link, RequestConfiguration, i); 922 922 goto failed; 923 923 }
+48 -71
drivers/bluetooth/bt3c_cs.c
··· 678 678 kfree(info); 679 679 } 680 680 681 - static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 681 + static int bt3c_check_config(struct pcmcia_device *p_dev, 682 + cistpl_cftable_entry_t *cf, 683 + cistpl_cftable_entry_t *dflt, 684 + unsigned int vcc, 685 + void *priv_data) 682 686 { 683 - int i; 687 + unsigned long try = (unsigned long) priv_data; 684 688 685 - i = pcmcia_get_tuple_data(handle, tuple); 686 - if (i != CS_SUCCESS) 687 - return i; 688 - 689 - return pcmcia_parse_tuple(handle, tuple, parse); 689 + if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 690 + p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 691 + if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && 692 + (cf->io.win[0].base != 0)) { 693 + p_dev->io.BasePort1 = cf->io.win[0].base; 694 + p_dev->io.IOAddrLines = (try == 0) ? 16 : 695 + cf->io.flags & CISTPL_IO_LINES_MASK; 696 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 697 + return 0; 698 + } 699 + return -ENODEV; 690 700 } 691 701 692 - static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 702 + static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev, 703 + cistpl_cftable_entry_t *cf, 704 + cistpl_cftable_entry_t *dflt, 705 + unsigned int vcc, 706 + void *priv_data) 693 707 { 694 - if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) 695 - return CS_NO_MORE_ITEMS; 696 - return get_tuple(handle, tuple, parse); 697 - } 708 + static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 709 + int j; 698 710 699 - static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 700 - { 701 - if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) 702 - return CS_NO_MORE_ITEMS; 703 - return get_tuple(handle, tuple, parse); 711 + if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 712 + for (j = 0; j < 5; j++) { 713 + p_dev->io.BasePort1 = base[j]; 714 + p_dev->io.IOAddrLines = base[j] ? 16 : 3; 715 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 716 + return 0; 717 + } 718 + } 719 + return -ENODEV; 704 720 } 705 721 706 722 static int bt3c_config(struct pcmcia_device *link) 707 723 { 708 - static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 709 724 bt3c_info_t *info = link->priv; 710 - tuple_t tuple; 711 - u_short buf[256]; 712 - cisparse_t parse; 713 - cistpl_cftable_entry_t *cf = &parse.cftable_entry; 714 - int i, j, try; 725 + int i; 726 + unsigned long try; 715 727 716 - /* First pass: look for a config entry that looks normal. */ 717 - tuple.TupleData = (cisdata_t *)buf; 718 - tuple.TupleOffset = 0; 719 - tuple.TupleDataMax = 255; 720 - tuple.Attributes = 0; 721 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 722 - /* Two tries: without IO aliases, then with aliases */ 723 - for (try = 0; try < 2; try++) { 724 - i = first_tuple(link, &tuple, &parse); 725 - while (i != CS_NO_MORE_ITEMS) { 726 - if (i != CS_SUCCESS) 727 - goto next_entry; 728 - if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 729 - link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 730 - if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { 731 - link->conf.ConfigIndex = cf->index; 732 - link->io.BasePort1 = cf->io.win[0].base; 733 - link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 734 - i = pcmcia_request_io(link, &link->io); 735 - if (i == CS_SUCCESS) 736 - goto found_port; 737 - } 738 - next_entry: 739 - i = next_tuple(link, &tuple, &parse); 740 - } 741 - } 728 + /* First pass: look for a config entry that looks normal. 729 + Two tries: without IO aliases, then with aliases */ 730 + for (try = 0; try < 2; try++) 731 + if (!pcmcia_loop_config(link, bt3c_check_config, (void *) try)) 732 + goto found_port; 742 733 743 734 /* Second pass: try to find an entry that isn't picky about 744 735 its base address, then try to grab any standard serial port 745 736 address, and finally try to get any free port. */ 746 - i = first_tuple(link, &tuple, &parse); 747 - while (i != CS_NO_MORE_ITEMS) { 748 - if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 749 - link->conf.ConfigIndex = cf->index; 750 - for (j = 0; j < 5; j++) { 751 - link->io.BasePort1 = base[j]; 752 - link->io.IOAddrLines = base[j] ? 16 : 3; 753 - i = pcmcia_request_io(link, &link->io); 754 - if (i == CS_SUCCESS) 755 - goto found_port; 756 - } 757 - } 758 - i = next_tuple(link, &tuple, &parse); 759 - } 737 + if (!pcmcia_loop_config(link, bt3c_check_config_notpicky, NULL)) 738 + goto found_port; 739 + 740 + BT_ERR("No usable port range found"); 741 + cs_error(link, RequestIO, -ENODEV); 742 + goto failed; 760 743 761 744 found_port: 762 - if (i != CS_SUCCESS) { 763 - BT_ERR("No usable port range found"); 764 - cs_error(link, RequestIO, i); 765 - goto failed; 766 - } 767 - 768 745 i = pcmcia_request_irq(link, &link->irq); 769 - if (i != CS_SUCCESS) { 746 + if (i != 0) { 770 747 cs_error(link, RequestIRQ, i); 771 748 link->irq.AssignedIRQ = 0; 772 749 } 773 750 774 751 i = pcmcia_request_configuration(link, &link->conf); 775 - if (i != CS_SUCCESS) { 752 + if (i != 0) { 776 753 cs_error(link, RequestConfiguration, i); 777 754 goto failed; 778 755 }
+48 -72
drivers/bluetooth/btuart_cs.c
··· 607 607 kfree(info); 608 608 } 609 609 610 - static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 610 + static int btuart_check_config(struct pcmcia_device *p_dev, 611 + cistpl_cftable_entry_t *cf, 612 + cistpl_cftable_entry_t *dflt, 613 + unsigned int vcc, 614 + void *priv_data) 611 615 { 612 - int i; 616 + int *try = priv_data; 613 617 614 - i = pcmcia_get_tuple_data(handle, tuple); 615 - if (i != CS_SUCCESS) 616 - return i; 617 - 618 - return pcmcia_parse_tuple(handle, tuple, parse); 618 + if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 619 + p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 620 + if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && 621 + (cf->io.win[0].base != 0)) { 622 + p_dev->io.BasePort1 = cf->io.win[0].base; 623 + p_dev->io.IOAddrLines = (*try == 0) ? 16 : 624 + cf->io.flags & CISTPL_IO_LINES_MASK; 625 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 626 + return 0; 627 + } 628 + return -ENODEV; 619 629 } 620 630 621 - static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 631 + static int btuart_check_config_notpicky(struct pcmcia_device *p_dev, 632 + cistpl_cftable_entry_t *cf, 633 + cistpl_cftable_entry_t *dflt, 634 + unsigned int vcc, 635 + void *priv_data) 622 636 { 623 - if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) 624 - return CS_NO_MORE_ITEMS; 625 - return get_tuple(handle, tuple, parse); 626 - } 637 + static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 638 + int j; 627 639 628 - static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 629 - { 630 - if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) 631 - return CS_NO_MORE_ITEMS; 632 - return get_tuple(handle, tuple, parse); 640 + if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 641 + for (j = 0; j < 5; j++) { 642 + p_dev->io.BasePort1 = base[j]; 643 + p_dev->io.IOAddrLines = base[j] ? 16 : 3; 644 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 645 + return 0; 646 + } 647 + } 648 + return -ENODEV; 633 649 } 634 650 635 651 static int btuart_config(struct pcmcia_device *link) 636 652 { 637 - static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 638 653 btuart_info_t *info = link->priv; 639 - tuple_t tuple; 640 - u_short buf[256]; 641 - cisparse_t parse; 642 - cistpl_cftable_entry_t *cf = &parse.cftable_entry; 643 - int i, j, try; 654 + int i; 655 + int try; 644 656 645 - /* First pass: look for a config entry that looks normal. */ 646 - tuple.TupleData = (cisdata_t *) buf; 647 - tuple.TupleOffset = 0; 648 - tuple.TupleDataMax = 255; 649 - tuple.Attributes = 0; 650 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 651 - /* Two tries: without IO aliases, then with aliases */ 652 - for (try = 0; try < 2; try++) { 653 - i = first_tuple(link, &tuple, &parse); 654 - while (i != CS_NO_MORE_ITEMS) { 655 - if (i != CS_SUCCESS) 656 - goto next_entry; 657 - if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 658 - link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 659 - if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { 660 - link->conf.ConfigIndex = cf->index; 661 - link->io.BasePort1 = cf->io.win[0].base; 662 - link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 663 - i = pcmcia_request_io(link, &link->io); 664 - if (i == CS_SUCCESS) 665 - goto found_port; 666 - } 667 - next_entry: 668 - i = next_tuple(link, &tuple, &parse); 669 - } 670 - } 657 + /* First pass: look for a config entry that looks normal. 658 + Two tries: without IO aliases, then with aliases */ 659 + for (try = 0; try < 2; try++) 660 + if (!pcmcia_loop_config(link, btuart_check_config, &try)) 661 + goto found_port; 671 662 672 663 /* Second pass: try to find an entry that isn't picky about 673 664 its base address, then try to grab any standard serial port 674 665 address, and finally try to get any free port. */ 675 - i = first_tuple(link, &tuple, &parse); 676 - while (i != CS_NO_MORE_ITEMS) { 677 - if ((i == CS_SUCCESS) && (cf->io.nwin > 0) 678 - && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 679 - link->conf.ConfigIndex = cf->index; 680 - for (j = 0; j < 5; j++) { 681 - link->io.BasePort1 = base[j]; 682 - link->io.IOAddrLines = base[j] ? 16 : 3; 683 - i = pcmcia_request_io(link, &link->io); 684 - if (i == CS_SUCCESS) 685 - goto found_port; 686 - } 687 - } 688 - i = next_tuple(link, &tuple, &parse); 689 - } 666 + if (!pcmcia_loop_config(link, btuart_check_config_notpicky, NULL)) 667 + goto found_port; 668 + 669 + BT_ERR("No usable port range found"); 670 + cs_error(link, RequestIO, -ENODEV); 671 + goto failed; 690 672 691 673 found_port: 692 - if (i != CS_SUCCESS) { 693 - BT_ERR("No usable port range found"); 694 - cs_error(link, RequestIO, i); 695 - goto failed; 696 - } 697 - 698 674 i = pcmcia_request_irq(link, &link->irq); 699 - if (i != CS_SUCCESS) { 675 + if (i != 0) { 700 676 cs_error(link, RequestIRQ, i); 701 677 link->irq.AssignedIRQ = 0; 702 678 } 703 679 704 680 i = pcmcia_request_configuration(link, &link->conf); 705 - if (i != CS_SUCCESS) { 681 + if (i != 0) { 706 682 cs_error(link, RequestConfiguration, i); 707 683 goto failed; 708 684 }
+16 -51
drivers/bluetooth/dtl1_cs.c
··· 590 590 kfree(info); 591 591 } 592 592 593 - static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 593 + static int dtl1_confcheck(struct pcmcia_device *p_dev, 594 + cistpl_cftable_entry_t *cf, 595 + cistpl_cftable_entry_t *dflt, 596 + unsigned int vcc, 597 + void *priv_data) 594 598 { 595 - int i; 596 - 597 - i = pcmcia_get_tuple_data(handle, tuple); 598 - if (i != CS_SUCCESS) 599 - return i; 600 - 601 - return pcmcia_parse_tuple(handle, tuple, parse); 602 - } 603 - 604 - static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 605 - { 606 - if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) 607 - return CS_NO_MORE_ITEMS; 608 - return get_tuple(handle, tuple, parse); 609 - } 610 - 611 - static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 612 - { 613 - if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) 614 - return CS_NO_MORE_ITEMS; 615 - return get_tuple(handle, tuple, parse); 599 + if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { 600 + p_dev->io.BasePort1 = cf->io.win[0].base; 601 + p_dev->io.NumPorts1 = cf->io.win[0].len; /*yo */ 602 + p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 603 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 604 + return 0; 605 + } 606 + return -ENODEV; 616 607 } 617 608 618 609 static int dtl1_config(struct pcmcia_device *link) 619 610 { 620 611 dtl1_info_t *info = link->priv; 621 - tuple_t tuple; 622 - u_short buf[256]; 623 - cisparse_t parse; 624 - cistpl_cftable_entry_t *cf = &parse.cftable_entry; 625 612 int i; 626 - 627 - tuple.TupleData = (cisdata_t *)buf; 628 - tuple.TupleOffset = 0; 629 - tuple.TupleDataMax = 255; 630 - tuple.Attributes = 0; 631 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 632 613 633 614 /* Look for a generic full-sized window */ 634 615 link->io.NumPorts1 = 8; 635 - i = first_tuple(link, &tuple, &parse); 636 - while (i != CS_NO_MORE_ITEMS) { 637 - if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { 638 - link->conf.ConfigIndex = cf->index; 639 - link->io.BasePort1 = cf->io.win[0].base; 640 - link->io.NumPorts1 = cf->io.win[0].len; /*yo */ 641 - link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 642 - i = pcmcia_request_io(link, &link->io); 643 - if (i == CS_SUCCESS) 644 - break; 645 - } 646 - i = next_tuple(link, &tuple, &parse); 647 - } 648 - 649 - if (i != CS_SUCCESS) { 650 - cs_error(link, RequestIO, i); 616 + if (!pcmcia_loop_config(link, dtl1_confcheck, NULL)) 651 617 goto failed; 652 - } 653 618 654 619 i = pcmcia_request_irq(link, &link->irq); 655 - if (i != CS_SUCCESS) { 620 + if (i != 0) { 656 621 cs_error(link, RequestIRQ, i); 657 622 link->irq.AssignedIRQ = 0; 658 623 } 659 624 660 625 i = pcmcia_request_configuration(link, &link->conf); 661 - if (i != CS_SUCCESS) { 626 + if (i != 0) { 662 627 cs_error(link, RequestConfiguration, i); 663 628 goto failed; 664 629 }
+24 -49
drivers/char/pcmcia/cm4000_cs.c
··· 1759 1759 1760 1760 /*==== Interface to PCMCIA Layer =======================================*/ 1761 1761 1762 + static int cm4000_config_check(struct pcmcia_device *p_dev, 1763 + cistpl_cftable_entry_t *cfg, 1764 + cistpl_cftable_entry_t *dflt, 1765 + unsigned int vcc, 1766 + void *priv_data) 1767 + { 1768 + if (!cfg->io.nwin) 1769 + return -ENODEV; 1770 + 1771 + /* Get the IOaddr */ 1772 + p_dev->io.BasePort1 = cfg->io.win[0].base; 1773 + p_dev->io.NumPorts1 = cfg->io.win[0].len; 1774 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 1775 + if (!(cfg->io.flags & CISTPL_IO_8BIT)) 1776 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 1777 + if (!(cfg->io.flags & CISTPL_IO_16BIT)) 1778 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1779 + p_dev->io.IOAddrLines = cfg->io.flags & CISTPL_IO_LINES_MASK; 1780 + 1781 + return pcmcia_request_io(p_dev, &p_dev->io); 1782 + } 1783 + 1762 1784 static int cm4000_config(struct pcmcia_device * link, int devno) 1763 1785 { 1764 1786 struct cm4000_dev *dev; 1765 - tuple_t tuple; 1766 - cisparse_t parse; 1767 - u_char buf[64]; 1768 - int fail_fn, fail_rc; 1769 - int rc; 1770 1787 1771 1788 /* read the config-tuples */ 1772 - tuple.Attributes = 0; 1773 - tuple.TupleData = buf; 1774 - tuple.TupleDataMax = sizeof(buf); 1775 - tuple.TupleOffset = 0; 1776 - 1777 - link->io.BasePort2 = 0; 1778 - link->io.NumPorts2 = 0; 1779 - link->io.Attributes2 = 0; 1780 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 1781 - for (rc = pcmcia_get_first_tuple(link, &tuple); 1782 - rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(link, &tuple)) { 1783 - 1784 - rc = pcmcia_get_tuple_data(link, &tuple); 1785 - if (rc != CS_SUCCESS) 1786 - continue; 1787 - rc = pcmcia_parse_tuple(link, &tuple, &parse); 1788 - if (rc != CS_SUCCESS) 1789 - continue; 1790 - 1791 - link->conf.ConfigIndex = parse.cftable_entry.index; 1792 - 1793 - if (!parse.cftable_entry.io.nwin) 1794 - continue; 1795 - 1796 - /* Get the IOaddr */ 1797 - link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 1798 - link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; 1799 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 1800 - if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT)) 1801 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 1802 - if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT)) 1803 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1804 - link->io.IOAddrLines = parse.cftable_entry.io.flags 1805 - & CISTPL_IO_LINES_MASK; 1806 - 1807 - rc = pcmcia_request_io(link, &link->io); 1808 - if (rc == CS_SUCCESS) 1809 - break; /* we are done */ 1810 - } 1811 - if (rc != CS_SUCCESS) 1789 + if (pcmcia_loop_config(link, cm4000_config_check, NULL)) 1812 1790 goto cs_release; 1813 1791 1814 1792 link->conf.IntType = 00000002; 1815 1793 1816 - if ((fail_rc = 1817 - pcmcia_request_configuration(link, &link->conf)) != CS_SUCCESS) { 1818 - fail_fn = RequestConfiguration; 1794 + if (pcmcia_request_configuration(link, &link->conf)) 1819 1795 goto cs_release; 1820 - } 1821 1796 1822 1797 dev = link->priv; 1823 1798 sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
+31 -47
drivers/char/pcmcia/cm4040_cs.c
··· 526 526 return; 527 527 } 528 528 529 + static int cm4040_config_check(struct pcmcia_device *p_dev, 530 + cistpl_cftable_entry_t *cfg, 531 + cistpl_cftable_entry_t *dflt, 532 + unsigned int vcc, 533 + void *priv_data) 534 + { 535 + int rc; 536 + if (!cfg->io.nwin) 537 + return -ENODEV; 538 + 539 + /* Get the IOaddr */ 540 + p_dev->io.BasePort1 = cfg->io.win[0].base; 541 + p_dev->io.NumPorts1 = cfg->io.win[0].len; 542 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 543 + if (!(cfg->io.flags & CISTPL_IO_8BIT)) 544 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 545 + if (!(cfg->io.flags & CISTPL_IO_16BIT)) 546 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 547 + p_dev->io.IOAddrLines = cfg->io.flags & CISTPL_IO_LINES_MASK; 548 + 549 + rc = pcmcia_request_io(p_dev, &p_dev->io); 550 + dev_printk(KERN_INFO, &handle_to_dev(p_dev), 551 + "pcmcia_request_io returned 0x%x\n", rc); 552 + return rc; 553 + } 554 + 555 + 529 556 static int reader_config(struct pcmcia_device *link, int devno) 530 557 { 531 558 struct reader_dev *dev; 532 - tuple_t tuple; 533 - cisparse_t parse; 534 - u_char buf[64]; 535 - int fail_fn, fail_rc; 536 - int rc; 537 - 538 - tuple.Attributes = 0; 539 - tuple.TupleData = buf; 540 - tuple.TupleDataMax = sizeof(buf); 541 - tuple.TupleOffset = 0; 559 + int fail_rc; 542 560 543 561 link->io.BasePort2 = 0; 544 562 link->io.NumPorts2 = 0; 545 563 link->io.Attributes2 = 0; 546 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 547 - for (rc = pcmcia_get_first_tuple(link, &tuple); 548 - rc == CS_SUCCESS; 549 - rc = pcmcia_get_next_tuple(link, &tuple)) { 550 - rc = pcmcia_get_tuple_data(link, &tuple); 551 - if (rc != CS_SUCCESS) 552 - continue; 553 - rc = pcmcia_parse_tuple(link, &tuple, &parse); 554 - if (rc != CS_SUCCESS) 555 - continue; 556 564 557 - link->conf.ConfigIndex = parse.cftable_entry.index; 558 - 559 - if (!parse.cftable_entry.io.nwin) 560 - continue; 561 - 562 - link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 563 - link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; 564 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 565 - if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT)) 566 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 567 - if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT)) 568 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 569 - link->io.IOAddrLines = parse.cftable_entry.io.flags 570 - & CISTPL_IO_LINES_MASK; 571 - rc = pcmcia_request_io(link, &link->io); 572 - 573 - dev_printk(KERN_INFO, &handle_to_dev(link), "foo"); 574 - if (rc == CS_SUCCESS) 575 - break; 576 - else 577 - dev_printk(KERN_INFO, &handle_to_dev(link), 578 - "pcmcia_request_io failed 0x%x\n", rc); 579 - } 580 - if (rc != CS_SUCCESS) 565 + if (pcmcia_loop_config(link, cm4040_config_check, NULL)) 581 566 goto cs_release; 582 567 583 568 link->conf.IntType = 00000002; 584 569 585 - if ((fail_rc = pcmcia_request_configuration(link,&link->conf)) 586 - !=CS_SUCCESS) { 587 - fail_fn = RequestConfiguration; 570 + fail_rc = pcmcia_request_configuration(link, &link->conf); 571 + if (fail_rc != 0) { 588 572 dev_printk(KERN_INFO, &handle_to_dev(link), 589 573 "pcmcia_request_configuration failed 0x%x\n", 590 574 fail_rc);
+22 -32
drivers/char/pcmcia/ipwireless/main.c
··· 65 65 struct ipw_dev *ipw = container_of(work_reboot, struct ipw_dev, 66 66 work_reboot); 67 67 struct pcmcia_device *link = ipw->link; 68 - int ret = pccard_reset_card(link->socket); 68 + int ret = pcmcia_reset_card(link->socket); 69 69 70 - if (ret != CS_SUCCESS) 70 + if (ret != 0) 71 71 cs_error(link, ResetCard, ret); 72 72 } 73 73 ··· 83 83 { 84 84 struct pcmcia_device *link = ipw->link; 85 85 int ret; 86 - config_info_t conf; 87 86 tuple_t tuple; 88 87 unsigned short buf[64]; 89 88 cisparse_t parse; ··· 104 105 while (ret == 0) { 105 106 ret = pcmcia_get_tuple_data(link, &tuple); 106 107 107 - if (ret != CS_SUCCESS) { 108 + if (ret != 0) { 108 109 cs_error(link, GetTupleData, ret); 109 110 goto exit0; 110 111 } ··· 115 116 116 117 ret = pcmcia_get_first_tuple(link, &tuple); 117 118 118 - if (ret != CS_SUCCESS) { 119 + if (ret != 0) { 119 120 cs_error(link, GetFirstTuple, ret); 120 121 goto exit0; 121 122 } 122 123 123 124 ret = pcmcia_get_tuple_data(link, &tuple); 124 125 125 - if (ret != CS_SUCCESS) { 126 + if (ret != 0) { 126 127 cs_error(link, GetTupleData, ret); 127 128 goto exit0; 128 129 } 129 130 130 - ret = pcmcia_parse_tuple(link, &tuple, &parse); 131 + ret = pcmcia_parse_tuple(&tuple, &parse); 131 132 132 - if (ret != CS_SUCCESS) { 133 + if (ret != 0) { 133 134 cs_error(link, ParseTuple, ret); 134 135 goto exit0; 135 136 } ··· 151 152 152 153 ret = pcmcia_get_first_tuple(link, &tuple); 153 154 154 - if (ret != CS_SUCCESS) { 155 + if (ret != 0) { 155 156 cs_error(link, GetFirstTuple, ret); 156 157 goto exit0; 157 158 } 158 159 159 160 ret = pcmcia_get_tuple_data(link, &tuple); 160 161 161 - if (ret != CS_SUCCESS) { 162 + if (ret != 0) { 162 163 cs_error(link, GetTupleData, ret); 163 164 goto exit0; 164 165 } 165 166 166 - ret = pcmcia_parse_tuple(link, &tuple, &parse); 167 + ret = pcmcia_parse_tuple(&tuple, &parse); 167 168 168 - if (ret != CS_SUCCESS) { 169 + if (ret != 0) { 169 170 cs_error(link, GetTupleData, ret); 170 171 goto exit0; 171 172 } ··· 180 181 181 182 ret = pcmcia_request_io(link, &link->io); 182 183 183 - if (ret != CS_SUCCESS) { 184 + if (ret != 0) { 184 185 cs_error(link, RequestIO, ret); 185 186 goto exit0; 186 187 } ··· 194 195 195 196 ret = pcmcia_get_first_tuple(link, &tuple); 196 197 197 - if (ret != CS_SUCCESS) { 198 + if (ret != 0) { 198 199 cs_error(link, GetFirstTuple, ret); 199 200 goto exit1; 200 201 } 201 202 202 203 ret = pcmcia_get_tuple_data(link, &tuple); 203 204 204 - if (ret != CS_SUCCESS) { 205 + if (ret != 0) { 205 206 cs_error(link, GetTupleData, ret); 206 207 goto exit1; 207 208 } 208 209 209 - ret = pcmcia_parse_tuple(link, &tuple, &parse); 210 + ret = pcmcia_parse_tuple(&tuple, &parse); 210 211 211 - if (ret != CS_SUCCESS) { 212 + if (ret != 0) { 212 213 cs_error(link, ParseTuple, ret); 213 214 goto exit1; 214 215 } ··· 226 227 ret = pcmcia_request_window(&link, &ipw->request_common_memory, 227 228 &ipw->handle_common_memory); 228 229 229 - if (ret != CS_SUCCESS) { 230 + if (ret != 0) { 230 231 cs_error(link, RequestWindow, ret); 231 232 goto exit1; 232 233 } ··· 238 239 ret = pcmcia_map_mem_page(ipw->handle_common_memory, 239 240 &memreq_common_memory); 240 241 241 - if (ret != CS_SUCCESS) { 242 + if (ret != 0) { 242 243 cs_error(link, MapMemPage, ret); 243 244 goto exit1; 244 245 } ··· 260 261 ret = pcmcia_request_window(&link, &ipw->request_attr_memory, 261 262 &ipw->handle_attr_memory); 262 263 263 - if (ret != CS_SUCCESS) { 264 + if (ret != 0) { 264 265 cs_error(link, RequestWindow, ret); 265 266 goto exit2; 266 267 } ··· 271 272 ret = pcmcia_map_mem_page(ipw->handle_attr_memory, 272 273 &memreq_attr_memory); 273 274 274 - if (ret != CS_SUCCESS) { 275 + if (ret != 0) { 275 276 cs_error(link, MapMemPage, ret); 276 277 goto exit2; 277 278 } ··· 291 292 292 293 ret = pcmcia_request_irq(link, &link->irq); 293 294 294 - if (ret != CS_SUCCESS) { 295 + if (ret != 0) { 295 296 cs_error(link, RequestIRQ, ret); 296 297 goto exit3; 297 - } 298 - 299 - /* Look up current Vcc */ 300 - 301 - ret = pcmcia_get_configuration_info(link, &conf); 302 - 303 - if (ret != CS_SUCCESS) { 304 - cs_error(link, GetConfigurationInfo, ret); 305 - goto exit4; 306 298 } 307 299 308 300 printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": Card type %s\n", ··· 331 341 */ 332 342 ret = pcmcia_request_configuration(link, &link->conf); 333 343 334 - if (ret != CS_SUCCESS) { 344 + if (ret != 0) { 335 345 cs_error(link, RequestConfiguration, ret); 336 346 goto exit4; 337 347 }
+73 -83
drivers/ide/legacy/ide-cs.c
··· 219 219 #define CS_CHECK(fn, ret) \ 220 220 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 221 221 222 + struct pcmcia_config_check { 223 + unsigned long ctl_base; 224 + int skip_vcc; 225 + int is_kme; 226 + }; 227 + 228 + static int pcmcia_check_one_config(struct pcmcia_device *pdev, 229 + cistpl_cftable_entry_t *cfg, 230 + cistpl_cftable_entry_t *dflt, 231 + unsigned int vcc, 232 + void *priv_data) 233 + { 234 + struct pcmcia_config_check *stk = priv_data; 235 + 236 + /* Check for matching Vcc, unless we're desperate */ 237 + if (!stk->skip_vcc) { 238 + if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 239 + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) 240 + return -ENODEV; 241 + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { 242 + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) 243 + return -ENODEV; 244 + } 245 + } 246 + 247 + if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 248 + pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 249 + else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) 250 + pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 251 + 252 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 253 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 254 + pdev->conf.ConfigIndex = cfg->index; 255 + pdev->io.BasePort1 = io->win[0].base; 256 + pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 257 + if (!(io->flags & CISTPL_IO_16BIT)) 258 + pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 259 + if (io->nwin == 2) { 260 + pdev->io.NumPorts1 = 8; 261 + pdev->io.BasePort2 = io->win[1].base; 262 + pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1; 263 + if (pcmcia_request_io(pdev, &pdev->io) != 0) 264 + return -ENODEV; 265 + stk->ctl_base = pdev->io.BasePort2; 266 + } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { 267 + pdev->io.NumPorts1 = io->win[0].len; 268 + pdev->io.NumPorts2 = 0; 269 + if (pcmcia_request_io(pdev, &pdev->io) != 0) 270 + return -ENODEV; 271 + stk->ctl_base = pdev->io.BasePort1 + 0x0e; 272 + } else 273 + return -ENODEV; 274 + /* If we've got this far, we're done */ 275 + return 0; 276 + } 277 + return -ENODEV; 278 + } 279 + 222 280 static int ide_config(struct pcmcia_device *link) 223 281 { 224 282 ide_info_t *info = link->priv; 225 - tuple_t tuple; 226 - struct { 227 - u_short buf[128]; 228 - cisparse_t parse; 229 - config_info_t conf; 230 - cistpl_cftable_entry_t dflt; 231 - } *stk = NULL; 232 - cistpl_cftable_entry_t *cfg; 233 - int pass, last_ret = 0, last_fn = 0, is_kme = 0; 283 + struct pcmcia_config_check *stk = NULL; 284 + int last_ret = 0, last_fn = 0, is_kme = 0; 234 285 unsigned long io_base, ctl_base; 235 286 struct ide_host *host; 236 287 237 288 DEBUG(0, "ide_config(0x%p)\n", link); 238 289 239 - stk = kzalloc(sizeof(*stk), GFP_KERNEL); 240 - if (!stk) goto err_mem; 241 - cfg = &stk->parse.cftable_entry; 242 - 243 - tuple.TupleData = (cisdata_t *)&stk->buf; 244 - tuple.TupleOffset = 0; 245 - tuple.TupleDataMax = 255; 246 - tuple.Attributes = 0; 247 - 248 290 is_kme = ((link->manf_id == MANFID_KME) && 249 291 ((link->card_id == PRODID_KME_KXLC005_A) || 250 292 (link->card_id == PRODID_KME_KXLC005_B))); 251 293 252 - /* Not sure if this is right... look up the current Vcc */ 253 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); 294 + stk = kzalloc(sizeof(*stk), GFP_KERNEL); 295 + if (!stk) 296 + goto err_mem; 297 + stk->is_kme = is_kme; 298 + stk->skip_vcc = io_base = ctl_base = 0; 254 299 255 - pass = io_base = ctl_base = 0; 256 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 257 - tuple.Attributes = 0; 258 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 259 - while (1) { 260 - if (pcmcia_get_tuple_data(link, &tuple) != 0) goto next_entry; 261 - if (pcmcia_parse_tuple(link, &tuple, &stk->parse) != 0) goto next_entry; 262 - 263 - /* Check for matching Vcc, unless we're desperate */ 264 - if (!pass) { 265 - if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 266 - if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) 267 - goto next_entry; 268 - } else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { 269 - if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) 270 - goto next_entry; 271 - } 272 - } 273 - 274 - if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 275 - link->conf.Vpp = 276 - cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 277 - else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 278 - link->conf.Vpp = 279 - stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 280 - 281 - if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { 282 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; 283 - link->conf.ConfigIndex = cfg->index; 284 - link->io.BasePort1 = io->win[0].base; 285 - link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 286 - if (!(io->flags & CISTPL_IO_16BIT)) 287 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 288 - if (io->nwin == 2) { 289 - link->io.NumPorts1 = 8; 290 - link->io.BasePort2 = io->win[1].base; 291 - link->io.NumPorts2 = (is_kme) ? 2 : 1; 292 - if (pcmcia_request_io(link, &link->io) != 0) 293 - goto next_entry; 294 - io_base = link->io.BasePort1; 295 - ctl_base = link->io.BasePort2; 296 - } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { 297 - link->io.NumPorts1 = io->win[0].len; 298 - link->io.NumPorts2 = 0; 299 - if (pcmcia_request_io(link, &link->io) != 0) 300 - goto next_entry; 301 - io_base = link->io.BasePort1; 302 - ctl_base = link->io.BasePort1 + 0x0e; 303 - } else goto next_entry; 304 - /* If we've got this far, we're done */ 305 - break; 306 - } 307 - 308 - next_entry: 309 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 310 - memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); 311 - if (pass) { 312 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 313 - } else if (pcmcia_get_next_tuple(link, &tuple) != 0) { 314 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 315 - memset(&stk->dflt, 0, sizeof(stk->dflt)); 316 - pass++; 317 - } 300 + if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) { 301 + stk->skip_vcc = 1; 302 + if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) 303 + goto failed; /* No suitable config found */ 318 304 } 305 + io_base = link->io.BasePort1; 306 + ctl_base = stk->ctl_base; 319 307 320 308 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 321 309 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); ··· 391 403 PCMCIA_DEVICE_MANF_CARD(0x000a, 0x0000), /* I-O Data CFA */ 392 404 PCMCIA_DEVICE_MANF_CARD(0x001c, 0x0001), /* Mitsubishi CFA */ 393 405 PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), 406 + PCMCIA_DEVICE_MANF_CARD(0x0032, 0x2904), 394 407 PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ 395 408 PCMCIA_DEVICE_MANF_CARD(0x004f, 0x0000), /* Kingston */ 409 + PCMCIA_DEVICE_MANF_CARD(0x0097, 0x1620), /* TI emulated */ 396 410 PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ 397 411 PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), 398 412 PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */
+26 -59
drivers/isdn/hardware/avm/avm_cs.c
··· 154 154 155 155 ======================================================================*/ 156 156 157 - static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 158 - cisparse_t *parse) 157 + static int avmcs_configcheck(struct pcmcia_device *p_dev, 158 + cistpl_cftable_entry_t *cf, 159 + cistpl_cftable_entry_t *dflt, 160 + unsigned int vcc, 161 + void *priv_data) 159 162 { 160 - int i = pcmcia_get_tuple_data(handle, tuple); 161 - if (i != CS_SUCCESS) return i; 162 - return pcmcia_parse_tuple(handle, tuple, parse); 163 - } 163 + if (cf->io.nwin <= 0) 164 + return -ENODEV; 164 165 165 - static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 166 - cisparse_t *parse) 167 - { 168 - int i = pcmcia_get_first_tuple(handle, tuple); 169 - if (i != CS_SUCCESS) return i; 170 - return get_tuple(handle, tuple, parse); 171 - } 172 - 173 - static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 174 - cisparse_t *parse) 175 - { 176 - int i = pcmcia_get_next_tuple(handle, tuple); 177 - if (i != CS_SUCCESS) return i; 178 - return get_tuple(handle, tuple, parse); 166 + p_dev->io.BasePort1 = cf->io.win[0].base; 167 + p_dev->io.NumPorts1 = cf->io.win[0].len; 168 + p_dev->io.NumPorts2 = 0; 169 + printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n", 170 + p_dev->io.BasePort1, 171 + p_dev->io.BasePort1+p_dev->io.NumPorts1-1); 172 + return pcmcia_request_io(p_dev, &p_dev->io); 179 173 } 180 174 181 175 static int avmcs_config(struct pcmcia_device *link) 182 176 { 183 - tuple_t tuple; 184 - cisparse_t parse; 185 - cistpl_cftable_entry_t *cf = &parse.cftable_entry; 186 177 local_info_t *dev; 187 178 int i; 188 - u_char buf[64]; 189 179 char devname[128]; 190 180 int cardtype; 191 181 int (*addcard)(unsigned int port, unsigned irq); 192 182 193 183 dev = link->priv; 194 184 185 + devname[0] = 0; 186 + if (link->prod_id[1]) 187 + strlcpy(devname, link->prod_id[1], sizeof(devname)); 188 + 189 + /* 190 + * find IO port 191 + */ 192 + if (pcmcia_loop_config(link, avmcs_configcheck, NULL)) 193 + return -ENODEV; 194 + 195 195 do { 196 - devname[0] = 0; 197 - if (link->prod_id[1]) 198 - strlcpy(devname, link->prod_id[1], sizeof(devname)); 199 - 200 - /* 201 - * find IO port 202 - */ 203 - tuple.TupleData = (cisdata_t *)buf; 204 - tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 205 - tuple.Attributes = 0; 206 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 207 - i = first_tuple(link, &tuple, &parse); 208 - while (i == CS_SUCCESS) { 209 - if (cf->io.nwin > 0) { 210 - link->conf.ConfigIndex = cf->index; 211 - link->io.BasePort1 = cf->io.win[0].base; 212 - link->io.NumPorts1 = cf->io.win[0].len; 213 - link->io.NumPorts2 = 0; 214 - printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n", 215 - link->io.BasePort1, 216 - link->io.BasePort1+link->io.NumPorts1-1); 217 - i = pcmcia_request_io(link, &link->io); 218 - if (i == CS_SUCCESS) goto found_port; 219 - } 220 - i = next_tuple(link, &tuple, &parse); 221 - } 222 - 223 - found_port: 224 - if (i != CS_SUCCESS) { 225 - cs_error(link, RequestIO, i); 226 - break; 227 - } 228 - 229 196 /* 230 197 * allocate an interrupt line 231 198 */ 232 199 i = pcmcia_request_irq(link, &link->irq); 233 - if (i != CS_SUCCESS) { 200 + if (i != 0) { 234 201 cs_error(link, RequestIRQ, i); 235 202 /* undo */ 236 203 pcmcia_disable_device(link); ··· 208 241 * configure the PCMCIA socket 209 242 */ 210 243 i = pcmcia_request_configuration(link, &link->conf); 211 - if (i != CS_SUCCESS) { 244 + if (i != 0) { 212 245 cs_error(link, RequestConfiguration, i); 213 246 pcmcia_disable_device(link); 214 247 break;
+24 -59
drivers/isdn/hisax/avma1_cs.c
··· 174 174 175 175 ======================================================================*/ 176 176 177 - static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 178 - cisparse_t *parse) 177 + static int avma1cs_configcheck(struct pcmcia_device *p_dev, 178 + cistpl_cftable_entry_t *cf, 179 + cistpl_cftable_entry_t *dflt, 180 + unsigned int vcc, 181 + void *priv_data) 179 182 { 180 - int i = pcmcia_get_tuple_data(handle, tuple); 181 - if (i != CS_SUCCESS) return i; 182 - return pcmcia_parse_tuple(handle, tuple, parse); 183 + if (cf->io.nwin <= 0) 184 + return -ENODEV; 185 + 186 + p_dev->io.BasePort1 = cf->io.win[0].base; 187 + p_dev->io.NumPorts1 = cf->io.win[0].len; 188 + p_dev->io.NumPorts2 = 0; 189 + printk(KERN_INFO "avma1_cs: testing i/o %#x-%#x\n", 190 + p_dev->io.BasePort1, 191 + p_dev->io.BasePort1+p_dev->io.NumPorts1-1); 192 + return pcmcia_request_io(p_dev, &p_dev->io); 183 193 } 184 194 185 - static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 186 - cisparse_t *parse) 187 - { 188 - int i = pcmcia_get_first_tuple(handle, tuple); 189 - if (i != CS_SUCCESS) return i; 190 - return get_tuple(handle, tuple, parse); 191 - } 192 - 193 - static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 194 - cisparse_t *parse) 195 - { 196 - int i = pcmcia_get_next_tuple(handle, tuple); 197 - if (i != CS_SUCCESS) return i; 198 - return get_tuple(handle, tuple, parse); 199 - } 200 195 201 196 static int avma1cs_config(struct pcmcia_device *link) 202 197 { 203 - tuple_t tuple; 204 - cisparse_t parse; 205 - cistpl_cftable_entry_t *cf = &parse.cftable_entry; 206 198 local_info_t *dev; 207 199 int i; 208 - u_char buf[64]; 209 200 char devname[128]; 210 201 IsdnCard_t icard; 211 202 int busy = 0; ··· 205 214 206 215 DEBUG(0, "avma1cs_config(0x%p)\n", link); 207 216 217 + devname[0] = 0; 218 + if (link->prod_id[1]) 219 + strlcpy(devname, link->prod_id[1], sizeof(devname)); 220 + 221 + if (pcmcia_loop_config(link, avma1cs_configcheck, NULL)) 222 + return -ENODEV; 223 + 208 224 do { 209 - devname[0] = 0; 210 - if (link->prod_id[1]) 211 - strlcpy(devname, link->prod_id[1], sizeof(devname)); 212 - 213 - /* 214 - * find IO port 215 - */ 216 - tuple.TupleData = (cisdata_t *)buf; 217 - tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 218 - tuple.Attributes = 0; 219 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 220 - i = first_tuple(link, &tuple, &parse); 221 - while (i == CS_SUCCESS) { 222 - if (cf->io.nwin > 0) { 223 - link->conf.ConfigIndex = cf->index; 224 - link->io.BasePort1 = cf->io.win[0].base; 225 - link->io.NumPorts1 = cf->io.win[0].len; 226 - link->io.NumPorts2 = 0; 227 - printk(KERN_INFO "avma1_cs: testing i/o %#x-%#x\n", 228 - link->io.BasePort1, 229 - link->io.BasePort1+link->io.NumPorts1 - 1); 230 - i = pcmcia_request_io(link, &link->io); 231 - if (i == CS_SUCCESS) goto found_port; 232 - } 233 - i = next_tuple(link, &tuple, &parse); 234 - } 235 - 236 - found_port: 237 - if (i != CS_SUCCESS) { 238 - cs_error(link, RequestIO, i); 239 - break; 240 - } 241 - 242 225 /* 243 226 * allocate an interrupt line 244 227 */ 245 228 i = pcmcia_request_irq(link, &link->irq); 246 - if (i != CS_SUCCESS) { 229 + if (i != 0) { 247 230 cs_error(link, RequestIRQ, i); 248 231 /* undo */ 249 232 pcmcia_disable_device(link); ··· 228 263 * configure the PCMCIA socket 229 264 */ 230 265 i = pcmcia_request_configuration(link, &link->conf); 231 - if (i != CS_SUCCESS) { 266 + if (i != 0) { 232 267 cs_error(link, RequestConfiguration, i); 233 268 pcmcia_disable_device(link); 234 269 break;
+25 -52
drivers/isdn/hisax/elsa_cs.c
··· 203 203 device available to the system. 204 204 205 205 ======================================================================*/ 206 - static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 207 - cisparse_t *parse) 208 - { 209 - int i = pcmcia_get_tuple_data(handle, tuple); 210 - if (i != CS_SUCCESS) return i; 211 - return pcmcia_parse_tuple(handle, tuple, parse); 212 - } 213 206 214 - static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 215 - cisparse_t *parse) 207 + static int elsa_cs_configcheck(struct pcmcia_device *p_dev, 208 + cistpl_cftable_entry_t *cf, 209 + cistpl_cftable_entry_t *dflt, 210 + unsigned int vcc, 211 + void *priv_data) 216 212 { 217 - int i = pcmcia_get_first_tuple(handle, tuple); 218 - if (i != CS_SUCCESS) return i; 219 - return get_tuple(handle, tuple, parse); 220 - } 213 + int j; 221 214 222 - static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 223 - cisparse_t *parse) 224 - { 225 - int i = pcmcia_get_next_tuple(handle, tuple); 226 - if (i != CS_SUCCESS) return i; 227 - return get_tuple(handle, tuple, parse); 215 + if ((cf->io.nwin > 0) && cf->io.win[0].base) { 216 + printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n"); 217 + p_dev->io.BasePort1 = cf->io.win[0].base; 218 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 219 + return 0; 220 + } else { 221 + printk(KERN_INFO "(elsa_cs: looks like the 97 model)\n"); 222 + for (j = 0x2f0; j > 0x100; j -= 0x10) { 223 + p_dev->io.BasePort1 = j; 224 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 225 + return 0; 226 + } 227 + } 228 + return -ENODEV; 228 229 } 229 230 230 231 static int elsa_cs_config(struct pcmcia_device *link) 231 232 { 232 - tuple_t tuple; 233 - cisparse_t parse; 234 233 local_info_t *dev; 235 - int i, j, last_fn; 236 - u_short buf[128]; 237 - cistpl_cftable_entry_t *cf = &parse.cftable_entry; 234 + int i, last_fn; 238 235 IsdnCard_t icard; 239 236 240 237 DEBUG(0, "elsa_config(0x%p)\n", link); 241 238 dev = link->priv; 242 239 243 - tuple.TupleData = (cisdata_t *)buf; 244 - tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 245 - tuple.Attributes = 0; 246 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 247 - i = first_tuple(link, &tuple, &parse); 248 - while (i == CS_SUCCESS) { 249 - if ( (cf->io.nwin > 0) && cf->io.win[0].base) { 250 - printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n"); 251 - link->conf.ConfigIndex = cf->index; 252 - link->io.BasePort1 = cf->io.win[0].base; 253 - i = pcmcia_request_io(link, &link->io); 254 - if (i == CS_SUCCESS) break; 255 - } else { 256 - printk(KERN_INFO "(elsa_cs: looks like the 97 model)\n"); 257 - link->conf.ConfigIndex = cf->index; 258 - for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) { 259 - link->io.BasePort1 = j; 260 - i = pcmcia_request_io(link, &link->io); 261 - if (i == CS_SUCCESS) break; 262 - } 263 - break; 264 - } 265 - i = next_tuple(link, &tuple, &parse); 266 - } 267 - 268 - if (i != CS_SUCCESS) { 240 + i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL); 241 + if (i != 0) { 269 242 last_fn = RequestIO; 270 243 goto cs_failed; 271 244 } 272 245 273 246 i = pcmcia_request_irq(link, &link->irq); 274 - if (i != CS_SUCCESS) { 247 + if (i != 0) { 275 248 link->irq.AssignedIRQ = 0; 276 249 last_fn = RequestIRQ; 277 250 goto cs_failed; 278 251 } 279 252 280 253 i = pcmcia_request_configuration(link, &link->conf); 281 - if (i != CS_SUCCESS) { 254 + if (i != 0) { 282 255 last_fn = RequestConfiguration; 283 256 goto cs_failed; 284 257 }
+91 -106
drivers/isdn/hisax/sedlbauer_cs.c
··· 217 217 #define CS_CHECK(fn, ret) \ 218 218 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 219 219 220 - static int sedlbauer_config(struct pcmcia_device *link) 220 + static int sedlbauer_config_check(struct pcmcia_device *p_dev, 221 + cistpl_cftable_entry_t *cfg, 222 + cistpl_cftable_entry_t *dflt, 223 + unsigned int vcc, 224 + void *priv_data) 221 225 { 222 - local_info_t *dev = link->priv; 223 - tuple_t tuple; 224 - cisparse_t parse; 225 - int last_fn, last_ret; 226 - u8 buf[64]; 227 - config_info_t conf; 228 - win_req_t req; 229 - memreq_t map; 230 - IsdnCard_t icard; 226 + win_req_t *req = priv_data; 231 227 232 - DEBUG(0, "sedlbauer_config(0x%p)\n", link); 228 + if (cfg->index == 0) 229 + return -ENODEV; 233 230 234 - tuple.Attributes = 0; 235 - tuple.TupleData = buf; 236 - tuple.TupleDataMax = sizeof(buf); 237 - tuple.TupleOffset = 0; 238 - 239 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 240 - 241 - /* 242 - In this loop, we scan the CIS for configuration table entries, 243 - each of which describes a valid card configuration, including 244 - voltage, IO window, memory window, and interrupt settings. 245 - 246 - We make no assumptions about the card to be configured: we use 247 - just the information available in the CIS. In an ideal world, 248 - this would work for any PCMCIA card, but it requires a complete 249 - and accurate CIS. In practice, a driver usually "knows" most of 250 - these things without consulting the CIS, and most client drivers 251 - will only use the CIS to fill in implementation-defined details. 252 - */ 253 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 254 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 255 - while (1) { 256 - cistpl_cftable_entry_t dflt = { 0 }; 257 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 258 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 259 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 260 - goto next_entry; 261 - 262 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 263 - if (cfg->index == 0) goto next_entry; 264 - link->conf.ConfigIndex = cfg->index; 265 - 266 231 /* Does this card need audio output? */ 267 232 if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 268 - link->conf.Attributes |= CONF_ENABLE_SPKR; 269 - link->conf.Status = CCSR_AUDIO_ENA; 233 + p_dev->conf.Attributes |= CONF_ENABLE_SPKR; 234 + p_dev->conf.Status = CCSR_AUDIO_ENA; 270 235 } 271 - 236 + 272 237 /* Use power settings for Vcc and Vpp if present */ 273 238 /* Note that the CIS values need to be rescaled */ 274 239 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 275 - if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) 276 - goto next_entry; 277 - } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { 278 - if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM]/10000) 279 - goto next_entry; 240 + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) 241 + return -ENODEV; 242 + } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { 243 + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) 244 + return -ENODEV; 280 245 } 281 - 246 + 282 247 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 283 - link->conf.Vpp = 284 - cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 285 - else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 286 - link->conf.Vpp = 287 - dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 288 - 248 + p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 249 + else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) 250 + p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; 251 + 289 252 /* Do we need to allocate an interrupt? */ 290 - if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) 291 - link->conf.Attributes |= CONF_ENABLE_IRQ; 292 - 253 + if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) 254 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 255 + 293 256 /* IO window settings */ 294 - link->io.NumPorts1 = link->io.NumPorts2 = 0; 295 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 296 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 297 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 298 - if (!(io->flags & CISTPL_IO_8BIT)) 299 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 300 - if (!(io->flags & CISTPL_IO_16BIT)) 301 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 302 - /* new in dummy.cs 2001/01/28 MN 303 - link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 304 - */ 305 - link->io.BasePort1 = io->win[0].base; 306 - link->io.NumPorts1 = io->win[0].len; 307 - if (io->nwin > 1) { 308 - link->io.Attributes2 = link->io.Attributes1; 309 - link->io.BasePort2 = io->win[1].base; 310 - link->io.NumPorts2 = io->win[1].len; 311 - } 312 - /* This reserves IO space but doesn't actually enable it */ 313 - if (pcmcia_request_io(link, &link->io) != 0) 314 - goto next_entry; 257 + p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 258 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 259 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 260 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 261 + if (!(io->flags & CISTPL_IO_8BIT)) 262 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 263 + if (!(io->flags & CISTPL_IO_16BIT)) 264 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 265 + p_dev->io.BasePort1 = io->win[0].base; 266 + p_dev->io.NumPorts1 = io->win[0].len; 267 + if (io->nwin > 1) { 268 + p_dev->io.Attributes2 = p_dev->io.Attributes1; 269 + p_dev->io.BasePort2 = io->win[1].base; 270 + p_dev->io.NumPorts2 = io->win[1].len; 271 + } 272 + /* This reserves IO space but doesn't actually enable it */ 273 + if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 274 + return -ENODEV; 315 275 } 316 276 317 277 /* ··· 285 325 needs to be mapped to virtual space with ioremap() before it 286 326 is used. 287 327 */ 288 - if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { 289 - cistpl_mem_t *mem = 290 - (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; 291 - req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 292 - req.Attributes |= WIN_ENABLE; 293 - req.Base = mem->win[0].host_addr; 294 - req.Size = mem->win[0].len; 295 - /* new in dummy.cs 2001/01/28 MN 296 - if (req.Size < 0x1000) 297 - req.Size = 0x1000; 298 - */ 299 - req.AccessSpeed = 0; 300 - if (pcmcia_request_window(&link, &req, &link->win) != 0) 301 - goto next_entry; 302 - map.Page = 0; map.CardOffset = mem->win[0].card_addr; 303 - if (pcmcia_map_mem_page(link->win, &map) != 0) 304 - goto next_entry; 328 + if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { 329 + cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; 330 + memreq_t map; 331 + req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 332 + req->Attributes |= WIN_ENABLE; 333 + req->Base = mem->win[0].host_addr; 334 + req->Size = mem->win[0].len; 335 + req->AccessSpeed = 0; 336 + if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0) 337 + return -ENODEV; 338 + map.Page = 0; 339 + map.CardOffset = mem->win[0].card_addr; 340 + if (pcmcia_map_mem_page(p_dev->win, &map) != 0) 341 + return -ENODEV; 305 342 } 306 - /* If we got this far, we're cool! */ 307 - break; 343 + return 0; 344 + } 308 345 309 - next_entry: 310 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 311 - } 346 + 347 + 348 + static int sedlbauer_config(struct pcmcia_device *link) 349 + { 350 + local_info_t *dev = link->priv; 351 + win_req_t *req; 352 + int last_fn, last_ret; 353 + IsdnCard_t icard; 354 + 355 + DEBUG(0, "sedlbauer_config(0x%p)\n", link); 356 + 357 + req = kzalloc(sizeof(win_req_t), GFP_KERNEL); 358 + if (!req) 359 + return -ENOMEM; 360 + 361 + /* 362 + In this loop, we scan the CIS for configuration table entries, 363 + each of which describes a valid card configuration, including 364 + voltage, IO window, memory window, and interrupt settings. 365 + 366 + We make no assumptions about the card to be configured: we use 367 + just the information available in the CIS. In an ideal world, 368 + this would work for any PCMCIA card, but it requires a complete 369 + and accurate CIS. In practice, a driver usually "knows" most of 370 + these things without consulting the CIS, and most client drivers 371 + will only use the CIS to fill in implementation-defined details. 372 + */ 373 + last_ret = pcmcia_loop_config(link, sedlbauer_config_check, req); 374 + if (last_ret) 375 + goto failed; 312 376 313 377 /* 314 378 Allocate an interrupt line. Note that this does not assign a ··· 371 387 printk(" & 0x%04x-0x%04x", link->io.BasePort2, 372 388 link->io.BasePort2+link->io.NumPorts2-1); 373 389 if (link->win) 374 - printk(", mem 0x%06lx-0x%06lx", req.Base, 375 - req.Base+req.Size-1); 390 + printk(", mem 0x%06lx-0x%06lx", req->Base, 391 + req->Base+req->Size-1); 376 392 printk("\n"); 377 393 378 394 icard.para[0] = link->irq.AssignedIRQ; ··· 393 409 394 410 cs_failed: 395 411 cs_error(link, last_fn, last_ret); 412 + failed: 396 413 sedlbauer_release(link); 397 414 return -ENODEV; 398 415
+25 -52
drivers/isdn/hisax/teles_cs.c
··· 193 193 device available to the system. 194 194 195 195 ======================================================================*/ 196 - static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 197 - cisparse_t *parse) 198 - { 199 - int i = pcmcia_get_tuple_data(handle, tuple); 200 - if (i != CS_SUCCESS) return i; 201 - return pcmcia_parse_tuple(handle, tuple, parse); 202 - } 203 196 204 - static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 205 - cisparse_t *parse) 197 + static int teles_cs_configcheck(struct pcmcia_device *p_dev, 198 + cistpl_cftable_entry_t *cf, 199 + cistpl_cftable_entry_t *dflt, 200 + unsigned int vcc, 201 + void *priv_data) 206 202 { 207 - int i = pcmcia_get_first_tuple(handle, tuple); 208 - if (i != CS_SUCCESS) return i; 209 - return get_tuple(handle, tuple, parse); 210 - } 203 + int j; 211 204 212 - static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 213 - cisparse_t *parse) 214 - { 215 - int i = pcmcia_get_next_tuple(handle, tuple); 216 - if (i != CS_SUCCESS) return i; 217 - return get_tuple(handle, tuple, parse); 205 + if ((cf->io.nwin > 0) && cf->io.win[0].base) { 206 + printk(KERN_INFO "(teles_cs: looks like the 96 model)\n"); 207 + p_dev->io.BasePort1 = cf->io.win[0].base; 208 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 209 + return 0; 210 + } else { 211 + printk(KERN_INFO "(teles_cs: looks like the 97 model)\n"); 212 + for (j = 0x2f0; j > 0x100; j -= 0x10) { 213 + p_dev->io.BasePort1 = j; 214 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 215 + return 0; 216 + } 217 + } 218 + return -ENODEV; 218 219 } 219 220 220 221 static int teles_cs_config(struct pcmcia_device *link) 221 222 { 222 - tuple_t tuple; 223 - cisparse_t parse; 224 223 local_info_t *dev; 225 - int i, j, last_fn; 226 - u_short buf[128]; 227 - cistpl_cftable_entry_t *cf = &parse.cftable_entry; 224 + int i, last_fn; 228 225 IsdnCard_t icard; 229 226 230 227 DEBUG(0, "teles_config(0x%p)\n", link); 231 228 dev = link->priv; 232 229 233 - tuple.TupleData = (cisdata_t *)buf; 234 - tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 235 - tuple.Attributes = 0; 236 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 237 - i = first_tuple(link, &tuple, &parse); 238 - while (i == CS_SUCCESS) { 239 - if ( (cf->io.nwin > 0) && cf->io.win[0].base) { 240 - printk(KERN_INFO "(teles_cs: looks like the 96 model)\n"); 241 - link->conf.ConfigIndex = cf->index; 242 - link->io.BasePort1 = cf->io.win[0].base; 243 - i = pcmcia_request_io(link, &link->io); 244 - if (i == CS_SUCCESS) break; 245 - } else { 246 - printk(KERN_INFO "(teles_cs: looks like the 97 model)\n"); 247 - link->conf.ConfigIndex = cf->index; 248 - for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) { 249 - link->io.BasePort1 = j; 250 - i = pcmcia_request_io(link, &link->io); 251 - if (i == CS_SUCCESS) break; 252 - } 253 - break; 254 - } 255 - i = next_tuple(link, &tuple, &parse); 256 - } 257 - 258 - if (i != CS_SUCCESS) { 230 + i = pcmcia_loop_config(link, teles_cs_configcheck, NULL); 231 + if (i != 0) { 259 232 last_fn = RequestIO; 260 233 goto cs_failed; 261 234 } 262 235 263 236 i = pcmcia_request_irq(link, &link->irq); 264 - if (i != CS_SUCCESS) { 237 + if (i != 0) { 265 238 link->irq.AssignedIRQ = 0; 266 239 last_fn = RequestIRQ; 267 240 goto cs_failed; 268 241 } 269 242 270 243 i = pcmcia_request_configuration(link, &link->conf); 271 - if (i != CS_SUCCESS) { 244 + if (i != 0) { 272 245 last_fn = RequestConfiguration; 273 246 goto cs_failed; 274 247 }
+9 -25
drivers/mtd/maps/pcmciamtd.c
··· 118 118 DEBUG(2, "Remapping window from 0x%8.8x to 0x%8.8x", 119 119 dev->offset, mrq.CardOffset); 120 120 mrq.Page = 0; 121 - if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) { 121 + ret = pcmcia_map_mem_page(win, &mrq); 122 + if (ret != 0) { 122 123 cs_error(dev->p_dev, MapMemPage, ret); 123 124 return NULL; 124 125 } ··· 327 326 328 327 DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); 329 328 ret = pcmcia_modify_configuration(link, &mod); 330 - if(ret != CS_SUCCESS) { 329 + if (ret != 0) 331 330 cs_error(link, ModifyConfiguration, ret); 332 - } 333 331 } 334 332 335 333 ··· 368 368 tuple.DesiredTuple = RETURN_FIRST_TUPLE; 369 369 370 370 rc = pcmcia_get_first_tuple(link, &tuple); 371 - while(rc == CS_SUCCESS) { 371 + while (rc == 0) { 372 372 rc = pcmcia_get_tuple_data(link, &tuple); 373 - if(rc != CS_SUCCESS) { 373 + if (rc != 0) { 374 374 cs_error(link, GetTupleData, rc); 375 375 break; 376 376 } 377 - rc = pcmcia_parse_tuple(link, &tuple, &parse); 378 - if(rc != CS_SUCCESS) { 377 + rc = pcmcia_parse_tuple(&tuple, &parse); 378 + if (rc != 0) { 379 379 cs_error(link, ParseTuple, rc); 380 380 break; 381 381 } ··· 493 493 int last_ret = 0, last_fn = 0; 494 494 int ret; 495 495 int i; 496 - config_info_t t; 497 496 static char *probes[] = { "jedec_probe", "cfi_probe" }; 498 497 int new_name = 0; 499 498 500 499 DEBUG(3, "link=0x%p", link); 501 - 502 - DEBUG(2, "Validating CIS"); 503 - ret = pcmcia_validate_cis(link, NULL); 504 - if(ret != CS_SUCCESS) { 505 - cs_error(link, GetTupleData, ret); 506 - } 507 500 508 501 card_settings(dev, link, &new_name); 509 502 ··· 564 571 dev->pcmcia_map.map_priv_1 = (unsigned long)dev; 565 572 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; 566 573 567 - DEBUG(2, "Getting configuration"); 568 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &t)); 569 - DEBUG(2, "Vcc = %d Vpp1 = %d Vpp2 = %d", t.Vcc, t.Vpp1, t.Vpp2); 570 - dev->vpp = (vpp) ? vpp : t.Vpp1; 574 + dev->vpp = (vpp) ? vpp : link->socket.socket.Vpp; 571 575 link->conf.Attributes = 0; 572 576 if(setvpp == 2) { 573 577 link->conf.Vpp = dev->vpp; ··· 573 583 } 574 584 575 585 link->conf.IntType = INT_MEMORY; 576 - link->conf.ConfigBase = t.ConfigBase; 577 - link->conf.Status = t.Status; 578 - link->conf.Pin = t.Pin; 579 - link->conf.Copy = t.Copy; 580 - link->conf.ExtStatus = t.ExtStatus; 581 586 link->conf.ConfigIndex = 0; 582 - link->conf.Present = t.Present; 583 587 DEBUG(2, "Setting Configuration"); 584 588 ret = pcmcia_request_configuration(link, &link->conf); 585 - if(ret != CS_SUCCESS) { 589 + if (ret != 0) { 586 590 cs_error(link, RequestConfiguration, ret); 587 591 if (dev->win_base) { 588 592 iounmap(dev->win_base);
+4 -3
drivers/net/pcmcia/3c574_cs.c
··· 355 355 for (i = j = 0; j < 0x400; j += 0x20) { 356 356 link->io.BasePort1 = j ^ 0x300; 357 357 i = pcmcia_request_io(link, &link->io); 358 - if (i == CS_SUCCESS) break; 358 + if (i == 0) 359 + break; 359 360 } 360 - if (i != CS_SUCCESS) { 361 + if (i != 0) { 361 362 cs_error(link, RequestIO, i); 362 363 goto failed; 363 364 } ··· 378 377 tuple.TupleDataMax = 64; 379 378 tuple.TupleOffset = 0; 380 379 tuple.DesiredTuple = 0x88; 381 - if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 380 + if (pcmcia_get_first_tuple(link, &tuple) == 0) { 382 381 pcmcia_get_tuple_data(link, &tuple); 383 382 for (i = 0; i < 3; i++) 384 383 phys_addr[i] = htons(le16_to_cpu(buf[i]));
+4 -3
drivers/net/pcmcia/3c589_cs.c
··· 278 278 if (multi && (j & 0x80)) continue; 279 279 link->io.BasePort1 = j ^ 0x300; 280 280 i = pcmcia_request_io(link, &link->io); 281 - if (i == CS_SUCCESS) break; 281 + if (i == 0) 282 + break; 282 283 } 283 - if (i != CS_SUCCESS) { 284 + if (i != 0) { 284 285 cs_error(link, RequestIO, i); 285 286 goto failed; 286 287 } ··· 296 295 /* The 3c589 has an extra EEPROM for configuration info, including 297 296 the hardware address. The 3c562 puts the address in the CIS. */ 298 297 tuple.DesiredTuple = 0x88; 299 - if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 298 + if (pcmcia_get_first_tuple(link, &tuple) == 0) { 300 299 pcmcia_get_tuple_data(link, &tuple); 301 300 for (i = 0; i < 3; i++) 302 301 phys_addr[i] = htons(le16_to_cpu(buf[i]));
+36 -44
drivers/net/pcmcia/axnet_cs.c
··· 262 262 if (link->io.NumPorts2 > 0) { 263 263 /* for master/slave multifunction cards */ 264 264 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 265 - link->irq.Attributes = 265 + link->irq.Attributes = 266 266 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 267 267 } 268 268 } else { ··· 276 276 link->io.BasePort1 = j ^ 0x300; 277 277 link->io.BasePort2 = (j ^ 0x300) + 0x10; 278 278 ret = pcmcia_request_io(link, &link->io); 279 - if (ret == CS_SUCCESS) return ret; 279 + if (ret == 0) 280 + return ret; 280 281 } 281 282 return ret; 282 283 } else { ··· 285 284 } 286 285 } 287 286 287 + static int axnet_configcheck(struct pcmcia_device *p_dev, 288 + cistpl_cftable_entry_t *cfg, 289 + cistpl_cftable_entry_t *dflt, 290 + unsigned int vcc, 291 + void *priv_data) 292 + { 293 + int i; 294 + cistpl_io_t *io = &cfg->io; 295 + 296 + if (cfg->index == 0 || cfg->io.nwin == 0) 297 + return -ENODEV; 298 + 299 + p_dev->conf.ConfigIndex = 0x05; 300 + /* For multifunction cards, by convention, we configure the 301 + network function with window 0, and serial with window 1 */ 302 + if (io->nwin > 1) { 303 + i = (io->win[1].len > io->win[0].len); 304 + p_dev->io.BasePort2 = io->win[1-i].base; 305 + p_dev->io.NumPorts2 = io->win[1-i].len; 306 + } else { 307 + i = p_dev->io.NumPorts2 = 0; 308 + } 309 + p_dev->io.BasePort1 = io->win[i].base; 310 + p_dev->io.NumPorts1 = io->win[i].len; 311 + p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 312 + if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) 313 + return try_io_port(p_dev); 314 + 315 + return -ENODEV; 316 + } 317 + 288 318 static int axnet_config(struct pcmcia_device *link) 289 319 { 290 320 struct net_device *dev = link->priv; 291 321 axnet_dev_t *info = PRIV(dev); 292 - tuple_t tuple; 293 - cisparse_t parse; 294 322 int i, j, last_ret, last_fn; 295 - u_short buf[64]; 296 323 DECLARE_MAC_BUF(mac); 297 324 298 325 DEBUG(0, "axnet_config(0x%p)\n", link); 299 326 300 - tuple.Attributes = 0; 301 - tuple.TupleData = (cisdata_t *)buf; 302 - tuple.TupleDataMax = sizeof(buf); 303 - tuple.TupleOffset = 0; 304 - 305 327 /* don't trust the CIS on this; Linksys got it wrong */ 306 328 link->conf.Present = 0x63; 307 - 308 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 309 - tuple.Attributes = 0; 310 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 311 - while (last_ret == CS_SUCCESS) { 312 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 313 - cistpl_io_t *io = &(parse.cftable_entry.io); 314 - 315 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 316 - pcmcia_parse_tuple(link, &tuple, &parse) != 0 || 317 - cfg->index == 0 || cfg->io.nwin == 0) 318 - goto next_entry; 319 - 320 - link->conf.ConfigIndex = 0x05; 321 - /* For multifunction cards, by convention, we configure the 322 - network function with window 0, and serial with window 1 */ 323 - if (io->nwin > 1) { 324 - i = (io->win[1].len > io->win[0].len); 325 - link->io.BasePort2 = io->win[1-i].base; 326 - link->io.NumPorts2 = io->win[1-i].len; 327 - } else { 328 - i = link->io.NumPorts2 = 0; 329 - } 330 - link->io.BasePort1 = io->win[i].base; 331 - link->io.NumPorts1 = io->win[i].len; 332 - link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 333 - if (link->io.NumPorts1 + link->io.NumPorts2 >= 32) { 334 - last_ret = try_io_port(link); 335 - if (last_ret == CS_SUCCESS) break; 336 - } 337 - next_entry: 338 - last_ret = pcmcia_get_next_tuple(link, &tuple); 339 - } 340 - if (last_ret != CS_SUCCESS) { 329 + last_ret = pcmcia_loop_config(link, axnet_configcheck, NULL); 330 + if (last_ret != 0) { 341 331 cs_error(link, RequestIO, last_ret); 342 332 goto failed; 343 333 }
+4 -4
drivers/net/pcmcia/com20020_cs.c
··· 260 260 DEBUG(0, "com20020_config(0x%p)\n", link); 261 261 262 262 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); 263 - i = !CS_SUCCESS; 263 + i = -ENODEV; 264 264 if (!link->io.BasePort1) 265 265 { 266 266 for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) 267 267 { 268 268 link->io.BasePort1 = ioaddr; 269 269 i = pcmcia_request_io(link, &link->io); 270 - if (i == CS_SUCCESS) 270 + if (i == 0) 271 271 break; 272 272 } 273 273 } 274 274 else 275 275 i = pcmcia_request_io(link, &link->io); 276 276 277 - if (i != CS_SUCCESS) 277 + if (i != 0) 278 278 { 279 279 DEBUG(1,"arcnet: requestIO failed totally!\n"); 280 280 goto failed; ··· 287 287 link->irq.AssignedIRQ, 288 288 link->irq.IRQInfo1, link->irq.IRQInfo2); 289 289 i = pcmcia_request_irq(link, &link->irq); 290 - if (i != CS_SUCCESS) 290 + if (i != 0) 291 291 { 292 292 DEBUG(1,"arcnet: requestIRQ failed totally!\n"); 293 293 goto failed;
+11 -10
drivers/net/pcmcia/fmvj18x_cs.c
··· 309 309 printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n"); 310 310 } 311 311 ret = pcmcia_request_io(link, &link->io); 312 - if (ret == CS_SUCCESS) return ret; 312 + if (ret == 0) 313 + return ret; 313 314 } 314 315 return ret; 315 316 } ··· 326 325 for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) { 327 326 link->io.BasePort1 = ioaddr; 328 327 ret = pcmcia_request_io(link, &link->io); 329 - if (ret == CS_SUCCESS) { 328 + if (ret == 0) { 330 329 /* calculate ConfigIndex value */ 331 330 link->conf.ConfigIndex = 332 331 ((link->io.BasePort1 & 0x0f0) >> 3) | 0x22; ··· 357 356 tuple.TupleOffset = 0; 358 357 tuple.DesiredTuple = CISTPL_FUNCE; 359 358 tuple.TupleOffset = 0; 360 - if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 359 + if (pcmcia_get_first_tuple(link, &tuple) == 0) { 361 360 /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */ 362 361 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 363 362 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 364 363 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 365 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 364 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(&tuple, &parse)); 366 365 link->conf.ConfigIndex = parse.cftable_entry.index; 367 366 switch (link->manf_id) { 368 367 case MANFID_TDK: ··· 431 430 link->irq.Attributes = 432 431 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT; 433 432 ret = mfc_try_io_port(link); 434 - if (ret != CS_SUCCESS) goto cs_failed; 433 + if (ret != 0) goto cs_failed; 435 434 } else if (cardtype == UNGERMANN) { 436 435 ret = ungermann_try_io_port(link); 437 - if (ret != CS_SUCCESS) goto cs_failed; 436 + if (ret != 0) goto cs_failed; 438 437 } else { 439 438 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 440 439 } ··· 566 565 req.Base = 0; req.Size = 0; 567 566 req.AccessSpeed = 0; 568 567 i = pcmcia_request_window(&link, &req, &link->win); 569 - if (i != CS_SUCCESS) { 568 + if (i != 0) { 570 569 cs_error(link, RequestWindow, i); 571 570 return -1; 572 571 } ··· 600 599 601 600 iounmap(base); 602 601 j = pcmcia_release_window(link->win); 603 - if (j != CS_SUCCESS) 602 + if (j != 0) 604 603 cs_error(link, ReleaseWindow, j); 605 604 return (i != 0x200) ? 0 : -1; 606 605 ··· 621 620 req.Base = 0; req.Size = 0; 622 621 req.AccessSpeed = 0; 623 622 i = pcmcia_request_window(&link, &req, &link->win); 624 - if (i != CS_SUCCESS) { 623 + if (i != 0) { 625 624 cs_error(link, RequestWindow, i); 626 625 return -1; 627 626 } ··· 643 642 644 643 iounmap(base); 645 644 j = pcmcia_release_window(link->win); 646 - if (j != CS_SUCCESS) 645 + if (j != 0) 647 646 cs_error(link, ReleaseWindow, j); 648 647 return 0; 649 648
+1 -1
drivers/net/pcmcia/ibmtr_cs.c
··· 238 238 /* Try PRIMARY card at 0xA20-0xA23 */ 239 239 link->io.BasePort1 = 0xA20; 240 240 i = pcmcia_request_io(link, &link->io); 241 - if (i != CS_SUCCESS) { 241 + if (i != 0) { 242 242 /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ 243 243 link->io.BasePort1 = 0xA24; 244 244 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
+1 -1
drivers/net/pcmcia/nmclan_cs.c
··· 925 925 printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); 926 926 #if RESET_ON_TIMEOUT 927 927 printk("resetting card\n"); 928 - pcmcia_reset_card(link, NULL); 928 + pcmcia_reset_card(link->socket); 929 929 #else /* #if RESET_ON_TIMEOUT */ 930 930 printk("NOT resetting card\n"); 931 931 #endif /* #if RESET_ON_TIMEOUT */
+41 -45
drivers/net/pcmcia/pcnet_cs.c
··· 310 310 req.Base = 0; req.Size = 0; 311 311 req.AccessSpeed = 0; 312 312 i = pcmcia_request_window(&link, &req, &link->win); 313 - if (i != CS_SUCCESS) { 313 + if (i != 0) { 314 314 cs_error(link, RequestWindow, i); 315 315 return NULL; 316 316 } ··· 333 333 334 334 iounmap(virt); 335 335 j = pcmcia_release_window(link->win); 336 - if (j != CS_SUCCESS) 336 + if (j != 0) 337 337 cs_error(link, ReleaseWindow, j); 338 338 return (i < NR_INFO) ? hw_info+i : NULL; 339 339 } /* get_hwinfo */ ··· 504 504 link->io.BasePort1 = j ^ 0x300; 505 505 link->io.BasePort2 = (j ^ 0x300) + 0x10; 506 506 ret = pcmcia_request_io(link, &link->io); 507 - if (ret == CS_SUCCESS) return ret; 507 + if (ret == 0) 508 + return ret; 508 509 } 509 510 return ret; 510 511 } else { ··· 513 512 } 514 513 } 515 514 515 + static int pcnet_confcheck(struct pcmcia_device *p_dev, 516 + cistpl_cftable_entry_t *cfg, 517 + cistpl_cftable_entry_t *dflt, 518 + unsigned int vcc, 519 + void *priv_data) 520 + { 521 + int *has_shmem = priv_data; 522 + int i; 523 + cistpl_io_t *io = &cfg->io; 524 + 525 + if (cfg->index == 0 || cfg->io.nwin == 0) 526 + return -EINVAL; 527 + 528 + /* For multifunction cards, by convention, we configure the 529 + network function with window 0, and serial with window 1 */ 530 + if (io->nwin > 1) { 531 + i = (io->win[1].len > io->win[0].len); 532 + p_dev->io.BasePort2 = io->win[1-i].base; 533 + p_dev->io.NumPorts2 = io->win[1-i].len; 534 + } else { 535 + i = p_dev->io.NumPorts2 = 0; 536 + } 537 + 538 + *has_shmem = ((cfg->mem.nwin == 1) && 539 + (cfg->mem.win[0].len >= 0x4000)); 540 + p_dev->io.BasePort1 = io->win[i].base; 541 + p_dev->io.NumPorts1 = io->win[i].len; 542 + p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 543 + if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) 544 + return try_io_port(p_dev); 545 + 546 + return 0; 547 + } 548 + 516 549 static int pcnet_config(struct pcmcia_device *link) 517 550 { 518 551 struct net_device *dev = link->priv; 519 552 pcnet_dev_t *info = PRIV(dev); 520 - tuple_t tuple; 521 - cisparse_t parse; 522 - int i, last_ret, last_fn, start_pg, stop_pg, cm_offset; 553 + int last_ret, last_fn, start_pg, stop_pg, cm_offset; 523 554 int has_shmem = 0; 524 - u_short buf[64]; 525 555 hw_info_t *local_hw_info; 526 556 DECLARE_MAC_BUF(mac); 527 557 528 558 DEBUG(0, "pcnet_config(0x%p)\n", link); 529 559 530 - tuple.TupleData = (cisdata_t *)buf; 531 - tuple.TupleDataMax = sizeof(buf); 532 - tuple.TupleOffset = 0; 533 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 534 - tuple.Attributes = 0; 535 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 536 - while (last_ret == CS_SUCCESS) { 537 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 538 - cistpl_io_t *io = &(parse.cftable_entry.io); 539 - 540 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 541 - pcmcia_parse_tuple(link, &tuple, &parse) != 0 || 542 - cfg->index == 0 || cfg->io.nwin == 0) 543 - goto next_entry; 544 - 545 - link->conf.ConfigIndex = cfg->index; 546 - /* For multifunction cards, by convention, we configure the 547 - network function with window 0, and serial with window 1 */ 548 - if (io->nwin > 1) { 549 - i = (io->win[1].len > io->win[0].len); 550 - link->io.BasePort2 = io->win[1-i].base; 551 - link->io.NumPorts2 = io->win[1-i].len; 552 - } else { 553 - i = link->io.NumPorts2 = 0; 554 - } 555 - has_shmem = ((cfg->mem.nwin == 1) && 556 - (cfg->mem.win[0].len >= 0x4000)); 557 - link->io.BasePort1 = io->win[i].base; 558 - link->io.NumPorts1 = io->win[i].len; 559 - link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 560 - if (link->io.NumPorts1 + link->io.NumPorts2 >= 32) { 561 - last_ret = try_io_port(link); 562 - if (last_ret == CS_SUCCESS) break; 563 - } 564 - next_entry: 565 - last_ret = pcmcia_get_next_tuple(link, &tuple); 566 - } 567 - if (last_ret != CS_SUCCESS) { 560 + last_ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem); 561 + if (last_ret) { 568 562 cs_error(link, RequestIO, last_ret); 569 563 goto failed; 570 564 }
+65 -86
drivers/net/pcmcia/smc91c92_cs.c
··· 409 409 { 410 410 int i; 411 411 412 - if ((i = pcmcia_get_first_tuple(handle, tuple)) != CS_SUCCESS || 413 - (i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS) 412 + i = pcmcia_get_first_tuple(handle, tuple); 413 + if (i != 0) 414 414 return i; 415 - return pcmcia_parse_tuple(handle, tuple, parse); 415 + i = pcmcia_get_tuple_data(handle, tuple); 416 + if (i != 0) 417 + return i; 418 + return pcmcia_parse_tuple(tuple, parse); 416 419 } 417 420 418 421 static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, ··· 423 420 { 424 421 int i; 425 422 426 - if ((i = pcmcia_get_next_tuple(handle, tuple)) != CS_SUCCESS || 427 - (i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS) 423 + if ((i = pcmcia_get_next_tuple(handle, tuple)) != 0 || 424 + (i = pcmcia_get_tuple_data(handle, tuple)) != 0) 428 425 return i; 429 - return pcmcia_parse_tuple(handle, tuple, parse); 426 + return pcmcia_parse_tuple(tuple, parse); 430 427 } 431 428 432 429 /*====================================================================== ··· 462 459 return 0; 463 460 } 464 461 462 + static int mhz_mfc_config_check(struct pcmcia_device *p_dev, 463 + cistpl_cftable_entry_t *cf, 464 + cistpl_cftable_entry_t *dflt, 465 + unsigned int vcc, 466 + void *priv_data) 467 + { 468 + int k; 469 + p_dev->io.BasePort2 = cf->io.win[0].base; 470 + for (k = 0; k < 0x400; k += 0x10) { 471 + if (k & 0x80) 472 + continue; 473 + p_dev->io.BasePort1 = k ^ 0x300; 474 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 475 + return 0; 476 + } 477 + return -ENODEV; 478 + } 479 + 465 480 static int mhz_mfc_config(struct pcmcia_device *link) 466 481 { 467 482 struct net_device *dev = link->priv; 468 483 struct smc_private *smc = netdev_priv(dev); 469 484 struct smc_cfg_mem *cfg_mem; 470 - tuple_t *tuple; 471 - cisparse_t *parse; 472 - cistpl_cftable_entry_t *cf; 473 - u_char *buf; 474 485 win_req_t req; 475 486 memreq_t mem; 476 - int i, k; 487 + int i; 477 488 478 489 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 479 490 if (!cfg_mem) 480 - return CS_OUT_OF_RESOURCE; 481 - 482 - tuple = &cfg_mem->tuple; 483 - parse = &cfg_mem->parse; 484 - cf = &parse->cftable_entry; 485 - buf = cfg_mem->buf; 491 + return -ENOMEM; 486 492 487 493 link->conf.Attributes |= CONF_ENABLE_SPKR; 488 494 link->conf.Status = CCSR_AUDIO_ENA; ··· 501 489 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 502 490 link->io.NumPorts2 = 8; 503 491 504 - tuple->Attributes = tuple->TupleOffset = 0; 505 - tuple->TupleData = (cisdata_t *)buf; 506 - tuple->TupleDataMax = 255; 507 - tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 508 - 509 - i = first_tuple(link, tuple, parse); 510 492 /* The Megahertz combo cards have modem-like CIS entries, so 511 493 we have to explicitly try a bunch of port combinations. */ 512 - while (i == CS_SUCCESS) { 513 - link->conf.ConfigIndex = cf->index; 514 - link->io.BasePort2 = cf->io.win[0].base; 515 - for (k = 0; k < 0x400; k += 0x10) { 516 - if (k & 0x80) continue; 517 - link->io.BasePort1 = k ^ 0x300; 518 - i = pcmcia_request_io(link, &link->io); 519 - if (i == CS_SUCCESS) break; 520 - } 521 - if (i == CS_SUCCESS) break; 522 - i = next_tuple(link, tuple, parse); 523 - } 524 - if (i != CS_SUCCESS) 494 + if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL)) 525 495 goto free_cfg_mem; 526 496 dev->base_addr = link->io.BasePort1; 527 497 ··· 512 518 req.Base = req.Size = 0; 513 519 req.AccessSpeed = 0; 514 520 i = pcmcia_request_window(&link, &req, &link->win); 515 - if (i != CS_SUCCESS) 521 + if (i != 0) 516 522 goto free_cfg_mem; 517 523 smc->base = ioremap(req.Base, req.Size); 518 524 mem.CardOffset = mem.Page = 0; ··· 520 526 mem.CardOffset = link->conf.ConfigBase; 521 527 i = pcmcia_map_mem_page(link->win, &mem); 522 528 523 - if ((i == CS_SUCCESS) 529 + if ((i == 0) 524 530 && (smc->manfid == MANFID_MEGAHERTZ) 525 531 && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 526 532 mhz_3288_power(link); 527 533 528 534 free_cfg_mem: 529 535 kfree(cfg_mem); 530 - return i; 536 + return -ENODEV; 531 537 } 532 538 533 539 static int mhz_setup(struct pcmcia_device *link) ··· 554 560 /* Read the station address from the CIS. It is stored as the last 555 561 (fourth) string in the Version 1 Version/ID tuple. */ 556 562 tuple->DesiredTuple = CISTPL_VERS_1; 557 - if (first_tuple(link, tuple, parse) != CS_SUCCESS) { 563 + if (first_tuple(link, tuple, parse) != 0) { 558 564 rc = -1; 559 565 goto free_cfg_mem; 560 566 } 561 567 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ 562 - if (next_tuple(link, tuple, parse) != CS_SUCCESS) 568 + if (next_tuple(link, tuple, parse) != 0) 563 569 first_tuple(link, tuple, parse); 564 570 if (parse->version_1.ns > 3) { 565 571 station_addr = parse->version_1.str + parse->version_1.ofs[3]; ··· 571 577 572 578 /* Another possibility: for the EM3288, in a special tuple */ 573 579 tuple->DesiredTuple = 0x81; 574 - if (pcmcia_get_first_tuple(link, tuple) != CS_SUCCESS) { 580 + if (pcmcia_get_first_tuple(link, tuple) != 0) { 575 581 rc = -1; 576 582 goto free_cfg_mem; 577 583 } 578 - if (pcmcia_get_tuple_data(link, tuple) != CS_SUCCESS) { 584 + if (pcmcia_get_tuple_data(link, tuple) != 0) { 579 585 rc = -1; 580 586 goto free_cfg_mem; 581 587 } ··· 654 660 655 661 /*====================================================================*/ 656 662 663 + static int smc_configcheck(struct pcmcia_device *p_dev, 664 + cistpl_cftable_entry_t *cf, 665 + cistpl_cftable_entry_t *dflt, 666 + unsigned int vcc, 667 + void *priv_data) 668 + { 669 + p_dev->io.BasePort1 = cf->io.win[0].base; 670 + p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 671 + return pcmcia_request_io(p_dev, &p_dev->io); 672 + } 673 + 657 674 static int smc_config(struct pcmcia_device *link) 658 675 { 659 676 struct net_device *dev = link->priv; 660 - struct smc_cfg_mem *cfg_mem; 661 - tuple_t *tuple; 662 - cisparse_t *parse; 663 - cistpl_cftable_entry_t *cf; 664 - u_char *buf; 665 677 int i; 666 678 667 - cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 668 - if (!cfg_mem) 669 - return CS_OUT_OF_RESOURCE; 670 - 671 - tuple = &cfg_mem->tuple; 672 - parse = &cfg_mem->parse; 673 - cf = &parse->cftable_entry; 674 - buf = cfg_mem->buf; 675 - 676 - tuple->Attributes = tuple->TupleOffset = 0; 677 - tuple->TupleData = (cisdata_t *)buf; 678 - tuple->TupleDataMax = 255; 679 - tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 680 - 681 679 link->io.NumPorts1 = 16; 682 - i = first_tuple(link, tuple, parse); 683 - while (i != CS_NO_MORE_ITEMS) { 684 - if (i == CS_SUCCESS) { 685 - link->conf.ConfigIndex = cf->index; 686 - link->io.BasePort1 = cf->io.win[0].base; 687 - link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 688 - i = pcmcia_request_io(link, &link->io); 689 - if (i == CS_SUCCESS) break; 690 - } 691 - i = next_tuple(link, tuple, parse); 692 - } 693 - if (i == CS_SUCCESS) 694 - dev->base_addr = link->io.BasePort1; 680 + i = pcmcia_loop_config(link, smc_configcheck, NULL); 681 + if (!i) 682 + dev->base_addr = link->io.BasePort1; 695 683 696 - kfree(cfg_mem); 697 684 return i; 698 685 } 699 686 ··· 690 715 691 716 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 692 717 if (!cfg_mem) 693 - return CS_OUT_OF_RESOURCE; 718 + return -ENOMEM; 694 719 695 720 tuple = &cfg_mem->tuple; 696 721 parse = &cfg_mem->parse; ··· 703 728 /* Check for a LAN function extension tuple */ 704 729 tuple->DesiredTuple = CISTPL_FUNCE; 705 730 i = first_tuple(link, tuple, parse); 706 - while (i == CS_SUCCESS) { 731 + while (i == 0) { 707 732 if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) 708 733 break; 709 734 i = next_tuple(link, tuple, parse); 710 735 } 711 - if (i == CS_SUCCESS) { 736 + if (i == 0) { 712 737 node_id = (cistpl_lan_node_id_t *)parse->funce.data; 713 738 if (node_id->nb == 6) { 714 739 for (i = 0; i < 6; i++) ··· 755 780 for (i = j = 0; j < 4; j++) { 756 781 link->io.BasePort2 = com[j]; 757 782 i = pcmcia_request_io(link, &link->io); 758 - if (i == CS_SUCCESS) break; 783 + if (i == 0) 784 + break; 759 785 } 760 - if (i != CS_SUCCESS) { 786 + if (i != 0) { 761 787 /* Fallback: turn off hard decode */ 762 788 link->conf.ConfigIndex = 0x03; 763 789 link->io.NumPorts2 = 0; ··· 791 815 /* Read the station address from tuple 0x90, subtuple 0x04 */ 792 816 tuple->DesiredTuple = 0x90; 793 817 i = pcmcia_get_first_tuple(link, tuple); 794 - while (i == CS_SUCCESS) { 818 + while (i == 0) { 795 819 i = pcmcia_get_tuple_data(link, tuple); 796 - if ((i != CS_SUCCESS) || (buf[0] == 0x04)) 820 + if ((i != 0) || (buf[0] == 0x04)) 797 821 break; 798 822 i = pcmcia_get_next_tuple(link, tuple); 799 823 } 800 - if (i != CS_SUCCESS) { 824 + if (i != 0) { 801 825 rc = -1; 802 826 goto free_cfg_mem; 803 827 } ··· 935 959 936 960 ======================================================================*/ 937 961 938 - #define CS_EXIT_TEST(ret, svc, label) \ 939 - if (ret != CS_SUCCESS) { cs_error(link, svc, ret); goto label; } 962 + #define CS_EXIT_TEST(ret, svc, label) \ 963 + if (ret != 0) { \ 964 + cs_error(link, svc, ret); \ 965 + goto label; \ 966 + } 940 967 941 968 static int smc91c92_config(struct pcmcia_device *link) 942 969 {
+48 -31
drivers/net/pcmcia/xirc2ps_cs.c
··· 377 377 378 378 if ((err = pcmcia_get_first_tuple(handle, tuple)) == 0 && 379 379 (err = pcmcia_get_tuple_data(handle, tuple)) == 0) 380 - err = pcmcia_parse_tuple(handle, tuple, parse); 380 + err = pcmcia_parse_tuple(tuple, parse); 381 381 return err; 382 382 } 383 383 ··· 388 388 389 389 if ((err = pcmcia_get_next_tuple(handle, tuple)) == 0 && 390 390 (err = pcmcia_get_tuple_data(handle, tuple)) == 0) 391 - err = pcmcia_parse_tuple(handle, tuple, parse); 391 + err = pcmcia_parse_tuple(tuple, parse); 392 392 return err; 393 393 } 394 394 ··· 715 715 return 0; 716 716 } 717 717 718 + static int 719 + xirc2ps_config_modem(struct pcmcia_device *p_dev, 720 + cistpl_cftable_entry_t *cf, 721 + cistpl_cftable_entry_t *dflt, 722 + unsigned int vcc, 723 + void *priv_data) 724 + { 725 + unsigned int ioaddr; 726 + 727 + if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 728 + for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 729 + p_dev->io.BasePort2 = cf->io.win[0].base; 730 + p_dev->io.BasePort1 = ioaddr; 731 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 732 + return 0; 733 + } 734 + } 735 + return -ENODEV; 736 + } 737 + 738 + static int 739 + xirc2ps_config_check(struct pcmcia_device *p_dev, 740 + cistpl_cftable_entry_t *cf, 741 + cistpl_cftable_entry_t *dflt, 742 + unsigned int vcc, 743 + void *priv_data) 744 + { 745 + int *pass = priv_data; 746 + 747 + if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 748 + p_dev->io.BasePort2 = cf->io.win[0].base; 749 + p_dev->io.BasePort1 = p_dev->io.BasePort2 750 + + (*pass ? (cf->index & 0x20 ? -24:8) 751 + : (cf->index & 0x20 ? 8:-24)); 752 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 753 + return 0; 754 + } 755 + return -ENODEV; 756 + 757 + } 758 + 718 759 /**************** 719 760 * xirc2ps_config() is scheduled to run after a CARD_INSERTION event 720 761 * is received, to configure the PCMCIA socket, and to make the ··· 766 725 { 767 726 struct net_device *dev = link->priv; 768 727 local_info_t *local = netdev_priv(dev); 728 + unsigned int ioaddr; 769 729 tuple_t tuple; 770 730 cisparse_t parse; 771 - unsigned int ioaddr; 772 731 int err, i; 773 732 u_char buf[64]; 774 733 cistpl_lan_node_id_t *node_id = (cistpl_lan_node_id_t*)parse.funce.data; 775 - cistpl_cftable_entry_t *cf = &parse.cftable_entry; 776 734 DECLARE_MAC_BUF(mac); 777 735 778 736 local->dingo_ccr = NULL; ··· 886 846 /* Take the Modem IO port from the CIS and scan for a free 887 847 * Ethernet port */ 888 848 link->io.NumPorts1 = 16; /* no Mako stuff anymore */ 889 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 890 - for (err = first_tuple(link, &tuple, &parse); !err; 891 - err = next_tuple(link, &tuple, &parse)) { 892 - if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 893 - for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 894 - link->conf.ConfigIndex = cf->index ; 895 - link->io.BasePort2 = cf->io.win[0].base; 896 - link->io.BasePort1 = ioaddr; 897 - if (!(err=pcmcia_request_io(link, &link->io))) 898 - goto port_found; 899 - } 900 - } 901 - } 849 + if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL)) 850 + goto port_found; 902 851 } else { 903 852 link->io.NumPorts1 = 18; 904 853 /* We do 2 passes here: The first one uses the regular mapping and ··· 895 866 * mirrored every 32 bytes. Actually we use a mirrored port for 896 867 * the Mako if (on the first pass) the COR bit 5 is set. 897 868 */ 898 - for (pass=0; pass < 2; pass++) { 899 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 900 - for (err = first_tuple(link, &tuple, &parse); !err; 901 - err = next_tuple(link, &tuple, &parse)){ 902 - if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8){ 903 - link->conf.ConfigIndex = cf->index ; 904 - link->io.BasePort2 = cf->io.win[0].base; 905 - link->io.BasePort1 = link->io.BasePort2 906 - + (pass ? (cf->index & 0x20 ? -24:8) 907 - : (cf->index & 0x20 ? 8:-24)); 908 - if (!(err=pcmcia_request_io(link, &link->io))) 869 + for (pass=0; pass < 2; pass++) 870 + if (!pcmcia_loop_config(link, xirc2ps_config_check, &pass)) 909 871 goto port_found; 910 - } 911 - } 912 - } 913 872 /* if special option: 914 873 * try to configure as Ethernet only. 915 874 * .... */
+111 -111
drivers/net/wireless/airo_cs.c
··· 206 206 #define CS_CHECK(fn, ret) \ 207 207 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 208 208 209 + static int airo_cs_config_check(struct pcmcia_device *p_dev, 210 + cistpl_cftable_entry_t *cfg, 211 + cistpl_cftable_entry_t *dflt, 212 + unsigned int vcc, 213 + void *priv_data) 214 + { 215 + win_req_t *req = priv_data; 216 + 217 + if (cfg->index == 0) 218 + return -ENODEV; 219 + 220 + /* Does this card need audio output? */ 221 + if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 222 + p_dev->conf.Attributes |= CONF_ENABLE_SPKR; 223 + p_dev->conf.Status = CCSR_AUDIO_ENA; 224 + } 225 + 226 + /* Use power settings for Vcc and Vpp if present */ 227 + /* Note that the CIS values need to be rescaled */ 228 + if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 229 + p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 230 + else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) 231 + p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; 232 + 233 + /* Do we need to allocate an interrupt? */ 234 + if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) 235 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 236 + 237 + /* IO window settings */ 238 + p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 239 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 240 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 241 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 242 + if (!(io->flags & CISTPL_IO_8BIT)) 243 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 244 + if (!(io->flags & CISTPL_IO_16BIT)) 245 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 246 + p_dev->io.BasePort1 = io->win[0].base; 247 + p_dev->io.NumPorts1 = io->win[0].len; 248 + if (io->nwin > 1) { 249 + p_dev->io.Attributes2 = p_dev->io.Attributes1; 250 + p_dev->io.BasePort2 = io->win[1].base; 251 + p_dev->io.NumPorts2 = io->win[1].len; 252 + } 253 + } 254 + 255 + /* This reserves IO space but doesn't actually enable it */ 256 + if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 257 + return -ENODEV; 258 + 259 + /* 260 + Now set up a common memory window, if needed. There is room 261 + in the struct pcmcia_device structure for one memory window handle, 262 + but if the base addresses need to be saved, or if multiple 263 + windows are needed, the info should go in the private data 264 + structure for this device. 265 + 266 + Note that the memory window base is a physical address, and 267 + needs to be mapped to virtual space with ioremap() before it 268 + is used. 269 + */ 270 + if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { 271 + cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; 272 + memreq_t map; 273 + req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 274 + req->Base = mem->win[0].host_addr; 275 + req->Size = mem->win[0].len; 276 + req->AccessSpeed = 0; 277 + if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0) 278 + return -ENODEV; 279 + map.Page = 0; 280 + map.CardOffset = mem->win[0].card_addr; 281 + if (pcmcia_map_mem_page(p_dev->win, &map) != 0) 282 + return -ENODEV; 283 + } 284 + /* If we got this far, we're cool! */ 285 + return 0; 286 + } 287 + 288 + 209 289 static int airo_config(struct pcmcia_device *link) 210 290 { 211 - tuple_t tuple; 212 - cisparse_t parse; 213 291 local_info_t *dev; 292 + win_req_t *req; 214 293 int last_fn, last_ret; 215 - u_char buf[64]; 216 - win_req_t req; 217 - memreq_t map; 218 294 219 295 dev = link->priv; 220 296 221 297 DEBUG(0, "airo_config(0x%p)\n", link); 222 298 299 + req = kzalloc(sizeof(win_req_t), GFP_KERNEL); 300 + if (!req) 301 + return -ENOMEM; 302 + 223 303 /* 224 - In this loop, we scan the CIS for configuration table entries, 225 - each of which describes a valid card configuration, including 226 - voltage, IO window, memory window, and interrupt settings. 227 - 228 - We make no assumptions about the card to be configured: we use 229 - just the information available in the CIS. In an ideal world, 230 - this would work for any PCMCIA card, but it requires a complete 231 - and accurate CIS. In practice, a driver usually "knows" most of 232 - these things without consulting the CIS, and most client drivers 233 - will only use the CIS to fill in implementation-defined details. 304 + * In this loop, we scan the CIS for configuration table 305 + * entries, each of which describes a valid card 306 + * configuration, including voltage, IO window, memory window, 307 + * and interrupt settings. 308 + * 309 + * We make no assumptions about the card to be configured: we 310 + * use just the information available in the CIS. In an ideal 311 + * world, this would work for any PCMCIA card, but it requires 312 + * a complete and accurate CIS. In practice, a driver usually 313 + * "knows" most of these things without consulting the CIS, 314 + * and most client drivers will only use the CIS to fill in 315 + * implementation-defined details. 316 + */ 317 + last_ret = pcmcia_loop_config(link, airo_cs_config_check, req); 318 + if (last_ret) 319 + goto failed; 320 + 321 + /* 322 + Allocate an interrupt line. Note that this does not assign a 323 + handler to the interrupt, unless the 'Handler' member of the 324 + irq structure is initialized. 234 325 */ 235 - tuple.Attributes = 0; 236 - tuple.TupleData = buf; 237 - tuple.TupleDataMax = sizeof(buf); 238 - tuple.TupleOffset = 0; 239 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 240 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 241 - while (1) { 242 - cistpl_cftable_entry_t dflt = { 0 }; 243 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 244 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 245 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 246 - goto next_entry; 247 - 248 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 249 - if (cfg->index == 0) goto next_entry; 250 - link->conf.ConfigIndex = cfg->index; 251 - 252 - /* Does this card need audio output? */ 253 - if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 254 - link->conf.Attributes |= CONF_ENABLE_SPKR; 255 - link->conf.Status = CCSR_AUDIO_ENA; 256 - } 257 - 258 - /* Use power settings for Vcc and Vpp if present */ 259 - /* Note that the CIS values need to be rescaled */ 260 - if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 261 - link->conf.Vpp = 262 - cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 263 - else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 264 - link->conf.Vpp = 265 - dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 266 - 267 - /* Do we need to allocate an interrupt? */ 268 - if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) 269 - link->conf.Attributes |= CONF_ENABLE_IRQ; 270 - 271 - /* IO window settings */ 272 - link->io.NumPorts1 = link->io.NumPorts2 = 0; 273 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 274 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 275 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 276 - if (!(io->flags & CISTPL_IO_8BIT)) 277 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 278 - if (!(io->flags & CISTPL_IO_16BIT)) 279 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 280 - link->io.BasePort1 = io->win[0].base; 281 - link->io.NumPorts1 = io->win[0].len; 282 - if (io->nwin > 1) { 283 - link->io.Attributes2 = link->io.Attributes1; 284 - link->io.BasePort2 = io->win[1].base; 285 - link->io.NumPorts2 = io->win[1].len; 286 - } 287 - } 288 - 289 - /* This reserves IO space but doesn't actually enable it */ 290 - if (pcmcia_request_io(link, &link->io) != 0) 291 - goto next_entry; 292 - 293 - /* 294 - Now set up a common memory window, if needed. There is room 295 - in the struct pcmcia_device structure for one memory window handle, 296 - but if the base addresses need to be saved, or if multiple 297 - windows are needed, the info should go in the private data 298 - structure for this device. 299 - 300 - Note that the memory window base is a physical address, and 301 - needs to be mapped to virtual space with ioremap() before it 302 - is used. 303 - */ 304 - if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { 305 - cistpl_mem_t *mem = 306 - (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; 307 - req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 308 - req.Base = mem->win[0].host_addr; 309 - req.Size = mem->win[0].len; 310 - req.AccessSpeed = 0; 311 - if (pcmcia_request_window(&link, &req, &link->win) != 0) 312 - goto next_entry; 313 - map.Page = 0; map.CardOffset = mem->win[0].card_addr; 314 - if (pcmcia_map_mem_page(link->win, &map) != 0) 315 - goto next_entry; 316 - } 317 - /* If we got this far, we're cool! */ 318 - break; 319 - 320 - next_entry: 321 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 322 - } 323 - 324 - /* 325 - Allocate an interrupt line. Note that this does not assign a 326 - handler to the interrupt, unless the 'Handler' member of the 327 - irq structure is initialized. 328 - */ 329 326 if (link->conf.Attributes & CONF_ENABLE_IRQ) 330 327 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 331 328 ··· 359 362 printk(" & 0x%04x-0x%04x", link->io.BasePort2, 360 363 link->io.BasePort2+link->io.NumPorts2-1); 361 364 if (link->win) 362 - printk(", mem 0x%06lx-0x%06lx", req.Base, 363 - req.Base+req.Size-1); 365 + printk(", mem 0x%06lx-0x%06lx", req->Base, 366 + req->Base+req->Size-1); 364 367 printk("\n"); 368 + kfree(req); 365 369 return 0; 366 370 367 371 cs_failed: 368 372 cs_error(link, last_fn, last_ret); 373 + failed: 369 374 airo_release(link); 375 + kfree(req); 370 376 return -ENODEV; 371 377 } /* airo_config */ 372 378
+51 -68
drivers/net/wireless/atmel_cs.c
··· 224 224 return 0; 225 225 } 226 226 227 + static int atmel_config_check(struct pcmcia_device *p_dev, 228 + cistpl_cftable_entry_t *cfg, 229 + cistpl_cftable_entry_t *dflt, 230 + unsigned int vcc, 231 + void *priv_data) 232 + { 233 + if (cfg->index == 0) 234 + return -ENODEV; 235 + 236 + /* Does this card need audio output? */ 237 + if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 238 + p_dev->conf.Attributes |= CONF_ENABLE_SPKR; 239 + p_dev->conf.Status = CCSR_AUDIO_ENA; 240 + } 241 + 242 + /* Use power settings for Vcc and Vpp if present */ 243 + /* Note that the CIS values need to be rescaled */ 244 + if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 245 + p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 246 + else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) 247 + p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; 248 + 249 + /* Do we need to allocate an interrupt? */ 250 + if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) 251 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 252 + 253 + /* IO window settings */ 254 + p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 255 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 256 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 257 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 258 + if (!(io->flags & CISTPL_IO_8BIT)) 259 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 260 + if (!(io->flags & CISTPL_IO_16BIT)) 261 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 262 + p_dev->io.BasePort1 = io->win[0].base; 263 + p_dev->io.NumPorts1 = io->win[0].len; 264 + if (io->nwin > 1) { 265 + p_dev->io.Attributes2 = p_dev->io.Attributes1; 266 + p_dev->io.BasePort2 = io->win[1].base; 267 + p_dev->io.NumPorts2 = io->win[1].len; 268 + } 269 + } 270 + 271 + /* This reserves IO space but doesn't actually enable it */ 272 + return pcmcia_request_io(p_dev, &p_dev->io); 273 + } 274 + 227 275 static int atmel_config(struct pcmcia_device *link) 228 276 { 229 - tuple_t tuple; 230 - cisparse_t parse; 231 277 local_info_t *dev; 232 278 int last_fn, last_ret; 233 - u_char buf[64]; 234 279 struct pcmcia_device_id *did; 235 280 236 281 dev = link->priv; 237 282 did = handle_to_dev(link).driver_data; 238 283 239 284 DEBUG(0, "atmel_config(0x%p)\n", link); 240 - 241 - tuple.Attributes = 0; 242 - tuple.TupleData = buf; 243 - tuple.TupleDataMax = sizeof(buf); 244 - tuple.TupleOffset = 0; 245 285 246 286 /* 247 287 In this loop, we scan the CIS for configuration table entries, ··· 295 255 these things without consulting the CIS, and most client drivers 296 256 will only use the CIS to fill in implementation-defined details. 297 257 */ 298 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 299 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 300 - while (1) { 301 - cistpl_cftable_entry_t dflt = { 0 }; 302 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 303 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 304 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 305 - goto next_entry; 306 - 307 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 308 - if (cfg->index == 0) goto next_entry; 309 - link->conf.ConfigIndex = cfg->index; 310 - 311 - /* Does this card need audio output? */ 312 - if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 313 - link->conf.Attributes |= CONF_ENABLE_SPKR; 314 - link->conf.Status = CCSR_AUDIO_ENA; 315 - } 316 - 317 - /* Use power settings for Vcc and Vpp if present */ 318 - /* Note that the CIS values need to be rescaled */ 319 - if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 320 - link->conf.Vpp = 321 - cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 322 - else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 323 - link->conf.Vpp = 324 - dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 325 - 326 - /* Do we need to allocate an interrupt? */ 327 - if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) 328 - link->conf.Attributes |= CONF_ENABLE_IRQ; 329 - 330 - /* IO window settings */ 331 - link->io.NumPorts1 = link->io.NumPorts2 = 0; 332 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 333 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 334 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 335 - if (!(io->flags & CISTPL_IO_8BIT)) 336 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 337 - if (!(io->flags & CISTPL_IO_16BIT)) 338 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 339 - link->io.BasePort1 = io->win[0].base; 340 - link->io.NumPorts1 = io->win[0].len; 341 - if (io->nwin > 1) { 342 - link->io.Attributes2 = link->io.Attributes1; 343 - link->io.BasePort2 = io->win[1].base; 344 - link->io.NumPorts2 = io->win[1].len; 345 - } 346 - } 347 - 348 - /* This reserves IO space but doesn't actually enable it */ 349 - if (pcmcia_request_io(link, &link->io) != 0) 350 - goto next_entry; 351 - 352 - /* If we got this far, we're cool! */ 353 - break; 354 - 355 - next_entry: 356 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 357 - } 258 + if (pcmcia_loop_config(link, atmel_config_check, NULL)) 259 + goto failed; 358 260 359 261 /* 360 262 Allocate an interrupt line. Note that this does not assign a ··· 342 360 343 361 cs_failed: 344 362 cs_error(link, last_fn, last_ret); 363 + failed: 345 364 atmel_release(link); 346 365 return -ENODEV; 347 366 }
+8 -8
drivers/net/wireless/b43/pcmcia.c
··· 82 82 tuple.TupleOffset = 0; 83 83 84 84 res = pcmcia_get_first_tuple(dev, &tuple); 85 - if (res != CS_SUCCESS) 85 + if (res != 0) 86 86 goto err_kfree_ssb; 87 87 res = pcmcia_get_tuple_data(dev, &tuple); 88 - if (res != CS_SUCCESS) 88 + if (res != 0) 89 89 goto err_kfree_ssb; 90 - res = pcmcia_parse_tuple(dev, &tuple, &parse); 91 - if (res != CS_SUCCESS) 90 + res = pcmcia_parse_tuple(&tuple, &parse); 91 + if (res != 0) 92 92 goto err_kfree_ssb; 93 93 94 94 dev->conf.ConfigBase = parse.config.base; ··· 107 107 win.Size = SSB_CORE_SIZE; 108 108 win.AccessSpeed = 250; 109 109 res = pcmcia_request_window(&dev, &win, &dev->win); 110 - if (res != CS_SUCCESS) 110 + if (res != 0) 111 111 goto err_kfree_ssb; 112 112 113 113 mem.CardOffset = 0; 114 114 mem.Page = 0; 115 115 res = pcmcia_map_mem_page(dev->win, &mem); 116 - if (res != CS_SUCCESS) 116 + if (res != 0) 117 117 goto err_disable; 118 118 119 119 dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; ··· 121 121 dev->irq.Handler = NULL; /* The handler is registered later. */ 122 122 dev->irq.Instance = NULL; 123 123 res = pcmcia_request_irq(dev, &dev->irq); 124 - if (res != CS_SUCCESS) 124 + if (res != 0) 125 125 goto err_disable; 126 126 127 127 res = pcmcia_request_configuration(dev, &dev->conf); 128 - if (res != CS_SUCCESS) 128 + if (res != 0) 129 129 goto err_disable; 130 130 131 131 err = ssb_bus_pcmciabus_register(ssb, dev, win.Base);
+104 -133
drivers/net/wireless/hostap/hostap_cs.c
··· 234 234 reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; 235 235 res = pcmcia_access_configuration_register(hw_priv->link, 236 236 &reg); 237 - if (res != CS_SUCCESS) { 237 + if (res != 0) { 238 238 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" 239 239 " res=%d\n", res); 240 240 } ··· 246 246 reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; 247 247 res = pcmcia_access_configuration_register(hw_priv->link, 248 248 &reg); 249 - if (res != CS_SUCCESS) { 249 + if (res != 0) { 250 250 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" 251 251 " res=%d\n", res); 252 252 } ··· 305 305 tuple.DesiredTuple = CISTPL_LONGLINK_MFC; 306 306 if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || 307 307 pcmcia_get_tuple_data(hw_priv->link, &tuple) || 308 - pcmcia_parse_tuple(hw_priv->link, &tuple, parse) || 308 + pcmcia_parse_tuple(&tuple, parse) || 309 309 parse->longlink_mfc.nfn < 2) { 310 310 /* No multi-function links found */ 311 311 ret = -ENODEV; ··· 322 322 reg.Value = COR_SOFT_RESET; 323 323 res = pcmcia_access_configuration_register(hw_priv->link, 324 324 &reg); 325 - if (res != CS_SUCCESS) { 325 + if (res != 0) { 326 326 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 327 327 dev->name, res); 328 328 goto done; ··· 339 339 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; 340 340 res = pcmcia_access_configuration_register(hw_priv->link, 341 341 &reg); 342 - if (res != CS_SUCCESS) { 342 + if (res != 0) { 343 343 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 344 344 dev->name, res); 345 345 goto done; ··· 374 374 reg.Value = 0; 375 375 res = pcmcia_access_configuration_register(hw_priv->link, 376 376 &reg); 377 - if (res != CS_SUCCESS) { 377 + if (res != 0) { 378 378 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", 379 379 res); 380 380 return; ··· 386 386 reg.Value |= COR_SOFT_RESET; 387 387 res = pcmcia_access_configuration_register(hw_priv->link, 388 388 &reg); 389 - if (res != CS_SUCCESS) { 389 + if (res != 0) { 390 390 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", 391 391 res); 392 392 return; ··· 399 399 reg.Value |= COR_IREQ_ENA; 400 400 res = pcmcia_access_configuration_register(hw_priv->link, 401 401 &reg); 402 - if (res != CS_SUCCESS) { 402 + if (res != 0) { 403 403 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", 404 404 res); 405 405 return; ··· 433 433 reg.Value = 0; 434 434 res = pcmcia_access_configuration_register(hw_priv->link, 435 435 &reg); 436 - if (res != CS_SUCCESS) { 436 + if (res != 0) { 437 437 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " 438 438 "(%d)\n", res); 439 439 return; ··· 446 446 reg.Value |= COR_SOFT_RESET; 447 447 res = pcmcia_access_configuration_register(hw_priv->link, 448 448 &reg); 449 - if (res != CS_SUCCESS) { 449 + if (res != 0) { 450 450 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " 451 451 "(%d)\n", res); 452 452 return; ··· 460 460 reg.Offset = CISREG_CCSR; 461 461 res = pcmcia_access_configuration_register(hw_priv->link, 462 462 &reg); 463 - if (res != CS_SUCCESS) { 463 + if (res != 0) { 464 464 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " 465 465 "(%d)\n", res); 466 466 return; ··· 472 472 reg.Value = old_cor & ~COR_SOFT_RESET; 473 473 res = pcmcia_access_configuration_register(hw_priv->link, 474 474 &reg); 475 - if (res != CS_SUCCESS) { 475 + if (res != 0) { 476 476 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " 477 477 "(%d)\n", res); 478 478 return; ··· 532 532 #define CS_CHECK(fn, ret) \ 533 533 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 534 534 535 - #define CFG_CHECK2(fn, retf) \ 536 - do { int _ret = (retf); \ 537 - if (_ret != 0) { \ 538 - PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", _ret); \ 539 - cs_error(link, fn, _ret); \ 540 - goto next_entry; \ 541 - } \ 542 - } while (0) 543 - 544 535 545 536 /* run after a CARD_INSERTION event is received to configure the PCMCIA 546 537 * socket and make the device available to the system */ 538 + 539 + static int prism2_config_check(struct pcmcia_device *p_dev, 540 + cistpl_cftable_entry_t *cfg, 541 + cistpl_cftable_entry_t *dflt, 542 + unsigned int vcc, 543 + void *priv_data) 544 + { 545 + if (cfg->index == 0) 546 + return -ENODEV; 547 + 548 + PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X " 549 + "(default 0x%02X)\n", cfg->index, dflt->index); 550 + 551 + /* Does this card need audio output? */ 552 + if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 553 + p_dev->conf.Attributes |= CONF_ENABLE_SPKR; 554 + p_dev->conf.Status = CCSR_AUDIO_ENA; 555 + } 556 + 557 + /* Use power settings for Vcc and Vpp if present */ 558 + /* Note that the CIS values need to be rescaled */ 559 + if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 560 + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 561 + 10000 && !ignore_cis_vcc) { 562 + PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping" 563 + " this entry\n"); 564 + return -ENODEV; 565 + } 566 + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { 567 + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 568 + 10000 && !ignore_cis_vcc) { 569 + PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " 570 + "- skipping this entry\n"); 571 + return -ENODEV; 572 + } 573 + } 574 + 575 + if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 576 + p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 577 + else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) 578 + p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 579 + 580 + /* Do we need to allocate an interrupt? */ 581 + if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) 582 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 583 + else if (!(p_dev->conf.Attributes & CONF_ENABLE_IRQ)) { 584 + /* At least Compaq WL200 does not have IRQInfo1 set, 585 + * but it does not work without interrupts.. */ 586 + printk(KERN_WARNING "Config has no IRQ info, but trying to " 587 + "enable IRQ anyway..\n"); 588 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 589 + } 590 + 591 + /* IO window settings */ 592 + PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " 593 + "dflt->io.nwin=%d\n", 594 + cfg->io.nwin, dflt->io.nwin); 595 + p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 596 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 597 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 598 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 599 + PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " 600 + "io.base=0x%04x, len=%d\n", io->flags, 601 + io->win[0].base, io->win[0].len); 602 + if (!(io->flags & CISTPL_IO_8BIT)) 603 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 604 + if (!(io->flags & CISTPL_IO_16BIT)) 605 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 606 + p_dev->io.IOAddrLines = io->flags & 607 + CISTPL_IO_LINES_MASK; 608 + p_dev->io.BasePort1 = io->win[0].base; 609 + p_dev->io.NumPorts1 = io->win[0].len; 610 + if (io->nwin > 1) { 611 + p_dev->io.Attributes2 = p_dev->io.Attributes1; 612 + p_dev->io.BasePort2 = io->win[1].base; 613 + p_dev->io.NumPorts2 = io->win[1].len; 614 + } 615 + } 616 + 617 + /* This reserves IO space but doesn't actually enable it */ 618 + return pcmcia_request_io(p_dev, &p_dev->io); 619 + } 620 + 547 621 static int prism2_config(struct pcmcia_device *link) 548 622 { 549 623 struct net_device *dev; 550 624 struct hostap_interface *iface; 551 625 local_info_t *local; 552 626 int ret = 1; 553 - tuple_t tuple; 554 - cisparse_t *parse; 555 627 int last_fn, last_ret; 556 - u_char buf[64]; 557 - config_info_t conf; 558 - cistpl_cftable_entry_t dflt = { 0 }; 559 628 struct hostap_cs_priv *hw_priv; 560 629 561 630 PDEBUG(DEBUG_FLOW, "prism2_config()\n"); 562 631 563 - parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); 564 632 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); 565 - if (parse == NULL || hw_priv == NULL) { 633 + if (hw_priv == NULL) { 566 634 ret = -ENOMEM; 567 635 goto failed; 568 636 } 569 637 570 - tuple.Attributes = 0; 571 - tuple.TupleData = buf; 572 - tuple.TupleDataMax = sizeof(buf); 573 - tuple.TupleOffset = 0; 574 - 575 - CS_CHECK(GetConfigurationInfo, 576 - pcmcia_get_configuration_info(link, &conf)); 577 - 578 638 /* Look for an appropriate configuration table entry in the CIS */ 579 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 580 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 581 - for (;;) { 582 - cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); 583 - CFG_CHECK2(GetTupleData, 584 - pcmcia_get_tuple_data(link, &tuple)); 585 - CFG_CHECK2(ParseTuple, 586 - pcmcia_parse_tuple(link, &tuple, parse)); 587 - 588 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 589 - dflt = *cfg; 590 - if (cfg->index == 0) 591 - goto next_entry; 592 - link->conf.ConfigIndex = cfg->index; 593 - PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X " 594 - "(default 0x%02X)\n", cfg->index, dflt.index); 595 - 596 - /* Does this card need audio output? */ 597 - if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 598 - link->conf.Attributes |= CONF_ENABLE_SPKR; 599 - link->conf.Status = CCSR_AUDIO_ENA; 600 - } 601 - 602 - /* Use power settings for Vcc and Vpp if present */ 603 - /* Note that the CIS values need to be rescaled */ 604 - if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 605 - if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 606 - 10000 && !ignore_cis_vcc) { 607 - PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping" 608 - " this entry\n"); 609 - goto next_entry; 610 - } 611 - } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { 612 - if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 613 - 10000 && !ignore_cis_vcc) { 614 - PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " 615 - "- skipping this entry\n"); 616 - goto next_entry; 617 - } 618 - } 619 - 620 - if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 621 - link->conf.Vpp = 622 - cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 623 - else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 624 - link->conf.Vpp = 625 - dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 626 - 627 - /* Do we need to allocate an interrupt? */ 628 - if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) 629 - link->conf.Attributes |= CONF_ENABLE_IRQ; 630 - else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) { 631 - /* At least Compaq WL200 does not have IRQInfo1 set, 632 - * but it does not work without interrupts.. */ 633 - printk("Config has no IRQ info, but trying to enable " 634 - "IRQ anyway..\n"); 635 - link->conf.Attributes |= CONF_ENABLE_IRQ; 636 - } 637 - 638 - /* IO window settings */ 639 - PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " 640 - "dflt.io.nwin=%d\n", 641 - cfg->io.nwin, dflt.io.nwin); 642 - link->io.NumPorts1 = link->io.NumPorts2 = 0; 643 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 644 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 645 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 646 - PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " 647 - "io.base=0x%04x, len=%d\n", io->flags, 648 - io->win[0].base, io->win[0].len); 649 - if (!(io->flags & CISTPL_IO_8BIT)) 650 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 651 - if (!(io->flags & CISTPL_IO_16BIT)) 652 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 653 - link->io.IOAddrLines = io->flags & 654 - CISTPL_IO_LINES_MASK; 655 - link->io.BasePort1 = io->win[0].base; 656 - link->io.NumPorts1 = io->win[0].len; 657 - if (io->nwin > 1) { 658 - link->io.Attributes2 = link->io.Attributes1; 659 - link->io.BasePort2 = io->win[1].base; 660 - link->io.NumPorts2 = io->win[1].len; 661 - } 662 - } 663 - 664 - /* This reserves IO space but doesn't actually enable it */ 665 - CFG_CHECK2(RequestIO, 666 - pcmcia_request_io(link, &link->io)); 667 - 668 - /* This configuration table entry is OK */ 669 - break; 670 - 671 - next_entry: 672 - CS_CHECK(GetNextTuple, 673 - pcmcia_get_next_tuple(link, &tuple)); 639 + last_ret = pcmcia_loop_config(link, prism2_config_check, NULL); 640 + if (last_ret) { 641 + if (!ignore_cis_vcc) 642 + printk(KERN_ERR "GetNextTuple(): No matching " 643 + "CIS configuration. Maybe you need the " 644 + "ignore_cis_vcc=1 parameter.\n"); 645 + cs_error(link, RequestIO, last_ret); 646 + goto failed; 674 647 } 675 648 676 649 /* Need to allocate net_device before requesting IRQ handler */ ··· 711 738 if (ret == 0 && local->ddev) 712 739 strcpy(hw_priv->node.dev_name, local->ddev->name); 713 740 } 714 - kfree(parse); 715 741 return ret; 716 742 717 743 cs_failed: 718 744 cs_error(link, last_fn, last_ret); 719 745 720 746 failed: 721 - kfree(parse); 722 747 kfree(hw_priv); 723 748 prism2_release((u_long)link); 724 749 return ret;
+1 -1
drivers/net/wireless/libertas/if_cs.c
··· 791 791 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 792 792 if ((ret = pcmcia_get_first_tuple(p_dev, &tuple)) != 0 || 793 793 (ret = pcmcia_get_tuple_data(p_dev, &tuple)) != 0 || 794 - (ret = pcmcia_parse_tuple(p_dev, &tuple, &parse)) != 0) 794 + (ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) 795 795 { 796 796 lbs_pr_err("error in pcmcia_get_first_tuple etc\n"); 797 797 goto out1;
+3 -2
drivers/net/wireless/netwave_cs.c
··· 749 749 for (i = j = 0x0; j < 0x400; j += 0x20) { 750 750 link->io.BasePort1 = j ^ 0x300; 751 751 i = pcmcia_request_io(link, &link->io); 752 - if (i == CS_SUCCESS) break; 752 + if (i == 0) 753 + break; 753 754 } 754 - if (i != CS_SUCCESS) { 755 + if (i != 0) { 755 756 cs_error(link, RequestIO, i); 756 757 goto failed; 757 758 }
+70 -95
drivers/net/wireless/orinoco_cs.c
··· 80 80 /* We need atomic ops here, because we're not holding the lock */ 81 81 set_bit(0, &card->hard_reset_in_progress); 82 82 83 - err = pcmcia_reset_card(link, NULL); 83 + err = pcmcia_reset_card(link->socket); 84 84 if (err) 85 85 return err; 86 86 ··· 165 165 last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ 166 166 } while (0) 167 167 168 + static int orinoco_cs_config_check(struct pcmcia_device *p_dev, 169 + cistpl_cftable_entry_t *cfg, 170 + cistpl_cftable_entry_t *dflt, 171 + unsigned int vcc, 172 + void *priv_data) 173 + { 174 + if (cfg->index == 0) 175 + goto next_entry; 176 + 177 + /* Use power settings for Vcc and Vpp if present */ 178 + /* Note that the CIS values need to be rescaled */ 179 + if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 180 + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { 181 + DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); 182 + if (!ignore_cis_vcc) 183 + goto next_entry; 184 + } 185 + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { 186 + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) { 187 + DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); 188 + if (!ignore_cis_vcc) 189 + goto next_entry; 190 + } 191 + } 192 + 193 + if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 194 + p_dev->conf.Vpp = 195 + cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 196 + else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) 197 + p_dev->conf.Vpp = 198 + dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 199 + 200 + /* Do we need to allocate an interrupt? */ 201 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 202 + 203 + /* IO window settings */ 204 + p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 205 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 206 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 207 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 208 + if (!(io->flags & CISTPL_IO_8BIT)) 209 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 210 + if (!(io->flags & CISTPL_IO_16BIT)) 211 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 212 + p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 213 + p_dev->io.BasePort1 = io->win[0].base; 214 + p_dev->io.NumPorts1 = io->win[0].len; 215 + if (io->nwin > 1) { 216 + p_dev->io.Attributes2 = p_dev->io.Attributes1; 217 + p_dev->io.BasePort2 = io->win[1].base; 218 + p_dev->io.NumPorts2 = io->win[1].len; 219 + } 220 + 221 + /* This reserves IO space but doesn't actually enable it */ 222 + if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 223 + goto next_entry; 224 + } 225 + return 0; 226 + 227 + next_entry: 228 + pcmcia_disable_device(p_dev); 229 + return -ENODEV; 230 + }; 231 + 168 232 static int 169 233 orinoco_cs_config(struct pcmcia_device *link) 170 234 { ··· 237 173 struct orinoco_pccard *card = priv->card; 238 174 hermes_t *hw = &priv->hw; 239 175 int last_fn, last_ret; 240 - u_char buf[64]; 241 - config_info_t conf; 242 - tuple_t tuple; 243 - cisparse_t parse; 244 176 void __iomem *mem; 245 - 246 - /* Look up the current Vcc */ 247 - CS_CHECK(GetConfigurationInfo, 248 - pcmcia_get_configuration_info(link, &conf)); 249 177 250 178 /* 251 179 * In this loop, we scan the CIS for configuration table ··· 253 197 * and most client drivers will only use the CIS to fill in 254 198 * implementation-defined details. 255 199 */ 256 - tuple.Attributes = 0; 257 - tuple.TupleData = buf; 258 - tuple.TupleDataMax = sizeof(buf); 259 - tuple.TupleOffset = 0; 260 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 261 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 262 - while (1) { 263 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 264 - cistpl_cftable_entry_t dflt = { .index = 0 }; 265 - 266 - if ( (pcmcia_get_tuple_data(link, &tuple) != 0) 267 - || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) 268 - goto next_entry; 269 - 270 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 271 - dflt = *cfg; 272 - if (cfg->index == 0) 273 - goto next_entry; 274 - link->conf.ConfigIndex = cfg->index; 275 - 276 - /* Use power settings for Vcc and Vpp if present */ 277 - /* Note that the CIS values need to be rescaled */ 278 - if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 279 - if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { 280 - DEBUG(2, "orinoco_cs_config: Vcc mismatch (conf.Vcc = %d, cfg CIS = %d)\n", conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); 281 - if (!ignore_cis_vcc) 282 - goto next_entry; 283 - } 284 - } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { 285 - if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) { 286 - DEBUG(2, "orinoco_cs_config: Vcc mismatch (conf.Vcc = %d, dflt CIS = %d)\n", conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); 287 - if(!ignore_cis_vcc) 288 - goto next_entry; 289 - } 290 - } 291 - 292 - if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 293 - link->conf.Vpp = 294 - cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 295 - else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 296 - link->conf.Vpp = 297 - dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 298 - 299 - /* Do we need to allocate an interrupt? */ 300 - link->conf.Attributes |= CONF_ENABLE_IRQ; 301 - 302 - /* IO window settings */ 303 - link->io.NumPorts1 = link->io.NumPorts2 = 0; 304 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 305 - cistpl_io_t *io = 306 - (cfg->io.nwin) ? &cfg->io : &dflt.io; 307 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 308 - if (!(io->flags & CISTPL_IO_8BIT)) 309 - link->io.Attributes1 = 310 - IO_DATA_PATH_WIDTH_16; 311 - if (!(io->flags & CISTPL_IO_16BIT)) 312 - link->io.Attributes1 = 313 - IO_DATA_PATH_WIDTH_8; 314 - link->io.IOAddrLines = 315 - io->flags & CISTPL_IO_LINES_MASK; 316 - link->io.BasePort1 = io->win[0].base; 317 - link->io.NumPorts1 = io->win[0].len; 318 - if (io->nwin > 1) { 319 - link->io.Attributes2 = 320 - link->io.Attributes1; 321 - link->io.BasePort2 = io->win[1].base; 322 - link->io.NumPorts2 = io->win[1].len; 323 - } 324 - 325 - /* This reserves IO space but doesn't actually enable it */ 326 - if (pcmcia_request_io(link, &link->io) != 0) 327 - goto next_entry; 328 - } 329 - 330 - 331 - /* If we got this far, we're cool! */ 332 - 333 - break; 334 - 335 - next_entry: 336 - pcmcia_disable_device(link); 337 - last_ret = pcmcia_get_next_tuple(link, &tuple); 338 - if (last_ret == CS_NO_MORE_ITEMS) { 200 + last_ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL); 201 + if (last_ret) { 202 + if (!ignore_cis_vcc) 339 203 printk(KERN_ERR PFX "GetNextTuple(): No matching " 340 204 "CIS configuration. Maybe you need the " 341 205 "ignore_cis_vcc=1 parameter.\n"); 342 - goto cs_failed; 343 - } 206 + cs_error(link, RequestIO, last_ret); 207 + goto failed; 344 208 } 345 209 346 210 /* ··· 311 335 "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id, 312 336 link->irq.AssignedIRQ, link->io.BasePort1, 313 337 link->io.BasePort1 + link->io.NumPorts1 - 1); 314 - 315 338 return 0; 316 339 317 340 cs_failed:
+2 -2
drivers/net/wireless/ray_cs.c
··· 798 798 iounmap(local->amem); 799 799 /* Do bother checking to see if these succeed or not */ 800 800 i = pcmcia_release_window(local->amem_handle); 801 - if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); 801 + if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); 802 802 i = pcmcia_release_window(local->rmem_handle); 803 - if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); 803 + if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); 804 804 pcmcia_disable_device(link); 805 805 806 806 DEBUG(2,"ray_release ending\n");
+69 -93
drivers/net/wireless/spectrum_cs.c
··· 235 235 * device available to the system. 236 236 */ 237 237 238 + static int spectrum_cs_config_check(struct pcmcia_device *p_dev, 239 + cistpl_cftable_entry_t *cfg, 240 + cistpl_cftable_entry_t *dflt, 241 + unsigned int vcc, 242 + void *priv_data) 243 + { 244 + if (cfg->index == 0) 245 + goto next_entry; 246 + 247 + /* Use power settings for Vcc and Vpp if present */ 248 + /* Note that the CIS values need to be rescaled */ 249 + if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 250 + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { 251 + DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); 252 + if (!ignore_cis_vcc) 253 + goto next_entry; 254 + } 255 + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { 256 + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) { 257 + DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); 258 + if (!ignore_cis_vcc) 259 + goto next_entry; 260 + } 261 + } 262 + 263 + if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 264 + p_dev->conf.Vpp = 265 + cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 266 + else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) 267 + p_dev->conf.Vpp = 268 + dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 269 + 270 + /* Do we need to allocate an interrupt? */ 271 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 272 + 273 + /* IO window settings */ 274 + p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 275 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 276 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 277 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 278 + if (!(io->flags & CISTPL_IO_8BIT)) 279 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 280 + if (!(io->flags & CISTPL_IO_16BIT)) 281 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 282 + p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 283 + p_dev->io.BasePort1 = io->win[0].base; 284 + p_dev->io.NumPorts1 = io->win[0].len; 285 + if (io->nwin > 1) { 286 + p_dev->io.Attributes2 = p_dev->io.Attributes1; 287 + p_dev->io.BasePort2 = io->win[1].base; 288 + p_dev->io.NumPorts2 = io->win[1].len; 289 + } 290 + 291 + /* This reserves IO space but doesn't actually enable it */ 292 + if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 293 + goto next_entry; 294 + } 295 + return 0; 296 + 297 + next_entry: 298 + pcmcia_disable_device(p_dev); 299 + return -ENODEV; 300 + }; 301 + 238 302 static int 239 303 spectrum_cs_config(struct pcmcia_device *link) 240 304 { ··· 307 243 struct orinoco_pccard *card = priv->card; 308 244 hermes_t *hw = &priv->hw; 309 245 int last_fn, last_ret; 310 - u_char buf[64]; 311 - config_info_t conf; 312 - tuple_t tuple; 313 - cisparse_t parse; 314 246 void __iomem *mem; 315 - 316 - /* Look up the current Vcc */ 317 - CS_CHECK(GetConfigurationInfo, 318 - pcmcia_get_configuration_info(link, &conf)); 319 247 320 248 /* 321 249 * In this loop, we scan the CIS for configuration table ··· 323 267 * and most client drivers will only use the CIS to fill in 324 268 * implementation-defined details. 325 269 */ 326 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 327 - tuple.Attributes = 0; 328 - tuple.TupleData = buf; 329 - tuple.TupleDataMax = sizeof(buf); 330 - tuple.TupleOffset = 0; 331 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 332 - while (1) { 333 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 334 - cistpl_cftable_entry_t dflt = { .index = 0 }; 335 - 336 - if ( (pcmcia_get_tuple_data(link, &tuple) != 0) 337 - || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) 338 - goto next_entry; 339 - 340 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 341 - dflt = *cfg; 342 - if (cfg->index == 0) 343 - goto next_entry; 344 - link->conf.ConfigIndex = cfg->index; 345 - 346 - /* Use power settings for Vcc and Vpp if present */ 347 - /* Note that the CIS values need to be rescaled */ 348 - if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 349 - if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { 350 - DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); 351 - if (!ignore_cis_vcc) 352 - goto next_entry; 353 - } 354 - } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { 355 - if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) { 356 - DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); 357 - if(!ignore_cis_vcc) 358 - goto next_entry; 359 - } 360 - } 361 - 362 - if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 363 - link->conf.Vpp = 364 - cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 365 - else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 366 - link->conf.Vpp = 367 - dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 368 - 369 - /* Do we need to allocate an interrupt? */ 370 - link->conf.Attributes |= CONF_ENABLE_IRQ; 371 - 372 - /* IO window settings */ 373 - link->io.NumPorts1 = link->io.NumPorts2 = 0; 374 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 375 - cistpl_io_t *io = 376 - (cfg->io.nwin) ? &cfg->io : &dflt.io; 377 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 378 - if (!(io->flags & CISTPL_IO_8BIT)) 379 - link->io.Attributes1 = 380 - IO_DATA_PATH_WIDTH_16; 381 - if (!(io->flags & CISTPL_IO_16BIT)) 382 - link->io.Attributes1 = 383 - IO_DATA_PATH_WIDTH_8; 384 - link->io.IOAddrLines = 385 - io->flags & CISTPL_IO_LINES_MASK; 386 - link->io.BasePort1 = io->win[0].base; 387 - link->io.NumPorts1 = io->win[0].len; 388 - if (io->nwin > 1) { 389 - link->io.Attributes2 = 390 - link->io.Attributes1; 391 - link->io.BasePort2 = io->win[1].base; 392 - link->io.NumPorts2 = io->win[1].len; 393 - } 394 - 395 - /* This reserves IO space but doesn't actually enable it */ 396 - if (pcmcia_request_io(link, &link->io) != 0) 397 - goto next_entry; 398 - } 399 - 400 - 401 - /* If we got this far, we're cool! */ 402 - 403 - break; 404 - 405 - next_entry: 406 - pcmcia_disable_device(link); 407 - last_ret = pcmcia_get_next_tuple(link, &tuple); 408 - if (last_ret == CS_NO_MORE_ITEMS) { 270 + last_ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL); 271 + if (last_ret) { 272 + if (!ignore_cis_vcc) 409 273 printk(KERN_ERR PFX "GetNextTuple(): No matching " 410 274 "CIS configuration. Maybe you need the " 411 275 "ignore_cis_vcc=1 parameter.\n"); 412 - goto cs_failed; 413 - } 276 + cs_error(link, RequestIO, last_ret); 277 + goto failed; 414 278 } 415 279 416 280 /*
+8 -8
drivers/net/wireless/wavelan_cs.c
··· 3702 3702 #endif 3703 3703 3704 3704 i = pcmcia_access_configuration_register(link, &reg); 3705 - if(i != CS_SUCCESS) 3705 + if (i != 0) 3706 3706 { 3707 3707 cs_error(link, AccessConfigurationRegister, i); 3708 3708 return FALSE; ··· 3716 3716 reg.Action = CS_WRITE; 3717 3717 reg.Value = reg.Value | COR_SW_RESET; 3718 3718 i = pcmcia_access_configuration_register(link, &reg); 3719 - if(i != CS_SUCCESS) 3719 + if (i != 0) 3720 3720 { 3721 3721 cs_error(link, AccessConfigurationRegister, i); 3722 3722 return FALSE; ··· 3725 3725 reg.Action = CS_WRITE; 3726 3726 reg.Value = COR_LEVEL_IRQ | COR_CONFIG; 3727 3727 i = pcmcia_access_configuration_register(link, &reg); 3728 - if(i != CS_SUCCESS) 3728 + if (i != 0) 3729 3729 { 3730 3730 cs_error(link, AccessConfigurationRegister, i); 3731 3731 return FALSE; ··· 3903 3903 do 3904 3904 { 3905 3905 i = pcmcia_request_io(link, &link->io); 3906 - if(i != CS_SUCCESS) 3906 + if (i != 0) 3907 3907 { 3908 3908 cs_error(link, RequestIO, i); 3909 3909 break; ··· 3914 3914 * actually assign a handler to the interrupt. 3915 3915 */ 3916 3916 i = pcmcia_request_irq(link, &link->irq); 3917 - if(i != CS_SUCCESS) 3917 + if (i != 0) 3918 3918 { 3919 3919 cs_error(link, RequestIRQ, i); 3920 3920 break; ··· 3926 3926 */ 3927 3927 link->conf.ConfigIndex = 1; 3928 3928 i = pcmcia_request_configuration(link, &link->conf); 3929 - if(i != CS_SUCCESS) 3929 + if (i != 0) 3930 3930 { 3931 3931 cs_error(link, RequestConfiguration, i); 3932 3932 break; ··· 3942 3942 req.Base = req.Size = 0; 3943 3943 req.AccessSpeed = mem_speed; 3944 3944 i = pcmcia_request_window(&link, &req, &link->win); 3945 - if(i != CS_SUCCESS) 3945 + if (i != 0) 3946 3946 { 3947 3947 cs_error(link, RequestWindow, i); 3948 3948 break; ··· 3954 3954 3955 3955 mem.CardOffset = 0; mem.Page = 0; 3956 3956 i = pcmcia_map_mem_page(link->win, &mem); 3957 - if(i != CS_SUCCESS) 3957 + if (i != 0) 3958 3958 { 3959 3959 cs_error(link, MapMemPage, i); 3960 3960 break;
+2 -2
drivers/net/wireless/wl3501_cs.c
··· 1977 1977 link->io.BasePort1 = j; 1978 1978 link->io.BasePort2 = link->io.BasePort1 + 0x10; 1979 1979 i = pcmcia_request_io(link, &link->io); 1980 - if (i == CS_SUCCESS) 1980 + if (i == 0) 1981 1981 break; 1982 1982 } 1983 - if (i != CS_SUCCESS) { 1983 + if (i != 0) { 1984 1984 cs_error(link, RequestIO, i); 1985 1985 goto failed; 1986 1986 }
+31 -39
drivers/parport/parport_cs.c
··· 149 149 #define CS_CHECK(fn, ret) \ 150 150 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 151 151 152 + static int parport_config_check(struct pcmcia_device *p_dev, 153 + cistpl_cftable_entry_t *cfg, 154 + cistpl_cftable_entry_t *dflt, 155 + unsigned int vcc, 156 + void *priv_data) 157 + { 158 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 159 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 160 + if (epp_mode) 161 + p_dev->conf.ConfigIndex |= FORCE_EPP_MODE; 162 + p_dev->io.BasePort1 = io->win[0].base; 163 + p_dev->io.NumPorts1 = io->win[0].len; 164 + p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 165 + if (io->nwin == 2) { 166 + p_dev->io.BasePort2 = io->win[1].base; 167 + p_dev->io.NumPorts2 = io->win[1].len; 168 + } 169 + if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 170 + return -ENODEV; 171 + return 0; 172 + } 173 + return -ENODEV; 174 + } 175 + 152 176 static int parport_config(struct pcmcia_device *link) 153 177 { 154 178 parport_info_t *info = link->priv; 155 - tuple_t tuple; 156 - u_short buf[128]; 157 - cisparse_t parse; 158 - cistpl_cftable_entry_t *cfg = &parse.cftable_entry; 159 - cistpl_cftable_entry_t dflt = { 0 }; 160 179 struct parport *p; 161 180 int last_ret, last_fn; 162 - 163 - DEBUG(0, "parport_config(0x%p)\n", link); 164 - 165 - tuple.TupleData = (cisdata_t *)buf; 166 - tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 167 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 168 - tuple.Attributes = 0; 169 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 170 - while (1) { 171 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 172 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 173 - goto next_entry; 174 181 175 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 176 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 177 - link->conf.ConfigIndex = cfg->index; 178 - if (epp_mode) 179 - link->conf.ConfigIndex |= FORCE_EPP_MODE; 180 - link->io.BasePort1 = io->win[0].base; 181 - link->io.NumPorts1 = io->win[0].len; 182 - link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 183 - if (io->nwin == 2) { 184 - link->io.BasePort2 = io->win[1].base; 185 - link->io.NumPorts2 = io->win[1].len; 186 - } 187 - if (pcmcia_request_io(link, &link->io) != 0) 188 - goto next_entry; 189 - /* If we've got this far, we're done */ 190 - break; 191 - } 192 - 193 - next_entry: 194 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 195 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 182 + DEBUG(0, "parport_config(0x%p)\n", link); 183 + 184 + last_ret = pcmcia_loop_config(link, parport_config_check, NULL); 185 + if (last_ret) { 186 + cs_error(link, RequestIO, last_ret); 187 + goto failed; 196 188 } 197 - 189 + 198 190 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 199 191 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 200 192
-4
drivers/pcmcia/Makefile
··· 2 2 # Makefile for the kernel pcmcia subsystem (c/o David Hinds) 3 3 # 4 4 5 - ifeq ($(CONFIG_PCMCIA_DEBUG),y) 6 - EXTRA_CFLAGS += -DDEBUG 7 - endif 8 - 9 5 pcmcia_core-y += cs.o cistpl.o rsrc_mgr.o socket_sysfs.o 10 6 pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o 11 7 obj-$(CONFIG_PCCARD) += pcmcia_core.o
+1 -1
drivers/pcmcia/au1000_generic.c
··· 292 292 skt->spd_io[map->map] = speed; 293 293 } 294 294 295 - map->start=(ioaddr_t)(u32)skt->virt_io; 295 + map->start=(unsigned int)(u32)skt->virt_io; 296 296 map->stop=map->start+MAP_SIZE; 297 297 return 0; 298 298
+1 -1
drivers/pcmcia/au1000_generic.h
··· 116 116 struct resource res_attr; 117 117 118 118 void * virt_io; 119 - ioaddr_t phys_io; 119 + unsigned int phys_io; 120 120 unsigned int phys_attr; 121 121 unsigned int phys_mem; 122 122 unsigned short speed_io, speed_attr, speed_mem;
-1
drivers/pcmcia/au1000_pb1x00.c
··· 37 37 #include <pcmcia/ss.h> 38 38 #include <pcmcia/cistpl.h> 39 39 #include <pcmcia/bus_ops.h> 40 - #include "cs_internal.h" 41 40 42 41 #include <asm/io.h> 43 42 #include <asm/irq.h>
-1
drivers/pcmcia/au1000_xxs1500.c
··· 41 41 #include <pcmcia/ss.h> 42 42 #include <pcmcia/cistpl.h> 43 43 #include <pcmcia/bus_ops.h> 44 - #include "cs_internal.h" 45 44 46 45 #include <asm/io.h> 47 46 #include <asm/irq.h>
+1 -1
drivers/pcmcia/cardbus.c
··· 238 238 pci_bus_add_devices(bus); 239 239 240 240 s->irq.AssignedIRQ = s->pci_irq; 241 - return CS_SUCCESS; 241 + return 0; 242 242 } 243 243 244 244 void cb_free(struct pcmcia_socket * s)
+176 -121
drivers/pcmcia/cistpl.c
··· 92 92 if (!(s->features & SS_CAP_STATIC_MAP) && (mem->res == NULL)) { 93 93 mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s); 94 94 if (mem->res == NULL) { 95 - printk(KERN_NOTICE "cs: unable to map card memory!\n"); 95 + dev_printk(KERN_NOTICE, &s->dev, 96 + "cs: unable to map card memory!\n"); 96 97 return NULL; 97 98 } 98 99 s->cis_virt = NULL; ··· 266 265 ======================================================================*/ 267 266 268 267 static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, 269 - u_int len, void *ptr) 268 + size_t len, void *ptr) 270 269 { 271 270 struct cis_cache_entry *cis; 272 271 int ret; 273 272 274 273 if (s->fake_cis) { 275 - if (s->fake_cis_len > addr+len) 274 + if (s->fake_cis_len >= addr+len) 276 275 memcpy(ptr, s->fake_cis+addr, len); 277 276 else 278 277 memset(ptr, 0xff, len); ··· 352 351 353 352 buf = kmalloc(256, GFP_KERNEL); 354 353 if (buf == NULL) 355 - return -1; 354 + dev_printk(KERN_WARNING, &s->dev, 355 + "no memory for verifying CIS\n"); 356 + return -ENOMEM; 356 357 list_for_each_entry(cis, &s->cis_cache, node) { 357 358 int len = cis->len; 358 359 ··· 383 380 384 381 ======================================================================*/ 385 382 386 - int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) 383 + int pcmcia_replace_cis(struct pcmcia_socket *s, 384 + const u8 *data, const size_t len) 387 385 { 388 - kfree(s->fake_cis); 389 - s->fake_cis = NULL; 390 - if (cis->Length > CISTPL_MAX_CIS_SIZE) 391 - return CS_BAD_SIZE; 392 - s->fake_cis = kmalloc(cis->Length, GFP_KERNEL); 393 - if (s->fake_cis == NULL) 394 - return CS_OUT_OF_RESOURCE; 395 - s->fake_cis_len = cis->Length; 396 - memcpy(s->fake_cis, cis->Data, cis->Length); 397 - return CS_SUCCESS; 386 + if (len > CISTPL_MAX_CIS_SIZE) { 387 + dev_printk(KERN_WARNING, &s->dev, "replacement CIS too big\n"); 388 + return -EINVAL; 389 + } 390 + kfree(s->fake_cis); 391 + s->fake_cis = kmalloc(len, GFP_KERNEL); 392 + if (s->fake_cis == NULL) { 393 + dev_printk(KERN_WARNING, &s->dev, "no memory to replace CIS\n"); 394 + return -ENOMEM; 395 + } 396 + s->fake_cis_len = len; 397 + memcpy(s->fake_cis, data, len); 398 + return 0; 398 399 } 399 400 EXPORT_SYMBOL(pcmcia_replace_cis); 400 401 ··· 425 418 int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple) 426 419 { 427 420 if (!s) 428 - return CS_BAD_HANDLE; 421 + return -EINVAL; 429 422 if (!(s->state & SOCKET_PRESENT)) 430 - return CS_NO_CARD; 423 + return -ENODEV; 431 424 tuple->TupleLink = tuple->Flags = 0; 432 425 #ifdef CONFIG_CARDBUS 433 426 if (s->state & SOCKET_CARDBUS) { ··· 447 440 !(tuple->Attributes & TUPLE_RETURN_COMMON)) { 448 441 cisdata_t req = tuple->DesiredTuple; 449 442 tuple->DesiredTuple = CISTPL_LONGLINK_MFC; 450 - if (pccard_get_next_tuple(s, function, tuple) == CS_SUCCESS) { 443 + if (pccard_get_next_tuple(s, function, tuple) == 0) { 451 444 tuple->DesiredTuple = CISTPL_LINKTARGET; 452 - if (pccard_get_next_tuple(s, function, tuple) != CS_SUCCESS) 453 - return CS_NO_MORE_ITEMS; 445 + if (pccard_get_next_tuple(s, function, tuple) != 0) 446 + return -ENOSPC; 454 447 } else 455 448 tuple->CISOffset = tuple->TupleLink = 0; 456 449 tuple->DesiredTuple = req; ··· 505 498 int ofs, i, attr; 506 499 507 500 if (!s) 508 - return CS_BAD_HANDLE; 501 + return -EINVAL; 509 502 if (!(s->state & SOCKET_PRESENT)) 510 - return CS_NO_CARD; 503 + return -ENODEV; 511 504 512 505 link[1] = tuple->TupleLink; 513 506 ofs = tuple->CISOffset + tuple->TupleLink; ··· 526 519 /* End of chain? Follow long link if possible */ 527 520 if (link[0] == CISTPL_END) { 528 521 if ((ofs = follow_link(s, tuple)) < 0) 529 - return CS_NO_MORE_ITEMS; 522 + return -ENOSPC; 530 523 attr = SPACE(tuple->Flags); 531 524 read_cis_cache(s, attr, ofs, 2, link); 532 525 } ··· 584 577 } 585 578 if (i == MAX_TUPLES) { 586 579 cs_dbg(s, 1, "cs: overrun in pcmcia_get_next_tuple\n"); 587 - return CS_NO_MORE_ITEMS; 580 + return -ENOSPC; 588 581 } 589 582 590 583 tuple->TupleCode = link[0]; 591 584 tuple->TupleLink = link[1]; 592 585 tuple->CISOffset = ofs + 2; 593 - return CS_SUCCESS; 586 + return 0; 594 587 } 595 588 EXPORT_SYMBOL(pccard_get_next_tuple); 596 589 ··· 603 596 u_int len; 604 597 605 598 if (!s) 606 - return CS_BAD_HANDLE; 599 + return -EINVAL; 607 600 608 601 if (tuple->TupleLink < tuple->TupleOffset) 609 - return CS_NO_MORE_ITEMS; 602 + return -ENOSPC; 610 603 len = tuple->TupleLink - tuple->TupleOffset; 611 604 tuple->TupleDataLen = tuple->TupleLink; 612 605 if (len == 0) 613 - return CS_SUCCESS; 606 + return 0; 614 607 read_cis_cache(s, SPACE(tuple->Flags), 615 608 tuple->CISOffset + tuple->TupleOffset, 616 609 _MIN(len, tuple->TupleDataMax), tuple->TupleData); 617 - return CS_SUCCESS; 610 + return 0; 618 611 } 619 612 EXPORT_SYMBOL(pccard_get_tuple_data); 620 613 ··· 647 640 case 3: device->dev[i].speed = 150; break; 648 641 case 4: device->dev[i].speed = 100; break; 649 642 case 7: 650 - if (++p == q) return CS_BAD_TUPLE; 643 + if (++p == q) 644 + return -EINVAL; 651 645 device->dev[i].speed = SPEED_CVT(*p); 652 646 while (*p & 0x80) 653 - if (++p == q) return CS_BAD_TUPLE; 647 + if (++p == q) 648 + return -EINVAL; 654 649 break; 655 650 default: 656 - return CS_BAD_TUPLE; 651 + return -EINVAL; 657 652 } 658 653 659 - if (++p == q) return CS_BAD_TUPLE; 660 - if (*p == 0xff) break; 654 + if (++p == q) 655 + return -EINVAL; 656 + if (*p == 0xff) 657 + break; 661 658 scale = *p & 7; 662 - if (scale == 7) return CS_BAD_TUPLE; 659 + if (scale == 7) 660 + return -EINVAL; 663 661 device->dev[i].size = ((*p >> 3) + 1) * (512 << (scale*2)); 664 662 device->ndev++; 665 - if (++p == q) break; 663 + if (++p == q) 664 + break; 666 665 } 667 666 668 - return CS_SUCCESS; 667 + return 0; 669 668 } 670 669 671 670 /*====================================================================*/ ··· 680 667 { 681 668 u_char *p; 682 669 if (tuple->TupleDataLen < 5) 683 - return CS_BAD_TUPLE; 670 + return -EINVAL; 684 671 p = (u_char *) tuple->TupleData; 685 672 csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2; 686 673 csum->len = get_unaligned_le16(p + 2); 687 674 csum->sum = *(p + 4); 688 - return CS_SUCCESS; 675 + return 0; 689 676 } 690 677 691 678 /*====================================================================*/ ··· 693 680 static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) 694 681 { 695 682 if (tuple->TupleDataLen < 4) 696 - return CS_BAD_TUPLE; 683 + return -EINVAL; 697 684 link->addr = get_unaligned_le32(tuple->TupleData); 698 - return CS_SUCCESS; 685 + return 0; 699 686 } 700 687 701 688 /*====================================================================*/ ··· 710 697 711 698 link->nfn = *p; p++; 712 699 if (tuple->TupleDataLen <= link->nfn*5) 713 - return CS_BAD_TUPLE; 700 + return -EINVAL; 714 701 for (i = 0; i < link->nfn; i++) { 715 702 link->fn[i].space = *p; p++; 716 703 link->fn[i].addr = get_unaligned_le32(p); 717 704 p += 4; 718 705 } 719 - return CS_SUCCESS; 706 + return 0; 720 707 } 721 708 722 709 /*====================================================================*/ ··· 726 713 { 727 714 int i, j, ns; 728 715 729 - if (p == q) return CS_BAD_TUPLE; 716 + if (p == q) 717 + return -EINVAL; 730 718 ns = 0; j = 0; 731 719 for (i = 0; i < max; i++) { 732 - if (*p == 0xff) break; 720 + if (*p == 0xff) 721 + break; 733 722 ofs[i] = j; 734 723 ns++; 735 724 for (;;) { 736 725 s[j++] = (*p == 0xff) ? '\0' : *p; 737 726 if ((*p == '\0') || (*p == 0xff)) break; 738 - if (++p == q) return CS_BAD_TUPLE; 727 + if (++p == q) 728 + return -EINVAL; 739 729 } 740 730 if ((*p == 0xff) || (++p == q)) break; 741 731 } 742 732 if (found) { 743 733 *found = ns; 744 - return CS_SUCCESS; 734 + return 0; 745 735 } else { 746 - return (ns == max) ? CS_SUCCESS : CS_BAD_TUPLE; 736 + return (ns == max) ? 0 : -EINVAL; 747 737 } 748 738 } 749 739 ··· 761 745 762 746 vers_1->major = *p; p++; 763 747 vers_1->minor = *p; p++; 764 - if (p >= q) return CS_BAD_TUPLE; 748 + if (p >= q) 749 + return -EINVAL; 765 750 766 751 return parse_strings(p, q, CISTPL_VERS_1_MAX_PROD_STRINGS, 767 752 vers_1->str, vers_1->ofs, &vers_1->ns); ··· 798 781 p += 2; 799 782 } 800 783 jedec->nid = nid; 801 - return CS_SUCCESS; 784 + return 0; 802 785 } 803 786 804 787 /*====================================================================*/ ··· 806 789 static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) 807 790 { 808 791 if (tuple->TupleDataLen < 4) 809 - return CS_BAD_TUPLE; 792 + return -EINVAL; 810 793 m->manf = get_unaligned_le16(tuple->TupleData); 811 794 m->card = get_unaligned_le16(tuple->TupleData + 2); 812 - return CS_SUCCESS; 795 + return 0; 813 796 } 814 797 815 798 /*====================================================================*/ ··· 818 801 { 819 802 u_char *p; 820 803 if (tuple->TupleDataLen < 2) 821 - return CS_BAD_TUPLE; 804 + return -EINVAL; 822 805 p = (u_char *)tuple->TupleData; 823 806 f->func = p[0]; 824 807 f->sysinit = p[1]; 825 - return CS_SUCCESS; 808 + return 0; 826 809 } 827 810 828 811 /*====================================================================*/ ··· 832 815 u_char *p; 833 816 int i; 834 817 if (tuple->TupleDataLen < 1) 835 - return CS_BAD_TUPLE; 818 + return -EINVAL; 836 819 p = (u_char *)tuple->TupleData; 837 820 f->type = p[0]; 838 821 for (i = 1; i < tuple->TupleDataLen; i++) 839 822 f->data[i-1] = p[i]; 840 - return CS_SUCCESS; 823 + return 0; 841 824 } 842 825 843 826 /*====================================================================*/ ··· 851 834 rasz = *p & 0x03; 852 835 rmsz = (*p & 0x3c) >> 2; 853 836 if (tuple->TupleDataLen < rasz+rmsz+4) 854 - return CS_BAD_TUPLE; 837 + return -EINVAL; 855 838 config->last_idx = *(++p); 856 839 p++; 857 840 config->base = 0; ··· 863 846 for (i = 0; i <= rmsz; i++) 864 847 config->rmask[i>>2] += p[i] << (8*(i%4)); 865 848 config->subtuples = tuple->TupleDataLen - (rasz+rmsz+4); 866 - return CS_SUCCESS; 849 + return 0; 867 850 } 868 851 869 852 /*====================================================================== ··· 1019 1002 1020 1003 static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq) 1021 1004 { 1022 - if (p == q) return NULL; 1005 + if (p == q) 1006 + return NULL; 1023 1007 irq->IRQInfo1 = *p; p++; 1024 1008 if (irq->IRQInfo1 & IRQ_INFO2_VALID) { 1025 - if (p+2 > q) return NULL; 1009 + if (p+2 > q) 1010 + return NULL; 1026 1011 irq->IRQInfo2 = (p[1]<<8) + p[0]; 1027 1012 p += 2; 1028 1013 } ··· 1045 1026 if (*p & 0x40) 1046 1027 entry->flags |= CISTPL_CFTABLE_DEFAULT; 1047 1028 if (*p & 0x80) { 1048 - if (++p == q) return CS_BAD_TUPLE; 1029 + if (++p == q) 1030 + return -EINVAL; 1049 1031 if (*p & 0x10) 1050 1032 entry->flags |= CISTPL_CFTABLE_BVDS; 1051 1033 if (*p & 0x20) ··· 1060 1040 entry->interface = 0; 1061 1041 1062 1042 /* Process optional features */ 1063 - if (++p == q) return CS_BAD_TUPLE; 1043 + if (++p == q) 1044 + return -EINVAL; 1064 1045 features = *p; p++; 1065 1046 1066 1047 /* Power options */ 1067 1048 if ((features & 3) > 0) { 1068 1049 p = parse_power(p, q, &entry->vcc); 1069 - if (p == NULL) return CS_BAD_TUPLE; 1050 + if (p == NULL) 1051 + return -EINVAL; 1070 1052 } else 1071 1053 entry->vcc.present = 0; 1072 1054 if ((features & 3) > 1) { 1073 1055 p = parse_power(p, q, &entry->vpp1); 1074 - if (p == NULL) return CS_BAD_TUPLE; 1056 + if (p == NULL) 1057 + return -EINVAL; 1075 1058 } else 1076 1059 entry->vpp1.present = 0; 1077 1060 if ((features & 3) > 2) { 1078 1061 p = parse_power(p, q, &entry->vpp2); 1079 - if (p == NULL) return CS_BAD_TUPLE; 1062 + if (p == NULL) 1063 + return -EINVAL; 1080 1064 } else 1081 1065 entry->vpp2.present = 0; 1082 1066 1083 1067 /* Timing options */ 1084 1068 if (features & 0x04) { 1085 1069 p = parse_timing(p, q, &entry->timing); 1086 - if (p == NULL) return CS_BAD_TUPLE; 1070 + if (p == NULL) 1071 + return -EINVAL; 1087 1072 } else { 1088 1073 entry->timing.wait = 0; 1089 1074 entry->timing.ready = 0; ··· 1098 1073 /* I/O window options */ 1099 1074 if (features & 0x08) { 1100 1075 p = parse_io(p, q, &entry->io); 1101 - if (p == NULL) return CS_BAD_TUPLE; 1076 + if (p == NULL) 1077 + return -EINVAL; 1102 1078 } else 1103 1079 entry->io.nwin = 0; 1104 1080 1105 1081 /* Interrupt options */ 1106 1082 if (features & 0x10) { 1107 1083 p = parse_irq(p, q, &entry->irq); 1108 - if (p == NULL) return CS_BAD_TUPLE; 1084 + if (p == NULL) 1085 + return -EINVAL; 1109 1086 } else 1110 1087 entry->irq.IRQInfo1 = 0; 1111 1088 ··· 1121 1094 entry->mem.win[0].card_addr = 0; 1122 1095 entry->mem.win[0].host_addr = 0; 1123 1096 p += 2; 1124 - if (p > q) return CS_BAD_TUPLE; 1097 + if (p > q) 1098 + return -EINVAL; 1125 1099 break; 1126 1100 case 0x40: 1127 1101 entry->mem.nwin = 1; ··· 1130 1102 entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8; 1131 1103 entry->mem.win[0].host_addr = 0; 1132 1104 p += 4; 1133 - if (p > q) return CS_BAD_TUPLE; 1105 + if (p > q) 1106 + return -EINVAL; 1134 1107 break; 1135 1108 case 0x60: 1136 1109 p = parse_mem(p, q, &entry->mem); 1137 - if (p == NULL) return CS_BAD_TUPLE; 1110 + if (p == NULL) 1111 + return -EINVAL; 1138 1112 break; 1139 1113 } 1140 1114 1141 1115 /* Misc features */ 1142 1116 if (features & 0x80) { 1143 - if (p == q) return CS_BAD_TUPLE; 1117 + if (p == q) 1118 + return -EINVAL; 1144 1119 entry->flags |= (*p << 8); 1145 1120 while (*p & 0x80) 1146 - if (++p == q) return CS_BAD_TUPLE; 1121 + if (++p == q) 1122 + return -EINVAL; 1147 1123 p++; 1148 1124 } 1149 1125 1150 1126 entry->subtuples = q-p; 1151 1127 1152 - return CS_SUCCESS; 1128 + return 0; 1153 1129 } 1154 1130 1155 1131 /*====================================================================*/ ··· 1164 1132 { 1165 1133 u_char *p; 1166 1134 if (tuple->TupleDataLen < 6) 1167 - return CS_BAD_TUPLE; 1135 + return -EINVAL; 1168 1136 p = (u_char *)tuple->TupleData; 1169 1137 bar->attr = *p; 1170 1138 p += 2; 1171 1139 bar->size = get_unaligned_le32(p); 1172 - return CS_SUCCESS; 1140 + return 0; 1173 1141 } 1174 1142 1175 1143 static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) ··· 1178 1146 1179 1147 p = (u_char *)tuple->TupleData; 1180 1148 if ((*p != 3) || (tuple->TupleDataLen < 6)) 1181 - return CS_BAD_TUPLE; 1149 + return -EINVAL; 1182 1150 config->last_idx = *(++p); 1183 1151 p++; 1184 1152 config->base = get_unaligned_le32(p); 1185 1153 config->subtuples = tuple->TupleDataLen - 6; 1186 - return CS_SUCCESS; 1154 + return 0; 1187 1155 } 1188 1156 1189 1157 static int parse_cftable_entry_cb(tuple_t *tuple, ··· 1199 1167 entry->flags |= CISTPL_CFTABLE_DEFAULT; 1200 1168 1201 1169 /* Process optional features */ 1202 - if (++p == q) return CS_BAD_TUPLE; 1170 + if (++p == q) 1171 + return -EINVAL; 1203 1172 features = *p; p++; 1204 1173 1205 1174 /* Power options */ 1206 1175 if ((features & 3) > 0) { 1207 1176 p = parse_power(p, q, &entry->vcc); 1208 - if (p == NULL) return CS_BAD_TUPLE; 1177 + if (p == NULL) 1178 + return -EINVAL; 1209 1179 } else 1210 1180 entry->vcc.present = 0; 1211 1181 if ((features & 3) > 1) { 1212 1182 p = parse_power(p, q, &entry->vpp1); 1213 - if (p == NULL) return CS_BAD_TUPLE; 1183 + if (p == NULL) 1184 + return -EINVAL; 1214 1185 } else 1215 1186 entry->vpp1.present = 0; 1216 1187 if ((features & 3) > 2) { 1217 1188 p = parse_power(p, q, &entry->vpp2); 1218 - if (p == NULL) return CS_BAD_TUPLE; 1189 + if (p == NULL) 1190 + return -EINVAL; 1219 1191 } else 1220 1192 entry->vpp2.present = 0; 1221 1193 1222 1194 /* I/O window options */ 1223 1195 if (features & 0x08) { 1224 - if (p == q) return CS_BAD_TUPLE; 1196 + if (p == q) 1197 + return -EINVAL; 1225 1198 entry->io = *p; p++; 1226 1199 } else 1227 1200 entry->io = 0; ··· 1234 1197 /* Interrupt options */ 1235 1198 if (features & 0x10) { 1236 1199 p = parse_irq(p, q, &entry->irq); 1237 - if (p == NULL) return CS_BAD_TUPLE; 1200 + if (p == NULL) 1201 + return -EINVAL; 1238 1202 } else 1239 1203 entry->irq.IRQInfo1 = 0; 1240 1204 1241 1205 if (features & 0x20) { 1242 - if (p == q) return CS_BAD_TUPLE; 1206 + if (p == q) 1207 + return -EINVAL; 1243 1208 entry->mem = *p; p++; 1244 1209 } else 1245 1210 entry->mem = 0; 1246 1211 1247 1212 /* Misc features */ 1248 1213 if (features & 0x80) { 1249 - if (p == q) return CS_BAD_TUPLE; 1214 + if (p == q) 1215 + return -EINVAL; 1250 1216 entry->flags |= (*p << 8); 1251 1217 if (*p & 0x80) { 1252 - if (++p == q) return CS_BAD_TUPLE; 1218 + if (++p == q) 1219 + return -EINVAL; 1253 1220 entry->flags |= (*p << 16); 1254 1221 } 1255 1222 while (*p & 0x80) 1256 - if (++p == q) return CS_BAD_TUPLE; 1223 + if (++p == q) 1224 + return -EINVAL; 1257 1225 p++; 1258 1226 } 1259 1227 1260 1228 entry->subtuples = q-p; 1261 1229 1262 - return CS_SUCCESS; 1230 + return 0; 1263 1231 } 1264 1232 1265 1233 #endif ··· 1290 1248 p += 6; 1291 1249 } 1292 1250 geo->ngeo = n; 1293 - return CS_SUCCESS; 1251 + return 0; 1294 1252 } 1295 1253 1296 1254 /*====================================================================*/ ··· 1300 1258 u_char *p, *q; 1301 1259 1302 1260 if (tuple->TupleDataLen < 10) 1303 - return CS_BAD_TUPLE; 1261 + return -EINVAL; 1304 1262 1305 1263 p = tuple->TupleData; 1306 1264 q = p + tuple->TupleDataLen; ··· 1324 1282 1325 1283 p = tuple->TupleData; 1326 1284 q = p + tuple->TupleDataLen; 1327 - if (p == q) return CS_BAD_TUPLE; 1285 + if (p == q) 1286 + return -EINVAL; 1328 1287 org->data_org = *p; 1329 - if (++p == q) return CS_BAD_TUPLE; 1288 + if (++p == q) 1289 + return -EINVAL; 1330 1290 for (i = 0; i < 30; i++) { 1331 1291 org->desc[i] = *p; 1332 1292 if (*p == '\0') break; 1333 - if (++p == q) return CS_BAD_TUPLE; 1293 + if (++p == q) 1294 + return -EINVAL; 1334 1295 } 1335 - return CS_SUCCESS; 1296 + return 0; 1336 1297 } 1337 1298 1338 1299 /*====================================================================*/ ··· 1345 1300 u_char *p; 1346 1301 1347 1302 if (tuple->TupleDataLen < 10) 1348 - return CS_BAD_TUPLE; 1303 + return -EINVAL; 1349 1304 1350 1305 p = tuple->TupleData; 1351 1306 ··· 1354 1309 fmt->offset = get_unaligned_le32(p + 2); 1355 1310 fmt->length = get_unaligned_le32(p + 6); 1356 1311 1357 - return CS_SUCCESS; 1312 + return 0; 1358 1313 } 1359 1314 1360 1315 /*====================================================================*/ 1361 1316 1362 - int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) 1317 + int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse) 1363 1318 { 1364 - int ret = CS_SUCCESS; 1319 + int ret = 0; 1365 1320 1366 1321 if (tuple->TupleDataLen > tuple->TupleDataMax) 1367 - return CS_BAD_TUPLE; 1322 + return -EINVAL; 1368 1323 switch (tuple->TupleCode) { 1369 1324 case CISTPL_DEVICE: 1370 1325 case CISTPL_DEVICE_A: ··· 1432 1387 break; 1433 1388 case CISTPL_NO_LINK: 1434 1389 case CISTPL_LINKTARGET: 1435 - ret = CS_SUCCESS; 1390 + ret = 0; 1436 1391 break; 1437 1392 default: 1438 - ret = CS_UNSUPPORTED_FUNCTION; 1393 + ret = -EINVAL; 1439 1394 break; 1440 1395 } 1396 + if (ret) 1397 + __cs_dbg(0, "parse_tuple failed %d\n", ret); 1441 1398 return ret; 1442 1399 } 1443 - EXPORT_SYMBOL(pccard_parse_tuple); 1400 + EXPORT_SYMBOL(pcmcia_parse_tuple); 1444 1401 1445 1402 /*====================================================================== 1446 1403 ··· 1457 1410 int ret; 1458 1411 1459 1412 buf = kmalloc(256, GFP_KERNEL); 1460 - if (buf == NULL) 1461 - return CS_OUT_OF_RESOURCE; 1413 + if (buf == NULL) { 1414 + dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n"); 1415 + return -ENOMEM; 1416 + } 1462 1417 tuple.DesiredTuple = code; 1463 1418 tuple.Attributes = TUPLE_RETURN_COMMON; 1464 1419 ret = pccard_get_first_tuple(s, function, &tuple); 1465 - if (ret != CS_SUCCESS) goto done; 1420 + if (ret != 0) 1421 + goto done; 1466 1422 tuple.TupleData = buf; 1467 1423 tuple.TupleOffset = 0; 1468 1424 tuple.TupleDataMax = 255; 1469 1425 ret = pccard_get_tuple_data(s, &tuple); 1470 - if (ret != CS_SUCCESS) goto done; 1471 - ret = pccard_parse_tuple(&tuple, parse); 1426 + if (ret != 0) 1427 + goto done; 1428 + ret = pcmcia_parse_tuple(&tuple, parse); 1472 1429 done: 1473 1430 kfree(buf); 1474 1431 return ret; ··· 1497 1446 int ret, reserved, dev_ok = 0, ident_ok = 0; 1498 1447 1499 1448 if (!s) 1500 - return CS_BAD_HANDLE; 1449 + return -EINVAL; 1501 1450 1502 1451 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); 1503 - if (tuple == NULL) 1504 - return CS_OUT_OF_RESOURCE; 1452 + if (tuple == NULL) { 1453 + dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n"); 1454 + return -ENOMEM; 1455 + } 1505 1456 p = kmalloc(sizeof(*p), GFP_KERNEL); 1506 1457 if (p == NULL) { 1507 - kfree(tuple); 1508 - return CS_OUT_OF_RESOURCE; 1458 + kfree(tuple); 1459 + dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n"); 1460 + return -ENOMEM; 1509 1461 } 1510 1462 1511 1463 count = reserved = 0; 1512 1464 tuple->DesiredTuple = RETURN_FIRST_TUPLE; 1513 1465 tuple->Attributes = TUPLE_RETURN_COMMON; 1514 1466 ret = pccard_get_first_tuple(s, function, tuple); 1515 - if (ret != CS_SUCCESS) 1467 + if (ret != 0) 1516 1468 goto done; 1517 1469 1518 1470 /* First tuple should be DEVICE; we should really have either that 1519 1471 or a CFTABLE_ENTRY of some sort */ 1520 1472 if ((tuple->TupleCode == CISTPL_DEVICE) || 1521 - (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == CS_SUCCESS) || 1522 - (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == CS_SUCCESS)) 1473 + (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == 0) || 1474 + (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == 0)) 1523 1475 dev_ok++; 1524 1476 1525 1477 /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2 1526 1478 tuple, for card identification. Certain old D-Link and Linksys 1527 1479 cards have only a broken VERS_2 tuple; hence the bogus test. */ 1528 - if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == CS_SUCCESS) || 1529 - (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == CS_SUCCESS) || 1530 - (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != CS_NO_MORE_ITEMS)) 1480 + if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == 0) || 1481 + (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == 0) || 1482 + (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != -ENOSPC)) 1531 1483 ident_ok++; 1532 1484 1533 1485 if (!dev_ok && !ident_ok) ··· 1538 1484 1539 1485 for (count = 1; count < MAX_TUPLES; count++) { 1540 1486 ret = pccard_get_next_tuple(s, function, tuple); 1541 - if (ret != CS_SUCCESS) break; 1487 + if (ret != 0) 1488 + break; 1542 1489 if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || 1543 1490 ((tuple->TupleCode > 0x47) && (tuple->TupleCode < 0x80)) || 1544 1491 ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff))) ··· 1554 1499 *info = count; 1555 1500 kfree(tuple); 1556 1501 kfree(p); 1557 - return CS_SUCCESS; 1502 + return 0; 1558 1503 } 1559 1504 EXPORT_SYMBOL(pccard_validate_cis);
+41 -37
drivers/pcmcia/cs.c
··· 61 61 /* Access speed for attribute memory windows */ 62 62 INT_MODULE_PARM(cis_speed, 300); /* ns */ 63 63 64 - #ifdef DEBUG 64 + #ifdef CONFIG_PCMCIA_DEBUG 65 65 static int pc_debug; 66 66 67 67 module_param(pc_debug, int, 0644); ··· 247 247 248 248 wait_for_completion(&socket->thread_done); 249 249 if (!socket->thread) { 250 - printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket); 250 + dev_printk(KERN_WARNING, &socket->dev, 251 + "PCMCIA: warning: socket thread did not start\n"); 251 252 return -EIO; 252 253 } 253 254 ··· 367 366 skt->ops->get_status(skt, &status); 368 367 369 368 if (!(status & SS_DETECT)) 370 - return CS_NO_CARD; 369 + return -ENODEV; 371 370 372 371 if (status & SS_READY) 373 - return CS_SUCCESS; 372 + return 0; 374 373 375 374 msleep(unreset_check * 10); 376 375 } 377 376 378 377 cs_err(skt, "time out after reset.\n"); 379 - return CS_GENERAL_FAILURE; 378 + return -ETIMEDOUT; 380 379 } 381 380 382 381 /* ··· 413 412 414 413 s->ops->get_status(s, &status); 415 414 if (status & SS_POWERON) { 416 - printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); 415 + dev_printk(KERN_ERR, &s->dev, 416 + "*** DANGER *** unable to remove socket power\n"); 417 417 } 418 418 419 419 cs_socket_put(s); ··· 428 426 429 427 skt->ops->get_status(skt, &status); 430 428 if (!(status & SS_DETECT)) 431 - return CS_NO_CARD; 429 + return -ENODEV; 432 430 433 431 msleep(initial_delay * 10); 434 432 435 433 for (i = 0; i < 100; i++) { 436 434 skt->ops->get_status(skt, &status); 437 435 if (!(status & SS_DETECT)) 438 - return CS_NO_CARD; 436 + return -ENODEV; 439 437 440 438 if (!(status & SS_PENDING)) 441 439 break; ··· 445 443 446 444 if (status & SS_PENDING) { 447 445 cs_err(skt, "voltage interrogation timed out.\n"); 448 - return CS_GENERAL_FAILURE; 446 + return -ETIMEDOUT; 449 447 } 450 448 451 449 if (status & SS_CARDBUS) { 452 450 if (!(skt->features & SS_CAP_CARDBUS)) { 453 451 cs_err(skt, "cardbus cards are not supported.\n"); 454 - return CS_BAD_TYPE; 452 + return -EINVAL; 455 453 } 456 454 skt->state |= SOCKET_CARDBUS; 457 455 } ··· 465 463 skt->socket.Vcc = skt->socket.Vpp = 50; 466 464 else { 467 465 cs_err(skt, "unsupported voltage key.\n"); 468 - return CS_BAD_TYPE; 466 + return -EIO; 469 467 } 470 468 471 469 if (skt->power_hook) ··· 482 480 skt->ops->get_status(skt, &status); 483 481 if (!(status & SS_POWERON)) { 484 482 cs_err(skt, "unable to apply power.\n"); 485 - return CS_BAD_TYPE; 483 + return -EIO; 486 484 } 487 485 488 486 status = socket_reset(skt); ··· 504 502 cs_dbg(skt, 4, "insert\n"); 505 503 506 504 if (!cs_socket_get(skt)) 507 - return CS_NO_CARD; 505 + return -ENODEV; 508 506 509 507 ret = socket_setup(skt, setup_delay); 510 - if (ret == CS_SUCCESS) { 508 + if (ret == 0) { 511 509 skt->state |= SOCKET_PRESENT; 512 510 513 - printk(KERN_NOTICE "pccard: %s card inserted into slot %d\n", 514 - (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", 515 - skt->sock); 511 + dev_printk(KERN_NOTICE, &skt->dev, 512 + "pccard: %s card inserted into slot %d\n", 513 + (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", 514 + skt->sock); 516 515 517 516 #ifdef CONFIG_CARDBUS 518 517 if (skt->state & SOCKET_CARDBUS) { ··· 534 531 static int socket_suspend(struct pcmcia_socket *skt) 535 532 { 536 533 if (skt->state & SOCKET_SUSPEND) 537 - return CS_IN_USE; 534 + return -EBUSY; 538 535 539 536 send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); 540 537 skt->socket = dead_socket; ··· 543 540 skt->ops->suspend(skt); 544 541 skt->state |= SOCKET_SUSPEND; 545 542 546 - return CS_SUCCESS; 543 + return 0; 547 544 } 548 545 549 546 /* ··· 556 553 int ret; 557 554 558 555 if (!(skt->state & SOCKET_SUSPEND)) 559 - return CS_IN_USE; 556 + return -EBUSY; 560 557 561 558 skt->socket = dead_socket; 562 559 skt->ops->init(skt); ··· 568 565 } 569 566 570 567 ret = socket_setup(skt, resume_delay); 571 - if (ret == CS_SUCCESS) { 568 + if (ret == 0) { 572 569 /* 573 570 * FIXME: need a better check here for cardbus cards. 574 571 */ ··· 593 590 594 591 skt->state &= ~SOCKET_SUSPEND; 595 592 596 - return CS_SUCCESS; 593 + return 0; 597 594 } 598 595 599 596 static void socket_remove(struct pcmcia_socket *skt) 600 597 { 601 - printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock); 598 + dev_printk(KERN_NOTICE, &skt->dev, 599 + "pccard: card ejected from slot %d\n", skt->sock); 602 600 socket_shutdown(skt); 603 601 } 604 602 ··· 645 641 /* register with the device core */ 646 642 ret = device_register(&skt->dev); 647 643 if (ret) { 648 - printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n", 649 - skt); 644 + dev_printk(KERN_WARNING, &skt->dev, 645 + "PCMCIA: unable to register socket\n"); 650 646 skt->thread = NULL; 651 647 complete(&skt->thread_done); 652 648 return 0; ··· 752 748 * CIS register. 753 749 */ 754 750 755 - int pccard_reset_card(struct pcmcia_socket *skt) 751 + int pcmcia_reset_card(struct pcmcia_socket *skt) 756 752 { 757 753 int ret; 758 754 ··· 761 757 mutex_lock(&skt->skt_mutex); 762 758 do { 763 759 if (!(skt->state & SOCKET_PRESENT)) { 764 - ret = CS_NO_CARD; 760 + ret = -ENODEV; 765 761 break; 766 762 } 767 763 if (skt->state & SOCKET_SUSPEND) { 768 - ret = CS_IN_USE; 764 + ret = -EBUSY; 769 765 break; 770 766 } 771 767 if (skt->state & SOCKET_CARDBUS) { 772 - ret = CS_UNSUPPORTED_FUNCTION; 768 + ret = -EPERM; 773 769 break; 774 770 } 775 771 ··· 778 774 send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); 779 775 if (skt->callback) 780 776 skt->callback->suspend(skt); 781 - if (socket_reset(skt) == CS_SUCCESS) { 777 + if (socket_reset(skt) == 0) { 782 778 send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); 783 779 if (skt->callback) 784 780 skt->callback->resume(skt); 785 781 } 786 782 } 787 783 788 - ret = CS_SUCCESS; 784 + ret = 0; 789 785 } while (0); 790 786 mutex_unlock(&skt->skt_mutex); 791 787 792 788 return ret; 793 789 } /* reset_card */ 794 - EXPORT_SYMBOL(pccard_reset_card); 790 + EXPORT_SYMBOL(pcmcia_reset_card); 795 791 796 792 797 793 /* These shut down or wake up a socket. They are sort of user ··· 806 802 mutex_lock(&skt->skt_mutex); 807 803 do { 808 804 if (!(skt->state & SOCKET_PRESENT)) { 809 - ret = CS_NO_CARD; 805 + ret = -ENODEV; 810 806 break; 811 807 } 812 808 if (skt->state & SOCKET_CARDBUS) { 813 - ret = CS_UNSUPPORTED_FUNCTION; 809 + ret = -EPERM; 814 810 break; 815 811 } 816 812 if (skt->callback) { ··· 836 832 mutex_lock(&skt->skt_mutex); 837 833 do { 838 834 if (!(skt->state & SOCKET_PRESENT)) { 839 - ret = CS_NO_CARD; 835 + ret = -ENODEV; 840 836 break; 841 837 } 842 838 if (skt->state & SOCKET_CARDBUS) { 843 - ret = CS_UNSUPPORTED_FUNCTION; 839 + ret = -EPERM; 844 840 break; 845 841 } 846 842 ret = socket_resume(skt); ··· 896 892 ret = -EBUSY; 897 893 break; 898 894 } 899 - if (socket_insert(skt) == CS_NO_CARD) { 895 + if (socket_insert(skt) == -ENODEV) { 900 896 ret = -ENODEV; 901 897 break; 902 898 }
+167 -59
drivers/pcmcia/cs_internal.h
··· 1 1 /* 2 - * cs_internal.h 2 + * cs_internal.h -- definitions internal to the PCMCIA core modules 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License version 2 as ··· 10 10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 11 11 * 12 12 * (C) 1999 David A. Hinds 13 + * (C) 2003 - 2008 Dominik Brodowski 14 + * 15 + * 16 + * This file contains definitions _only_ needed by the PCMCIA core modules. 17 + * It must not be included by PCMCIA socket drivers or by PCMCIA device 18 + * drivers. 13 19 */ 14 20 15 21 #ifndef _LINUX_CS_INTERNAL_H ··· 24 18 #include <linux/kref.h> 25 19 26 20 /* Flags in client state */ 27 - #define CLIENT_CONFIG_LOCKED 0x0001 28 - #define CLIENT_IRQ_REQ 0x0002 29 - #define CLIENT_IO_REQ 0x0004 30 - #define CLIENT_UNBOUND 0x0008 31 - #define CLIENT_STALE 0x0010 32 21 #define CLIENT_WIN_REQ(i) (0x1<<(i)) 33 - #define CLIENT_CARDBUS 0x8000 34 22 35 23 /* Each card function gets one of these guys */ 36 24 typedef struct config_t { 37 25 struct kref ref; 38 - u_int state; 39 - u_int Attributes; 40 - u_int IntType; 41 - u_int ConfigBase; 42 - u_char Status, Pin, Copy, Option, ExtStatus; 43 - u_int CardValues; 44 - io_req_t io; 45 - struct { 46 - u_int Attributes; 47 - } irq; 26 + unsigned int state; 27 + unsigned int Attributes; 28 + unsigned int IntType; 29 + unsigned int ConfigBase; 30 + unsigned char Status, Pin, Copy, Option, ExtStatus; 31 + unsigned int CardValues; 32 + io_req_t io; 33 + struct { 34 + u_int Attributes; 35 + } irq; 48 36 } config_t; 37 + 49 38 50 39 struct cis_cache_entry { 51 40 struct list_head node; ··· 48 47 unsigned int len; 49 48 unsigned int attr; 50 49 unsigned char cache[0]; 50 + }; 51 + 52 + struct pccard_resource_ops { 53 + int (*validate_mem) (struct pcmcia_socket *s); 54 + int (*adjust_io_region) (struct resource *res, 55 + unsigned long r_start, 56 + unsigned long r_end, 57 + struct pcmcia_socket *s); 58 + struct resource* (*find_io) (unsigned long base, int num, 59 + unsigned long align, 60 + struct pcmcia_socket *s); 61 + struct resource* (*find_mem) (unsigned long base, unsigned long num, 62 + unsigned long align, int low, 63 + struct pcmcia_socket *s); 64 + int (*add_io) (struct pcmcia_socket *s, 65 + unsigned int action, 66 + unsigned long r_start, 67 + unsigned long r_end); 68 + int (*add_mem) (struct pcmcia_socket *s, 69 + unsigned int action, 70 + unsigned long r_start, 71 + unsigned long r_end); 72 + int (*init) (struct pcmcia_socket *s); 73 + void (*exit) (struct pcmcia_socket *s); 51 74 }; 52 75 53 76 /* Flags in config state */ ··· 84 59 #define SOCKET_INUSE 0x0010 85 60 #define SOCKET_SUSPEND 0x0080 86 61 #define SOCKET_WIN_REQ(i) (0x0100<<(i)) 87 - #define SOCKET_REGION_INFO 0x4000 88 62 #define SOCKET_CARDBUS 0x8000 89 63 #define SOCKET_CARDBUS_CONFIG 0x10000 90 64 ··· 107 83 } 108 84 } 109 85 110 - /* In cardbus.c */ 111 - int cb_alloc(struct pcmcia_socket *s); 112 - void cb_free(struct pcmcia_socket *s); 113 - int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len, void *ptr); 86 + #ifdef CONFIG_PCMCIA_DEBUG 87 + extern int cs_debug_level(int); 114 88 115 - /* In cistpl.c */ 116 - int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, 117 - u_int addr, u_int len, void *ptr); 118 - void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, 119 - u_int addr, u_int len, void *ptr); 120 - void release_cis_mem(struct pcmcia_socket *s); 121 - void destroy_cis_cache(struct pcmcia_socket *s); 89 + #define cs_dbg(skt, lvl, fmt, arg...) do { \ 90 + if (cs_debug_level(lvl)) \ 91 + dev_printk(KERN_DEBUG, &skt->dev, \ 92 + "cs: " fmt, ## arg); \ 93 + } while (0) 94 + #define __cs_dbg(lvl, fmt, arg...) do { \ 95 + if (cs_debug_level(lvl)) \ 96 + printk(KERN_DEBUG \ 97 + "cs: " fmt, ## arg); \ 98 + } while (0) 99 + 100 + #else 101 + #define cs_dbg(skt, lvl, fmt, arg...) do { } while (0) 102 + #define __cs_dbg(lvl, fmt, arg...) do { } while (0) 103 + #endif 104 + 105 + #define cs_err(skt, fmt, arg...) \ 106 + dev_printk(KERN_ERR, &skt->dev, "cs: " fmt, ## arg) 107 + 108 + 109 + /* 110 + * Stuff internal to module "pcmcia_core": 111 + */ 112 + 113 + /* cistpl.c */ 122 114 int verify_cis_cache(struct pcmcia_socket *s); 123 - int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse); 124 115 125 - /* In rsrc_mgr */ 126 - int pcmcia_validate_mem(struct pcmcia_socket *s); 127 - struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align, 128 - struct pcmcia_socket *s); 129 - int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start, 130 - unsigned long r_end, struct pcmcia_socket *s); 131 - struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align, 132 - int low, struct pcmcia_socket *s); 116 + /* rsrc_mgr.c */ 133 117 void release_resource_db(struct pcmcia_socket *s); 134 118 135 - /* In socket_sysfs.c */ 119 + /* socket_sysfs.c */ 136 120 extern int pccard_sysfs_add_socket(struct device *dev); 137 121 extern void pccard_sysfs_remove_socket(struct device *dev); 138 122 139 - /* In cs.c */ 140 - extern struct rw_semaphore pcmcia_socket_list_rwsem; 141 - extern struct list_head pcmcia_socket_list; 142 - int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); 143 - int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config); 144 - int pccard_reset_card(struct pcmcia_socket *skt); 123 + /* cardbus.c */ 124 + int cb_alloc(struct pcmcia_socket *s); 125 + void cb_free(struct pcmcia_socket *s); 126 + int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len, 127 + void *ptr); 145 128 129 + 130 + 131 + /* 132 + * Stuff exported by module "pcmcia_core" to module "pcmcia" 133 + */ 146 134 147 135 struct pcmcia_callback{ 148 136 struct module *owner; 149 - int (*event) (struct pcmcia_socket *s, event_t event, int priority); 137 + int (*event) (struct pcmcia_socket *s, 138 + event_t event, int priority); 150 139 void (*requery) (struct pcmcia_socket *s, int new_cis); 151 140 int (*suspend) (struct pcmcia_socket *s); 152 141 int (*resume) (struct pcmcia_socket *s); 153 142 }; 154 143 144 + /* cs.c */ 145 + extern struct rw_semaphore pcmcia_socket_list_rwsem; 146 + extern struct list_head pcmcia_socket_list; 147 + extern struct class pcmcia_socket_class; 148 + 149 + int pcmcia_get_window(struct pcmcia_socket *s, 150 + window_handle_t *handle, 151 + int idx, 152 + win_req_t *req); 155 153 int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); 154 + struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); 156 155 157 - #define cs_socket_name(skt) ((skt)->dev.bus_id) 156 + int pcmcia_suspend_card(struct pcmcia_socket *skt); 157 + int pcmcia_resume_card(struct pcmcia_socket *skt); 158 158 159 - #ifdef DEBUG 160 - extern int cs_debug_level(int); 159 + int pcmcia_eject_card(struct pcmcia_socket *skt); 160 + int pcmcia_insert_card(struct pcmcia_socket *skt); 161 161 162 - #define cs_dbg(skt, lvl, fmt, arg...) do { \ 163 - if (cs_debug_level(lvl)) \ 164 - printk(KERN_DEBUG "cs: %s: " fmt, \ 165 - cs_socket_name(skt) , ## arg); \ 166 - } while (0) 162 + struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt); 163 + void pcmcia_put_socket(struct pcmcia_socket *skt); 167 164 168 - #else 169 - #define cs_dbg(skt, lvl, fmt, arg...) do { } while (0) 170 - #endif 165 + /* cistpl.c */ 166 + int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, 167 + u_int addr, u_int len, void *ptr); 168 + void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, 169 + u_int addr, u_int len, void *ptr); 170 + void release_cis_mem(struct pcmcia_socket *s); 171 + void destroy_cis_cache(struct pcmcia_socket *s); 172 + int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, 173 + cisdata_t code, void *parse); 174 + int pcmcia_replace_cis(struct pcmcia_socket *s, 175 + const u8 *data, const size_t len); 176 + int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, 177 + unsigned int *count); 171 178 172 - #define cs_err(skt, fmt, arg...) \ 173 - printk(KERN_ERR "cs: %s: " fmt, (skt)->dev.bus_id , ## arg) 179 + /* rsrc_mgr.c */ 180 + int pcmcia_validate_mem(struct pcmcia_socket *s); 181 + struct resource *pcmcia_find_io_region(unsigned long base, 182 + int num, 183 + unsigned long align, 184 + struct pcmcia_socket *s); 185 + int pcmcia_adjust_io_region(struct resource *res, 186 + unsigned long r_start, 187 + unsigned long r_end, 188 + struct pcmcia_socket *s); 189 + struct resource *pcmcia_find_mem_region(u_long base, 190 + u_long num, 191 + u_long align, 192 + int low, 193 + struct pcmcia_socket *s); 194 + 195 + /* 196 + * Stuff internal to module "pcmcia". 197 + */ 198 + /* ds.c */ 199 + extern struct bus_type pcmcia_bus_type; 200 + 201 + /* pcmcia_resource.c */ 202 + extern int pcmcia_release_configuration(struct pcmcia_device *p_dev); 203 + 204 + #ifdef CONFIG_PCMCIA_IOCTL 205 + /* ds.c */ 206 + extern spinlock_t pcmcia_dev_list_lock; 207 + 208 + extern struct pcmcia_device *pcmcia_get_dev(struct pcmcia_device *p_dev); 209 + extern void pcmcia_put_dev(struct pcmcia_device *p_dev); 210 + 211 + struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, 212 + unsigned int function); 213 + 214 + /* pcmcia_ioctl.c */ 215 + extern void __init pcmcia_setup_ioctl(void); 216 + extern void __exit pcmcia_cleanup_ioctl(void); 217 + extern void handle_event(struct pcmcia_socket *s, event_t event); 218 + extern int handle_request(struct pcmcia_socket *s, event_t event); 219 + 220 + #else /* CONFIG_PCMCIA_IOCTL */ 221 + 222 + static inline void __init pcmcia_setup_ioctl(void) { return; } 223 + static inline void __exit pcmcia_cleanup_ioctl(void) { return; } 224 + static inline void handle_event(struct pcmcia_socket *s, event_t event) 225 + { 226 + return; 227 + } 228 + static inline int handle_request(struct pcmcia_socket *s, event_t event) 229 + { 230 + return 0; 231 + } 232 + 233 + #endif /* CONFIG_PCMCIA_IOCTL */ 174 234 175 235 #endif /* _LINUX_CS_INTERNAL_H */
+101 -138
drivers/pcmcia/ds.c
··· 32 32 #include <pcmcia/ss.h> 33 33 34 34 #include "cs_internal.h" 35 - #include "ds_internal.h" 36 35 37 36 /*====================================================================*/ 38 37 ··· 41 42 MODULE_DESCRIPTION("PCMCIA Driver Services"); 42 43 MODULE_LICENSE("GPL"); 43 44 44 - #ifdef DEBUG 45 + #ifdef CONFIG_PCMCIA_DEBUG 45 46 int ds_pc_debug; 46 47 47 48 module_param_named(pc_debug, ds_pc_debug, int, 0644); 48 49 49 50 #define ds_dbg(lvl, fmt, arg...) do { \ 50 - if (ds_pc_debug > (lvl)) \ 51 + if (ds_pc_debug > (lvl)) \ 51 52 printk(KERN_DEBUG "ds: " fmt , ## arg); \ 53 + } while (0) 54 + #define ds_dev_dbg(lvl, dev, fmt, arg...) do { \ 55 + if (ds_pc_debug > (lvl)) \ 56 + dev_printk(KERN_DEBUG, dev, "ds: " fmt , ## arg); \ 52 57 } while (0) 53 58 #else 54 59 #define ds_dbg(lvl, fmt, arg...) do { } while (0) 60 + #define ds_dev_dbg(lvl, dev, fmt, arg...) do { } while (0) 55 61 #endif 56 62 57 63 spinlock_t pcmcia_dev_list_lock; ··· 68 64 /* String tables for error messages */ 69 65 70 66 typedef struct lookup_t { 71 - int key; 72 - char *msg; 67 + const int key; 68 + const char *msg; 73 69 } lookup_t; 74 70 75 71 static const lookup_t error_table[] = { 76 - { CS_SUCCESS, "Operation succeeded" }, 77 - { CS_BAD_ADAPTER, "Bad adapter" }, 78 - { CS_BAD_ATTRIBUTE, "Bad attribute", }, 79 - { CS_BAD_BASE, "Bad base address" }, 80 - { CS_BAD_EDC, "Bad EDC" }, 81 - { CS_BAD_IRQ, "Bad IRQ" }, 82 - { CS_BAD_OFFSET, "Bad offset" }, 83 - { CS_BAD_PAGE, "Bad page number" }, 84 - { CS_READ_FAILURE, "Read failure" }, 85 - { CS_BAD_SIZE, "Bad size" }, 86 - { CS_BAD_SOCKET, "Bad socket" }, 87 - { CS_BAD_TYPE, "Bad type" }, 88 - { CS_BAD_VCC, "Bad Vcc" }, 89 - { CS_BAD_VPP, "Bad Vpp" }, 90 - { CS_BAD_WINDOW, "Bad window" }, 91 - { CS_WRITE_FAILURE, "Write failure" }, 92 - { CS_NO_CARD, "No card present" }, 93 - { CS_UNSUPPORTED_FUNCTION, "Usupported function" }, 94 - { CS_UNSUPPORTED_MODE, "Unsupported mode" }, 95 - { CS_BAD_SPEED, "Bad speed" }, 96 - { CS_BUSY, "Resource busy" }, 97 - { CS_GENERAL_FAILURE, "General failure" }, 98 - { CS_WRITE_PROTECTED, "Write protected" }, 99 - { CS_BAD_ARG_LENGTH, "Bad argument length" }, 100 - { CS_BAD_ARGS, "Bad arguments" }, 101 - { CS_CONFIGURATION_LOCKED, "Configuration locked" }, 102 - { CS_IN_USE, "Resource in use" }, 103 - { CS_NO_MORE_ITEMS, "No more items" }, 104 - { CS_OUT_OF_RESOURCE, "Out of resource" }, 105 - { CS_BAD_HANDLE, "Bad handle" }, 106 - { CS_BAD_TUPLE, "Bad CIS tuple" } 72 + { 0, "Operation succeeded" }, 73 + { -EIO, "Input/Output error" }, 74 + { -ENODEV, "No card present" }, 75 + { -EINVAL, "Bad parameter" }, 76 + { -EACCES, "Configuration locked" }, 77 + { -EBUSY, "Resource in use" }, 78 + { -ENOSPC, "No more items" }, 79 + { -ENOMEM, "Out of resource" }, 107 80 }; 108 81 109 82 ··· 136 155 { ReplaceCIS, "ReplaceCIS" } 137 156 }; 138 157 139 - 140 - static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err) 158 + const char *pcmcia_error_func(int func) 141 159 { 142 160 int i; 143 - char *serv; 144 - 145 - if (!p_dev) 146 - printk(KERN_NOTICE); 147 - else 148 - printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id); 149 161 150 162 for (i = 0; i < ARRAY_SIZE(service_table); i++) 151 - if (service_table[i].key == err->func) 152 - break; 153 - if (i < ARRAY_SIZE(service_table)) 154 - serv = service_table[i].msg; 155 - else 156 - serv = "Unknown service number"; 163 + if (service_table[i].key == func) 164 + return service_table[i].msg; 165 + 166 + return "Unknown service number"; 167 + } 168 + EXPORT_SYMBOL(pcmcia_error_func); 169 + 170 + const char *pcmcia_error_ret(int ret) 171 + { 172 + int i; 157 173 158 174 for (i = 0; i < ARRAY_SIZE(error_table); i++) 159 - if (error_table[i].key == err->retcode) 160 - break; 161 - if (i < ARRAY_SIZE(error_table)) 162 - printk("%s: %s\n", serv, error_table[i].msg); 163 - else 164 - printk("%s: Unknown error code %#x\n", serv, err->retcode); 175 + if (error_table[i].key == ret) 176 + return error_table[i].msg; 165 177 166 - return CS_SUCCESS; 167 - } /* report_error */ 168 - 169 - /* end of code which was in cs.c before */ 178 + return "unknown"; 179 + } 180 + EXPORT_SYMBOL(pcmcia_error_ret); 170 181 171 182 /*======================================================================*/ 172 183 173 - void cs_error(struct pcmcia_device *p_dev, int func, int ret) 174 - { 175 - error_info_t err = { func, ret }; 176 - pcmcia_report_error(p_dev, &err); 177 - } 178 - EXPORT_SYMBOL(cs_error); 179 184 180 185 181 186 static void pcmcia_check_driver(struct pcmcia_driver *p_drv) ··· 358 391 static void pcmcia_release_dev(struct device *dev) 359 392 { 360 393 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 361 - ds_dbg(1, "releasing device %s\n", p_dev->dev.bus_id); 394 + ds_dev_dbg(1, dev, "releasing device\n"); 362 395 pcmcia_put_socket(p_dev->socket); 363 396 kfree(p_dev->devname); 364 397 kref_put(&p_dev->function_config->ref, pcmcia_release_function); ··· 368 401 static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc) 369 402 { 370 403 if (!s->pcmcia_state.device_add_pending) { 371 - ds_dbg(1, "scheduling to add %s secondary" 404 + ds_dev_dbg(1, &s->dev, "scheduling to add %s secondary" 372 405 " device to %d\n", mfc ? "mfc" : "pfc", s->sock); 373 406 s->pcmcia_state.device_add_pending = 1; 374 407 s->pcmcia_state.mfc_pfc = mfc; ··· 406 439 */ 407 440 did = p_dev->dev.driver_data; 408 441 409 - ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id, 410 - p_drv->drv.name); 442 + ds_dev_dbg(1, dev, "trying to bind to %s\n", p_drv->drv.name); 411 443 412 444 if ((!p_drv->probe) || (!p_dev->function_config) || 413 445 (!try_module_get(p_drv->owner))) { ··· 421 455 p_dev->conf.ConfigBase = cis_config.base; 422 456 p_dev->conf.Present = cis_config.rmask[0]; 423 457 } else { 424 - printk(KERN_INFO "pcmcia: could not parse base and rmask0 of CIS\n"); 458 + dev_printk(KERN_INFO, dev, 459 + "pcmcia: could not parse base and rmask0 of CIS\n"); 425 460 p_dev->conf.ConfigBase = 0; 426 461 p_dev->conf.Present = 0; 427 462 } 428 463 429 464 ret = p_drv->probe(p_dev); 430 465 if (ret) { 431 - ds_dbg(1, "binding %s to %s failed with %d\n", 432 - p_dev->dev.bus_id, p_drv->drv.name, ret); 466 + ds_dev_dbg(1, dev, "binding to %s failed with %d\n", 467 + p_drv->drv.name, ret); 433 468 goto put_module; 434 469 } 435 470 ··· 457 490 struct pcmcia_device *tmp; 458 491 unsigned long flags; 459 492 460 - ds_dbg(2, "pcmcia_card_remove(%d) %s\n", s->sock, 461 - leftover ? leftover->devname : ""); 493 + ds_dev_dbg(2, leftover ? &leftover->dev : &s->dev, 494 + "pcmcia_card_remove(%d) %s\n", s->sock, 495 + leftover ? leftover->devname : ""); 462 496 463 497 if (!leftover) 464 498 s->device_count = 0; ··· 476 508 p_dev->_removed=1; 477 509 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 478 510 479 - ds_dbg(2, "unregistering device %s\n", p_dev->dev.bus_id); 511 + ds_dev_dbg(2, &p_dev->dev, "unregistering device\n"); 480 512 device_unregister(&p_dev->dev); 481 513 } 482 514 ··· 493 525 p_dev = to_pcmcia_dev(dev); 494 526 p_drv = to_pcmcia_drv(dev->driver); 495 527 496 - ds_dbg(1, "removing device %s\n", p_dev->dev.bus_id); 528 + ds_dev_dbg(1, dev, "removing device\n"); 497 529 498 530 /* If we're removing the primary module driving a 499 531 * pseudo multi-function card, we need to unbind ··· 516 548 517 549 /* check for proper unloading */ 518 550 if (p_dev->_irq || p_dev->_io || p_dev->_locked) 519 - printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", 520 - p_drv->drv.name); 551 + dev_printk(KERN_INFO, dev, 552 + "pcmcia: driver %s did not release config properly\n", 553 + p_drv->drv.name); 521 554 522 555 for (i = 0; i < MAX_WIN; i++) 523 556 if (p_dev->_win & CLIENT_WIN_REQ(i)) 524 - printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", 525 - p_drv->drv.name); 557 + dev_printk(KERN_INFO, dev, 558 + "pcmcia: driver %s did not release window properly\n", 559 + p_drv->drv.name); 526 560 527 561 /* references from pcmcia_probe_device */ 528 562 pcmcia_put_dev(p_dev); ··· 573 603 } 574 604 if (!pccard_read_tuple(p_dev->socket, p_dev->func, 575 605 CISTPL_DEVICE_GEO, devgeo)) { 576 - ds_dbg(0, "mem device geometry probably means " 577 - "FUNCID_MEMORY\n"); 606 + ds_dev_dbg(0, &p_dev->dev, 607 + "mem device geometry probably means " 608 + "FUNCID_MEMORY\n"); 578 609 p_dev->func_id = CISTPL_FUNCID_MEMORY; 579 610 p_dev->has_func_id = 1; 580 611 } ··· 656 685 if (!p_dev->devname) 657 686 goto err_free; 658 687 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); 659 - ds_dbg(3, "devname is %s\n", p_dev->devname); 688 + ds_dev_dbg(3, &p_dev->dev, "devname is %s\n", p_dev->devname); 660 689 661 690 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 662 691 ··· 677 706 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 678 707 679 708 if (!p_dev->function_config) { 680 - ds_dbg(3, "creating config_t for %s\n", p_dev->dev.bus_id); 709 + ds_dev_dbg(3, &p_dev->dev, "creating config_t\n"); 681 710 p_dev->function_config = kzalloc(sizeof(struct config_t), 682 711 GFP_KERNEL); 683 712 if (!p_dev->function_config) ··· 685 714 kref_init(&p_dev->function_config->ref); 686 715 } 687 716 688 - printk(KERN_NOTICE "pcmcia: registering new device %s\n", 689 - p_dev->devname); 717 + dev_printk(KERN_NOTICE, &p_dev->dev, 718 + "pcmcia: registering new device %s\n", 719 + p_dev->devname); 690 720 691 721 pcmcia_device_query(p_dev); 692 722 ··· 722 750 int ret = 0; 723 751 724 752 if (!(s->resource_setup_done)) { 725 - ds_dbg(3, "no resources available, delaying card_add\n"); 753 + ds_dev_dbg(3, &s->dev, 754 + "no resources available, delaying card_add\n"); 726 755 return -EAGAIN; /* try again, but later... */ 727 756 } 728 757 729 758 if (pcmcia_validate_mem(s)) { 730 - ds_dbg(3, "validating mem resources failed, " 759 + ds_dev_dbg(3, &s->dev, "validating mem resources failed, " 731 760 "delaying card_add\n"); 732 761 return -EAGAIN; /* try again, but later... */ 733 762 } 734 763 735 764 ret = pccard_validate_cis(s, BIND_FN_ALL, &no_chains); 736 765 if (ret || !no_chains) { 737 - ds_dbg(0, "invalid CIS or invalid resources\n"); 766 + ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n"); 738 767 return -ENODEV; 739 768 } 740 769 ··· 756 783 { 757 784 struct pcmcia_socket *s = 758 785 container_of(work, struct pcmcia_socket, device_add); 759 - ds_dbg(1, "adding additional device to %d\n", s->sock); 786 + ds_dev_dbg(1, &s->dev, "adding additional device to %d\n", s->sock); 760 787 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc); 761 788 s->pcmcia_state.device_add_pending = 0; 762 789 s->pcmcia_state.mfc_pfc = 0; ··· 766 793 { 767 794 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 768 795 if (!p_dev->dev.driver) { 769 - ds_dbg(1, "update device information for %s\n", 770 - p_dev->dev.bus_id); 796 + ds_dev_dbg(1, dev, "update device information\n"); 771 797 pcmcia_device_query(p_dev); 772 798 } 773 799 ··· 780 808 unsigned long flags; 781 809 782 810 /* must be called with skt_mutex held */ 783 - ds_dbg(0, "re-scanning socket %d\n", skt->sock); 811 + ds_dev_dbg(0, &skt->dev, "re-scanning socket %d\n", skt->sock); 784 812 785 813 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 786 814 if (list_empty(&skt->devices_list)) ··· 831 859 int ret = -ENOMEM; 832 860 int no_funcs; 833 861 int old_funcs; 834 - cisdump_t *cis; 835 862 cistpl_longlink_mfc_t mfc; 836 863 837 864 if (!filename) 838 865 return -EINVAL; 839 866 840 - ds_dbg(1, "trying to load CIS file %s\n", filename); 867 + ds_dev_dbg(1, &dev->dev, "trying to load CIS file %s\n", filename); 841 868 842 869 if (strlen(filename) > (FIRMWARE_NAME_MAX - 1)) { 843 - printk(KERN_WARNING "pcmcia: CIS filename is too long [%s]\n", 844 - filename); 870 + dev_printk(KERN_WARNING, &dev->dev, 871 + "pcmcia: CIS filename is too long [%s]\n", 872 + filename); 845 873 return -EINVAL; 846 874 } 847 875 ··· 850 878 if (request_firmware(&fw, path, &dev->dev) == 0) { 851 879 if (fw->size >= CISTPL_MAX_CIS_SIZE) { 852 880 ret = -EINVAL; 853 - printk(KERN_ERR "pcmcia: CIS override is too big\n"); 881 + dev_printk(KERN_ERR, &dev->dev, 882 + "pcmcia: CIS override is too big\n"); 854 883 goto release; 855 884 } 856 885 857 - cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL); 858 - if (!cis) { 859 - ret = -ENOMEM; 860 - goto release; 861 - } 862 - 863 - cis->Length = fw->size + 1; 864 - memcpy(cis->Data, fw->data, fw->size); 865 - 866 - if (!pcmcia_replace_cis(s, cis)) 886 + if (!pcmcia_replace_cis(s, fw->data, fw->size)) 867 887 ret = 0; 868 888 else { 869 - printk(KERN_ERR "pcmcia: CIS override failed\n"); 889 + dev_printk(KERN_ERR, &dev->dev, 890 + "pcmcia: CIS override failed\n"); 870 891 goto release; 871 892 } 872 893 ··· 963 998 * after it has re-checked that there is no possible module 964 999 * with a prod_id/manf_id/card_id match. 965 1000 */ 966 - ds_dbg(0, "skipping FUNC_ID match for %s until userspace " 967 - "interaction\n", dev->dev.bus_id); 1001 + ds_dev_dbg(0, &dev->dev, 1002 + "skipping FUNC_ID match until userspace interaction\n"); 968 1003 if (!dev->allow_func_id_match) 969 1004 return 0; 970 1005 } 971 1006 972 1007 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 973 - ds_dbg(0, "device %s needs a fake CIS\n", dev->dev.bus_id); 1008 + ds_dev_dbg(0, &dev->dev, "device needs a fake CIS\n"); 974 1009 if (!dev->socket->fake_cis) 975 1010 pcmcia_load_firmware(dev, did->cisfile); 976 1011 ··· 1002 1037 /* match dynamic devices first */ 1003 1038 spin_lock(&p_drv->dynids.lock); 1004 1039 list_for_each_entry(dynid, &p_drv->dynids.list, node) { 1005 - ds_dbg(3, "trying to match %s to %s\n", dev->bus_id, 1006 - drv->name); 1040 + ds_dev_dbg(3, dev, "trying to match to %s\n", drv->name); 1007 1041 if (pcmcia_devmatch(p_dev, &dynid->id)) { 1008 - ds_dbg(0, "matched %s to %s\n", dev->bus_id, 1009 - drv->name); 1042 + ds_dev_dbg(0, dev, "matched to %s\n", drv->name); 1010 1043 spin_unlock(&p_drv->dynids.lock); 1011 1044 return 1; 1012 1045 } ··· 1014 1051 #ifdef CONFIG_PCMCIA_IOCTL 1015 1052 /* matching by cardmgr */ 1016 1053 if (p_dev->cardmgr == p_drv) { 1017 - ds_dbg(0, "cardmgr matched %s to %s\n", dev->bus_id, 1018 - drv->name); 1054 + ds_dev_dbg(0, dev, "cardmgr matched to %s\n", drv->name); 1019 1055 return 1; 1020 1056 } 1021 1057 #endif 1022 1058 1023 1059 while (did && did->match_flags) { 1024 - ds_dbg(3, "trying to match %s to %s\n", dev->bus_id, 1025 - drv->name); 1060 + ds_dev_dbg(3, dev, "trying to match to %s\n", drv->name); 1026 1061 if (pcmcia_devmatch(p_dev, did)) { 1027 - ds_dbg(0, "matched %s to %s\n", dev->bus_id, 1028 - drv->name); 1062 + ds_dev_dbg(0, dev, "matched to %s\n", drv->name); 1029 1063 return 1; 1030 1064 } 1031 1065 did++; ··· 1228 1268 if (p_dev->suspended) 1229 1269 return 0; 1230 1270 1231 - ds_dbg(2, "suspending %s\n", dev->bus_id); 1271 + ds_dev_dbg(2, dev, "suspending\n"); 1232 1272 1233 1273 if (dev->driver) 1234 1274 p_drv = to_pcmcia_drv(dev->driver); ··· 1239 1279 if (p_drv->suspend) { 1240 1280 ret = p_drv->suspend(p_dev); 1241 1281 if (ret) { 1242 - printk(KERN_ERR "pcmcia: device %s (driver %s) did " 1243 - "not want to go to sleep (%d)\n", 1244 - p_dev->devname, p_drv->drv.name, ret); 1282 + dev_printk(KERN_ERR, dev, 1283 + "pcmcia: device %s (driver %s) did " 1284 + "not want to go to sleep (%d)\n", 1285 + p_dev->devname, p_drv->drv.name, ret); 1245 1286 goto out; 1246 1287 } 1247 1288 } 1248 1289 1249 1290 if (p_dev->device_no == p_dev->func) { 1250 - ds_dbg(2, "releasing configuration for %s\n", dev->bus_id); 1291 + ds_dev_dbg(2, dev, "releasing configuration\n"); 1251 1292 pcmcia_release_configuration(p_dev); 1252 1293 } 1253 1294 ··· 1268 1307 if (!p_dev->suspended) 1269 1308 return 0; 1270 1309 1271 - ds_dbg(2, "resuming %s\n", dev->bus_id); 1310 + ds_dev_dbg(2, dev, "resuming\n"); 1272 1311 1273 1312 if (dev->driver) 1274 1313 p_drv = to_pcmcia_drv(dev->driver); ··· 1277 1316 goto out; 1278 1317 1279 1318 if (p_dev->device_no == p_dev->func) { 1280 - ds_dbg(2, "requesting configuration for %s\n", dev->bus_id); 1319 + ds_dev_dbg(2, dev, "requesting configuration\n"); 1281 1320 ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1282 1321 if (ret) 1283 1322 goto out; ··· 1319 1358 1320 1359 static int pcmcia_bus_resume(struct pcmcia_socket *skt) 1321 1360 { 1322 - ds_dbg(2, "resuming socket %d\n", skt->sock); 1361 + ds_dev_dbg(2, &skt->dev, "resuming socket %d\n", skt->sock); 1323 1362 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); 1324 1363 return 0; 1325 1364 } 1326 1365 1327 1366 static int pcmcia_bus_suspend(struct pcmcia_socket *skt) 1328 1367 { 1329 - ds_dbg(2, "suspending socket %d\n", skt->sock); 1368 + ds_dev_dbg(2, &skt->dev, "suspending socket %d\n", skt->sock); 1330 1369 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, 1331 1370 pcmcia_bus_suspend_callback)) { 1332 1371 pcmcia_bus_resume(skt); ··· 1352 1391 struct pcmcia_socket *s = pcmcia_get_socket(skt); 1353 1392 1354 1393 if (!s) { 1355 - printk(KERN_ERR "PCMCIA obtaining reference to socket %p " \ 1356 - "failed, event 0x%x lost!\n", skt, event); 1394 + dev_printk(KERN_ERR, &skt->dev, 1395 + "PCMCIA obtaining reference to socket " \ 1396 + "failed, event 0x%x lost!\n", event); 1357 1397 return -ENODEV; 1358 1398 } 1359 1399 1360 - ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n", 1361 - event, priority, skt); 1400 + ds_dev_dbg(1, &skt->dev, "ds_event(0x%06x, %d, 0x%p)\n", 1401 + event, priority, skt); 1362 1402 1363 1403 switch (event) { 1364 1404 case CS_EVENT_CARD_REMOVAL: ··· 1434 1472 1435 1473 socket = pcmcia_get_socket(socket); 1436 1474 if (!socket) { 1437 - printk(KERN_ERR "PCMCIA obtaining reference to socket %p failed\n", socket); 1475 + dev_printk(KERN_ERR, dev, 1476 + "PCMCIA obtaining reference to socket failed\n"); 1438 1477 return -ENODEV; 1439 1478 } 1440 1479 ··· 1455 1492 1456 1493 ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback); 1457 1494 if (ret) { 1458 - printk(KERN_ERR "PCMCIA registration PCCard core failed for socket %p\n", socket); 1495 + dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n"); 1459 1496 pcmcia_put_socket(socket); 1460 1497 return (ret); 1461 1498 }
-23
drivers/pcmcia/ds_internal.h
··· 1 - /* ds_internal.h - internal header for 16-bit PCMCIA devices management */ 2 - 3 - extern spinlock_t pcmcia_dev_list_lock; 4 - extern struct bus_type pcmcia_bus_type; 5 - 6 - extern struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev); 7 - extern void pcmcia_put_dev(struct pcmcia_device *p_dev); 8 - 9 - struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function); 10 - 11 - extern int pcmcia_release_configuration(struct pcmcia_device *p_dev); 12 - 13 - #ifdef CONFIG_PCMCIA_IOCTL 14 - extern void __init pcmcia_setup_ioctl(void); 15 - extern void __exit pcmcia_cleanup_ioctl(void); 16 - extern void handle_event(struct pcmcia_socket *s, event_t event); 17 - extern int handle_request(struct pcmcia_socket *s, event_t event); 18 - #else 19 - static inline void __init pcmcia_setup_ioctl(void) { return; } 20 - static inline void __exit pcmcia_cleanup_ioctl(void) { return; } 21 - static inline void handle_event(struct pcmcia_socket *s, event_t event) { return; } 22 - static inline int handle_request(struct pcmcia_socket *s, event_t event) { return CS_SUCCESS; } 23 - #endif
-1
drivers/pcmcia/hd64465_ss.c
··· 46 46 #include <pcmcia/cistpl.h> 47 47 #include <pcmcia/ds.h> 48 48 #include <pcmcia/ss.h> 49 - #include "cs_internal.h" 50 49 51 50 #define MODNAME "hd64465_ss" 52 51
+1 -1
drivers/pcmcia/i82365.c
··· 63 63 #include "vg468.h" 64 64 #include "ricoh.h" 65 65 66 - #ifdef DEBUG 66 + #ifdef CONFIG_PCMCIA_DEBUG 67 67 static const char version[] = 68 68 "i82365.c 1.265 1999/11/10 18:36:21 (David Hinds)"; 69 69
+2 -2
drivers/pcmcia/m32r_cfc.c
··· 38 38 39 39 #include "m32r_cfc.h" 40 40 41 - #ifdef DEBUG 41 + #ifdef CONFIG_PCMCIA_DEBUG 42 42 static int m32r_cfc_debug; 43 43 module_param(m32r_cfc_debug, int, 0644); 44 44 #define debug(lvl, fmt, arg...) do { \ ··· 505 505 pcc_set(sock,(unsigned int)PLD_CFBUFCR,1); 506 506 } 507 507 508 - #ifdef DEBUG 508 + #ifdef CONFIG_PCMCIA_DEBUG 509 509 if(state->flags & SS_IOCARD){ 510 510 debug(3, ":IOCARD"); 511 511 }
+2 -2
drivers/pcmcia/m32r_pcc.c
··· 45 45 46 46 #define PCC_DEBUG_DBEX 47 47 48 - #ifdef DEBUG 48 + #ifdef CONFIG_PCMCIA_DEBUG 49 49 static int m32r_pcc_debug; 50 50 module_param(m32r_pcc_debug, int, 0644); 51 51 #define debug(lvl, fmt, arg...) do { \ ··· 460 460 461 461 pcc_set(sock,PCCSIGCR,reg); 462 462 463 - #ifdef DEBUG 463 + #ifdef CONFIG_PCMCIA_DEBUG 464 464 if(state->flags & SS_IOCARD){ 465 465 debug(3, ":IOCARD"); 466 466 }
+2 -2
drivers/pcmcia/m8xx_pcmcia.c
··· 64 64 #include <pcmcia/cs.h> 65 65 #include <pcmcia/ss.h> 66 66 67 - #ifdef PCMCIA_DEBUG 68 - static int pc_debug = PCMCIA_DEBUG; 67 + #ifdef CONFIG_PCMCIA_DEBUG 68 + static int pc_debug; 69 69 module_param(pc_debug, int, 0); 70 70 #define dprintk(args...) printk(KERN_DEBUG "m8xx_pcmcia: " args); 71 71 #else
+7 -3
drivers/pcmcia/o2micro.h
··· 140 140 a = config_readb(socket, O2_RESERVED1); 141 141 b = config_readb(socket, O2_RESERVED2); 142 142 143 - printk(KERN_INFO "Yenta O2: res at 0x94/0xD4: %02x/%02x\n", a, b); 143 + dev_printk(KERN_INFO, &socket->dev->dev, 144 + "O2: res at 0x94/0xD4: %02x/%02x\n", a, b); 144 145 145 146 switch (socket->dev->device) { 146 147 /* ··· 154 153 case PCI_DEVICE_ID_O2_6812: 155 154 case PCI_DEVICE_ID_O2_6832: 156 155 case PCI_DEVICE_ID_O2_6836: 157 - printk(KERN_INFO "Yenta O2: old bridge, disabling read prefetch/write burst\n"); 156 + dev_printk(KERN_INFO, &socket->dev->dev, 157 + "Yenta O2: old bridge, disabling read " 158 + "prefetch/write burst\n"); 158 159 config_writeb(socket, O2_RESERVED1, 159 160 a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST)); 160 161 config_writeb(socket, O2_RESERVED2, ··· 164 161 break; 165 162 166 163 default: 167 - printk(KERN_INFO "Yenta O2: enabling read prefetch/write burst\n"); 164 + dev_printk(KERN_INFO , &socket->dev->dev, 165 + "O2: enabling read prefetch/write burst\n"); 168 166 config_writeb(socket, O2_RESERVED1, 169 167 a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST); 170 168 config_writeb(socket, O2_RESERVED2,
+94 -26
drivers/pcmcia/pcmcia_ioctl.c
··· 38 38 #include <pcmcia/ss.h> 39 39 40 40 #include "cs_internal.h" 41 - #include "ds_internal.h" 42 41 43 42 static int major_dev = -1; 44 43 ··· 57 58 } user_info_t; 58 59 59 60 60 - #ifdef DEBUG 61 + #ifdef CONFIG_PCMCIA_DEBUG 61 62 extern int ds_pc_debug; 62 63 63 64 #define ds_dbg(lvl, fmt, arg...) do { \ ··· 148 149 149 150 irq = adj->resource.irq.IRQ; 150 151 if ((irq < 0) || (irq > 15)) 151 - return CS_BAD_IRQ; 152 + return -EINVAL; 152 153 153 154 if (adj->Action != REMOVE_MANAGED_RESOURCE) 154 155 return 0; ··· 166 167 #else 167 168 168 169 static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { 169 - return CS_SUCCESS; 170 + return 0; 170 171 } 171 172 172 173 #endif ··· 174 175 static int pcmcia_adjust_resource_info(adjust_t *adj) 175 176 { 176 177 struct pcmcia_socket *s; 177 - int ret = CS_UNSUPPORTED_FUNCTION; 178 + int ret = -ENOSYS; 178 179 unsigned long flags; 179 180 180 181 down_read(&pcmcia_socket_list_rwsem); ··· 247 248 if (s->state & SOCKET_SUSPEND) 248 249 status->CardState |= CS_EVENT_PM_SUSPEND; 249 250 if (!(s->state & SOCKET_PRESENT)) 250 - return CS_NO_CARD; 251 + return -ENODEV; 251 252 252 253 c = (p_dev) ? p_dev->function_config : NULL; 253 254 ··· 273 274 status->CardState |= 274 275 (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; 275 276 } 276 - return CS_SUCCESS; 277 + return 0; 277 278 } 278 279 status->CardState |= 279 280 (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0; ··· 283 284 (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0; 284 285 status->CardState |= 285 286 (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0; 286 - return CS_SUCCESS; 287 + return 0; 287 288 } /* pccard_get_status */ 289 + 290 + int pccard_get_configuration_info(struct pcmcia_socket *s, 291 + struct pcmcia_device *p_dev, 292 + config_info_t *config) 293 + { 294 + config_t *c; 295 + 296 + if (!(s->state & SOCKET_PRESENT)) 297 + return -ENODEV; 298 + 299 + 300 + #ifdef CONFIG_CARDBUS 301 + if (s->state & SOCKET_CARDBUS) { 302 + memset(config, 0, sizeof(config_info_t)); 303 + config->Vcc = s->socket.Vcc; 304 + config->Vpp1 = config->Vpp2 = s->socket.Vpp; 305 + config->Option = s->cb_dev->subordinate->number; 306 + if (s->state & SOCKET_CARDBUS_CONFIG) { 307 + config->Attributes = CONF_VALID_CLIENT; 308 + config->IntType = INT_CARDBUS; 309 + config->AssignedIRQ = s->irq.AssignedIRQ; 310 + if (config->AssignedIRQ) 311 + config->Attributes |= CONF_ENABLE_IRQ; 312 + if (s->io[0].res) { 313 + config->BasePort1 = s->io[0].res->start; 314 + config->NumPorts1 = s->io[0].res->end - 315 + config->BasePort1 + 1; 316 + } 317 + } 318 + return 0; 319 + } 320 + #endif 321 + 322 + if (p_dev) { 323 + c = p_dev->function_config; 324 + config->Function = p_dev->func; 325 + } else { 326 + c = NULL; 327 + config->Function = 0; 328 + } 329 + 330 + if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { 331 + config->Attributes = 0; 332 + config->Vcc = s->socket.Vcc; 333 + config->Vpp1 = config->Vpp2 = s->socket.Vpp; 334 + return 0; 335 + } 336 + 337 + config->Attributes = c->Attributes | CONF_VALID_CLIENT; 338 + config->Vcc = s->socket.Vcc; 339 + config->Vpp1 = config->Vpp2 = s->socket.Vpp; 340 + config->IntType = c->IntType; 341 + config->ConfigBase = c->ConfigBase; 342 + config->Status = c->Status; 343 + config->Pin = c->Pin; 344 + config->Copy = c->Copy; 345 + config->Option = c->Option; 346 + config->ExtStatus = c->ExtStatus; 347 + config->Present = config->CardValues = c->CardValues; 348 + config->IRQAttributes = c->irq.Attributes; 349 + config->AssignedIRQ = s->irq.AssignedIRQ; 350 + config->BasePort1 = c->io.BasePort1; 351 + config->NumPorts1 = c->io.NumPorts1; 352 + config->Attributes1 = c->io.Attributes1; 353 + config->BasePort2 = c->io.BasePort2; 354 + config->NumPorts2 = c->io.NumPorts2; 355 + config->Attributes2 = c->io.Attributes2; 356 + config->IOAddrLines = c->io.IOAddrLines; 357 + 358 + return 0; 359 + } /* pccard_get_configuration_info */ 360 + 288 361 289 362 /*====================================================================== 290 363 ··· 835 764 case DS_GET_CONFIGURATION_INFO: 836 765 if (buf->config.Function && 837 766 (buf->config.Function >= s->functions)) 838 - ret = CS_BAD_ARGS; 767 + ret = -EINVAL; 839 768 else { 840 769 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); 841 770 ret = pccard_get_configuration_info(s, p_dev, &buf->config); ··· 858 787 break; 859 788 case DS_PARSE_TUPLE: 860 789 buf->tuple.TupleData = buf->tuple_parse.data; 861 - ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); 790 + ret = pcmcia_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); 862 791 break; 863 792 case DS_RESET_CARD: 864 - ret = pccard_reset_card(s); 793 + ret = pcmcia_reset_card(s); 865 794 break; 866 795 case DS_GET_STATUS: 867 796 if (buf->status.Function && 868 797 (buf->status.Function >= s->functions)) 869 - ret = CS_BAD_ARGS; 798 + ret = -EINVAL; 870 799 else { 871 800 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); 872 801 ret = pccard_get_status(s, p_dev, &buf->status); ··· 897 826 goto free_out; 898 827 } 899 828 900 - ret = CS_BAD_ARGS; 829 + ret = -EINVAL; 901 830 902 831 if (!(buf->conf_reg.Function && 903 832 (buf->conf_reg.Function >= s->functions))) { ··· 938 867 &buf->win_info.map); 939 868 break; 940 869 case DS_REPLACE_CIS: 941 - ret = pcmcia_replace_cis(s, &buf->cisdump); 870 + ret = pcmcia_replace_cis(s, buf->cisdump.Data, buf->cisdump.Length); 942 871 break; 943 872 case DS_BIND_REQUEST: 944 873 if (!capable(CAP_SYS_ADMIN)) { ··· 960 889 err = -EINVAL; 961 890 } 962 891 963 - if ((err == 0) && (ret != CS_SUCCESS)) { 892 + if ((err == 0) && (ret != 0)) { 964 893 ds_dbg(2, "ds_ioctl: ret = %d\n", ret); 965 894 switch (ret) { 966 - case CS_BAD_SOCKET: case CS_NO_CARD: 967 - err = -ENODEV; break; 968 - case CS_BAD_ARGS: case CS_BAD_ATTRIBUTE: case CS_BAD_IRQ: 969 - case CS_BAD_TUPLE: 970 - err = -EINVAL; break; 971 - case CS_IN_USE: 972 - err = -EBUSY; break; 973 - case CS_OUT_OF_RESOURCE: 895 + case -ENODEV: 896 + case -EINVAL: 897 + case -EBUSY: 898 + case -ENOSYS: 899 + err = ret; 900 + break; 901 + case -ENOMEM: 974 902 err = -ENOSPC; break; 975 - case CS_NO_MORE_ITEMS: 903 + case -ENOSPC: 976 904 err = -ENODATA; break; 977 - case CS_UNSUPPORTED_FUNCTION: 978 - err = -ENOSYS; break; 979 905 default: 980 906 err = -EIO; break; 981 907 }
+214 -167
drivers/pcmcia/pcmcia_resource.c
··· 29 29 #include <pcmcia/ds.h> 30 30 31 31 #include "cs_internal.h" 32 - #include "ds_internal.h" 33 32 34 33 35 34 /* Access speed for IO windows */ ··· 43 44 #endif 44 45 45 46 46 - #ifdef DEBUG 47 + #ifdef CONFIG_PCMCIA_DEBUG 47 48 extern int ds_pc_debug; 48 49 49 50 #define ds_dbg(skt, lvl, fmt, arg...) do { \ 50 51 if (ds_pc_debug >= lvl) \ 51 - printk(KERN_DEBUG "pcmcia_resource: %s: " fmt, \ 52 - cs_socket_name(skt) , ## arg); \ 52 + dev_printk(KERN_DEBUG, &skt->dev, \ 53 + "pcmcia_resource: " fmt, \ 54 + ## arg); \ 53 55 } while (0) 54 56 #else 55 - #define ds_dbg(lvl, fmt, arg...) do { } while (0) 57 + #define ds_dbg(skt, lvl, fmt, arg...) do { } while (0) 56 58 #endif 57 59 58 60 ··· 168 168 u_char val; 169 169 170 170 if (!p_dev || !p_dev->function_config) 171 - return CS_NO_CARD; 171 + return -EINVAL; 172 172 173 173 s = p_dev->socket; 174 174 c = p_dev->function_config; 175 175 176 176 if (!(c->state & CONFIG_LOCKED)) 177 - return CS_CONFIGURATION_LOCKED; 177 + return -EACCES; 178 178 179 179 addr = (c->ConfigBase + reg->Offset) >> 1; 180 180 ··· 188 188 pcmcia_write_cis_mem(s, 1, addr, 1, &val); 189 189 break; 190 190 default: 191 - return CS_BAD_ARGS; 191 + return -EINVAL; 192 192 break; 193 193 } 194 - return CS_SUCCESS; 194 + return 0; 195 195 } /* pcmcia_access_configuration_register */ 196 196 EXPORT_SYMBOL(pcmcia_access_configuration_register); 197 - 198 - 199 - int pccard_get_configuration_info(struct pcmcia_socket *s, 200 - struct pcmcia_device *p_dev, 201 - config_info_t *config) 202 - { 203 - config_t *c; 204 - 205 - if (!(s->state & SOCKET_PRESENT)) 206 - return CS_NO_CARD; 207 - 208 - 209 - #ifdef CONFIG_CARDBUS 210 - if (s->state & SOCKET_CARDBUS) { 211 - memset(config, 0, sizeof(config_info_t)); 212 - config->Vcc = s->socket.Vcc; 213 - config->Vpp1 = config->Vpp2 = s->socket.Vpp; 214 - config->Option = s->cb_dev->subordinate->number; 215 - if (s->state & SOCKET_CARDBUS_CONFIG) { 216 - config->Attributes = CONF_VALID_CLIENT; 217 - config->IntType = INT_CARDBUS; 218 - config->AssignedIRQ = s->irq.AssignedIRQ; 219 - if (config->AssignedIRQ) 220 - config->Attributes |= CONF_ENABLE_IRQ; 221 - if (s->io[0].res) { 222 - config->BasePort1 = s->io[0].res->start; 223 - config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1; 224 - } 225 - } 226 - return CS_SUCCESS; 227 - } 228 - #endif 229 - 230 - if (p_dev) { 231 - c = p_dev->function_config; 232 - config->Function = p_dev->func; 233 - } else { 234 - c = NULL; 235 - config->Function = 0; 236 - } 237 - 238 - if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { 239 - config->Attributes = 0; 240 - config->Vcc = s->socket.Vcc; 241 - config->Vpp1 = config->Vpp2 = s->socket.Vpp; 242 - return CS_SUCCESS; 243 - } 244 - 245 - config->Attributes = c->Attributes | CONF_VALID_CLIENT; 246 - config->Vcc = s->socket.Vcc; 247 - config->Vpp1 = config->Vpp2 = s->socket.Vpp; 248 - config->IntType = c->IntType; 249 - config->ConfigBase = c->ConfigBase; 250 - config->Status = c->Status; 251 - config->Pin = c->Pin; 252 - config->Copy = c->Copy; 253 - config->Option = c->Option; 254 - config->ExtStatus = c->ExtStatus; 255 - config->Present = config->CardValues = c->CardValues; 256 - config->IRQAttributes = c->irq.Attributes; 257 - config->AssignedIRQ = s->irq.AssignedIRQ; 258 - config->BasePort1 = c->io.BasePort1; 259 - config->NumPorts1 = c->io.NumPorts1; 260 - config->Attributes1 = c->io.Attributes1; 261 - config->BasePort2 = c->io.BasePort2; 262 - config->NumPorts2 = c->io.NumPorts2; 263 - config->Attributes2 = c->io.Attributes2; 264 - config->IOAddrLines = c->io.IOAddrLines; 265 - 266 - return CS_SUCCESS; 267 - } /* pccard_get_configuration_info */ 268 - 269 - int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, 270 - config_info_t *config) 271 - { 272 - return pccard_get_configuration_info(p_dev->socket, p_dev, 273 - config); 274 - } 275 - EXPORT_SYMBOL(pcmcia_get_configuration_info); 276 197 277 198 278 199 /** pcmcia_get_window ··· 205 284 int w; 206 285 207 286 if (!s || !(s->state & SOCKET_PRESENT)) 208 - return CS_NO_CARD; 287 + return -ENODEV; 209 288 for (w = idx; w < MAX_WIN; w++) 210 289 if (s->state & SOCKET_WIN_REQ(w)) 211 290 break; 212 291 if (w == MAX_WIN) 213 - return CS_NO_MORE_ITEMS; 292 + return -EINVAL; 214 293 win = &s->win[w]; 215 294 req->Base = win->ctl.res->start; 216 295 req->Size = win->ctl.res->end - win->ctl.res->start + 1; ··· 225 304 if (win->ctl.flags & MAP_USE_WAIT) 226 305 req->Attributes |= WIN_USE_WAIT; 227 306 *handle = win; 228 - return CS_SUCCESS; 307 + return 0; 229 308 } /* pcmcia_get_window */ 230 309 EXPORT_SYMBOL(pcmcia_get_window); 231 310 ··· 237 316 int pcmcia_get_mem_page(window_handle_t win, memreq_t *req) 238 317 { 239 318 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 240 - return CS_BAD_HANDLE; 319 + return -EINVAL; 241 320 req->Page = 0; 242 321 req->CardOffset = win->ctl.card_start; 243 - return CS_SUCCESS; 322 + return 0; 244 323 } /* pcmcia_get_mem_page */ 245 324 EXPORT_SYMBOL(pcmcia_get_mem_page); 246 325 ··· 249 328 { 250 329 struct pcmcia_socket *s; 251 330 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 252 - return CS_BAD_HANDLE; 253 - if (req->Page != 0) 254 - return CS_BAD_PAGE; 331 + return -EINVAL; 255 332 s = win->sock; 333 + if (req->Page != 0) { 334 + ds_dbg(s, 0, "failure: requested page is zero\n"); 335 + return -EINVAL; 336 + } 256 337 win->ctl.card_start = req->CardOffset; 257 - if (s->ops->set_mem_map(s, &win->ctl) != 0) 258 - return CS_BAD_OFFSET; 259 - return CS_SUCCESS; 338 + if (s->ops->set_mem_map(s, &win->ctl) != 0) { 339 + ds_dbg(s, 0, "failed to set_mem_map\n"); 340 + return -EIO; 341 + } 342 + return 0; 260 343 } /* pcmcia_map_mem_page */ 261 344 EXPORT_SYMBOL(pcmcia_map_mem_page); 262 345 ··· 279 354 c = p_dev->function_config; 280 355 281 356 if (!(s->state & SOCKET_PRESENT)) 282 - return CS_NO_CARD; 357 + return -ENODEV; 283 358 if (!(c->state & CONFIG_LOCKED)) 284 - return CS_CONFIGURATION_LOCKED; 359 + return -EACCES; 285 360 286 361 if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { 287 362 if (mod->Attributes & CONF_ENABLE_IRQ) { ··· 294 369 s->ops->set_socket(s, &s->socket); 295 370 } 296 371 297 - if (mod->Attributes & CONF_VCC_CHANGE_VALID) 298 - return CS_BAD_VCC; 372 + if (mod->Attributes & CONF_VCC_CHANGE_VALID) { 373 + ds_dbg(s, 0, "changing Vcc is not allowed at this time\n"); 374 + return -EINVAL; 375 + } 299 376 300 377 /* We only allow changing Vpp1 and Vpp2 to the same value */ 301 378 if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && 302 379 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { 303 380 if (mod->Vpp1 != mod->Vpp2) 304 - return CS_BAD_VPP; 381 + ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n"); 382 + return -EINVAL; 305 383 s->socket.Vpp = mod->Vpp1; 306 - if (s->ops->set_socket(s, &s->socket)) 307 - return CS_BAD_VPP; 384 + if (s->ops->set_socket(s, &s->socket)) { 385 + dev_printk(KERN_WARNING, &s->dev, 386 + "Unable to set VPP\n"); 387 + return -EIO; 388 + } 308 389 } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || 309 - (mod->Attributes & CONF_VPP2_CHANGE_VALID)) 310 - return CS_BAD_VPP; 390 + (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { 391 + ds_dbg(s, 0, "changing Vcc is not allowed at this time\n"); 392 + return -EINVAL; 393 + } 311 394 312 395 if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { 313 396 pccard_io_map io_off = { 0, 0, 0, 0, 1 }; ··· 339 406 } 340 407 } 341 408 342 - return CS_SUCCESS; 409 + return 0; 343 410 } /* modify_configuration */ 344 411 EXPORT_SYMBOL(pcmcia_modify_configuration); 345 412 ··· 374 441 } 375 442 } 376 443 377 - return CS_SUCCESS; 444 + return 0; 378 445 } /* pcmcia_release_configuration */ 379 446 380 447 ··· 392 459 config_t *c = p_dev->function_config; 393 460 394 461 if (!p_dev->_io ) 395 - return CS_BAD_HANDLE; 462 + return -EINVAL; 396 463 397 464 p_dev->_io = 0; 398 465 ··· 400 467 (c->io.NumPorts1 != req->NumPorts1) || 401 468 (c->io.BasePort2 != req->BasePort2) || 402 469 (c->io.NumPorts2 != req->NumPorts2)) 403 - return CS_BAD_ARGS; 470 + return -EINVAL; 404 471 405 472 c->state &= ~CONFIG_IO_REQ; 406 473 ··· 408 475 if (req->NumPorts2) 409 476 release_io_space(s, req->BasePort2, req->NumPorts2); 410 477 411 - return CS_SUCCESS; 478 + return 0; 412 479 } /* pcmcia_release_io */ 413 480 414 481 ··· 418 485 config_t *c= p_dev->function_config; 419 486 420 487 if (!p_dev->_irq) 421 - return CS_BAD_HANDLE; 488 + return -EINVAL; 422 489 p_dev->_irq = 0; 423 490 424 491 if (c->state & CONFIG_LOCKED) 425 - return CS_CONFIGURATION_LOCKED; 426 - if (c->irq.Attributes != req->Attributes) 427 - return CS_BAD_ATTRIBUTE; 428 - if (s->irq.AssignedIRQ != req->AssignedIRQ) 429 - return CS_BAD_IRQ; 492 + return -EACCES; 493 + if (c->irq.Attributes != req->Attributes) { 494 + ds_dbg(s, 0, "IRQ attributes must match assigned ones\n"); 495 + return -EINVAL; 496 + } 497 + if (s->irq.AssignedIRQ != req->AssignedIRQ) { 498 + ds_dbg(s, 0, "IRQ must match assigned one\n"); 499 + return -EINVAL; 500 + } 430 501 if (--s->irq.Config == 0) { 431 502 c->state &= ~CONFIG_IRQ_REQ; 432 503 s->irq.AssignedIRQ = 0; ··· 444 507 pcmcia_used_irq[req->AssignedIRQ]--; 445 508 #endif 446 509 447 - return CS_SUCCESS; 510 + return 0; 448 511 } /* pcmcia_release_irq */ 449 512 450 513 ··· 453 516 struct pcmcia_socket *s; 454 517 455 518 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 456 - return CS_BAD_HANDLE; 519 + return -EINVAL; 457 520 s = win->sock; 458 521 if (!(win->handle->_win & CLIENT_WIN_REQ(win->index))) 459 - return CS_BAD_HANDLE; 522 + return -EINVAL; 460 523 461 524 /* Shut down memory window */ 462 525 win->ctl.flags &= ~MAP_ACTIVE; ··· 473 536 474 537 win->magic = 0; 475 538 476 - return CS_SUCCESS; 539 + return 0; 477 540 } /* pcmcia_release_window */ 478 541 EXPORT_SYMBOL(pcmcia_release_window); 479 542 ··· 488 551 pccard_io_map iomap; 489 552 490 553 if (!(s->state & SOCKET_PRESENT)) 491 - return CS_NO_CARD; 554 + return -ENODEV;; 492 555 493 - if (req->IntType & INT_CARDBUS) 494 - return CS_UNSUPPORTED_MODE; 556 + if (req->IntType & INT_CARDBUS) { 557 + ds_dbg(p_dev->socket, 0, "IntType may not be INT_CARDBUS\n"); 558 + return -EINVAL; 559 + } 495 560 c = p_dev->function_config; 496 561 if (c->state & CONFIG_LOCKED) 497 - return CS_CONFIGURATION_LOCKED; 562 + return -EACCES; 498 563 499 564 /* Do power control. We don't allow changes in Vcc. */ 500 565 s->socket.Vpp = req->Vpp; 501 - if (s->ops->set_socket(s, &s->socket)) 502 - return CS_BAD_VPP; 566 + if (s->ops->set_socket(s, &s->socket)) { 567 + dev_printk(KERN_WARNING, &s->dev, 568 + "Unable to set socket state\n"); 569 + return -EINVAL; 570 + } 503 571 504 572 /* Pick memory or I/O card, DMA mode, interrupt */ 505 573 c->IntType = req->IntType; ··· 593 651 594 652 c->state |= CONFIG_LOCKED; 595 653 p_dev->_locked = 1; 596 - return CS_SUCCESS; 654 + return 0; 597 655 } /* pcmcia_request_configuration */ 598 656 EXPORT_SYMBOL(pcmcia_request_configuration); 599 657 ··· 609 667 config_t *c; 610 668 611 669 if (!(s->state & SOCKET_PRESENT)) 612 - return CS_NO_CARD; 670 + return -ENODEV; 613 671 614 672 if (!req) 615 - return CS_UNSUPPORTED_MODE; 673 + return -EINVAL; 616 674 c = p_dev->function_config; 617 675 if (c->state & CONFIG_LOCKED) 618 - return CS_CONFIGURATION_LOCKED; 619 - if (c->state & CONFIG_IO_REQ) 620 - return CS_IN_USE; 621 - if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) 622 - return CS_BAD_ATTRIBUTE; 676 + return -EACCES; 677 + if (c->state & CONFIG_IO_REQ) { 678 + ds_dbg(s, 0, "IO already configured\n"); 679 + return -EBUSY; 680 + } 681 + if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) { 682 + ds_dbg(s, 0, "bad attribute setting for IO region 1\n"); 683 + return -EINVAL; 684 + } 623 685 if ((req->NumPorts2 > 0) && 624 - (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) 625 - return CS_BAD_ATTRIBUTE; 686 + (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) { 687 + ds_dbg(s, 0, "bad attribute setting for IO region 2\n"); 688 + return -EINVAL; 689 + } 626 690 691 + ds_dbg(s, 1, "trying to allocate resource 1\n"); 627 692 if (alloc_io_space(s, req->Attributes1, &req->BasePort1, 628 - req->NumPorts1, req->IOAddrLines)) 629 - return CS_IN_USE; 693 + req->NumPorts1, req->IOAddrLines)) { 694 + ds_dbg(s, 0, "allocation of resource 1 failed\n"); 695 + return -EBUSY; 696 + } 630 697 631 698 if (req->NumPorts2) { 699 + ds_dbg(s, 1, "trying to allocate resource 2\n"); 632 700 if (alloc_io_space(s, req->Attributes2, &req->BasePort2, 633 701 req->NumPorts2, req->IOAddrLines)) { 702 + ds_dbg(s, 0, "allocation of resource 2 failed\n"); 634 703 release_io_space(s, req->BasePort1, req->NumPorts1); 635 - return CS_IN_USE; 704 + return -EBUSY; 636 705 } 637 706 } 638 707 639 708 c->io = *req; 640 709 c->state |= CONFIG_IO_REQ; 641 710 p_dev->_io = 1; 642 - return CS_SUCCESS; 711 + return 0; 643 712 } /* pcmcia_request_io */ 644 713 EXPORT_SYMBOL(pcmcia_request_io); 645 714 ··· 676 723 { 677 724 struct pcmcia_socket *s = p_dev->socket; 678 725 config_t *c; 679 - int ret = CS_IN_USE, irq = 0; 726 + int ret = -EINVAL, irq = 0; 680 727 int type; 681 728 682 729 if (!(s->state & SOCKET_PRESENT)) 683 - return CS_NO_CARD; 730 + return -ENODEV; 684 731 c = p_dev->function_config; 685 732 if (c->state & CONFIG_LOCKED) 686 - return CS_CONFIGURATION_LOCKED; 687 - if (c->state & CONFIG_IRQ_REQ) 688 - return CS_IN_USE; 733 + return -EACCES; 734 + if (c->state & CONFIG_IRQ_REQ) { 735 + ds_dbg(s, 0, "IRQ already configured\n"); 736 + return -EBUSY; 737 + } 689 738 690 739 /* Decide what type of interrupt we are registering */ 691 740 type = 0; ··· 750 795 } 751 796 752 797 if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) { 753 - if (request_irq(irq, req->Handler, type, p_dev->devname, req->Instance)) 754 - return CS_IN_USE; 798 + ret = request_irq(irq, req->Handler, type, 799 + p_dev->devname, req->Instance); 800 + if (ret) 801 + return ret; 755 802 } 756 803 757 804 /* Make sure the fact the request type was overridden is passed back */ 758 805 if (type == IRQF_SHARED && !(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) { 759 806 req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING; 760 - printk(KERN_WARNING "pcmcia: request for exclusive IRQ could not be fulfilled.\n"); 761 - printk(KERN_WARNING "pcmcia: the driver needs updating to supported shared IRQ lines.\n"); 807 + dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: " 808 + "request for exclusive IRQ could not be fulfilled.\n"); 809 + dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: the driver " 810 + "needs updating to supported shared IRQ lines.\n"); 762 811 } 763 812 c->irq.Attributes = req->Attributes; 764 813 s->irq.AssignedIRQ = req->AssignedIRQ = irq; ··· 775 816 pcmcia_used_irq[irq]++; 776 817 #endif 777 818 778 - return CS_SUCCESS; 819 + return 0; 779 820 } /* pcmcia_request_irq */ 780 821 EXPORT_SYMBOL(pcmcia_request_irq); 781 822 ··· 793 834 int w; 794 835 795 836 if (!(s->state & SOCKET_PRESENT)) 796 - return CS_NO_CARD; 797 - if (req->Attributes & (WIN_PAGED | WIN_SHARED)) 798 - return CS_BAD_ATTRIBUTE; 837 + return -ENODEV; 838 + if (req->Attributes & (WIN_PAGED | WIN_SHARED)) { 839 + ds_dbg(s, 0, "bad attribute setting for iomem region\n"); 840 + return -EINVAL; 841 + } 799 842 800 843 /* Window size defaults to smallest available */ 801 844 if (req->Size == 0) ··· 805 844 align = (((s->features & SS_CAP_MEM_ALIGN) || 806 845 (req->Attributes & WIN_STRICT_ALIGN)) ? 807 846 req->Size : s->map_size); 808 - if (req->Size & (s->map_size-1)) 809 - return CS_BAD_SIZE; 847 + if (req->Size & (s->map_size-1)) { 848 + ds_dbg(s, 0, "invalid map size\n"); 849 + return -EINVAL; 850 + } 810 851 if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || 811 - (req->Base & (align-1))) 812 - return CS_BAD_BASE; 852 + (req->Base & (align-1))) { 853 + ds_dbg(s, 0, "invalid base address\n"); 854 + return -EINVAL; 855 + } 813 856 if (req->Base) 814 857 align = 0; 815 858 816 859 /* Allocate system memory window */ 817 860 for (w = 0; w < MAX_WIN; w++) 818 861 if (!(s->state & SOCKET_WIN_REQ(w))) break; 819 - if (w == MAX_WIN) 820 - return CS_OUT_OF_RESOURCE; 862 + if (w == MAX_WIN) { 863 + ds_dbg(s, 0, "all windows are used already\n"); 864 + return -EINVAL; 865 + } 821 866 822 867 win = &s->win[w]; 823 868 win->magic = WINDOW_MAGIC; ··· 834 867 if (!(s->features & SS_CAP_STATIC_MAP)) { 835 868 win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, 836 869 (req->Attributes & WIN_MAP_BELOW_1MB), s); 837 - if (!win->ctl.res) 838 - return CS_IN_USE; 870 + if (!win->ctl.res) { 871 + ds_dbg(s, 0, "allocating mem region failed\n"); 872 + return -EINVAL; 873 + } 839 874 } 840 875 (*p_dev)->_win |= CLIENT_WIN_REQ(w); 841 876 ··· 854 885 if (req->Attributes & WIN_USE_WAIT) 855 886 win->ctl.flags |= MAP_USE_WAIT; 856 887 win->ctl.card_start = 0; 857 - if (s->ops->set_mem_map(s, &win->ctl) != 0) 858 - return CS_BAD_ARGS; 888 + if (s->ops->set_mem_map(s, &win->ctl) != 0) { 889 + ds_dbg(s, 0, "failed to set memory mapping\n"); 890 + return -EIO; 891 + } 859 892 s->state |= SOCKET_WIN_REQ(w); 860 893 861 894 /* Return window handle */ ··· 868 897 } 869 898 *wh = win; 870 899 871 - return CS_SUCCESS; 900 + return 0; 872 901 } /* pcmcia_request_window */ 873 902 EXPORT_SYMBOL(pcmcia_request_window); 874 903 ··· 880 909 pcmcia_release_window(p_dev->win); 881 910 } 882 911 EXPORT_SYMBOL(pcmcia_disable_device); 912 + 913 + 914 + struct pcmcia_cfg_mem { 915 + tuple_t tuple; 916 + cisparse_t parse; 917 + u8 buf[256]; 918 + cistpl_cftable_entry_t dflt; 919 + }; 920 + 921 + /** 922 + * pcmcia_loop_config() - loop over configuration options 923 + * @p_dev: the struct pcmcia_device which we need to loop for. 924 + * @conf_check: function to call for each configuration option. 925 + * It gets passed the struct pcmcia_device, the CIS data 926 + * describing the configuration option, and private data 927 + * being passed to pcmcia_loop_config() 928 + * @priv_data: private data to be passed to the conf_check function. 929 + * 930 + * pcmcia_loop_config() loops over all configuration options, and calls 931 + * the driver-specific conf_check() for each one, checking whether 932 + * it is a valid one. 933 + */ 934 + int pcmcia_loop_config(struct pcmcia_device *p_dev, 935 + int (*conf_check) (struct pcmcia_device *p_dev, 936 + cistpl_cftable_entry_t *cfg, 937 + cistpl_cftable_entry_t *dflt, 938 + unsigned int vcc, 939 + void *priv_data), 940 + void *priv_data) 941 + { 942 + struct pcmcia_cfg_mem *cfg_mem; 943 + 944 + tuple_t *tuple; 945 + int ret = -ENODEV; 946 + unsigned int vcc; 947 + 948 + cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL); 949 + if (cfg_mem == NULL) 950 + return -ENOMEM; 951 + 952 + /* get the current Vcc setting */ 953 + vcc = p_dev->socket->socket.Vcc; 954 + 955 + tuple = &cfg_mem->tuple; 956 + tuple->TupleData = cfg_mem->buf; 957 + tuple->TupleDataMax = 255; 958 + tuple->TupleOffset = 0; 959 + tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 960 + tuple->Attributes = 0; 961 + 962 + ret = pcmcia_get_first_tuple(p_dev, tuple); 963 + while (!ret) { 964 + cistpl_cftable_entry_t *cfg = &cfg_mem->parse.cftable_entry; 965 + 966 + if (pcmcia_get_tuple_data(p_dev, tuple)) 967 + goto next_entry; 968 + 969 + if (pcmcia_parse_tuple(tuple, &cfg_mem->parse)) 970 + goto next_entry; 971 + 972 + /* default values */ 973 + p_dev->conf.ConfigIndex = cfg->index; 974 + if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 975 + cfg_mem->dflt = *cfg; 976 + 977 + ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data); 978 + if (!ret) 979 + break; 980 + 981 + next_entry: 982 + ret = pcmcia_get_next_tuple(p_dev, tuple); 983 + } 984 + 985 + return ret; 986 + } 987 + EXPORT_SYMBOL(pcmcia_loop_config);
-1
drivers/pcmcia/pxa2xx_base.c
··· 36 36 #include <pcmcia/ss.h> 37 37 #include <pcmcia/cistpl.h> 38 38 39 - #include "cs_internal.h" 40 39 #include "soc_common.h" 41 40 #include "pxa2xx_base.h" 42 41
+38 -29
drivers/pcmcia/rsrc_nonstatic.c
··· 122 122 123 123 static int add_interval(struct resource_map *map, u_long base, u_long num) 124 124 { 125 - struct resource_map *p, *q; 125 + struct resource_map *p, *q; 126 126 127 - for (p = map; ; p = p->next) { 128 - if ((p != map) && (p->base+p->num-1 >= base)) 129 - return -1; 130 - if ((p->next == map) || (p->next->base > base+num-1)) 131 - break; 132 - } 133 - q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 134 - if (!q) return CS_OUT_OF_RESOURCE; 135 - q->base = base; q->num = num; 136 - q->next = p->next; p->next = q; 137 - return CS_SUCCESS; 127 + for (p = map; ; p = p->next) { 128 + if ((p != map) && (p->base+p->num-1 >= base)) 129 + return -1; 130 + if ((p->next == map) || (p->next->base > base+num-1)) 131 + break; 132 + } 133 + q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 134 + if (!q) { 135 + printk(KERN_WARNING "out of memory to update resources\n"); 136 + return -ENOMEM; 137 + } 138 + q->base = base; q->num = num; 139 + q->next = p->next; p->next = q; 140 + return 0; 138 141 } 139 142 140 143 /*====================================================================*/ ··· 169 166 } else { 170 167 /* Split the block into two pieces */ 171 168 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 172 - if (!p) return CS_OUT_OF_RESOURCE; 169 + if (!p) { 170 + printk(KERN_WARNING "out of memory to update resources\n"); 171 + return -ENOMEM; 172 + } 173 173 p->base = base+num; 174 174 p->num = q->base+q->num - p->base; 175 175 q->num = base - q->base; ··· 180 174 } 181 175 } 182 176 } 183 - return CS_SUCCESS; 177 + return 0; 184 178 } 185 179 186 180 /*====================================================================== ··· 200 194 int any; 201 195 u_char *b, hole, most; 202 196 203 - printk(KERN_INFO "cs: IO port probe %#x-%#x:", 204 - base, base+num-1); 197 + dev_printk(KERN_INFO, &s->dev, "cs: IO port probe %#x-%#x:", 198 + base, base+num-1); 205 199 206 200 /* First, what does a floating port look like? */ 207 201 b = kzalloc(256, GFP_KERNEL); 208 202 if (!b) { 209 - printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes"); 203 + dev_printk(KERN_ERR, &s->dev, 204 + "do_io_probe: unable to kmalloc 256 bytes"); 210 205 return; 211 206 } 212 207 for (i = base, most = 0; i < base+num; i += 8) { ··· 373 366 struct socket_data *s_data = s->resource_data; 374 367 u_long i, j, bad, fail, step; 375 368 376 - printk(KERN_INFO "cs: memory probe 0x%06lx-0x%06lx:", 377 - base, base+num-1); 369 + dev_printk(KERN_INFO, &s->dev, "cs: memory probe 0x%06lx-0x%06lx:", 370 + base, base+num-1); 378 371 bad = fail = 0; 379 372 step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff); 380 373 /* don't allow too large steps */ ··· 438 431 if (probe_mask & MEM_PROBE_HIGH) { 439 432 if (inv_probe(s_data->mem_db.next, s) > 0) 440 433 return 0; 441 - printk(KERN_NOTICE "cs: warning: no high memory space " 442 - "available!\n"); 434 + dev_printk(KERN_NOTICE, &s->dev, 435 + "cs: warning: no high memory space available!\n"); 443 436 return -ENODEV; 444 437 } 445 438 ··· 801 794 if (res->flags & IORESOURCE_IO) { 802 795 if (res == &ioport_resource) 803 796 continue; 804 - printk(KERN_INFO "pcmcia: parent PCI bridge I/O " 805 - "window: 0x%llx - 0x%llx\n", 806 - (unsigned long long)res->start, 807 - (unsigned long long)res->end); 797 + dev_printk(KERN_INFO, &s->cb_dev->dev, 798 + "pcmcia: parent PCI bridge I/O " 799 + "window: 0x%llx - 0x%llx\n", 800 + (unsigned long long)res->start, 801 + (unsigned long long)res->end); 808 802 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 809 803 done |= IORESOURCE_IO; 810 804 ··· 814 806 if (res->flags & IORESOURCE_MEM) { 815 807 if (res == &iomem_resource) 816 808 continue; 817 - printk(KERN_INFO "pcmcia: parent PCI bridge Memory " 818 - "window: 0x%llx - 0x%llx\n", 819 - (unsigned long long)res->start, 820 - (unsigned long long)res->end); 809 + dev_printk(KERN_INFO, &s->cb_dev->dev, 810 + "pcmcia: parent PCI bridge Memory " 811 + "window: 0x%llx - 0x%llx\n", 812 + (unsigned long long)res->start, 813 + (unsigned long long)res->end); 821 814 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 822 815 done |= IORESOURCE_MEM; 823 816 }
+1 -1
drivers/pcmcia/soc_common.c
··· 54 54 #include <mach/pxa-regs.h> 55 55 #endif 56 56 57 - #ifdef DEBUG 57 + #ifdef CONFIG_PCMCIA_DEBUG 58 58 59 59 static int pc_debug; 60 60 module_param(pc_debug, int, 0644);
+1 -2
drivers/pcmcia/soc_common.h
··· 15 15 #include <pcmcia/cs.h> 16 16 #include <pcmcia/ss.h> 17 17 #include <pcmcia/cistpl.h> 18 - #include "cs_internal.h" 19 18 20 19 21 20 struct device; ··· 136 137 extern int soc_common_drv_pcmcia_remove(struct device *dev); 137 138 138 139 139 - #ifdef DEBUG 140 + #ifdef CONFIG_PCMCIA_DEBUG 140 141 141 142 extern void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func, 142 143 int lvl, const char *fmt, ...);
+2 -11
drivers/pcmcia/socket_sysfs.c
··· 316 316 char *buf, loff_t off, size_t count) 317 317 { 318 318 struct pcmcia_socket *s = to_socket(container_of(kobj, struct device, kobj)); 319 - cisdump_t *cis; 320 319 int error; 321 320 322 321 if (off) 323 322 return -EINVAL; 324 323 325 - if (count >= 0x200) 324 + if (count >= CISTPL_MAX_CIS_SIZE) 326 325 return -EINVAL; 327 326 328 327 if (!(s->state & SOCKET_PRESENT)) 329 328 return -ENODEV; 330 329 331 - cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL); 332 - if (!cis) 333 - return -ENOMEM; 334 - 335 - cis->Length = count + 1; 336 - memcpy(cis->Data, buf, count); 337 - 338 - error = pcmcia_replace_cis(s, cis); 339 - kfree(cis); 330 + error = pcmcia_replace_cis(s, buf, count); 340 331 if (error) 341 332 return -EIO; 342 333
+1 -1
drivers/pcmcia/tcic.c
··· 55 55 #include <pcmcia/ss.h> 56 56 #include "tcic.h" 57 57 58 - #ifdef DEBUG 58 + #ifdef CONFIG_PCMCIA_DEBUG 59 59 static int pc_debug; 60 60 61 61 module_param(pc_debug, int, 0644);
+43 -35
drivers/pcmcia/ti113x.h
··· 339 339 340 340 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); 341 341 devctl = config_readb(socket, TI113X_DEVICE_CONTROL); 342 - printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n", 343 - pci_name(socket->dev), mfunc, devctl); 342 + dev_printk(KERN_INFO, &socket->dev->dev, 343 + "TI: mfunc 0x%08x, devctl 0x%02x\n", mfunc, devctl); 344 344 345 345 /* make sure PCI interrupts are enabled before probing */ 346 346 ti_init(socket); ··· 354 354 * We're here which means PCI interrupts are _not_ delivered. try to 355 355 * find the right setting (all serial or parallel) 356 356 */ 357 - printk(KERN_INFO "Yenta TI: socket %s probing PCI interrupt failed, trying to fix\n", 358 - pci_name(socket->dev)); 357 + dev_printk(KERN_INFO, &socket->dev->dev, 358 + "TI: probing PCI interrupt failed, trying to fix\n"); 359 359 360 360 /* for serial PCI make sure MFUNC3 is set to IRQSER */ 361 361 if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { ··· 379 379 380 380 pci_irq_status = yenta_probe_cb_irq(socket); 381 381 if (pci_irq_status == 1) { 382 - printk(KERN_INFO "Yenta TI: socket %s all-serial interrupts ok\n", 383 - pci_name(socket->dev)); 382 + dev_printk(KERN_INFO, &socket->dev->dev, 383 + "TI: all-serial interrupts ok\n"); 384 384 mfunc_old = mfunc; 385 385 goto out; 386 386 } ··· 395 395 } 396 396 397 397 /* serial PCI interrupts not working fall back to parallel */ 398 - printk(KERN_INFO "Yenta TI: socket %s falling back to parallel PCI interrupts\n", 399 - pci_name(socket->dev)); 398 + dev_printk(KERN_INFO, &socket->dev->dev, 399 + "TI: falling back to parallel PCI interrupts\n"); 400 400 devctl &= ~TI113X_DCR_IMODE_MASK; 401 401 devctl |= TI113X_DCR_IMODE_SERIAL; /* serial ISA could be right */ 402 402 config_writeb(socket, TI113X_DEVICE_CONTROL, devctl); ··· 427 427 pci_irq_status = yenta_probe_cb_irq(socket); 428 428 if (pci_irq_status == 1) { 429 429 mfunc_old = mfunc; 430 - printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts ok\n", 431 - pci_name(socket->dev)); 430 + dev_printk(KERN_INFO, &socket->dev->dev, 431 + "TI: parallel PCI interrupts ok\n"); 432 432 } else { 433 433 /* not working, back to old value */ 434 434 mfunc = mfunc_old; ··· 440 440 out: 441 441 if (pci_irq_status < 1) { 442 442 socket->cb_irq = 0; 443 - printk(KERN_INFO "Yenta TI: socket %s no PCI interrupts. Fish. Please report.\n", 444 - pci_name(socket->dev)); 443 + dev_printk(KERN_INFO, &socket->dev->dev, 444 + "Yenta TI: no PCI interrupts. Fish. " 445 + "Please report.\n"); 445 446 } 446 447 } 447 448 ··· 514 513 515 514 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); 516 515 devctl = config_readb(socket, TI113X_DEVICE_CONTROL); 517 - printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n", 518 - pci_name(socket->dev), mfunc, devctl); 516 + dev_printk(KERN_INFO, &socket->dev->dev, 517 + "TI: mfunc 0x%08x, devctl 0x%02x\n", 518 + mfunc, devctl); 519 519 520 520 /* if IRQs are configured as tied, align irq of func1 with func0 */ 521 521 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); ··· 535 533 * We're here which means PCI interrupts are _not_ delivered. try to 536 534 * find the right setting 537 535 */ 538 - printk(KERN_INFO "Yenta TI: socket %s probing PCI interrupt failed, trying to fix\n", 539 - pci_name(socket->dev)); 540 - 536 + dev_printk(KERN_INFO, &socket->dev->dev, 537 + "TI: probing PCI interrupt failed, trying to fix\n"); 541 538 542 539 /* if all serial: set INTRTIE, probe again */ 543 540 if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { ··· 545 544 if (ti12xx_tie_interrupts(socket, &old_irq)) { 546 545 pci_irq_status = yenta_probe_cb_irq(socket); 547 546 if (pci_irq_status == 1) { 548 - printk(KERN_INFO "Yenta TI: socket %s all-serial interrupts, tied ok\n", 549 - pci_name(socket->dev)); 547 + dev_printk(KERN_INFO, &socket->dev->dev, 548 + "TI: all-serial interrupts, tied ok\n"); 550 549 goto out; 551 550 } 552 551 ··· 583 582 584 583 pci_irq_status = yenta_probe_cb_irq(socket); 585 584 if (pci_irq_status == 1) { 586 - printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts ok\n", 587 - pci_name(socket->dev)); 585 + dev_printk(KERN_INFO, &socket->dev->dev, 586 + "TI: parallel PCI interrupts ok\n"); 588 587 goto out; 589 588 } 590 589 ··· 594 593 if (pci_irq_status == -1) 595 594 goto out; 596 595 } 597 - 596 + 598 597 /* still nothing: set INTRTIE */ 599 598 if (ti12xx_tie_interrupts(socket, &old_irq)) { 600 599 pci_irq_status = yenta_probe_cb_irq(socket); 601 600 if (pci_irq_status == 1) { 602 - printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts, tied ok\n", 603 - pci_name(socket->dev)); 601 + dev_printk(KERN_INFO, &socket->dev->dev, 602 + "TI: parallel PCI interrupts, tied ok\n"); 604 603 goto out; 605 604 } 606 605 ··· 611 610 out: 612 611 if (pci_irq_status < 1) { 613 612 socket->cb_irq = 0; 614 - printk(KERN_INFO "Yenta TI: socket %s no PCI interrupts. Fish. Please report.\n", 615 - pci_name(socket->dev)); 613 + dev_printk(KERN_INFO, &socket->dev->dev, 614 + "TI: no PCI interrupts. Fish. Please report.\n"); 616 615 } 617 616 } 618 617 ··· 816 815 /* make sure that memory burst is active */ 817 816 val_orig = val = config_readl(socket, TI113X_SYSTEM_CONTROL); 818 817 if (disable_clkrun && PCI_FUNC(socket->dev->devfn) == 0) { 819 - printk(KERN_INFO "Yenta: Disabling CLKRUN feature\n"); 818 + dev_printk(KERN_INFO, &socket->dev->dev, 819 + "Disabling CLKRUN feature\n"); 820 820 val |= TI113X_SCR_KEEPCLK; 821 821 } 822 822 if (!(val & TI122X_SCR_MRBURSTUP)) { 823 - printk(KERN_INFO "Yenta: Enabling burst memory read transactions\n"); 823 + dev_printk(KERN_INFO, &socket->dev->dev, 824 + "Enabling burst memory read transactions\n"); 824 825 val |= TI122X_SCR_MRBURSTUP; 825 826 } 826 827 if (val_orig != val) ··· 833 830 * CSC interrupts to PCI rather than INTVAL. 834 831 */ 835 832 val = config_readb(socket, TI1250_DIAGNOSTIC); 836 - printk(KERN_INFO "Yenta: Using %s to route CSC interrupts to PCI\n", 837 - (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL"); 838 - printk(KERN_INFO "Yenta: Routing CardBus interrupts to %s\n", 839 - (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA"); 833 + dev_printk(KERN_INFO, &socket->dev->dev, 834 + "Using %s to route CSC interrupts to PCI\n", 835 + (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL"); 836 + dev_printk(KERN_INFO, &socket->dev->dev, 837 + "Routing CardBus interrupts to %s\n", 838 + (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA"); 840 839 841 840 /* do irqrouting, depending on function */ 842 841 if (PCI_FUNC(socket->dev->devfn) == 0) ··· 863 858 diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ; 864 859 865 860 if (diag != old) { 866 - printk(KERN_INFO "Yenta: adjusting diagnostic: %02x -> %02x\n", 867 - old, diag); 861 + dev_printk(KERN_INFO, &socket->dev->dev, 862 + "adjusting diagnostic: %02x -> %02x\n", 863 + old, diag); 868 864 config_writeb(socket, TI1250_DIAGNOSTIC, diag); 869 865 } 870 866 ··· 930 924 /* default to clear TLTEnable bit, old behaviour */ 931 925 test_c9 &= ~ENE_TEST_C9_TLTENABLE; 932 926 933 - printk(KERN_INFO "yenta EnE: chaning testregister 0xC9, %02x -> %02x\n", old_c9, test_c9); 927 + dev_printk(KERN_INFO, &socket->dev->dev, 928 + "EnE: chaning testregister 0xC9, %02x -> %02x\n", 929 + old_c9, test_c9); 934 930 config_writeb(socket, ENE_TEST_C9, test_c9); 935 931 } 936 932
+47 -39
drivers/pcmcia/yenta_socket.c
··· 38 38 module_param(pwr_irqs_off, bool, 0644); 39 39 MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!"); 40 40 41 - #if 0 42 - #define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args) 43 - #else 44 - #define debug(x,args...) 45 - #endif 41 + #define debug(x, s, args...) dev_dbg(&s->dev->dev, x, ##args) 46 42 47 43 /* Don't ask.. */ 48 44 #define to_cycles(ns) ((ns)/120) ··· 65 69 static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg) 66 70 { 67 71 u32 val = readl(socket->base + reg); 68 - debug("%p %04x %08x\n", socket, reg, val); 72 + debug("%04x %08x\n", socket, reg, val); 69 73 return val; 70 74 } 71 75 72 76 static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val) 73 77 { 74 - debug("%p %04x %08x\n", socket, reg, val); 78 + debug("%04x %08x\n", socket, reg, val); 75 79 writel(val, socket->base + reg); 76 80 readl(socket->base + reg); /* avoid problems with PCI write posting */ 77 81 } ··· 80 84 { 81 85 u8 val; 82 86 pci_read_config_byte(socket->dev, offset, &val); 83 - debug("%p %04x %02x\n", socket, offset, val); 87 + debug("%04x %02x\n", socket, offset, val); 84 88 return val; 85 89 } 86 90 ··· 88 92 { 89 93 u16 val; 90 94 pci_read_config_word(socket->dev, offset, &val); 91 - debug("%p %04x %04x\n", socket, offset, val); 95 + debug("%04x %04x\n", socket, offset, val); 92 96 return val; 93 97 } 94 98 ··· 96 100 { 97 101 u32 val; 98 102 pci_read_config_dword(socket->dev, offset, &val); 99 - debug("%p %04x %08x\n", socket, offset, val); 103 + debug("%04x %08x\n", socket, offset, val); 100 104 return val; 101 105 } 102 106 103 107 static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val) 104 108 { 105 - debug("%p %04x %02x\n", socket, offset, val); 109 + debug("%04x %02x\n", socket, offset, val); 106 110 pci_write_config_byte(socket->dev, offset, val); 107 111 } 108 112 109 113 static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val) 110 114 { 111 - debug("%p %04x %04x\n", socket, offset, val); 115 + debug("%04x %04x\n", socket, offset, val); 112 116 pci_write_config_word(socket->dev, offset, val); 113 117 } 114 118 115 119 static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val) 116 120 { 117 - debug("%p %04x %08x\n", socket, offset, val); 121 + debug("%04x %08x\n", socket, offset, val); 118 122 pci_write_config_dword(socket->dev, offset, val); 119 123 } 120 124 121 125 static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg) 122 126 { 123 127 u8 val = readb(socket->base + 0x800 + reg); 124 - debug("%p %04x %02x\n", socket, reg, val); 128 + debug("%04x %02x\n", socket, reg, val); 125 129 return val; 126 130 } 127 131 ··· 130 134 u16 val; 131 135 val = readb(socket->base + 0x800 + reg); 132 136 val |= readb(socket->base + 0x800 + reg + 1) << 8; 133 - debug("%p %04x %04x\n", socket, reg, val); 137 + debug("%04x %04x\n", socket, reg, val); 134 138 return val; 135 139 } 136 140 137 141 static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val) 138 142 { 139 - debug("%p %04x %02x\n", socket, reg, val); 143 + debug("%04x %02x\n", socket, reg, val); 140 144 writeb(val, socket->base + 0x800 + reg); 141 145 readb(socket->base + 0x800 + reg); /* PCI write posting... */ 142 146 } 143 147 144 148 static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) 145 149 { 146 - debug("%p %04x %04x\n", socket, reg, val); 150 + debug("%04x %04x\n", socket, reg, val); 147 151 writeb(val, socket->base + 0x800 + reg); 148 152 writeb(val >> 8, socket->base + 0x800 + reg + 1); 149 153 ··· 203 207 204 208 205 209 if (state & CB_CBCARD) { 206 - val |= SS_CARDBUS; 210 + val |= SS_CARDBUS; 207 211 val |= (state & CB_CARDSTS) ? SS_STSCHG : 0; 208 212 val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT; 209 213 val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0; ··· 646 650 root = pci_find_parent_resource(socket->dev, res); 647 651 if (root && (request_resource(root, res) == 0)) 648 652 return 0; 649 - printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n", 650 - pci_name(socket->dev), nr); 653 + dev_printk(KERN_INFO, &socket->dev->dev, 654 + "Preassigned resource %d busy or not available, " 655 + "reconfiguring...\n", 656 + nr); 651 657 } 652 658 653 659 if (type & IORESOURCE_IO) { ··· 672 674 return 1; 673 675 } 674 676 675 - printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n", 676 - pci_name(socket->dev), type); 677 + dev_printk(KERN_INFO, &socket->dev->dev, 678 + "no resource of type %x available, trying to continue...\n", 679 + type); 677 680 res->start = res->end = res->flags = 0; 678 681 return 0; 679 682 } ··· 922 923 socket->probe_status = 0; 923 924 924 925 if (request_irq(socket->cb_irq, yenta_probe_handler, IRQF_SHARED, "yenta", socket)) { 925 - printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n"); 926 + dev_printk(KERN_WARNING, &socket->dev->dev, 927 + "request_irq() in yenta_probe_cb_irq() failed!\n"); 926 928 return -1; 927 929 } 928 930 ··· 960 960 else 961 961 socket->socket.irq_mask = 0; 962 962 963 - printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n", 964 - socket->socket.irq_mask, socket->cb_irq); 963 + dev_printk(KERN_INFO, &socket->dev->dev, 964 + "ISA IRQ mask 0x%04x, PCI irq %d\n", 965 + socket->socket.irq_mask, socket->cb_irq); 965 966 } 966 967 967 968 /* ··· 1052 1051 1053 1052 /* Show that the wanted subordinate number is not possible: */ 1054 1053 if (cardbus_bridge->subordinate > upper_limit) 1055 - printk(KERN_WARNING "Yenta: Upper limit for fixing this " 1056 - "bridge's parent bridge: #%02x\n", upper_limit); 1054 + dev_printk(KERN_WARNING, &cardbus_bridge->dev, 1055 + "Upper limit for fixing this " 1056 + "bridge's parent bridge: #%02x\n", upper_limit); 1057 1057 1058 1058 /* If we have room to increase the bridge's subordinate number, */ 1059 1059 if (bridge_to_fix->subordinate < upper_limit) { ··· 1063 1061 unsigned char subordinate_to_assign = 1064 1062 min(cardbus_bridge->subordinate, upper_limit); 1065 1063 1066 - printk(KERN_INFO "Yenta: Raising subordinate bus# of parent " 1067 - "bus (#%02x) from #%02x to #%02x\n", 1068 - bridge_to_fix->number, 1069 - bridge_to_fix->subordinate, subordinate_to_assign); 1064 + dev_printk(KERN_INFO, &bridge_to_fix->dev, 1065 + "Raising subordinate bus# of parent " 1066 + "bus (#%02x) from #%02x to #%02x\n", 1067 + bridge_to_fix->number, 1068 + bridge_to_fix->subordinate, subordinate_to_assign); 1070 1069 1071 1070 /* Save the new subordinate in the bus struct of the bridge */ 1072 1071 bridge_to_fix->subordinate = subordinate_to_assign; ··· 1094 1091 * Bail out if so. 1095 1092 */ 1096 1093 if (!dev->subordinate) { 1097 - printk(KERN_ERR "Yenta: no bus associated with %s! " 1098 - "(try 'pci=assign-busses')\n", pci_name(dev)); 1094 + dev_printk(KERN_ERR, &dev->dev, "no bus associated! " 1095 + "(try 'pci=assign-busses')\n"); 1099 1096 return -ENODEV; 1100 1097 } 1101 1098 ··· 1130 1127 goto disable; 1131 1128 1132 1129 if (!pci_resource_start(dev, 0)) { 1133 - printk(KERN_ERR "No cardbus resource!\n"); 1130 + dev_printk(KERN_ERR, &dev->dev, "No cardbus resource!\n"); 1134 1131 ret = -ENODEV; 1135 1132 goto release; 1136 1133 } ··· 1149 1146 * report the subsystem vendor and device for help debugging 1150 1147 * the irq stuff... 1151 1148 */ 1152 - printk(KERN_INFO "Yenta: CardBus bridge found at %s [%04x:%04x]\n", 1153 - pci_name(dev), dev->subsystem_vendor, dev->subsystem_device); 1149 + dev_printk(KERN_INFO, &dev->dev, "CardBus bridge found [%04x:%04x]\n", 1150 + dev->subsystem_vendor, dev->subsystem_device); 1154 1151 1155 1152 yenta_config_init(socket); 1156 1153 ··· 1182 1179 socket->poll_timer.data = (unsigned long)socket; 1183 1180 socket->poll_timer.expires = jiffies + HZ; 1184 1181 add_timer(&socket->poll_timer); 1185 - printk(KERN_INFO "Yenta: no PCI IRQ, CardBus support disabled for this socket.\n" 1186 - KERN_INFO "Yenta: check your BIOS CardBus, BIOS IRQ or ACPI settings.\n"); 1182 + dev_printk(KERN_INFO, &dev->dev, 1183 + "no PCI IRQ, CardBus support disabled for this " 1184 + "socket.\n"); 1185 + dev_printk(KERN_INFO, &dev->dev, 1186 + "check your BIOS CardBus, BIOS IRQ or ACPI " 1187 + "settings.\n"); 1187 1188 } else { 1188 1189 socket->socket.features |= SS_CAP_CARDBUS; 1189 1190 } ··· 1195 1188 /* Figure out what the dang thing can do for the PCMCIA layer... */ 1196 1189 yenta_interrogate(socket); 1197 1190 yenta_get_socket_capabilities(socket, isa_interrupts); 1198 - printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE)); 1191 + dev_printk(KERN_INFO, &dev->dev, 1192 + "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE)); 1199 1193 1200 1194 yenta_fixup_parent_bridge(dev->subordinate); 1201 1195
+28 -30
drivers/scsi/pcmcia/aha152x_stub.c
··· 140 140 #define CS_CHECK(fn, ret) \ 141 141 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 142 142 143 + static int aha152x_config_check(struct pcmcia_device *p_dev, 144 + cistpl_cftable_entry_t *cfg, 145 + cistpl_cftable_entry_t *dflt, 146 + unsigned int vcc, 147 + void *priv_data) 148 + { 149 + /* For New Media T&J, look for a SCSI window */ 150 + if (cfg->io.win[0].len >= 0x20) 151 + p_dev->io.BasePort1 = cfg->io.win[0].base; 152 + else if ((cfg->io.nwin > 1) && 153 + (cfg->io.win[1].len >= 0x20)) 154 + p_dev->io.BasePort1 = cfg->io.win[1].base; 155 + if ((cfg->io.nwin > 0) && 156 + (p_dev->io.BasePort1 < 0xffff)) { 157 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 158 + return 0; 159 + } 160 + return -EINVAL; 161 + } 162 + 143 163 static int aha152x_config_cs(struct pcmcia_device *link) 144 164 { 145 165 scsi_info_t *info = link->priv; 146 166 struct aha152x_setup s; 147 - tuple_t tuple; 148 - cisparse_t parse; 149 - int i, last_ret, last_fn; 150 - u_char tuple_data[64]; 167 + int last_ret, last_fn; 151 168 struct Scsi_Host *host; 152 - 169 + 153 170 DEBUG(0, "aha152x_config(0x%p)\n", link); 154 171 155 - tuple.TupleData = tuple_data; 156 - tuple.TupleDataMax = 64; 157 - tuple.TupleOffset = 0; 158 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 159 - tuple.Attributes = 0; 160 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 161 - while (1) { 162 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 163 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 164 - goto next_entry; 165 - /* For New Media T&J, look for a SCSI window */ 166 - if (parse.cftable_entry.io.win[0].len >= 0x20) 167 - link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 168 - else if ((parse.cftable_entry.io.nwin > 1) && 169 - (parse.cftable_entry.io.win[1].len >= 0x20)) 170 - link->io.BasePort1 = parse.cftable_entry.io.win[1].base; 171 - if ((parse.cftable_entry.io.nwin > 0) && 172 - (link->io.BasePort1 < 0xffff)) { 173 - link->conf.ConfigIndex = parse.cftable_entry.index; 174 - i = pcmcia_request_io(link, &link->io); 175 - if (i == CS_SUCCESS) break; 176 - } 177 - next_entry: 178 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 172 + last_ret = pcmcia_loop_config(link, aha152x_config_check, NULL); 173 + if (last_ret) { 174 + cs_error(link, RequestIO, last_ret); 175 + goto failed; 179 176 } 180 - 177 + 181 178 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 182 179 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 183 180 ··· 205 208 206 209 cs_failed: 207 210 cs_error(link, last_fn, last_ret); 211 + failed: 208 212 aha152x_release_cs(link); 209 213 return -ENODEV; 210 214 }
+17 -20
drivers/scsi/pcmcia/fdomain_stub.c
··· 123 123 #define CS_CHECK(fn, ret) \ 124 124 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 125 125 126 + static int fdomain_config_check(struct pcmcia_device *p_dev, 127 + cistpl_cftable_entry_t *cfg, 128 + cistpl_cftable_entry_t *dflt, 129 + unsigned int vcc, 130 + void *priv_data) 131 + { 132 + p_dev->io.BasePort1 = cfg->io.win[0].base; 133 + return pcmcia_request_io(p_dev, &p_dev->io); 134 + } 135 + 136 + 126 137 static int fdomain_config(struct pcmcia_device *link) 127 138 { 128 139 scsi_info_t *info = link->priv; 129 - tuple_t tuple; 130 - cisparse_t parse; 131 - int i, last_ret, last_fn; 132 - u_char tuple_data[64]; 140 + int last_ret, last_fn; 133 141 char str[22]; 134 142 struct Scsi_Host *host; 135 143 136 144 DEBUG(0, "fdomain_config(0x%p)\n", link); 137 145 138 - tuple.TupleData = tuple_data; 139 - tuple.TupleDataMax = 64; 140 - tuple.TupleOffset = 0; 141 - 142 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 143 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 144 - while (1) { 145 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 146 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 147 - goto next_entry; 148 - link->conf.ConfigIndex = parse.cftable_entry.index; 149 - link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 150 - i = pcmcia_request_io(link, &link->io); 151 - if (i == CS_SUCCESS) break; 152 - next_entry: 153 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 146 + last_ret = pcmcia_loop_config(link, fdomain_config_check, NULL); 147 + if (last_ret) { 148 + cs_error(link, RequestIO, last_ret); 149 + goto failed; 154 150 } 155 151 156 152 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); ··· 177 181 178 182 cs_failed: 179 183 cs_error(link, last_fn, last_ret); 184 + failed: 180 185 fdomain_release(link); 181 186 return -ENODEV; 182 187 } /* fdomain_config */
+114 -118
drivers/scsi/pcmcia/nsp_cs.c
··· 1606 1606 is received, to configure the PCMCIA socket, and to make the 1607 1607 ethernet device available to the system. 1608 1608 ======================================================================*/ 1609 - #define CS_CHECK(fn, ret) \ 1610 - do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 1611 - /*====================================================================*/ 1609 + 1610 + struct nsp_cs_configdata { 1611 + nsp_hw_data *data; 1612 + win_req_t req; 1613 + }; 1614 + 1615 + static int nsp_cs_config_check(struct pcmcia_device *p_dev, 1616 + cistpl_cftable_entry_t *cfg, 1617 + cistpl_cftable_entry_t *dflt, 1618 + unsigned int vcc, 1619 + void *priv_data) 1620 + { 1621 + struct nsp_cs_configdata *cfg_mem = priv_data; 1622 + 1623 + if (cfg->index == 0) 1624 + return -ENODEV; 1625 + 1626 + /* Does this card need audio output? */ 1627 + if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 1628 + p_dev->conf.Attributes |= CONF_ENABLE_SPKR; 1629 + p_dev->conf.Status = CCSR_AUDIO_ENA; 1630 + } 1631 + 1632 + /* Use power settings for Vcc and Vpp if present */ 1633 + /* Note that the CIS values need to be rescaled */ 1634 + if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 1635 + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) 1636 + return -ENODEV; 1637 + else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { 1638 + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) 1639 + return -ENODEV; 1640 + } 1641 + 1642 + if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1643 + p_dev->conf.Vpp = 1644 + cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 1645 + } else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1646 + p_dev->conf.Vpp = 1647 + dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 1648 + } 1649 + 1650 + /* Do we need to allocate an interrupt? */ 1651 + if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) 1652 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 1653 + 1654 + /* IO window settings */ 1655 + p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 1656 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 1657 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 1658 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 1659 + if (!(io->flags & CISTPL_IO_8BIT)) 1660 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 1661 + if (!(io->flags & CISTPL_IO_16BIT)) 1662 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1663 + p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 1664 + p_dev->io.BasePort1 = io->win[0].base; 1665 + p_dev->io.NumPorts1 = io->win[0].len; 1666 + if (io->nwin > 1) { 1667 + p_dev->io.Attributes2 = p_dev->io.Attributes1; 1668 + p_dev->io.BasePort2 = io->win[1].base; 1669 + p_dev->io.NumPorts2 = io->win[1].len; 1670 + } 1671 + /* This reserves IO space but doesn't actually enable it */ 1672 + if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 1673 + goto next_entry; 1674 + } 1675 + 1676 + if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { 1677 + memreq_t map; 1678 + cistpl_mem_t *mem = 1679 + (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; 1680 + cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 1681 + cfg_mem->req.Attributes |= WIN_ENABLE; 1682 + cfg_mem->req.Base = mem->win[0].host_addr; 1683 + cfg_mem->req.Size = mem->win[0].len; 1684 + if (cfg_mem->req.Size < 0x1000) 1685 + cfg_mem->req.Size = 0x1000; 1686 + cfg_mem->req.AccessSpeed = 0; 1687 + if (pcmcia_request_window(&p_dev, &cfg_mem->req, &p_dev->win) != 0) 1688 + goto next_entry; 1689 + map.Page = 0; map.CardOffset = mem->win[0].card_addr; 1690 + if (pcmcia_map_mem_page(p_dev->win, &map) != 0) 1691 + goto next_entry; 1692 + 1693 + cfg_mem->data->MmioAddress = (unsigned long) ioremap_nocache(cfg_mem->req.Base, cfg_mem->req.Size); 1694 + cfg_mem->data->MmioLength = cfg_mem->req.Size; 1695 + } 1696 + /* If we got this far, we're cool! */ 1697 + return 0; 1698 + } 1699 + 1700 + next_entry: 1701 + nsp_dbg(NSP_DEBUG_INIT, "next"); 1702 + pcmcia_disable_device(p_dev); 1703 + return -ENODEV; 1704 + } 1705 + 1612 1706 static int nsp_cs_config(struct pcmcia_device *link) 1613 1707 { 1614 1708 int ret; 1615 1709 scsi_info_t *info = link->priv; 1616 - tuple_t tuple; 1617 - cisparse_t parse; 1618 - int last_ret, last_fn; 1619 - unsigned char tuple_data[64]; 1620 - config_info_t conf; 1621 - win_req_t req; 1622 - memreq_t map; 1623 - cistpl_cftable_entry_t dflt = { 0 }; 1710 + struct nsp_cs_configdata *cfg_mem; 1624 1711 struct Scsi_Host *host; 1625 1712 nsp_hw_data *data = &nsp_data_base; 1626 1713 1627 1714 nsp_dbg(NSP_DEBUG_INIT, "in"); 1628 1715 1629 - tuple.Attributes = 0; 1630 - tuple.TupleData = tuple_data; 1631 - tuple.TupleDataMax = sizeof(tuple_data); 1632 - tuple.TupleOffset = 0; 1716 + cfg_mem = kzalloc(sizeof(cfg_mem), GFP_KERNEL); 1717 + if (!cfg_mem) 1718 + return -ENOMEM; 1719 + cfg_mem->data = data; 1633 1720 1634 - /* Look up the current Vcc */ 1635 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 1636 - 1637 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 1638 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 1639 - while (1) { 1640 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 1641 - 1642 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 1643 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 1644 - goto next_entry; 1645 - 1646 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { dflt = *cfg; } 1647 - if (cfg->index == 0) { goto next_entry; } 1648 - link->conf.ConfigIndex = cfg->index; 1649 - 1650 - /* Does this card need audio output? */ 1651 - if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 1652 - link->conf.Attributes |= CONF_ENABLE_SPKR; 1653 - link->conf.Status = CCSR_AUDIO_ENA; 1654 - } 1655 - 1656 - /* Use power settings for Vcc and Vpp if present */ 1657 - /* Note that the CIS values need to be rescaled */ 1658 - if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 1659 - if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) { 1660 - goto next_entry; 1661 - } 1662 - } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { 1663 - if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM]/10000) { 1664 - goto next_entry; 1665 - } 1666 - } 1667 - 1668 - if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1669 - link->conf.Vpp = 1670 - cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 1671 - } else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1672 - link->conf.Vpp = 1673 - dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 1674 - } 1675 - 1676 - /* Do we need to allocate an interrupt? */ 1677 - if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) { 1678 - link->conf.Attributes |= CONF_ENABLE_IRQ; 1679 - } 1680 - 1681 - /* IO window settings */ 1682 - link->io.NumPorts1 = link->io.NumPorts2 = 0; 1683 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 1684 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 1685 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 1686 - if (!(io->flags & CISTPL_IO_8BIT)) 1687 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 1688 - if (!(io->flags & CISTPL_IO_16BIT)) 1689 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1690 - link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 1691 - link->io.BasePort1 = io->win[0].base; 1692 - link->io.NumPorts1 = io->win[0].len; 1693 - if (io->nwin > 1) { 1694 - link->io.Attributes2 = link->io.Attributes1; 1695 - link->io.BasePort2 = io->win[1].base; 1696 - link->io.NumPorts2 = io->win[1].len; 1697 - } 1698 - /* This reserves IO space but doesn't actually enable it */ 1699 - if (pcmcia_request_io(link, &link->io) != 0) 1700 - goto next_entry; 1701 - } 1702 - 1703 - if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { 1704 - cistpl_mem_t *mem = 1705 - (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; 1706 - req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 1707 - req.Attributes |= WIN_ENABLE; 1708 - req.Base = mem->win[0].host_addr; 1709 - req.Size = mem->win[0].len; 1710 - if (req.Size < 0x1000) { 1711 - req.Size = 0x1000; 1712 - } 1713 - req.AccessSpeed = 0; 1714 - if (pcmcia_request_window(&link, &req, &link->win) != 0) 1715 - goto next_entry; 1716 - map.Page = 0; map.CardOffset = mem->win[0].card_addr; 1717 - if (pcmcia_map_mem_page(link->win, &map) != 0) 1718 - goto next_entry; 1719 - 1720 - data->MmioAddress = (unsigned long)ioremap_nocache(req.Base, req.Size); 1721 - data->MmioLength = req.Size; 1722 - } 1723 - /* If we got this far, we're cool! */ 1724 - break; 1725 - 1726 - next_entry: 1727 - nsp_dbg(NSP_DEBUG_INIT, "next"); 1728 - pcmcia_disable_device(link); 1729 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 1730 - } 1721 + ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem); 1722 + goto cs_failed; 1731 1723 1732 1724 if (link->conf.Attributes & CONF_ENABLE_IRQ) { 1733 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 1725 + if (pcmcia_request_irq(link, &link->irq)) 1726 + goto cs_failed; 1734 1727 } 1735 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 1728 + 1729 + ret = pcmcia_request_configuration(link, &link->conf); 1730 + if (ret) 1731 + goto cs_failed; 1736 1732 1737 1733 if (free_ports) { 1738 1734 if (link->io.BasePort1) { ··· 1786 1790 printk(" & 0x%04x-0x%04x", link->io.BasePort2, 1787 1791 link->io.BasePort2+link->io.NumPorts2-1); 1788 1792 if (link->win) 1789 - printk(", mem 0x%06lx-0x%06lx", req.Base, 1790 - req.Base+req.Size-1); 1793 + printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base, 1794 + cfg_mem->req.Base+cfg_mem->req.Size-1); 1791 1795 printk("\n"); 1792 1796 1797 + kfree(cfg_mem); 1793 1798 return 0; 1794 1799 1795 1800 cs_failed: 1796 1801 nsp_dbg(NSP_DEBUG_INIT, "config fail"); 1797 - cs_error(link, last_fn, last_ret); 1798 1802 nsp_cs_release(link); 1803 + kfree(cfg_mem); 1799 1804 1800 1805 return -ENODEV; 1801 1806 } /* nsp_cs_config */ 1802 - #undef CS_CHECK 1803 1807 1804 1808 1805 1809 /*======================================================================
+21 -26
drivers/scsi/pcmcia/qlogic_stub.c
··· 195 195 #define CS_CHECK(fn, ret) \ 196 196 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 197 197 198 + static int qlogic_config_check(struct pcmcia_device *p_dev, 199 + cistpl_cftable_entry_t *cfg, 200 + cistpl_cftable_entry_t *dflt, 201 + unsigned int vcc, 202 + void *priv_data) 203 + { 204 + p_dev->io.BasePort1 = cfg->io.win[0].base; 205 + p_dev->io.NumPorts1 = cfg->io.win[0].len; 206 + 207 + if (p_dev->io.BasePort1 == 0) 208 + return -ENODEV; 209 + 210 + return pcmcia_request_io(p_dev, &p_dev->io); 211 + } 212 + 198 213 static int qlogic_config(struct pcmcia_device * link) 199 214 { 200 215 scsi_info_t *info = link->priv; 201 - tuple_t tuple; 202 - cisparse_t parse; 203 - int i, last_ret, last_fn; 204 - unsigned short tuple_data[32]; 216 + int last_ret, last_fn; 205 217 struct Scsi_Host *host; 206 218 207 219 DEBUG(0, "qlogic_config(0x%p)\n", link); 208 220 209 - info->manf_id = link->manf_id; 210 - 211 - tuple.TupleData = (cisdata_t *) tuple_data; 212 - tuple.TupleDataMax = 64; 213 - tuple.TupleOffset = 0; 214 - 215 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 216 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 217 - while (1) { 218 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 219 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 220 - goto next_entry; 221 - link->conf.ConfigIndex = parse.cftable_entry.index; 222 - link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 223 - link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; 224 - if (link->io.BasePort1 != 0) { 225 - i = pcmcia_request_io(link, &link->io); 226 - if (i == CS_SUCCESS) 227 - break; 228 - } 229 - next_entry: 230 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 221 + last_ret = pcmcia_loop_config(link, qlogic_config_check, NULL); 222 + if (last_ret) { 223 + cs_error(link, RequestIO, last_ret); 224 + goto failed; 231 225 } 232 226 233 227 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); ··· 256 262 cs_failed: 257 263 cs_error(link, last_fn, last_ret); 258 264 pcmcia_disable_device(link); 265 + failed: 259 266 return -ENODEV; 260 267 261 268 } /* qlogic_config */
+21 -25
drivers/scsi/pcmcia/sym53c500_cs.c
··· 700 700 #define CS_CHECK(fn, ret) \ 701 701 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 702 702 703 + static int SYM53C500_config_check(struct pcmcia_device *p_dev, 704 + cistpl_cftable_entry_t *cfg, 705 + cistpl_cftable_entry_t *dflt, 706 + unsigned int vcc, 707 + void *priv_data) 708 + { 709 + p_dev->io.BasePort1 = cfg->io.win[0].base; 710 + p_dev->io.NumPorts1 = cfg->io.win[0].len; 711 + 712 + if (p_dev->io.BasePort1 == 0) 713 + return -ENODEV; 714 + 715 + return pcmcia_request_io(p_dev, &p_dev->io); 716 + } 717 + 703 718 static int 704 719 SYM53C500_config(struct pcmcia_device *link) 705 720 { 706 721 struct scsi_info_t *info = link->priv; 707 - tuple_t tuple; 708 - cisparse_t parse; 709 - int i, last_ret, last_fn; 722 + int last_ret, last_fn; 710 723 int irq_level, port_base; 711 - unsigned short tuple_data[32]; 712 724 struct Scsi_Host *host; 713 725 struct scsi_host_template *tpnt = &sym53c500_driver_template; 714 726 struct sym53c500_data *data; ··· 729 717 730 718 info->manf_id = link->manf_id; 731 719 732 - tuple.TupleData = (cisdata_t *)tuple_data; 733 - tuple.TupleDataMax = 64; 734 - tuple.TupleOffset = 0; 735 - 736 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 737 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 738 - while (1) { 739 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 740 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 741 - goto next_entry; 742 - link->conf.ConfigIndex = parse.cftable_entry.index; 743 - link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 744 - link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; 745 - 746 - if (link->io.BasePort1 != 0) { 747 - i = pcmcia_request_io(link, &link->io); 748 - if (i == CS_SUCCESS) 749 - break; 750 - } 751 - next_entry: 752 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 720 + last_ret = pcmcia_loop_config(link, SYM53C500_config_check, NULL); 721 + if (last_ret) { 722 + cs_error(link, RequestIO, last_ret); 723 + goto failed; 753 724 } 754 725 755 726 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); ··· 826 831 827 832 cs_failed: 828 833 cs_error(link, last_fn, last_ret); 834 + failed: 829 835 SYM53C500_release(link); 830 836 return -ENODEV; 831 837 } /* SYM53C500_config */
+131 -175
drivers/serial/serial_cs.c
··· 431 431 { 432 432 int i; 433 433 i = pcmcia_get_first_tuple(handle, tuple); 434 - if (i != CS_SUCCESS) 435 - return CS_NO_MORE_ITEMS; 436 - i = pcmcia_get_tuple_data(handle, tuple); 437 - if (i != CS_SUCCESS) 434 + if (i != 0) 438 435 return i; 439 - return pcmcia_parse_tuple(handle, tuple, parse); 440 - } 441 - 442 - static int 443 - next_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) 444 - { 445 - int i; 446 - i = pcmcia_get_next_tuple(handle, tuple); 447 - if (i != CS_SUCCESS) 448 - return CS_NO_MORE_ITEMS; 449 436 i = pcmcia_get_tuple_data(handle, tuple); 450 - if (i != CS_SUCCESS) 437 + if (i != 0) 451 438 return i; 452 - return pcmcia_parse_tuple(handle, tuple, parse); 439 + return pcmcia_parse_tuple(tuple, parse); 453 440 } 454 441 455 442 /*====================================================================*/ 456 443 457 - static int simple_config(struct pcmcia_device *link) 444 + static int simple_config_check(struct pcmcia_device *p_dev, 445 + cistpl_cftable_entry_t *cf, 446 + cistpl_cftable_entry_t *dflt, 447 + unsigned int vcc, 448 + void *priv_data) 449 + { 450 + static const int size_table[2] = { 8, 16 }; 451 + int *try = priv_data; 452 + 453 + if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 454 + p_dev->conf.Vpp = 455 + cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 456 + 457 + if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[(*try >> 1)]) 458 + && (cf->io.win[0].base != 0)) { 459 + p_dev->io.BasePort1 = cf->io.win[0].base; 460 + p_dev->io.IOAddrLines = ((*try & 0x1) == 0) ? 461 + 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 462 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 463 + return 0; 464 + } 465 + return -EINVAL; 466 + } 467 + 468 + static int simple_config_check_notpicky(struct pcmcia_device *p_dev, 469 + cistpl_cftable_entry_t *cf, 470 + cistpl_cftable_entry_t *dflt, 471 + unsigned int vcc, 472 + void *priv_data) 458 473 { 459 474 static const unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 460 - static const int size_table[2] = { 8, 16 }; 475 + int j; 476 + 477 + if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 478 + for (j = 0; j < 5; j++) { 479 + p_dev->io.BasePort1 = base[j]; 480 + p_dev->io.IOAddrLines = base[j] ? 16 : 3; 481 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 482 + return 0; 483 + } 484 + } 485 + return -ENODEV; 486 + } 487 + 488 + static int simple_config(struct pcmcia_device *link) 489 + { 461 490 struct serial_info *info = link->priv; 462 - struct serial_cfg_mem *cfg_mem; 463 - tuple_t *tuple; 464 - u_char *buf; 465 - cisparse_t *parse; 466 - cistpl_cftable_entry_t *cf; 467 - config_info_t config; 468 - int i, j, try; 469 - int s; 470 - 471 - cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL); 472 - if (!cfg_mem) 473 - return -1; 474 - 475 - tuple = &cfg_mem->tuple; 476 - parse = &cfg_mem->parse; 477 - cf = &parse->cftable_entry; 478 - buf = cfg_mem->buf; 491 + int i = -ENODEV, try; 479 492 480 493 /* If the card is already configured, look up the port and irq */ 481 - i = pcmcia_get_configuration_info(link, &config); 482 - if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) { 494 + if (link->function_config) { 483 495 unsigned int port = 0; 484 - if ((config.BasePort2 != 0) && (config.NumPorts2 == 8)) { 485 - port = config.BasePort2; 496 + if ((link->io.BasePort2 != 0) && 497 + (link->io.NumPorts2 == 8)) { 498 + port = link->io.BasePort2; 486 499 info->slave = 1; 487 500 } else if ((info->manfid == MANFID_OSITECH) && 488 - (config.NumPorts1 == 0x40)) { 489 - port = config.BasePort1 + 0x28; 501 + (link->io.NumPorts1 == 0x40)) { 502 + port = link->io.BasePort1 + 0x28; 490 503 info->slave = 1; 491 504 } 492 505 if (info->slave) { 493 - kfree(cfg_mem); 494 - return setup_serial(link, info, port, config.AssignedIRQ); 506 + return setup_serial(link, info, port, 507 + link->irq.AssignedIRQ); 495 508 } 496 509 } 497 510 498 - /* First pass: look for a config entry that looks normal. */ 499 - tuple->TupleData = (cisdata_t *) buf; 500 - tuple->TupleOffset = 0; 501 - tuple->TupleDataMax = 255; 502 - tuple->Attributes = 0; 503 - tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 504 - /* Two tries: without IO aliases, then with aliases */ 505 - for (s = 0; s < 2; s++) { 506 - for (try = 0; try < 2; try++) { 507 - i = first_tuple(link, tuple, parse); 508 - while (i != CS_NO_MORE_ITEMS) { 509 - if (i != CS_SUCCESS) 510 - goto next_entry; 511 - if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 512 - link->conf.Vpp = 513 - cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 514 - if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[s]) && 515 - (cf->io.win[0].base != 0)) { 516 - link->conf.ConfigIndex = cf->index; 517 - link->io.BasePort1 = cf->io.win[0].base; 518 - link->io.IOAddrLines = (try == 0) ? 519 - 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 520 - i = pcmcia_request_io(link, &link->io); 521 - if (i == CS_SUCCESS) 522 - goto found_port; 523 - } 524 - next_entry: 525 - i = next_tuple(link, tuple, parse); 526 - } 527 - } 528 - } 511 + /* First pass: look for a config entry that looks normal. 512 + * Two tries: without IO aliases, then with aliases */ 513 + for (try = 0; try < 4; try++) 514 + if (!pcmcia_loop_config(link, simple_config_check, &try)) 515 + goto found_port; 516 + 529 517 /* Second pass: try to find an entry that isn't picky about 530 518 its base address, then try to grab any standard serial port 531 519 address, and finally try to get any free port. */ 532 - i = first_tuple(link, tuple, parse); 533 - while (i != CS_NO_MORE_ITEMS) { 534 - if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && 535 - ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 536 - link->conf.ConfigIndex = cf->index; 537 - for (j = 0; j < 5; j++) { 538 - link->io.BasePort1 = base[j]; 539 - link->io.IOAddrLines = base[j] ? 16 : 3; 540 - i = pcmcia_request_io(link, &link->io); 541 - if (i == CS_SUCCESS) 542 - goto found_port; 543 - } 544 - } 545 - i = next_tuple(link, tuple, parse); 546 - } 520 + if (!pcmcia_loop_config(link, simple_config_check_notpicky, NULL)) 521 + goto found_port; 547 522 548 - found_port: 549 - if (i != CS_SUCCESS) { 550 - printk(KERN_NOTICE 551 - "serial_cs: no usable port range found, giving up\n"); 552 - cs_error(link, RequestIO, i); 553 - kfree(cfg_mem); 554 - return -1; 555 - } 523 + printk(KERN_NOTICE 524 + "serial_cs: no usable port range found, giving up\n"); 525 + cs_error(link, RequestIO, i); 526 + return -1; 556 527 528 + found_port: 557 529 i = pcmcia_request_irq(link, &link->irq); 558 - if (i != CS_SUCCESS) { 530 + if (i != 0) { 559 531 cs_error(link, RequestIRQ, i); 560 532 link->irq.AssignedIRQ = 0; 561 533 } ··· 541 569 info->quirk->config(link); 542 570 543 571 i = pcmcia_request_configuration(link, &link->conf); 544 - if (i != CS_SUCCESS) { 572 + if (i != 0) { 545 573 cs_error(link, RequestConfiguration, i); 546 - kfree(cfg_mem); 547 574 return -1; 548 575 } 549 - kfree(cfg_mem); 550 576 return setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ); 551 577 } 552 578 553 - static int multi_config(struct pcmcia_device * link) 579 + static int multi_config_check(struct pcmcia_device *p_dev, 580 + cistpl_cftable_entry_t *cf, 581 + cistpl_cftable_entry_t *dflt, 582 + unsigned int vcc, 583 + void *priv_data) 584 + { 585 + int *base2 = priv_data; 586 + 587 + /* The quad port cards have bad CIS's, so just look for a 588 + window larger than 8 ports and assume it will be right */ 589 + if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { 590 + p_dev->io.BasePort1 = cf->io.win[0].base; 591 + p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 592 + if (!pcmcia_request_io(p_dev, &p_dev->io)) { 593 + *base2 = p_dev->io.BasePort1 + 8; 594 + return 0; 595 + } 596 + } 597 + return -ENODEV; 598 + } 599 + 600 + static int multi_config_check_notpicky(struct pcmcia_device *p_dev, 601 + cistpl_cftable_entry_t *cf, 602 + cistpl_cftable_entry_t *dflt, 603 + unsigned int vcc, 604 + void *priv_data) 605 + { 606 + int *base2 = priv_data; 607 + 608 + if (cf->io.nwin == 2) { 609 + p_dev->io.BasePort1 = cf->io.win[0].base; 610 + p_dev->io.BasePort2 = cf->io.win[1].base; 611 + p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 612 + if (!pcmcia_request_io(p_dev, &p_dev->io)) { 613 + *base2 = p_dev->io.BasePort2; 614 + return 0; 615 + } 616 + } 617 + return -ENODEV; 618 + } 619 + 620 + static int multi_config(struct pcmcia_device *link) 554 621 { 555 622 struct serial_info *info = link->priv; 556 - struct serial_cfg_mem *cfg_mem; 557 - tuple_t *tuple; 558 - u_char *buf; 559 - cisparse_t *parse; 560 - cistpl_cftable_entry_t *cf; 561 - int i, rc, base2 = 0; 562 - 563 - cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL); 564 - if (!cfg_mem) 565 - return -1; 566 - tuple = &cfg_mem->tuple; 567 - parse = &cfg_mem->parse; 568 - cf = &parse->cftable_entry; 569 - buf = cfg_mem->buf; 570 - 571 - tuple->TupleData = (cisdata_t *) buf; 572 - tuple->TupleOffset = 0; 573 - tuple->TupleDataMax = 255; 574 - tuple->Attributes = 0; 575 - tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 623 + int i, base2 = 0; 576 624 577 625 /* First, look for a generic full-sized window */ 578 626 link->io.NumPorts1 = info->multi * 8; 579 - i = first_tuple(link, tuple, parse); 580 - while (i != CS_NO_MORE_ITEMS) { 581 - /* The quad port cards have bad CIS's, so just look for a 582 - window larger than 8 ports and assume it will be right */ 583 - if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && 584 - (cf->io.win[0].len > 8)) { 585 - link->conf.ConfigIndex = cf->index; 586 - link->io.BasePort1 = cf->io.win[0].base; 587 - link->io.IOAddrLines = 588 - cf->io.flags & CISTPL_IO_LINES_MASK; 589 - i = pcmcia_request_io(link, &link->io); 590 - base2 = link->io.BasePort1 + 8; 591 - if (i == CS_SUCCESS) 592 - break; 593 - } 594 - i = next_tuple(link, tuple, parse); 595 - } 596 - 597 - /* If that didn't work, look for two windows */ 598 - if (i != CS_SUCCESS) { 627 + if (pcmcia_loop_config(link, multi_config_check, &base2)) { 628 + /* If that didn't work, look for two windows */ 599 629 link->io.NumPorts1 = link->io.NumPorts2 = 8; 600 630 info->multi = 2; 601 - i = first_tuple(link, tuple, parse); 602 - while (i != CS_NO_MORE_ITEMS) { 603 - if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) { 604 - link->conf.ConfigIndex = cf->index; 605 - link->io.BasePort1 = cf->io.win[0].base; 606 - link->io.BasePort2 = cf->io.win[1].base; 607 - link->io.IOAddrLines = 608 - cf->io.flags & CISTPL_IO_LINES_MASK; 609 - i = pcmcia_request_io(link, &link->io); 610 - base2 = link->io.BasePort2; 611 - if (i == CS_SUCCESS) 612 - break; 613 - } 614 - i = next_tuple(link, tuple, parse); 631 + if (pcmcia_loop_config(link, multi_config_check_notpicky, 632 + &base2)) { 633 + printk(KERN_NOTICE "serial_cs: no usable port range" 634 + "found, giving up\n"); 635 + return -ENODEV; 615 636 } 616 - } 617 - 618 - if (i != CS_SUCCESS) { 619 - cs_error(link, RequestIO, i); 620 - rc = -1; 621 - goto free_cfg_mem; 622 637 } 623 638 624 639 i = pcmcia_request_irq(link, &link->irq); 625 - if (i != CS_SUCCESS) { 640 + if (i != 0) { 641 + /* FIXME: comment does not fit, error handling does not fit */ 626 642 printk(KERN_NOTICE 627 643 "serial_cs: no usable port range found, giving up\n"); 628 644 cs_error(link, RequestIRQ, i); ··· 624 664 info->quirk->config(link); 625 665 626 666 i = pcmcia_request_configuration(link, &link->conf); 627 - if (i != CS_SUCCESS) { 667 + if (i != 0) { 628 668 cs_error(link, RequestConfiguration, i); 629 - rc = -1; 630 - goto free_cfg_mem; 669 + return -ENODEV; 631 670 } 632 671 633 672 /* The Oxford Semiconductor OXCF950 cards are in fact single-port: ··· 637 678 info->prodid == PRODID_POSSIO_GCC)) { 638 679 int err; 639 680 640 - if (cf->index == 1 || cf->index == 3) { 681 + if (link->conf.ConfigIndex == 1 || 682 + link->conf.ConfigIndex == 3) { 641 683 err = setup_serial(link, info, base2, 642 684 link->irq.AssignedIRQ); 643 685 base2 = link->io.BasePort1; ··· 655 695 if (info->quirk && info->quirk->wakeup) 656 696 info->quirk->wakeup(link); 657 697 658 - rc = 0; 659 - goto free_cfg_mem; 698 + return 0; 660 699 } 661 700 662 701 setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ); 663 702 for (i = 0; i < info->multi - 1; i++) 664 703 setup_serial(link, info, base2 + (8 * i), 665 704 link->irq.AssignedIRQ); 666 - rc = 0; 667 - free_cfg_mem: 668 - kfree(cfg_mem); 669 - return rc; 705 + return 0; 670 706 } 671 707 672 708 /*====================================================================== ··· 702 746 /* Is this a compliant multifunction card? */ 703 747 tuple->DesiredTuple = CISTPL_LONGLINK_MFC; 704 748 tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK; 705 - info->multi = (first_tuple(link, tuple, parse) == CS_SUCCESS); 749 + info->multi = (first_tuple(link, tuple, parse) == 0); 706 750 707 751 /* Is this a multiport card? */ 708 752 tuple->DesiredTuple = CISTPL_MANFID; ··· 726 770 ((link->func_id == CISTPL_FUNCID_MULTI) || 727 771 (link->func_id == CISTPL_FUNCID_SERIAL))) { 728 772 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 729 - if (first_tuple(link, tuple, parse) == CS_SUCCESS) { 773 + if (first_tuple(link, tuple, parse) == 0) { 730 774 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 731 775 info->multi = cf->io.win[0].len >> 3; 732 776 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) &&
+11 -11
drivers/ssb/pcmcia.c
··· 80 80 reg.Action = CS_WRITE; 81 81 reg.Value = value; 82 82 res = pcmcia_access_configuration_register(bus->host_pcmcia, &reg); 83 - if (unlikely(res != CS_SUCCESS)) 83 + if (unlikely(res != 0)) 84 84 return -EBUSY; 85 85 86 86 return 0; ··· 96 96 reg.Offset = offset; 97 97 reg.Action = CS_READ; 98 98 res = pcmcia_access_configuration_register(bus->host_pcmcia, &reg); 99 - if (unlikely(res != CS_SUCCESS)) 99 + if (unlikely(res != 0)) 100 100 return -EBUSY; 101 101 *value = reg.Value; 102 102 ··· 638 638 tuple.TupleData = buf; 639 639 tuple.TupleDataMax = sizeof(buf); 640 640 res = pcmcia_get_first_tuple(bus->host_pcmcia, &tuple); 641 - GOTO_ERROR_ON(res != CS_SUCCESS, "MAC first tpl"); 641 + GOTO_ERROR_ON(res != 0, "MAC first tpl"); 642 642 res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); 643 - GOTO_ERROR_ON(res != CS_SUCCESS, "MAC first tpl data"); 643 + GOTO_ERROR_ON(res != 0, "MAC first tpl data"); 644 644 while (1) { 645 645 GOTO_ERROR_ON(tuple.TupleDataLen < 1, "MAC tpl < 1"); 646 646 if (tuple.TupleData[0] == CISTPL_FUNCE_LAN_NODE_ID) 647 647 break; 648 648 res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple); 649 - GOTO_ERROR_ON(res != CS_SUCCESS, "MAC next tpl"); 649 + GOTO_ERROR_ON(res != 0, "MAC next tpl"); 650 650 res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); 651 - GOTO_ERROR_ON(res != CS_SUCCESS, "MAC next tpl data"); 651 + GOTO_ERROR_ON(res != 0, "MAC next tpl data"); 652 652 } 653 653 GOTO_ERROR_ON(tuple.TupleDataLen != ETH_ALEN + 2, "MAC tpl size"); 654 654 memcpy(sprom->il0mac, &tuple.TupleData[2], ETH_ALEN); ··· 659 659 tuple.TupleData = buf; 660 660 tuple.TupleDataMax = sizeof(buf); 661 661 res = pcmcia_get_first_tuple(bus->host_pcmcia, &tuple); 662 - GOTO_ERROR_ON(res != CS_SUCCESS, "VEN first tpl"); 662 + GOTO_ERROR_ON(res != 0, "VEN first tpl"); 663 663 res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); 664 - GOTO_ERROR_ON(res != CS_SUCCESS, "VEN first tpl data"); 664 + GOTO_ERROR_ON(res != 0, "VEN first tpl data"); 665 665 while (1) { 666 666 GOTO_ERROR_ON(tuple.TupleDataLen < 1, "VEN tpl < 1"); 667 667 switch (tuple.TupleData[0]) { ··· 733 733 break; 734 734 } 735 735 res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple); 736 - if (res == CS_NO_MORE_ITEMS) 736 + if (res == -ENOSPC) 737 737 break; 738 - GOTO_ERROR_ON(res != CS_SUCCESS, "VEN next tpl"); 738 + GOTO_ERROR_ON(res != 0, "VEN next tpl"); 739 739 res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); 740 - GOTO_ERROR_ON(res != CS_SUCCESS, "VEN next tpl data"); 740 + GOTO_ERROR_ON(res != 0, "VEN next tpl data"); 741 741 } 742 742 743 743 return 0;
+30 -42
drivers/telephony/ixj_pcmcia.c
··· 124 124 return; 125 125 } 126 126 127 + static int ixj_config_check(struct pcmcia_device *p_dev, 128 + cistpl_cftable_entry_t *cfg, 129 + cistpl_cftable_entry_t *dflt, 130 + unsigned int vcc, 131 + void *priv_data) 132 + { 133 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 134 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 135 + p_dev->io.BasePort1 = io->win[0].base; 136 + p_dev->io.NumPorts1 = io->win[0].len; 137 + if (io->nwin == 2) { 138 + p_dev->io.BasePort2 = io->win[1].base; 139 + p_dev->io.NumPorts2 = io->win[1].len; 140 + } 141 + if (!pcmcia_request_io(p_dev, &p_dev->io)) 142 + return 0; 143 + } 144 + return -ENODEV; 145 + } 146 + 127 147 static int ixj_config(struct pcmcia_device * link) 128 148 { 129 149 IXJ *j; 130 150 ixj_info_t *info; 131 - tuple_t tuple; 132 - u_short buf[128]; 133 - cisparse_t parse; 134 - cistpl_cftable_entry_t *cfg = &parse.cftable_entry; 135 - cistpl_cftable_entry_t dflt = 136 - { 137 - 0 138 - }; 139 - int last_ret, last_fn; 151 + cistpl_cftable_entry_t dflt = { 0 }; 152 + 140 153 info = link->priv; 141 154 DEBUG(0, "ixj_config(0x%p)\n", link); 142 - tuple.TupleData = (cisdata_t *) buf; 143 - tuple.TupleOffset = 0; 144 - tuple.TupleDataMax = 255; 145 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 146 - tuple.Attributes = 0; 147 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 148 - while (1) { 149 - if (pcmcia_get_tuple_data(link, &tuple) != 0 || 150 - pcmcia_parse_tuple(link, &tuple, &parse) != 0) 151 - goto next_entry; 152 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 153 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 154 - link->conf.ConfigIndex = cfg->index; 155 - link->io.BasePort1 = io->win[0].base; 156 - link->io.NumPorts1 = io->win[0].len; 157 - if (io->nwin == 2) { 158 - link->io.BasePort2 = io->win[1].base; 159 - link->io.NumPorts2 = io->win[1].len; 160 - } 161 - if (pcmcia_request_io(link, &link->io) != 0) 162 - goto next_entry; 163 - /* If we've got this far, we're done */ 164 - break; 165 - } 166 - next_entry: 167 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 168 - dflt = *cfg; 169 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 170 - } 171 155 172 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 156 + if (pcmcia_loop_config(link, ixj_config_check, &dflt)) 157 + goto cs_failed; 158 + 159 + if (pcmcia_request_configuration(link, &link->conf)) 160 + goto cs_failed; 173 161 174 162 /* 175 163 * Register the card with the core. 176 - */ 177 - j=ixj_pcmcia_probe(link->io.BasePort1,link->io.BasePort1 + 0x10); 164 + */ 165 + j = ixj_pcmcia_probe(link->io.BasePort1, link->io.BasePort1 + 0x10); 178 166 179 167 info->ndev = 1; 180 168 info->node.major = PHONE_MAJOR; 181 169 link->dev_node = &info->node; 182 170 ixj_get_serial(link, j); 183 171 return 0; 172 + 184 173 cs_failed: 185 - cs_error(link, last_fn, last_ret); 186 174 ixj_cs_release(link); 187 175 return -ENODEV; 188 176 }
+55 -78
drivers/usb/host/sl811_cs.c
··· 112 112 .num_resources = ARRAY_SIZE(resources), 113 113 }; 114 114 115 - static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) 115 + static int sl811_hc_init(struct device *parent, resource_size_t base_addr, 116 + int irq) 116 117 { 117 118 if (platform_dev.dev.parent) 118 119 return -EBUSY; ··· 156 155 platform_device_unregister(&platform_dev); 157 156 } 158 157 158 + static int sl811_cs_config_check(struct pcmcia_device *p_dev, 159 + cistpl_cftable_entry_t *cfg, 160 + cistpl_cftable_entry_t *dflt, 161 + unsigned int vcc, 162 + void *priv_data) 163 + { 164 + if (cfg->index == 0) 165 + return -ENODEV; 166 + 167 + /* Use power settings for Vcc and Vpp if present */ 168 + /* Note that the CIS values need to be rescaled */ 169 + if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 170 + if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc) 171 + return -ENODEV; 172 + } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { 173 + if (dflt->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc) 174 + return -ENODEV; 175 + } 176 + 177 + if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 178 + p_dev->conf.Vpp = 179 + cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 180 + else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) 181 + p_dev->conf.Vpp = 182 + dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; 183 + 184 + /* we need an interrupt */ 185 + if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) 186 + p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 187 + 188 + /* IO window settings */ 189 + p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 190 + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 191 + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 192 + 193 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 194 + p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 195 + p_dev->io.BasePort1 = io->win[0].base; 196 + p_dev->io.NumPorts1 = io->win[0].len; 197 + 198 + return pcmcia_request_io(p_dev, &p_dev->io); 199 + } 200 + pcmcia_disable_device(p_dev); 201 + return -ENODEV; 202 + } 203 + 204 + 159 205 static int sl811_cs_config(struct pcmcia_device *link) 160 206 { 161 207 struct device *parent = &handle_to_dev(link); 162 208 local_info_t *dev = link->priv; 163 - tuple_t tuple; 164 - cisparse_t parse; 165 209 int last_fn, last_ret; 166 - u_char buf[64]; 167 - config_info_t conf; 168 - cistpl_cftable_entry_t dflt = { 0 }; 169 210 170 211 DBG(0, "sl811_cs_config(0x%p)\n", link); 171 212 172 - /* Look up the current Vcc */ 173 - CS_CHECK(GetConfigurationInfo, 174 - pcmcia_get_configuration_info(link, &conf)); 175 - 176 - tuple.Attributes = 0; 177 - tuple.TupleData = buf; 178 - tuple.TupleDataMax = sizeof(buf); 179 - tuple.TupleOffset = 0; 180 - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 181 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 182 - while (1) { 183 - cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 184 - 185 - if (pcmcia_get_tuple_data(link, &tuple) != 0 186 - || pcmcia_parse_tuple(link, &tuple, &parse) 187 - != 0) 188 - goto next_entry; 189 - 190 - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { 191 - dflt = *cfg; 192 - } 193 - 194 - if (cfg->index == 0) 195 - goto next_entry; 196 - 197 - link->conf.ConfigIndex = cfg->index; 198 - 199 - /* Use power settings for Vcc and Vpp if present */ 200 - /* Note that the CIS values need to be rescaled */ 201 - if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 202 - if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 203 - != conf.Vcc) 204 - goto next_entry; 205 - } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { 206 - if (dflt.vcc.param[CISTPL_POWER_VNOM]/10000 207 - != conf.Vcc) 208 - goto next_entry; 209 - } 210 - 211 - if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 212 - link->conf.Vpp = 213 - cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 214 - else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 215 - link->conf.Vpp = 216 - dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 217 - 218 - /* we need an interrupt */ 219 - if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) 220 - link->conf.Attributes |= CONF_ENABLE_IRQ; 221 - 222 - /* IO window settings */ 223 - link->io.NumPorts1 = link->io.NumPorts2 = 0; 224 - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 225 - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 226 - 227 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 228 - link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 229 - link->io.BasePort1 = io->win[0].base; 230 - link->io.NumPorts1 = io->win[0].len; 231 - 232 - if (pcmcia_request_io(link, &link->io) != 0) 233 - goto next_entry; 234 - } 235 - break; 236 - 237 - next_entry: 238 - pcmcia_disable_device(link); 239 - last_ret = pcmcia_get_next_tuple(link, &tuple); 240 - } 213 + if (pcmcia_loop_config(link, sl811_cs_config_check, NULL)) 214 + goto failed; 241 215 242 216 /* require an IRQ and two registers */ 243 217 if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) 244 - goto cs_failed; 218 + goto failed; 245 219 if (link->conf.Attributes & CONF_ENABLE_IRQ) 246 220 CS_CHECK(RequestIRQ, 247 221 pcmcia_request_irq(link, &link->irq)); 248 222 else 249 - goto cs_failed; 223 + goto failed; 250 224 251 225 CS_CHECK(RequestConfiguration, 252 226 pcmcia_request_configuration(link, &link->conf)); ··· 242 266 if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) 243 267 < 0) { 244 268 cs_failed: 245 - printk("sl811_cs_config failed\n"); 246 269 cs_error(link, last_fn, last_ret); 270 + failed: 271 + printk(KERN_WARNING "sl811_cs_config failed\n"); 247 272 sl811_cs_release(link); 248 273 return -ENODEV; 249 274 }
+1 -1
include/pcmcia/ciscode.h
··· 119 119 120 120 #define MANFID_TOSHIBA 0x0098 121 121 122 - #define MANFID_UNGERMANN 0x02c0 122 + #define MANFID_UNGERMANN 0x02c0 123 123 124 124 #define MANFID_XIRCOM 0x0105 125 125
-38
include/pcmcia/cistpl.h
··· 573 573 #define TUPLE_RETURN_LINK 0x01 574 574 #define TUPLE_RETURN_COMMON 0x02 575 575 576 - /* For ValidateCIS */ 577 - typedef struct cisinfo_t { 578 - u_int Chains; 579 - } cisinfo_t; 580 - 581 576 #define CISTPL_MAX_CIS_SIZE 0x200 582 - 583 - /* For ReplaceCIS */ 584 - typedef struct cisdump_t { 585 - u_int Length; 586 - cisdata_t Data[CISTPL_MAX_CIS_SIZE]; 587 - } cisdump_t; 588 - 589 - 590 - int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis); 591 - 592 - /* don't use outside of PCMCIA core yet */ 593 - int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple); 594 - int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple); 595 - int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); 596 - int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse); 597 - 598 - int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned int *count); 599 - 600 - /* ... but use these wrappers instead */ 601 - #define pcmcia_get_first_tuple(p_dev, tuple) \ 602 - pccard_get_first_tuple(p_dev->socket, p_dev->func, tuple) 603 - 604 - #define pcmcia_get_next_tuple(p_dev, tuple) \ 605 - pccard_get_next_tuple(p_dev->socket, p_dev->func, tuple) 606 - 607 - #define pcmcia_get_tuple_data(p_dev, tuple) \ 608 - pccard_get_tuple_data(p_dev->socket, tuple) 609 - 610 - #define pcmcia_parse_tuple(p_dev, tuple, parse) \ 611 - pccard_parse_tuple(tuple, parse) 612 - 613 - #define pcmcia_validate_cis(p_dev, info) \ 614 - pccard_validate_cis(p_dev->socket, p_dev->func, info) 615 577 616 578 #endif /* LINUX_CISTPL_H */
+1 -164
include/pcmcia/cs.h
··· 28 28 #define CS_WRITE 2 29 29 30 30 /* for AdjustResourceInfo */ 31 - typedef struct adjust_t { 32 - u_int Action; 33 - u_int Resource; 34 - u_int Attributes; 35 - union { 36 - struct memory { 37 - u_long Base; 38 - u_long Size; 39 - } memory; 40 - struct io { 41 - ioaddr_t BasePort; 42 - ioaddr_t NumPorts; 43 - u_int IOAddrLines; 44 - } io; 45 - struct irq { 46 - u_int IRQ; 47 - } irq; 48 - } resource; 49 - } adjust_t; 50 - 51 31 /* Action field */ 52 32 #define REMOVE_MANAGED_RESOURCE 1 53 33 #define ADD_MANAGED_RESOURCE 2 54 - #define GET_FIRST_MANAGED_RESOURCE 3 55 - #define GET_NEXT_MANAGED_RESOURCE 4 56 - /* Resource field */ 57 - #define RES_MEMORY_RANGE 1 58 - #define RES_IO_RANGE 2 59 - #define RES_IRQ 3 60 - /* Attribute field */ 61 - #define RES_IRQ_TYPE 0x03 62 - #define RES_IRQ_TYPE_EXCLUSIVE 0 63 - #define RES_IRQ_TYPE_TIME 1 64 - #define RES_IRQ_TYPE_DYNAMIC 2 65 - #define RES_IRQ_CSC 0x04 66 - #define RES_SHARED 0x08 67 - #define RES_RESERVED 0x10 68 - #define RES_ALLOCATED 0x20 69 - #define RES_REMOVED 0x40 34 + 70 35 71 36 typedef struct event_callback_args_t { 72 37 struct pcmcia_device *client_handle; 73 38 void *client_data; 74 39 } event_callback_args_t; 75 - 76 - /* for GetConfigurationInfo */ 77 - typedef struct config_info_t { 78 - u_char Function; 79 - u_int Attributes; 80 - u_int Vcc, Vpp1, Vpp2; 81 - u_int IntType; 82 - u_int ConfigBase; 83 - u_char Status, Pin, Copy, Option, ExtStatus; 84 - u_int Present; 85 - u_int CardValues; 86 - u_int AssignedIRQ; 87 - u_int IRQAttributes; 88 - ioaddr_t BasePort1; 89 - ioaddr_t NumPorts1; 90 - u_int Attributes1; 91 - ioaddr_t BasePort2; 92 - ioaddr_t NumPorts2; 93 - u_int Attributes2; 94 - u_int IOAddrLines; 95 - } config_info_t; 96 40 97 41 /* For CardValues field */ 98 42 #define CV_OPTION_VALUE 0x01 ··· 201 257 #define WIN_BAR_MASK 0xe000 202 258 #define WIN_BAR_SHIFT 13 203 259 204 - /* Attributes for RegisterClient -- UNUSED -- */ 205 - #define INFO_MASTER_CLIENT 0x01 206 - #define INFO_IO_CLIENT 0x02 207 - #define INFO_MTD_CLIENT 0x04 208 - #define INFO_MEM_CLIENT 0x08 209 - #define MAX_NUM_CLIENTS 3 210 - 211 - #define INFO_CARD_SHARE 0x10 212 - #define INFO_CARD_EXCL 0x20 213 - 214 - typedef struct cs_status_t { 215 - u_char Function; 216 - event_t CardState; 217 - event_t SocketState; 218 - } cs_status_t; 219 - 220 260 typedef struct error_info_t { 221 261 int func; 222 262 int retcode; ··· 235 307 #define CS_EVENT_CB_DETECT 0x100000 236 308 #define CS_EVENT_3VCARD 0x200000 237 309 #define CS_EVENT_XVCARD 0x400000 238 - 239 - /* Return codes */ 240 - #define CS_SUCCESS 0x00 241 - #define CS_BAD_ADAPTER 0x01 242 - #define CS_BAD_ATTRIBUTE 0x02 243 - #define CS_BAD_BASE 0x03 244 - #define CS_BAD_EDC 0x04 245 - #define CS_BAD_IRQ 0x06 246 - #define CS_BAD_OFFSET 0x07 247 - #define CS_BAD_PAGE 0x08 248 - #define CS_READ_FAILURE 0x09 249 - #define CS_BAD_SIZE 0x0a 250 - #define CS_BAD_SOCKET 0x0b 251 - #define CS_BAD_TYPE 0x0d 252 - #define CS_BAD_VCC 0x0e 253 - #define CS_BAD_VPP 0x0f 254 - #define CS_BAD_WINDOW 0x11 255 - #define CS_WRITE_FAILURE 0x12 256 - #define CS_NO_CARD 0x14 257 - #define CS_UNSUPPORTED_FUNCTION 0x15 258 - #define CS_UNSUPPORTED_MODE 0x16 259 - #define CS_BAD_SPEED 0x17 260 - #define CS_BUSY 0x18 261 - #define CS_GENERAL_FAILURE 0x19 262 - #define CS_WRITE_PROTECTED 0x1a 263 - #define CS_BAD_ARG_LENGTH 0x1b 264 - #define CS_BAD_ARGS 0x1c 265 - #define CS_CONFIGURATION_LOCKED 0x1d 266 - #define CS_IN_USE 0x1e 267 - #define CS_NO_MORE_ITEMS 0x1f 268 - #define CS_OUT_OF_RESOURCE 0x20 269 - #define CS_BAD_HANDLE 0x21 270 - 271 - #define CS_BAD_TUPLE 0x40 272 - 273 - #ifdef __KERNEL__ 274 - 275 - /* 276 - * The main Card Services entry point 277 - */ 278 - 279 - enum service { 280 - AccessConfigurationRegister, AddSocketServices, 281 - AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory, 282 - DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo, 283 - GetClientInfo, GetConfigurationInfo, GetEventMask, 284 - GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple, 285 - GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple, 286 - GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage, 287 - MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow, 288 - OpenMemory, ParseTuple, ReadMemory, RegisterClient, 289 - RegisterEraseQueue, RegisterMTD, RegisterTimer, 290 - ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ, 291 - ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices, 292 - RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ, 293 - RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry, 294 - SetEventMask, SetRegion, ValidateCIS, VendorSpecific, 295 - WriteMemory, BindDevice, BindMTD, ReportError, 296 - SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS, 297 - GetFirstWindow, GetNextWindow, GetMemPage 298 - }; 299 - 300 - struct pcmcia_socket; 301 - 302 - int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, conf_reg_t *reg); 303 - int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, config_info_t *config); 304 - int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); 305 - int pcmcia_map_mem_page(window_handle_t win, memreq_t *req); 306 - int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); 307 - int pcmcia_release_window(window_handle_t win); 308 - int pcmcia_request_configuration(struct pcmcia_device *p_dev, config_req_t *req); 309 - int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req); 310 - int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req); 311 - int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh); 312 - int pcmcia_suspend_card(struct pcmcia_socket *skt); 313 - int pcmcia_resume_card(struct pcmcia_socket *skt); 314 - int pcmcia_eject_card(struct pcmcia_socket *skt); 315 - int pcmcia_insert_card(struct pcmcia_socket *skt); 316 - int pccard_reset_card(struct pcmcia_socket *skt); 317 - 318 - struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *p_dev); 319 - void pcmcia_disable_device(struct pcmcia_device *p_dev); 320 - 321 - struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt); 322 - void pcmcia_put_socket(struct pcmcia_socket *skt); 323 - 324 - /* compatibility functions */ 325 - #define pcmcia_reset_card(p_dev, req) \ 326 - pccard_reset_card(p_dev->socket) 327 - 328 - #endif /* __KERNEL__ */ 329 310 330 311 #endif /* _LINUX_CS_H */
-8
include/pcmcia/cs_types.h
··· 21 21 #include <sys/types.h> 22 22 #endif 23 23 24 - #if defined(__arm__) || defined(__mips__) || defined(__avr32__) || \ 25 - defined(__bfin__) 26 - /* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */ 27 - typedef u_int ioaddr_t; 28 - #else 29 - typedef u_short ioaddr_t; 30 - #endif 31 - 32 24 typedef u_short socket_t; 33 25 typedef u_int event_t; 34 26 typedef u_char cisdata_t;
+15 -3
include/pcmcia/device_id.h
··· 1 1 /* 2 - * Copyright (2003-2004) Dominik Brodowski <linux@brodo.de> 3 - * David Woodhouse 2 + * device_id.h -- PCMCIA driver matching helpers 4 3 * 5 - * License: GPL v2 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License version 2 as 6 + * published by the Free Software Foundation. 7 + * 8 + * (C) 2003 - 2004 David Woodhouse 9 + * (C) 2003 - 2004 Dominik Brodowski 6 10 */ 11 + 12 + #ifndef _LINUX_PCMCIA_DEVICE_ID_H 13 + #define _LINUX_PCMCIA_DEVICE_ID_H 14 + 15 + #ifdef __KERNEL__ 7 16 8 17 #define PCMCIA_DEVICE_MANF_CARD(manf, card) { \ 9 18 .match_flags = PCMCIA_DEV_ID_MATCH_MANF_ID| \ ··· 265 256 266 257 267 258 #define PCMCIA_DEVICE_NULL { .match_flags = 0, } 259 + 260 + #endif /* __KERNEL__ */ 261 + #endif /* _LINUX_PCMCIA_DEVICE_ID_H */
+313 -98
include/pcmcia/ds.h
··· 10 10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 11 11 * 12 12 * (C) 1999 David A. Hinds 13 - * (C) 2003 - 2004 Dominik Brodowski 13 + * (C) 2003 - 2008 Dominik Brodowski 14 14 */ 15 15 16 16 #ifndef _LINUX_DS_H ··· 23 23 #include <pcmcia/cs_types.h> 24 24 #include <pcmcia/device_id.h> 25 25 26 - typedef struct tuple_parse_t { 27 - tuple_t tuple; 28 - cisdata_t data[255]; 29 - cisparse_t parse; 30 - } tuple_parse_t; 31 - 32 - typedef struct win_info_t { 33 - window_handle_t handle; 34 - win_req_t window; 35 - memreq_t map; 36 - } win_info_t; 37 - 38 - typedef struct bind_info_t { 39 - dev_info_t dev_info; 40 - u_char function; 41 - struct pcmcia_device *instance; 42 - char name[DEV_NAME_LEN]; 43 - u_short major, minor; 44 - void *next; 45 - } bind_info_t; 46 - 47 - typedef struct mtd_info_t { 48 - dev_info_t dev_info; 49 - u_int Attributes; 50 - u_int CardOffset; 51 - } mtd_info_t; 52 - 53 - typedef struct region_info_t { 54 - u_int Attributes; 55 - u_int CardOffset; 56 - u_int RegionSize; 57 - u_int AccessSpeed; 58 - u_int BlockSize; 59 - u_int PartMultiple; 60 - u_char JedecMfr, JedecInfo; 61 - memory_handle_t next; 62 - } region_info_t; 63 - #define REGION_TYPE 0x0001 64 - #define REGION_TYPE_CM 0x0000 65 - #define REGION_TYPE_AM 0x0001 66 - #define REGION_PREFETCH 0x0008 67 - #define REGION_CACHEABLE 0x0010 68 - #define REGION_BAR_MASK 0xe000 69 - #define REGION_BAR_SHIFT 13 70 - 71 - typedef union ds_ioctl_arg_t { 72 - adjust_t adjust; 73 - config_info_t config; 74 - tuple_t tuple; 75 - tuple_parse_t tuple_parse; 76 - client_req_t client_req; 77 - cs_status_t status; 78 - conf_reg_t conf_reg; 79 - cisinfo_t cisinfo; 80 - region_info_t region; 81 - bind_info_t bind_info; 82 - mtd_info_t mtd_info; 83 - win_info_t win_info; 84 - cisdump_t cisdump; 85 - } ds_ioctl_arg_t; 86 - 87 - #define DS_ADJUST_RESOURCE_INFO _IOWR('d', 2, adjust_t) 88 - #define DS_GET_CONFIGURATION_INFO _IOWR('d', 3, config_info_t) 89 - #define DS_GET_FIRST_TUPLE _IOWR('d', 4, tuple_t) 90 - #define DS_GET_NEXT_TUPLE _IOWR('d', 5, tuple_t) 91 - #define DS_GET_TUPLE_DATA _IOWR('d', 6, tuple_parse_t) 92 - #define DS_PARSE_TUPLE _IOWR('d', 7, tuple_parse_t) 93 - #define DS_RESET_CARD _IO ('d', 8) 94 - #define DS_GET_STATUS _IOWR('d', 9, cs_status_t) 95 - #define DS_ACCESS_CONFIGURATION_REGISTER _IOWR('d', 10, conf_reg_t) 96 - #define DS_VALIDATE_CIS _IOR ('d', 11, cisinfo_t) 97 - #define DS_SUSPEND_CARD _IO ('d', 12) 98 - #define DS_RESUME_CARD _IO ('d', 13) 99 - #define DS_EJECT_CARD _IO ('d', 14) 100 - #define DS_INSERT_CARD _IO ('d', 15) 101 - #define DS_GET_FIRST_REGION _IOWR('d', 16, region_info_t) 102 - #define DS_GET_NEXT_REGION _IOWR('d', 17, region_info_t) 103 - #define DS_REPLACE_CIS _IOWR('d', 18, cisdump_t) 104 - #define DS_GET_FIRST_WINDOW _IOR ('d', 19, win_info_t) 105 - #define DS_GET_NEXT_WINDOW _IOWR('d', 20, win_info_t) 106 - #define DS_GET_MEM_PAGE _IOWR('d', 21, win_info_t) 107 - 108 - #define DS_BIND_REQUEST _IOWR('d', 60, bind_info_t) 109 - #define DS_GET_DEVICE_INFO _IOWR('d', 61, bind_info_t) 110 - #define DS_GET_NEXT_DEVICE _IOWR('d', 62, bind_info_t) 111 - #define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t) 112 - #define DS_BIND_MTD _IOWR('d', 64, mtd_info_t) 113 - 114 26 #ifdef __KERNEL__ 115 27 #include <linux/device.h> 116 28 #include <pcmcia/ss.h> 117 29 118 - typedef struct dev_node_t { 119 - char dev_name[DEV_NAME_LEN]; 120 - u_short major, minor; 121 - struct dev_node_t *next; 122 - } dev_node_t; 123 - 124 - 30 + /* 31 + * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus 32 + * a.k.a. PCI drivers 33 + */ 125 34 struct pcmcia_socket; 35 + struct pcmcia_device; 126 36 struct config_t; 127 37 38 + /* dynamic device IDs for PCMCIA device drivers. See 39 + * Documentation/pcmcia/driver.txt for details. 40 + */ 128 41 struct pcmcia_dynids { 129 42 spinlock_t lock; 130 43 struct list_head list; ··· 60 147 int pcmcia_register_driver(struct pcmcia_driver *driver); 61 148 void pcmcia_unregister_driver(struct pcmcia_driver *driver); 62 149 150 + /* Some drivers use dev_node_t to store char or block device information. 151 + * Don't use this in new drivers, though. 152 + */ 153 + typedef struct dev_node_t { 154 + char dev_name[DEV_NAME_LEN]; 155 + u_short major, minor; 156 + struct dev_node_t *next; 157 + } dev_node_t; 63 158 64 159 struct pcmcia_device { 65 160 /* the socket and the device_no [for multifunction devices] ··· 137 216 #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) 138 217 #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) 139 218 219 + /* deprecated -- don't use! */ 140 220 #define handle_to_dev(handle) (handle->dev) 141 221 142 - /* error reporting */ 143 - void cs_error(struct pcmcia_device *handle, int func, int ret); 222 + 223 + /* (deprecated) error reporting by PCMCIA devices. Use dev_printk() 224 + * or dev_dbg() directly in the driver, without referring to pcmcia_error_func() 225 + * and/or pcmcia_error_ret() for those functions will go away soon. 226 + */ 227 + enum service { 228 + AccessConfigurationRegister, AddSocketServices, 229 + AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory, 230 + DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo, 231 + GetClientInfo, GetConfigurationInfo, GetEventMask, 232 + GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple, 233 + GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple, 234 + GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage, 235 + MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow, 236 + OpenMemory, ParseTuple, ReadMemory, RegisterClient, 237 + RegisterEraseQueue, RegisterMTD, RegisterTimer, 238 + ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ, 239 + ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices, 240 + RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ, 241 + RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry, 242 + SetEventMask, SetRegion, ValidateCIS, VendorSpecific, 243 + WriteMemory, BindDevice, BindMTD, ReportError, 244 + SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS, 245 + GetFirstWindow, GetNextWindow, GetMemPage 246 + }; 247 + const char *pcmcia_error_func(int func); 248 + const char *pcmcia_error_ret(int ret); 249 + 250 + #define cs_error(p_dev, func, ret) \ 251 + { \ 252 + dev_printk(KERN_NOTICE, &p_dev->dev, \ 253 + "%s : %s\n", \ 254 + pcmcia_error_func(func), \ 255 + pcmcia_error_ret(ret)); \ 256 + } 257 + 258 + /* CIS access. 259 + * Use the pcmcia_* versions in PCMCIA drivers 260 + */ 261 + int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse); 262 + 263 + int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, 264 + tuple_t *tuple); 265 + #define pcmcia_get_first_tuple(p_dev, tuple) \ 266 + pccard_get_first_tuple(p_dev->socket, p_dev->func, tuple) 267 + 268 + int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, 269 + tuple_t *tuple); 270 + #define pcmcia_get_next_tuple(p_dev, tuple) \ 271 + pccard_get_next_tuple(p_dev->socket, p_dev->func, tuple) 272 + 273 + int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); 274 + #define pcmcia_get_tuple_data(p_dev, tuple) \ 275 + pccard_get_tuple_data(p_dev->socket, tuple) 276 + 277 + 278 + /* loop CIS entries for valid configuration */ 279 + int pcmcia_loop_config(struct pcmcia_device *p_dev, 280 + int (*conf_check) (struct pcmcia_device *p_dev, 281 + cistpl_cftable_entry_t *cf, 282 + cistpl_cftable_entry_t *dflt, 283 + unsigned int vcc, 284 + void *priv_data), 285 + void *priv_data); 286 + 287 + /* is the device still there? */ 288 + struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev); 289 + 290 + /* low-level interface reset */ 291 + int pcmcia_reset_card(struct pcmcia_socket *skt); 292 + 293 + /* CIS config */ 294 + int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, 295 + conf_reg_t *reg); 296 + 297 + /* device configuration */ 298 + int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req); 299 + int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req); 300 + int pcmcia_request_configuration(struct pcmcia_device *p_dev, 301 + config_req_t *req); 302 + 303 + int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, 304 + window_handle_t *wh); 305 + int pcmcia_release_window(window_handle_t win); 306 + 307 + int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); 308 + int pcmcia_map_mem_page(window_handle_t win, memreq_t *req); 309 + 310 + int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); 311 + void pcmcia_disable_device(struct pcmcia_device *p_dev); 144 312 145 313 #endif /* __KERNEL__ */ 314 + 315 + 316 + 317 + /* Below, there are only definitions which are used by 318 + * - the PCMCIA ioctl 319 + * - deprecated PCMCIA userspace tools only 320 + * 321 + * here be dragons ... here be dragons ... here be dragons ... here be drag 322 + */ 323 + 324 + #if defined(CONFIG_PCMCIA_IOCTL) || !defined(__KERNEL__) 325 + 326 + #if defined(__arm__) || defined(__mips__) || defined(__avr32__) || \ 327 + defined(__bfin__) 328 + /* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */ 329 + typedef u_int ioaddr_t; 330 + #else 331 + typedef u_short ioaddr_t; 332 + #endif 333 + 334 + /* for AdjustResourceInfo */ 335 + typedef struct adjust_t { 336 + u_int Action; 337 + u_int Resource; 338 + u_int Attributes; 339 + union { 340 + struct memory { 341 + u_long Base; 342 + u_long Size; 343 + } memory; 344 + struct io { 345 + ioaddr_t BasePort; 346 + ioaddr_t NumPorts; 347 + u_int IOAddrLines; 348 + } io; 349 + struct irq { 350 + u_int IRQ; 351 + } irq; 352 + } resource; 353 + } adjust_t; 354 + 355 + /* Action field */ 356 + #define REMOVE_MANAGED_RESOURCE 1 357 + #define ADD_MANAGED_RESOURCE 2 358 + #define GET_FIRST_MANAGED_RESOURCE 3 359 + #define GET_NEXT_MANAGED_RESOURCE 4 360 + /* Resource field */ 361 + #define RES_MEMORY_RANGE 1 362 + #define RES_IO_RANGE 2 363 + #define RES_IRQ 3 364 + /* Attribute field */ 365 + #define RES_IRQ_TYPE 0x03 366 + #define RES_IRQ_TYPE_EXCLUSIVE 0 367 + #define RES_IRQ_TYPE_TIME 1 368 + #define RES_IRQ_TYPE_DYNAMIC 2 369 + #define RES_IRQ_CSC 0x04 370 + #define RES_SHARED 0x08 371 + #define RES_RESERVED 0x10 372 + #define RES_ALLOCATED 0x20 373 + #define RES_REMOVED 0x40 374 + 375 + 376 + typedef struct tuple_parse_t { 377 + tuple_t tuple; 378 + cisdata_t data[255]; 379 + cisparse_t parse; 380 + } tuple_parse_t; 381 + 382 + typedef struct win_info_t { 383 + window_handle_t handle; 384 + win_req_t window; 385 + memreq_t map; 386 + } win_info_t; 387 + 388 + typedef struct bind_info_t { 389 + dev_info_t dev_info; 390 + u_char function; 391 + struct pcmcia_device *instance; 392 + char name[DEV_NAME_LEN]; 393 + u_short major, minor; 394 + void *next; 395 + } bind_info_t; 396 + 397 + typedef struct mtd_info_t { 398 + dev_info_t dev_info; 399 + u_int Attributes; 400 + u_int CardOffset; 401 + } mtd_info_t; 402 + 403 + typedef struct region_info_t { 404 + u_int Attributes; 405 + u_int CardOffset; 406 + u_int RegionSize; 407 + u_int AccessSpeed; 408 + u_int BlockSize; 409 + u_int PartMultiple; 410 + u_char JedecMfr, JedecInfo; 411 + memory_handle_t next; 412 + } region_info_t; 413 + 414 + #define REGION_TYPE 0x0001 415 + #define REGION_TYPE_CM 0x0000 416 + #define REGION_TYPE_AM 0x0001 417 + #define REGION_PREFETCH 0x0008 418 + #define REGION_CACHEABLE 0x0010 419 + #define REGION_BAR_MASK 0xe000 420 + #define REGION_BAR_SHIFT 13 421 + 422 + /* For ReplaceCIS */ 423 + typedef struct cisdump_t { 424 + u_int Length; 425 + cisdata_t Data[CISTPL_MAX_CIS_SIZE]; 426 + } cisdump_t; 427 + 428 + /* for GetConfigurationInfo */ 429 + typedef struct config_info_t { 430 + u_char Function; 431 + u_int Attributes; 432 + u_int Vcc, Vpp1, Vpp2; 433 + u_int IntType; 434 + u_int ConfigBase; 435 + u_char Status, Pin, Copy, Option, ExtStatus; 436 + u_int Present; 437 + u_int CardValues; 438 + u_int AssignedIRQ; 439 + u_int IRQAttributes; 440 + ioaddr_t BasePort1; 441 + ioaddr_t NumPorts1; 442 + u_int Attributes1; 443 + ioaddr_t BasePort2; 444 + ioaddr_t NumPorts2; 445 + u_int Attributes2; 446 + u_int IOAddrLines; 447 + } config_info_t; 448 + 449 + /* For ValidateCIS */ 450 + typedef struct cisinfo_t { 451 + u_int Chains; 452 + } cisinfo_t; 453 + 454 + typedef struct cs_status_t { 455 + u_char Function; 456 + event_t CardState; 457 + event_t SocketState; 458 + } cs_status_t; 459 + 460 + typedef union ds_ioctl_arg_t { 461 + adjust_t adjust; 462 + config_info_t config; 463 + tuple_t tuple; 464 + tuple_parse_t tuple_parse; 465 + client_req_t client_req; 466 + cs_status_t status; 467 + conf_reg_t conf_reg; 468 + cisinfo_t cisinfo; 469 + region_info_t region; 470 + bind_info_t bind_info; 471 + mtd_info_t mtd_info; 472 + win_info_t win_info; 473 + cisdump_t cisdump; 474 + } ds_ioctl_arg_t; 475 + 476 + #define DS_ADJUST_RESOURCE_INFO _IOWR('d', 2, adjust_t) 477 + #define DS_GET_CONFIGURATION_INFO _IOWR('d', 3, config_info_t) 478 + #define DS_GET_FIRST_TUPLE _IOWR('d', 4, tuple_t) 479 + #define DS_GET_NEXT_TUPLE _IOWR('d', 5, tuple_t) 480 + #define DS_GET_TUPLE_DATA _IOWR('d', 6, tuple_parse_t) 481 + #define DS_PARSE_TUPLE _IOWR('d', 7, tuple_parse_t) 482 + #define DS_RESET_CARD _IO ('d', 8) 483 + #define DS_GET_STATUS _IOWR('d', 9, cs_status_t) 484 + #define DS_ACCESS_CONFIGURATION_REGISTER _IOWR('d', 10, conf_reg_t) 485 + #define DS_VALIDATE_CIS _IOR ('d', 11, cisinfo_t) 486 + #define DS_SUSPEND_CARD _IO ('d', 12) 487 + #define DS_RESUME_CARD _IO ('d', 13) 488 + #define DS_EJECT_CARD _IO ('d', 14) 489 + #define DS_INSERT_CARD _IO ('d', 15) 490 + #define DS_GET_FIRST_REGION _IOWR('d', 16, region_info_t) 491 + #define DS_GET_NEXT_REGION _IOWR('d', 17, region_info_t) 492 + #define DS_REPLACE_CIS _IOWR('d', 18, cisdump_t) 493 + #define DS_GET_FIRST_WINDOW _IOR ('d', 19, win_info_t) 494 + #define DS_GET_NEXT_WINDOW _IOWR('d', 20, win_info_t) 495 + #define DS_GET_MEM_PAGE _IOWR('d', 21, win_info_t) 496 + 497 + #define DS_BIND_REQUEST _IOWR('d', 60, bind_info_t) 498 + #define DS_GET_DEVICE_INFO _IOWR('d', 61, bind_info_t) 499 + #define DS_GET_NEXT_DEVICE _IOWR('d', 62, bind_info_t) 500 + #define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t) 501 + #define DS_BIND_MTD _IOWR('d', 64, mtd_info_t) 502 + 503 + 504 + /* used in userspace only */ 505 + #define CS_IN_USE 0x1e 506 + 507 + #define INFO_MASTER_CLIENT 0x01 508 + #define INFO_IO_CLIENT 0x02 509 + #define INFO_MTD_CLIENT 0x04 510 + #define INFO_MEM_CLIENT 0x08 511 + #define MAX_NUM_CLIENTS 3 512 + 513 + #define INFO_CARD_SHARE 0x10 514 + #define INFO_CARD_EXCL 0x20 515 + 516 + 517 + #endif /* !defined(__KERNEL__) || defined(CONFIG_PCMCIA_IOCTL) */ 518 + 146 519 #endif /* _LINUX_DS_H */
+93 -109
include/pcmcia/ss.h
··· 53 53 54 54 /* for GetSocket, SetSocket */ 55 55 typedef struct socket_state_t { 56 - u_int flags; 57 - u_int csc_mask; 58 - u_char Vcc, Vpp; 59 - u_char io_irq; 56 + u_int flags; 57 + u_int csc_mask; 58 + u_char Vcc, Vpp; 59 + u_char io_irq; 60 60 } socket_state_t; 61 61 62 62 extern socket_state_t dead_socket; ··· 86 86 #define HOOK_POWER_PRE 0x01 87 87 #define HOOK_POWER_POST 0x02 88 88 89 - 90 89 typedef struct pccard_io_map { 91 - u_char map; 92 - u_char flags; 93 - u_short speed; 94 - u_int start, stop; 90 + u_char map; 91 + u_char flags; 92 + u_short speed; 93 + u_int start, stop; 95 94 } pccard_io_map; 96 95 97 96 typedef struct pccard_mem_map { 98 - u_char map; 99 - u_char flags; 100 - u_short speed; 101 - u_long static_start; 102 - u_int card_start; 103 - struct resource *res; 97 + u_char map; 98 + u_char flags; 99 + u_short speed; 100 + u_long static_start; 101 + u_int card_start; 102 + struct resource *res; 104 103 } pccard_mem_map; 105 - 106 - typedef struct cb_bridge_map { 107 - u_char map; 108 - u_char flags; 109 - u_int start, stop; 110 - } cb_bridge_map; 111 - 112 - /* 113 - * Socket operations. 114 - */ 115 - struct pcmcia_socket; 116 - 117 - struct pccard_operations { 118 - int (*init)(struct pcmcia_socket *sock); 119 - int (*suspend)(struct pcmcia_socket *sock); 120 - int (*get_status)(struct pcmcia_socket *sock, u_int *value); 121 - int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state); 122 - int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io); 123 - int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem); 124 - }; 125 - 126 - struct pccard_resource_ops { 127 - int (*validate_mem) (struct pcmcia_socket *s); 128 - int (*adjust_io_region) (struct resource *res, 129 - unsigned long r_start, 130 - unsigned long r_end, 131 - struct pcmcia_socket *s); 132 - struct resource* (*find_io) (unsigned long base, int num, 133 - unsigned long align, 134 - struct pcmcia_socket *s); 135 - struct resource* (*find_mem) (unsigned long base, unsigned long num, 136 - unsigned long align, int low, 137 - struct pcmcia_socket *s); 138 - int (*add_io) (struct pcmcia_socket *s, 139 - unsigned int action, 140 - unsigned long r_start, 141 - unsigned long r_end); 142 - int (*add_mem) (struct pcmcia_socket *s, 143 - unsigned int action, 144 - unsigned long r_start, 145 - unsigned long r_end); 146 - int (*init) (struct pcmcia_socket *s); 147 - void (*exit) (struct pcmcia_socket *s); 148 - }; 149 - /* SS_CAP_STATIC_MAP */ 150 - extern struct pccard_resource_ops pccard_static_ops; 151 - /* !SS_CAP_STATIC_MAP */ 152 - extern struct pccard_resource_ops pccard_nonstatic_ops; 153 - 154 - /* static mem, dynamic IO sockets */ 155 - extern struct pccard_resource_ops pccard_iodyn_ops; 156 - 157 - /* 158 - * Calls to set up low-level "Socket Services" drivers 159 - */ 160 - struct pcmcia_socket; 161 104 162 105 typedef struct io_window_t { 163 106 u_int InUse, Config; ··· 122 179 /* Maximum number of memory windows per socket */ 123 180 #define MAX_WIN 4 124 181 182 + 183 + /* 184 + * Socket operations. 185 + */ 186 + struct pcmcia_socket; 187 + struct pccard_resource_ops; 125 188 struct config_t; 126 189 struct pcmcia_callback; 127 190 struct user_info_t; 191 + 192 + struct pccard_operations { 193 + int (*init)(struct pcmcia_socket *s); 194 + int (*suspend)(struct pcmcia_socket *s); 195 + int (*get_status)(struct pcmcia_socket *s, u_int *value); 196 + int (*set_socket)(struct pcmcia_socket *s, socket_state_t *state); 197 + int (*set_io_map)(struct pcmcia_socket *s, struct pccard_io_map *io); 198 + int (*set_mem_map)(struct pcmcia_socket *s, struct pccard_mem_map *mem); 199 + }; 128 200 129 201 struct pcmcia_socket { 130 202 struct module *owner; ··· 157 199 io_window_t io[MAX_IO_WIN]; 158 200 window_t win[MAX_WIN]; 159 201 struct list_head cis_cache; 160 - u_int fake_cis_len; 161 - char *fake_cis; 202 + size_t fake_cis_len; 203 + u8 *fake_cis; 162 204 163 205 struct list_head socket_list; 164 206 struct completion socket_released; ··· 176 218 struct pci_dev * cb_dev; 177 219 178 220 179 - /* socket setup is done so resources should be able to be allocated. Only 180 - * if set to 1, calls to find_{io,mem}_region are handled, and insertion 181 - * events are actually managed by the PCMCIA layer.*/ 221 + /* socket setup is done so resources should be able to be allocated. 222 + * Only if set to 1, calls to find_{io,mem}_region are handled, and 223 + * insertio events are actually managed by the PCMCIA layer.*/ 182 224 u8 resource_setup_done:1; 183 225 184 - /* is set to one if resource setup is done using adjust_resource_info() */ 226 + /* It's old if resource setup is done using adjust_resource_info() */ 185 227 u8 resource_setup_old:1; 186 228 u8 resource_setup_new:1; 187 229 ··· 194 236 195 237 /* Zoom video behaviour is so chip specific its not worth adding 196 238 this to _ops */ 197 - void (*zoom_video)(struct pcmcia_socket *, int); 239 + void (*zoom_video)(struct pcmcia_socket *, 240 + int); 198 241 199 242 /* so is power hook */ 200 243 int (*power_hook)(struct pcmcia_socket *sock, int operation); 201 - #ifdef CONFIG_CARDBUS 244 + 202 245 /* allows tuning the CB bridge before loading driver for the CB card */ 246 + #ifdef CONFIG_CARDBUS 203 247 void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus); 204 248 #endif 205 249 206 250 /* state thread */ 207 - struct mutex skt_mutex; /* protects socket h/w state */ 208 - 209 251 struct task_struct *thread; 210 252 struct completion thread_done; 211 - spinlock_t thread_lock; /* protects thread_events */ 212 253 unsigned int thread_events; 254 + /* protects socket h/w state */ 255 + struct mutex skt_mutex; 256 + /* protects thread_events */ 257 + spinlock_t thread_lock; 213 258 214 259 /* pcmcia (16-bit) */ 215 260 struct pcmcia_callback *callback; 216 261 217 262 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) 218 - struct list_head devices_list; /* PCMCIA devices */ 219 - u8 device_count; /* the number of devices, used 220 - * only internally and subject 221 - * to incorrectness and change */ 263 + /* The following elements refer to 16-bit PCMCIA devices inserted 264 + * into the socket */ 265 + struct list_head devices_list; 222 266 267 + /* the number of devices, used only internally and subject to 268 + * incorrectness and change */ 269 + u8 device_count; 270 + 271 + /* 16-bit state: */ 223 272 struct { 224 - u8 present:1, /* PCMCIA card is present in socket */ 225 - busy:1, /* "master" ioctl is used */ 226 - dead:1, /* pcmcia module is being unloaded */ 227 - device_add_pending:1, /* a multifunction-device 228 - * add event is pending */ 229 - mfc_pfc:1, /* the pending event adds a mfc (1) or pfc (0) */ 230 - reserved:3; 231 - } pcmcia_state; 273 + /* PCMCIA card is present in socket */ 274 + u8 present:1; 275 + /* "master" ioctl is used */ 276 + u8 busy:1; 277 + /* pcmcia module is being unloaded */ 278 + u8 dead:1; 279 + /* a multifunction-device add event is pending */ 280 + u8 device_add_pending:1; 281 + /* the pending event adds a mfc (1) or pfc (0) */ 282 + u8 mfc_pfc:1; 232 283 233 - struct work_struct device_add; /* for adding further pseudo-multifunction 234 - * devices */ 284 + u8 reserved:3; 285 + } pcmcia_state; 286 + 287 + 288 + /* for adding further pseudo-multifunction devices */ 289 + struct work_struct device_add; 235 290 236 291 #ifdef CONFIG_PCMCIA_IOCTL 237 292 struct user_info_t *user; 238 293 wait_queue_head_t queue; 239 - #endif 240 - #endif 294 + #endif /* CONFIG_PCMCIA_IOCTL */ 295 + #endif /* CONFIG_PCMCIA */ 241 296 242 297 /* cardbus (32-bit) */ 243 298 #ifdef CONFIG_CARDBUS 244 299 struct resource * cb_cis_res; 245 300 void __iomem *cb_cis_virt; 246 - #endif 301 + #endif /* CONFIG_CARDBUS */ 247 302 248 303 /* socket device */ 249 304 struct device dev; 250 - void *driver_data; /* data internal to the socket driver */ 251 - 305 + /* data internal to the socket driver */ 306 + void *driver_data; 252 307 }; 253 308 254 - struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr); 255 309 256 - 257 - 258 - extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events); 259 - extern int pcmcia_register_socket(struct pcmcia_socket *socket); 260 - extern void pcmcia_unregister_socket(struct pcmcia_socket *socket); 261 - 262 - extern struct class pcmcia_socket_class; 310 + /* socket drivers must define the resource operations type they use. There 311 + * are three options: 312 + * - pccard_static_ops iomem and ioport areas are assigned statically 313 + * - pccard_iodyn_ops iomem areas is assigned statically, ioport 314 + * areas dynamically 315 + * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically. 316 + * If this option is selected, use 317 + * "select PCCARD_NONSTATIC" in Kconfig. 318 + */ 319 + extern struct pccard_resource_ops pccard_static_ops; 320 + extern struct pccard_resource_ops pccard_iodyn_ops; 321 + extern struct pccard_resource_ops pccard_nonstatic_ops; 263 322 264 323 /* socket drivers are expected to use these callbacks in their .drv struct */ 265 324 extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state); 266 325 extern int pcmcia_socket_dev_resume(struct device *dev); 326 + 327 + /* socket drivers use this callback in their IRQ handler */ 328 + extern void pcmcia_parse_events(struct pcmcia_socket *socket, 329 + unsigned int events); 330 + 331 + /* to register and unregister a socket */ 332 + extern int pcmcia_register_socket(struct pcmcia_socket *socket); 333 + extern void pcmcia_unregister_socket(struct pcmcia_socket *socket); 334 + 267 335 268 336 #endif /* _LINUX_SS_H */