diff options
Diffstat (limited to 'drivers/char/pcmcia/cm4040_cs.c')
-rw-r--r-- | drivers/char/pcmcia/cm4040_cs.c | 80 |
1 files changed, 32 insertions, 48 deletions
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 0b5934bef7a4..2d7c906435b7 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c | |||
@@ -526,65 +526,49 @@ static void cm4040_reader_release(struct pcmcia_device *link) | |||
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | 528 | ||
529 | static int reader_config(struct pcmcia_device *link, int devno) | 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) | ||
530 | { | 534 | { |
531 | 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; | 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 | |||
537 | 555 | ||
538 | tuple.Attributes = 0; | 556 | static int reader_config(struct pcmcia_device *link, int devno) |
539 | tuple.TupleData = buf; | 557 | { |
540 | tuple.TupleDataMax = sizeof(buf); | 558 | struct reader_dev *dev; |
541 | tuple.TupleOffset = 0; | 559 | int fail_rc; |
542 | 560 | ||
543 | link->io.BasePort2 = 0; | 561 | link->io.BasePort2 = 0; |
544 | link->io.NumPorts2 = 0; | 562 | link->io.NumPorts2 = 0; |
545 | link->io.Attributes2 = 0; | 563 | link->io.Attributes2 = 0; |
546 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 564 | |
547 | for (rc = pcmcia_get_first_tuple(link, &tuple); | 565 | if (pcmcia_loop_config(link, cm4040_config_check, NULL)) |
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 | |||
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) | ||
581 | goto cs_release; | 566 | goto cs_release; |
582 | 567 | ||
583 | link->conf.IntType = 00000002; | 568 | link->conf.IntType = 00000002; |
584 | 569 | ||
585 | if ((fail_rc = pcmcia_request_configuration(link,&link->conf)) | 570 | fail_rc = pcmcia_request_configuration(link, &link->conf); |
586 | !=CS_SUCCESS) { | 571 | if (fail_rc != 0) { |
587 | fail_fn = RequestConfiguration; | ||
588 | dev_printk(KERN_INFO, &handle_to_dev(link), | 572 | dev_printk(KERN_INFO, &handle_to_dev(link), |
589 | "pcmcia_request_configuration failed 0x%x\n", | 573 | "pcmcia_request_configuration failed 0x%x\n", |
590 | fail_rc); | 574 | fail_rc); |