diff options
Diffstat (limited to 'drivers/char/pcmcia/cm4040_cs.c')
-rw-r--r-- | drivers/char/pcmcia/cm4040_cs.c | 76 |
1 files changed, 30 insertions, 46 deletions
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 0b5934bef7a4..e0f5d8c9b266 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 | void *priv_data) | ||
530 | { | 532 | { |
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; | 533 | int rc; |
534 | p_dev->conf.ConfigIndex = cfg->index; | ||
535 | |||
536 | if (!cfg->io.nwin) | ||
537 | return -ENODEV; | ||
537 | 538 | ||
538 | tuple.Attributes = 0; | 539 | /* Get the IOaddr */ |
539 | tuple.TupleData = buf; | 540 | p_dev->io.BasePort1 = cfg->io.win[0].base; |
540 | tuple.TupleDataMax = sizeof(buf); | 541 | p_dev->io.NumPorts1 = cfg->io.win[0].len; |
541 | tuple.TupleOffset = 0; | 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 | |||
556 | static int reader_config(struct pcmcia_device *link, int devno) | ||
557 | { | ||
558 | struct reader_dev *dev; | ||
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 | if ((fail_rc = pcmcia_request_configuration(link,&link->conf)) |
586 | !=CS_SUCCESS) { | 571 | !=CS_SUCCESS) { |
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); |