aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/smc91c92_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/pcmcia/smc91c92_cs.c')
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c151
1 files changed, 65 insertions, 86 deletions
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 250eb1954c34..c74d6656d266 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -409,10 +409,13 @@ static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple,
409{ 409{
410 int i; 410 int i;
411 411
412 if ((i = pcmcia_get_first_tuple(handle, tuple)) != CS_SUCCESS || 412 i = pcmcia_get_first_tuple(handle, tuple);
413 (i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS) 413 if (i != 0)
414 return i; 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
418static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 421static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple,
@@ -420,10 +423,10 @@ static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple,
420{ 423{
421 int i; 424 int i;
422 425
423 if ((i = pcmcia_get_next_tuple(handle, tuple)) != CS_SUCCESS || 426 if ((i = pcmcia_get_next_tuple(handle, tuple)) != 0 ||
424 (i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS) 427 (i = pcmcia_get_tuple_data(handle, tuple)) != 0)
425 return i; 428 return i;
426 return pcmcia_parse_tuple(handle, tuple, parse); 429 return pcmcia_parse_tuple(tuple, parse);
427} 430}
428 431
429/*====================================================================== 432/*======================================================================
@@ -459,27 +462,36 @@ static int mhz_3288_power(struct pcmcia_device *link)
459 return 0; 462 return 0;
460} 463}
461 464
465static int mhz_mfc_config_check(struct pcmcia_device *p_dev,
466 cistpl_cftable_entry_t *cf,
467 cistpl_cftable_entry_t *dflt,
468 unsigned int vcc,
469 void *priv_data)
470{
471 int k;
472 p_dev->io.BasePort2 = cf->io.win[0].base;
473 for (k = 0; k < 0x400; k += 0x10) {
474 if (k & 0x80)
475 continue;
476 p_dev->io.BasePort1 = k ^ 0x300;
477 if (!pcmcia_request_io(p_dev, &p_dev->io))
478 return 0;
479 }
480 return -ENODEV;
481}
482
462static int mhz_mfc_config(struct pcmcia_device *link) 483static int mhz_mfc_config(struct pcmcia_device *link)
463{ 484{
464 struct net_device *dev = link->priv; 485 struct net_device *dev = link->priv;
465 struct smc_private *smc = netdev_priv(dev); 486 struct smc_private *smc = netdev_priv(dev);
466 struct smc_cfg_mem *cfg_mem; 487 struct smc_cfg_mem *cfg_mem;
467 tuple_t *tuple;
468 cisparse_t *parse;
469 cistpl_cftable_entry_t *cf;
470 u_char *buf;
471 win_req_t req; 488 win_req_t req;
472 memreq_t mem; 489 memreq_t mem;
473 int i, k; 490 int i;
474 491
475 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 492 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
476 if (!cfg_mem) 493 if (!cfg_mem)
477 return CS_OUT_OF_RESOURCE; 494 return -ENOMEM;
478
479 tuple = &cfg_mem->tuple;
480 parse = &cfg_mem->parse;
481 cf = &parse->cftable_entry;
482 buf = cfg_mem->buf;
483 495
484 link->conf.Attributes |= CONF_ENABLE_SPKR; 496 link->conf.Attributes |= CONF_ENABLE_SPKR;
485 link->conf.Status = CCSR_AUDIO_ENA; 497 link->conf.Status = CCSR_AUDIO_ENA;
@@ -489,27 +501,9 @@ static int mhz_mfc_config(struct pcmcia_device *link)
489 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 501 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
490 link->io.NumPorts2 = 8; 502 link->io.NumPorts2 = 8;
491 503
492 tuple->Attributes = tuple->TupleOffset = 0;
493 tuple->TupleData = (cisdata_t *)buf;
494 tuple->TupleDataMax = 255;
495 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
496
497 i = first_tuple(link, tuple, parse);
498 /* The Megahertz combo cards have modem-like CIS entries, so 504 /* The Megahertz combo cards have modem-like CIS entries, so
499 we have to explicitly try a bunch of port combinations. */ 505 we have to explicitly try a bunch of port combinations. */
500 while (i == CS_SUCCESS) { 506 if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL))
501 link->conf.ConfigIndex = cf->index;
502 link->io.BasePort2 = cf->io.win[0].base;
503 for (k = 0; k < 0x400; k += 0x10) {
504 if (k & 0x80) continue;
505 link->io.BasePort1 = k ^ 0x300;
506 i = pcmcia_request_io(link, &link->io);
507 if (i == CS_SUCCESS) break;
508 }
509 if (i == CS_SUCCESS) break;
510 i = next_tuple(link, tuple, parse);
511 }
512 if (i != CS_SUCCESS)
513 goto free_cfg_mem; 507 goto free_cfg_mem;
514 dev->base_addr = link->io.BasePort1; 508 dev->base_addr = link->io.BasePort1;
515 509
@@ -518,7 +512,7 @@ static int mhz_mfc_config(struct pcmcia_device *link)
518 req.Base = req.Size = 0; 512 req.Base = req.Size = 0;
519 req.AccessSpeed = 0; 513 req.AccessSpeed = 0;
520 i = pcmcia_request_window(&link, &req, &link->win); 514 i = pcmcia_request_window(&link, &req, &link->win);
521 if (i != CS_SUCCESS) 515 if (i != 0)
522 goto free_cfg_mem; 516 goto free_cfg_mem;
523 smc->base = ioremap(req.Base, req.Size); 517 smc->base = ioremap(req.Base, req.Size);
524 mem.CardOffset = mem.Page = 0; 518 mem.CardOffset = mem.Page = 0;
@@ -526,14 +520,14 @@ static int mhz_mfc_config(struct pcmcia_device *link)
526 mem.CardOffset = link->conf.ConfigBase; 520 mem.CardOffset = link->conf.ConfigBase;
527 i = pcmcia_map_mem_page(link->win, &mem); 521 i = pcmcia_map_mem_page(link->win, &mem);
528 522
529 if ((i == CS_SUCCESS) 523 if ((i == 0)
530 && (smc->manfid == MANFID_MEGAHERTZ) 524 && (smc->manfid == MANFID_MEGAHERTZ)
531 && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 525 && (smc->cardid == PRODID_MEGAHERTZ_EM3288))
532 mhz_3288_power(link); 526 mhz_3288_power(link);
533 527
534free_cfg_mem: 528free_cfg_mem:
535 kfree(cfg_mem); 529 kfree(cfg_mem);
536 return i; 530 return -ENODEV;
537} 531}
538 532
539static int mhz_setup(struct pcmcia_device *link) 533static int mhz_setup(struct pcmcia_device *link)
@@ -560,12 +554,12 @@ static int mhz_setup(struct pcmcia_device *link)
560 /* Read the station address from the CIS. It is stored as the last 554 /* Read the station address from the CIS. It is stored as the last
561 (fourth) string in the Version 1 Version/ID tuple. */ 555 (fourth) string in the Version 1 Version/ID tuple. */
562 tuple->DesiredTuple = CISTPL_VERS_1; 556 tuple->DesiredTuple = CISTPL_VERS_1;
563 if (first_tuple(link, tuple, parse) != CS_SUCCESS) { 557 if (first_tuple(link, tuple, parse) != 0) {
564 rc = -1; 558 rc = -1;
565 goto free_cfg_mem; 559 goto free_cfg_mem;
566 } 560 }
567 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ 561 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */
568 if (next_tuple(link, tuple, parse) != CS_SUCCESS) 562 if (next_tuple(link, tuple, parse) != 0)
569 first_tuple(link, tuple, parse); 563 first_tuple(link, tuple, parse);
570 if (parse->version_1.ns > 3) { 564 if (parse->version_1.ns > 3) {
571 station_addr = parse->version_1.str + parse->version_1.ofs[3]; 565 station_addr = parse->version_1.str + parse->version_1.ofs[3];
@@ -577,11 +571,11 @@ static int mhz_setup(struct pcmcia_device *link)
577 571
578 /* Another possibility: for the EM3288, in a special tuple */ 572 /* Another possibility: for the EM3288, in a special tuple */
579 tuple->DesiredTuple = 0x81; 573 tuple->DesiredTuple = 0x81;
580 if (pcmcia_get_first_tuple(link, tuple) != CS_SUCCESS) { 574 if (pcmcia_get_first_tuple(link, tuple) != 0) {
581 rc = -1; 575 rc = -1;
582 goto free_cfg_mem; 576 goto free_cfg_mem;
583 } 577 }
584 if (pcmcia_get_tuple_data(link, tuple) != CS_SUCCESS) { 578 if (pcmcia_get_tuple_data(link, tuple) != 0) {
585 rc = -1; 579 rc = -1;
586 goto free_cfg_mem; 580 goto free_cfg_mem;
587 } 581 }
@@ -660,46 +654,27 @@ static int mot_setup(struct pcmcia_device *link)
660 654
661/*====================================================================*/ 655/*====================================================================*/
662 656
657static int smc_configcheck(struct pcmcia_device *p_dev,
658 cistpl_cftable_entry_t *cf,
659 cistpl_cftable_entry_t *dflt,
660 unsigned int vcc,
661 void *priv_data)
662{
663 p_dev->io.BasePort1 = cf->io.win[0].base;
664 p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
665 return pcmcia_request_io(p_dev, &p_dev->io);
666}
667
663static int smc_config(struct pcmcia_device *link) 668static int smc_config(struct pcmcia_device *link)
664{ 669{
665 struct net_device *dev = link->priv; 670 struct net_device *dev = link->priv;
666 struct smc_cfg_mem *cfg_mem;
667 tuple_t *tuple;
668 cisparse_t *parse;
669 cistpl_cftable_entry_t *cf;
670 u_char *buf;
671 int i; 671 int i;
672 672
673 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
674 if (!cfg_mem)
675 return CS_OUT_OF_RESOURCE;
676
677 tuple = &cfg_mem->tuple;
678 parse = &cfg_mem->parse;
679 cf = &parse->cftable_entry;
680 buf = cfg_mem->buf;
681
682 tuple->Attributes = tuple->TupleOffset = 0;
683 tuple->TupleData = (cisdata_t *)buf;
684 tuple->TupleDataMax = 255;
685 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
686
687 link->io.NumPorts1 = 16; 673 link->io.NumPorts1 = 16;
688 i = first_tuple(link, tuple, parse); 674 i = pcmcia_loop_config(link, smc_configcheck, NULL);
689 while (i != CS_NO_MORE_ITEMS) { 675 if (!i)
690 if (i == CS_SUCCESS) { 676 dev->base_addr = link->io.BasePort1;
691 link->conf.ConfigIndex = cf->index;
692 link->io.BasePort1 = cf->io.win[0].base;
693 link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
694 i = pcmcia_request_io(link, &link->io);
695 if (i == CS_SUCCESS) break;
696 }
697 i = next_tuple(link, tuple, parse);
698 }
699 if (i == CS_SUCCESS)
700 dev->base_addr = link->io.BasePort1;
701 677
702 kfree(cfg_mem);
703 return i; 678 return i;
704} 679}
705 680
@@ -715,7 +690,7 @@ static int smc_setup(struct pcmcia_device *link)
715 690
716 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 691 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL);
717 if (!cfg_mem) 692 if (!cfg_mem)
718 return CS_OUT_OF_RESOURCE; 693 return -ENOMEM;
719 694
720 tuple = &cfg_mem->tuple; 695 tuple = &cfg_mem->tuple;
721 parse = &cfg_mem->parse; 696 parse = &cfg_mem->parse;
@@ -728,12 +703,12 @@ static int smc_setup(struct pcmcia_device *link)
728 /* Check for a LAN function extension tuple */ 703 /* Check for a LAN function extension tuple */
729 tuple->DesiredTuple = CISTPL_FUNCE; 704 tuple->DesiredTuple = CISTPL_FUNCE;
730 i = first_tuple(link, tuple, parse); 705 i = first_tuple(link, tuple, parse);
731 while (i == CS_SUCCESS) { 706 while (i == 0) {
732 if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) 707 if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID)
733 break; 708 break;
734 i = next_tuple(link, tuple, parse); 709 i = next_tuple(link, tuple, parse);
735 } 710 }
736 if (i == CS_SUCCESS) { 711 if (i == 0) {
737 node_id = (cistpl_lan_node_id_t *)parse->funce.data; 712 node_id = (cistpl_lan_node_id_t *)parse->funce.data;
738 if (node_id->nb == 6) { 713 if (node_id->nb == 6) {
739 for (i = 0; i < 6; i++) 714 for (i = 0; i < 6; i++)
@@ -780,9 +755,10 @@ static int osi_config(struct pcmcia_device *link)
780 for (i = j = 0; j < 4; j++) { 755 for (i = j = 0; j < 4; j++) {
781 link->io.BasePort2 = com[j]; 756 link->io.BasePort2 = com[j];
782 i = pcmcia_request_io(link, &link->io); 757 i = pcmcia_request_io(link, &link->io);
783 if (i == CS_SUCCESS) break; 758 if (i == 0)
759 break;
784 } 760 }
785 if (i != CS_SUCCESS) { 761 if (i != 0) {
786 /* Fallback: turn off hard decode */ 762 /* Fallback: turn off hard decode */
787 link->conf.ConfigIndex = 0x03; 763 link->conf.ConfigIndex = 0x03;
788 link->io.NumPorts2 = 0; 764 link->io.NumPorts2 = 0;
@@ -815,13 +791,13 @@ static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid)
815 /* Read the station address from tuple 0x90, subtuple 0x04 */ 791 /* Read the station address from tuple 0x90, subtuple 0x04 */
816 tuple->DesiredTuple = 0x90; 792 tuple->DesiredTuple = 0x90;
817 i = pcmcia_get_first_tuple(link, tuple); 793 i = pcmcia_get_first_tuple(link, tuple);
818 while (i == CS_SUCCESS) { 794 while (i == 0) {
819 i = pcmcia_get_tuple_data(link, tuple); 795 i = pcmcia_get_tuple_data(link, tuple);
820 if ((i != CS_SUCCESS) || (buf[0] == 0x04)) 796 if ((i != 0) || (buf[0] == 0x04))
821 break; 797 break;
822 i = pcmcia_get_next_tuple(link, tuple); 798 i = pcmcia_get_next_tuple(link, tuple);
823 } 799 }
824 if (i != CS_SUCCESS) { 800 if (i != 0) {
825 rc = -1; 801 rc = -1;
826 goto free_cfg_mem; 802 goto free_cfg_mem;
827 } 803 }
@@ -959,8 +935,11 @@ static int check_sig(struct pcmcia_device *link)
959 935
960======================================================================*/ 936======================================================================*/
961 937
962#define CS_EXIT_TEST(ret, svc, label) \ 938#define CS_EXIT_TEST(ret, svc, label) \
963if (ret != CS_SUCCESS) { cs_error(link, svc, ret); goto label; } 939if (ret != 0) { \
940 cs_error(link, svc, ret); \
941 goto label; \
942}
964 943
965static int smc91c92_config(struct pcmcia_device *link) 944static int smc91c92_config(struct pcmcia_device *link)
966{ 945{