diff options
Diffstat (limited to 'drivers/char/pcmcia/synclink_cs.c')
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 80 |
1 files changed, 30 insertions, 50 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index caf6e4d19469..c31a0d913d37 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -554,7 +554,6 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
554 | 554 | ||
555 | /* Interrupt setup */ | 555 | /* Interrupt setup */ |
556 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; | 556 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
557 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | ||
558 | link->irq.Handler = NULL; | 557 | link->irq.Handler = NULL; |
559 | 558 | ||
560 | link->conf.Attributes = 0; | 559 | link->conf.Attributes = 0; |
@@ -572,69 +571,51 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
572 | /* Card has been inserted. | 571 | /* Card has been inserted. |
573 | */ | 572 | */ |
574 | 573 | ||
575 | #define CS_CHECK(fn, ret) \ | 574 | static int mgslpc_ioprobe(struct pcmcia_device *p_dev, |
576 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 575 | cistpl_cftable_entry_t *cfg, |
576 | cistpl_cftable_entry_t *dflt, | ||
577 | unsigned int vcc, | ||
578 | void *priv_data) | ||
579 | { | ||
580 | if (cfg->io.nwin > 0) { | ||
581 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
582 | if (!(cfg->io.flags & CISTPL_IO_8BIT)) | ||
583 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
584 | if (!(cfg->io.flags & CISTPL_IO_16BIT)) | ||
585 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
586 | p_dev->io.IOAddrLines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
587 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
588 | p_dev->io.NumPorts1 = cfg->io.win[0].len; | ||
589 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
590 | } | ||
591 | return -ENODEV; | ||
592 | } | ||
577 | 593 | ||
578 | static int mgslpc_config(struct pcmcia_device *link) | 594 | static int mgslpc_config(struct pcmcia_device *link) |
579 | { | 595 | { |
580 | MGSLPC_INFO *info = link->priv; | 596 | MGSLPC_INFO *info = link->priv; |
581 | tuple_t tuple; | 597 | int ret; |
582 | cisparse_t parse; | ||
583 | int last_fn, last_ret; | ||
584 | u_char buf[64]; | ||
585 | cistpl_cftable_entry_t dflt = { 0 }; | ||
586 | cistpl_cftable_entry_t *cfg; | ||
587 | 598 | ||
588 | if (debug_level >= DEBUG_LEVEL_INFO) | 599 | if (debug_level >= DEBUG_LEVEL_INFO) |
589 | printk("mgslpc_config(0x%p)\n", link); | 600 | printk("mgslpc_config(0x%p)\n", link); |
590 | 601 | ||
591 | tuple.Attributes = 0; | 602 | ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL); |
592 | tuple.TupleData = buf; | 603 | if (ret != 0) |
593 | tuple.TupleDataMax = sizeof(buf); | 604 | goto failed; |
594 | tuple.TupleOffset = 0; | ||
595 | |||
596 | /* get CIS configuration entry */ | ||
597 | |||
598 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
599 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
600 | |||
601 | cfg = &(parse.cftable_entry); | ||
602 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); | ||
603 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(&tuple, &parse)); | ||
604 | |||
605 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | ||
606 | if (cfg->index == 0) | ||
607 | goto cs_failed; | ||
608 | |||
609 | link->conf.ConfigIndex = cfg->index; | ||
610 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
611 | |||
612 | /* IO window settings */ | ||
613 | link->io.NumPorts1 = 0; | ||
614 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
615 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
616 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
617 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
618 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
619 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
620 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
621 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
622 | link->io.BasePort1 = io->win[0].base; | ||
623 | link->io.NumPorts1 = io->win[0].len; | ||
624 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); | ||
625 | } | ||
626 | 605 | ||
627 | link->conf.Attributes = CONF_ENABLE_IRQ; | 606 | link->conf.Attributes = CONF_ENABLE_IRQ; |
628 | link->conf.IntType = INT_MEMORY_AND_IO; | 607 | link->conf.IntType = INT_MEMORY_AND_IO; |
629 | link->conf.ConfigIndex = 8; | 608 | link->conf.ConfigIndex = 8; |
630 | link->conf.Present = PRESENT_OPTION; | 609 | link->conf.Present = PRESENT_OPTION; |
631 | 610 | ||
632 | link->irq.Attributes |= IRQ_HANDLE_PRESENT; | ||
633 | link->irq.Handler = mgslpc_isr; | 611 | link->irq.Handler = mgslpc_isr; |
634 | link->irq.Instance = info; | ||
635 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | ||
636 | 612 | ||
637 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 613 | ret = pcmcia_request_irq(link, &link->irq); |
614 | if (ret) | ||
615 | goto failed; | ||
616 | ret = pcmcia_request_configuration(link, &link->conf); | ||
617 | if (ret) | ||
618 | goto failed; | ||
638 | 619 | ||
639 | info->io_base = link->io.BasePort1; | 620 | info->io_base = link->io.BasePort1; |
640 | info->irq_level = link->irq.AssignedIRQ; | 621 | info->irq_level = link->irq.AssignedIRQ; |
@@ -654,8 +635,7 @@ static int mgslpc_config(struct pcmcia_device *link) | |||
654 | printk("\n"); | 635 | printk("\n"); |
655 | return 0; | 636 | return 0; |
656 | 637 | ||
657 | cs_failed: | 638 | failed: |
658 | cs_error(link, last_fn, last_ret); | ||
659 | mgslpc_release((u_long)link); | 639 | mgslpc_release((u_long)link); |
660 | return -ENODEV; | 640 | return -ENODEV; |
661 | } | 641 | } |