diff options
Diffstat (limited to 'drivers/net/pcmcia/smc91c92_cs.c')
-rw-r--r-- | drivers/net/pcmcia/smc91c92_cs.c | 340 |
1 files changed, 106 insertions, 234 deletions
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 7bde2cd34c7e..9e0da370912e 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -79,14 +79,6 @@ MODULE_FIRMWARE(FIRMWARE_NAME); | |||
79 | */ | 79 | */ |
80 | INT_MODULE_PARM(if_port, 0); | 80 | INT_MODULE_PARM(if_port, 0); |
81 | 81 | ||
82 | #ifdef PCMCIA_DEBUG | ||
83 | INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); | ||
84 | static const char *version = | ||
85 | "smc91c92_cs.c 1.123 2006/11/09 Donald Becker, becker@scyld.com.\n"; | ||
86 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) | ||
87 | #else | ||
88 | #define DEBUG(n, args...) | ||
89 | #endif | ||
90 | 82 | ||
91 | #define DRV_NAME "smc91c92_cs" | 83 | #define DRV_NAME "smc91c92_cs" |
92 | #define DRV_VERSION "1.123" | 84 | #define DRV_VERSION "1.123" |
@@ -126,12 +118,6 @@ struct smc_private { | |||
126 | int rx_ovrn; | 118 | int rx_ovrn; |
127 | }; | 119 | }; |
128 | 120 | ||
129 | struct smc_cfg_mem { | ||
130 | tuple_t tuple; | ||
131 | cisparse_t parse; | ||
132 | u_char buf[255]; | ||
133 | }; | ||
134 | |||
135 | /* Special definitions for Megahertz multifunction cards */ | 121 | /* Special definitions for Megahertz multifunction cards */ |
136 | #define MEGAHERTZ_ISR 0x0380 | 122 | #define MEGAHERTZ_ISR 0x0380 |
137 | 123 | ||
@@ -329,7 +315,7 @@ static int smc91c92_probe(struct pcmcia_device *link) | |||
329 | struct smc_private *smc; | 315 | struct smc_private *smc; |
330 | struct net_device *dev; | 316 | struct net_device *dev; |
331 | 317 | ||
332 | DEBUG(0, "smc91c92_attach()\n"); | 318 | dev_dbg(&link->dev, "smc91c92_attach()\n"); |
333 | 319 | ||
334 | /* Create new ethernet device */ | 320 | /* Create new ethernet device */ |
335 | dev = alloc_etherdev(sizeof(struct smc_private)); | 321 | dev = alloc_etherdev(sizeof(struct smc_private)); |
@@ -343,10 +329,8 @@ static int smc91c92_probe(struct pcmcia_device *link) | |||
343 | link->io.NumPorts1 = 16; | 329 | link->io.NumPorts1 = 16; |
344 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 330 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
345 | link->io.IOAddrLines = 4; | 331 | link->io.IOAddrLines = 4; |
346 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; | 332 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
347 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | ||
348 | link->irq.Handler = &smc_interrupt; | 333 | link->irq.Handler = &smc_interrupt; |
349 | link->irq.Instance = dev; | ||
350 | link->conf.Attributes = CONF_ENABLE_IRQ; | 334 | link->conf.Attributes = CONF_ENABLE_IRQ; |
351 | link->conf.IntType = INT_MEMORY_AND_IO; | 335 | link->conf.IntType = INT_MEMORY_AND_IO; |
352 | 336 | ||
@@ -377,7 +361,7 @@ static void smc91c92_detach(struct pcmcia_device *link) | |||
377 | { | 361 | { |
378 | struct net_device *dev = link->priv; | 362 | struct net_device *dev = link->priv; |
379 | 363 | ||
380 | DEBUG(0, "smc91c92_detach(0x%p)\n", link); | 364 | dev_dbg(&link->dev, "smc91c92_detach\n"); |
381 | 365 | ||
382 | if (link->dev_node) | 366 | if (link->dev_node) |
383 | unregister_netdev(dev); | 367 | unregister_netdev(dev); |
@@ -408,34 +392,7 @@ static int cvt_ascii_address(struct net_device *dev, char *s) | |||
408 | return 0; | 392 | return 0; |
409 | } | 393 | } |
410 | 394 | ||
411 | /*====================================================================*/ | 395 | /*==================================================================== |
412 | |||
413 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
414 | cisparse_t *parse) | ||
415 | { | ||
416 | int i; | ||
417 | |||
418 | i = pcmcia_get_first_tuple(handle, tuple); | ||
419 | if (i != 0) | ||
420 | return i; | ||
421 | i = pcmcia_get_tuple_data(handle, tuple); | ||
422 | if (i != 0) | ||
423 | return i; | ||
424 | return pcmcia_parse_tuple(tuple, parse); | ||
425 | } | ||
426 | |||
427 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
428 | cisparse_t *parse) | ||
429 | { | ||
430 | int i; | ||
431 | |||
432 | if ((i = pcmcia_get_next_tuple(handle, tuple)) != 0 || | ||
433 | (i = pcmcia_get_tuple_data(handle, tuple)) != 0) | ||
434 | return i; | ||
435 | return pcmcia_parse_tuple(tuple, parse); | ||
436 | } | ||
437 | |||
438 | /*====================================================================== | ||
439 | 396 | ||
440 | Configuration stuff for Megahertz cards | 397 | Configuration stuff for Megahertz cards |
441 | 398 | ||
@@ -490,19 +447,14 @@ static int mhz_mfc_config(struct pcmcia_device *link) | |||
490 | { | 447 | { |
491 | struct net_device *dev = link->priv; | 448 | struct net_device *dev = link->priv; |
492 | struct smc_private *smc = netdev_priv(dev); | 449 | struct smc_private *smc = netdev_priv(dev); |
493 | struct smc_cfg_mem *cfg_mem; | ||
494 | win_req_t req; | 450 | win_req_t req; |
495 | memreq_t mem; | 451 | memreq_t mem; |
496 | int i; | 452 | int i; |
497 | 453 | ||
498 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | ||
499 | if (!cfg_mem) | ||
500 | return -ENOMEM; | ||
501 | |||
502 | link->conf.Attributes |= CONF_ENABLE_SPKR; | 454 | link->conf.Attributes |= CONF_ENABLE_SPKR; |
503 | link->conf.Status = CCSR_AUDIO_ENA; | 455 | link->conf.Status = CCSR_AUDIO_ENA; |
504 | link->irq.Attributes = | 456 | link->irq.Attributes = |
505 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT; | 457 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; |
506 | link->io.IOAddrLines = 16; | 458 | link->io.IOAddrLines = 16; |
507 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; | 459 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; |
508 | link->io.NumPorts2 = 8; | 460 | link->io.NumPorts2 = 8; |
@@ -510,91 +462,80 @@ static int mhz_mfc_config(struct pcmcia_device *link) | |||
510 | /* The Megahertz combo cards have modem-like CIS entries, so | 462 | /* The Megahertz combo cards have modem-like CIS entries, so |
511 | we have to explicitly try a bunch of port combinations. */ | 463 | we have to explicitly try a bunch of port combinations. */ |
512 | if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL)) | 464 | if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL)) |
513 | goto free_cfg_mem; | 465 | return -ENODEV; |
466 | |||
514 | dev->base_addr = link->io.BasePort1; | 467 | dev->base_addr = link->io.BasePort1; |
515 | 468 | ||
516 | /* Allocate a memory window, for accessing the ISR */ | 469 | /* Allocate a memory window, for accessing the ISR */ |
517 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; | 470 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; |
518 | req.Base = req.Size = 0; | 471 | req.Base = req.Size = 0; |
519 | req.AccessSpeed = 0; | 472 | req.AccessSpeed = 0; |
520 | i = pcmcia_request_window(&link, &req, &link->win); | 473 | i = pcmcia_request_window(link, &req, &link->win); |
521 | if (i != 0) | 474 | if (i != 0) |
522 | goto free_cfg_mem; | 475 | return -ENODEV; |
476 | |||
523 | smc->base = ioremap(req.Base, req.Size); | 477 | smc->base = ioremap(req.Base, req.Size); |
524 | mem.CardOffset = mem.Page = 0; | 478 | mem.CardOffset = mem.Page = 0; |
525 | if (smc->manfid == MANFID_MOTOROLA) | 479 | if (smc->manfid == MANFID_MOTOROLA) |
526 | mem.CardOffset = link->conf.ConfigBase; | 480 | mem.CardOffset = link->conf.ConfigBase; |
527 | i = pcmcia_map_mem_page(link->win, &mem); | 481 | i = pcmcia_map_mem_page(link, link->win, &mem); |
528 | 482 | ||
529 | if ((i == 0) | 483 | if ((i == 0) |
530 | && (smc->manfid == MANFID_MEGAHERTZ) | 484 | && (smc->manfid == MANFID_MEGAHERTZ) |
531 | && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) | 485 | && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) |
532 | mhz_3288_power(link); | 486 | mhz_3288_power(link); |
533 | 487 | ||
534 | free_cfg_mem: | 488 | return 0; |
535 | kfree(cfg_mem); | ||
536 | return -ENODEV; | ||
537 | } | 489 | } |
538 | 490 | ||
539 | static int mhz_setup(struct pcmcia_device *link) | 491 | static int pcmcia_get_versmac(struct pcmcia_device *p_dev, |
492 | tuple_t *tuple, | ||
493 | void *priv) | ||
540 | { | 494 | { |
541 | struct net_device *dev = link->priv; | 495 | struct net_device *dev = priv; |
542 | struct smc_cfg_mem *cfg_mem; | 496 | cisparse_t parse; |
543 | tuple_t *tuple; | ||
544 | cisparse_t *parse; | ||
545 | u_char *buf, *station_addr; | ||
546 | int rc; | ||
547 | 497 | ||
548 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | 498 | if (pcmcia_parse_tuple(tuple, &parse)) |
549 | if (!cfg_mem) | 499 | return -EINVAL; |
550 | return -1; | ||
551 | 500 | ||
552 | tuple = &cfg_mem->tuple; | 501 | if ((parse.version_1.ns > 3) && |
553 | parse = &cfg_mem->parse; | 502 | (cvt_ascii_address(dev, |
554 | buf = cfg_mem->buf; | 503 | (parse.version_1.str + parse.version_1.ofs[3])))) |
504 | return 0; | ||
555 | 505 | ||
556 | tuple->Attributes = tuple->TupleOffset = 0; | 506 | return -EINVAL; |
557 | tuple->TupleData = (cisdata_t *)buf; | 507 | }; |
558 | tuple->TupleDataMax = 255; | 508 | |
509 | static int mhz_setup(struct pcmcia_device *link) | ||
510 | { | ||
511 | struct net_device *dev = link->priv; | ||
512 | size_t len; | ||
513 | u8 *buf; | ||
514 | int rc; | ||
559 | 515 | ||
560 | /* Read the station address from the CIS. It is stored as the last | 516 | /* Read the station address from the CIS. It is stored as the last |
561 | (fourth) string in the Version 1 Version/ID tuple. */ | 517 | (fourth) string in the Version 1 Version/ID tuple. */ |
562 | tuple->DesiredTuple = CISTPL_VERS_1; | 518 | if ((link->prod_id[3]) && |
563 | if (first_tuple(link, tuple, parse) != 0) { | 519 | (cvt_ascii_address(dev, link->prod_id[3]) == 0)) |
564 | rc = -1; | 520 | return 0; |
565 | goto free_cfg_mem; | 521 | |
566 | } | 522 | /* Workarounds for broken cards start here. */ |
567 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ | 523 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ |
568 | if (next_tuple(link, tuple, parse) != 0) | 524 | if (!pcmcia_loop_tuple(link, CISTPL_VERS_1, pcmcia_get_versmac, dev)) |
569 | first_tuple(link, tuple, parse); | 525 | return 0; |
570 | if (parse->version_1.ns > 3) { | ||
571 | station_addr = parse->version_1.str + parse->version_1.ofs[3]; | ||
572 | if (cvt_ascii_address(dev, station_addr) == 0) { | ||
573 | rc = 0; | ||
574 | goto free_cfg_mem; | ||
575 | } | ||
576 | } | ||
577 | 526 | ||
578 | /* Another possibility: for the EM3288, in a special tuple */ | 527 | /* Another possibility: for the EM3288, in a special tuple */ |
579 | tuple->DesiredTuple = 0x81; | ||
580 | if (pcmcia_get_first_tuple(link, tuple) != 0) { | ||
581 | rc = -1; | ||
582 | goto free_cfg_mem; | ||
583 | } | ||
584 | if (pcmcia_get_tuple_data(link, tuple) != 0) { | ||
585 | rc = -1; | ||
586 | goto free_cfg_mem; | ||
587 | } | ||
588 | buf[12] = '\0'; | ||
589 | if (cvt_ascii_address(dev, buf) == 0) { | ||
590 | rc = 0; | ||
591 | goto free_cfg_mem; | ||
592 | } | ||
593 | rc = -1; | 528 | rc = -1; |
594 | free_cfg_mem: | 529 | len = pcmcia_get_tuple(link, 0x81, &buf); |
595 | kfree(cfg_mem); | 530 | if (buf && len >= 13) { |
596 | return rc; | 531 | buf[12] = '\0'; |
597 | } | 532 | if (cvt_ascii_address(dev, buf)) |
533 | rc = 0; | ||
534 | } | ||
535 | kfree(buf); | ||
536 | |||
537 | return rc; | ||
538 | }; | ||
598 | 539 | ||
599 | /*====================================================================== | 540 | /*====================================================================== |
600 | 541 | ||
@@ -684,58 +625,21 @@ static int smc_config(struct pcmcia_device *link) | |||
684 | return i; | 625 | return i; |
685 | } | 626 | } |
686 | 627 | ||
628 | |||
687 | static int smc_setup(struct pcmcia_device *link) | 629 | static int smc_setup(struct pcmcia_device *link) |
688 | { | 630 | { |
689 | struct net_device *dev = link->priv; | 631 | struct net_device *dev = link->priv; |
690 | struct smc_cfg_mem *cfg_mem; | ||
691 | tuple_t *tuple; | ||
692 | cisparse_t *parse; | ||
693 | cistpl_lan_node_id_t *node_id; | ||
694 | u_char *buf, *station_addr; | ||
695 | int i, rc; | ||
696 | |||
697 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | ||
698 | if (!cfg_mem) | ||
699 | return -ENOMEM; | ||
700 | |||
701 | tuple = &cfg_mem->tuple; | ||
702 | parse = &cfg_mem->parse; | ||
703 | buf = cfg_mem->buf; | ||
704 | |||
705 | tuple->Attributes = tuple->TupleOffset = 0; | ||
706 | tuple->TupleData = (cisdata_t *)buf; | ||
707 | tuple->TupleDataMax = 255; | ||
708 | 632 | ||
709 | /* Check for a LAN function extension tuple */ | 633 | /* Check for a LAN function extension tuple */ |
710 | tuple->DesiredTuple = CISTPL_FUNCE; | 634 | if (!pcmcia_get_mac_from_cis(link, dev)) |
711 | i = first_tuple(link, tuple, parse); | 635 | return 0; |
712 | while (i == 0) { | 636 | |
713 | if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) | ||
714 | break; | ||
715 | i = next_tuple(link, tuple, parse); | ||
716 | } | ||
717 | if (i == 0) { | ||
718 | node_id = (cistpl_lan_node_id_t *)parse->funce.data; | ||
719 | if (node_id->nb == 6) { | ||
720 | for (i = 0; i < 6; i++) | ||
721 | dev->dev_addr[i] = node_id->id[i]; | ||
722 | rc = 0; | ||
723 | goto free_cfg_mem; | ||
724 | } | ||
725 | } | ||
726 | /* Try the third string in the Version 1 Version/ID tuple. */ | 637 | /* Try the third string in the Version 1 Version/ID tuple. */ |
727 | if (link->prod_id[2]) { | 638 | if (link->prod_id[2]) { |
728 | station_addr = link->prod_id[2]; | 639 | if (cvt_ascii_address(dev, link->prod_id[2]) == 0) |
729 | if (cvt_ascii_address(dev, station_addr) == 0) { | 640 | return 0; |
730 | rc = 0; | ||
731 | goto free_cfg_mem; | ||
732 | } | ||
733 | } | 641 | } |
734 | 642 | return -1; | |
735 | rc = -1; | ||
736 | free_cfg_mem: | ||
737 | kfree(cfg_mem); | ||
738 | return rc; | ||
739 | } | 643 | } |
740 | 644 | ||
741 | /*====================================================================*/ | 645 | /*====================================================================*/ |
@@ -749,7 +653,7 @@ static int osi_config(struct pcmcia_device *link) | |||
749 | link->conf.Attributes |= CONF_ENABLE_SPKR; | 653 | link->conf.Attributes |= CONF_ENABLE_SPKR; |
750 | link->conf.Status = CCSR_AUDIO_ENA; | 654 | link->conf.Status = CCSR_AUDIO_ENA; |
751 | link->irq.Attributes = | 655 | link->irq.Attributes = |
752 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT; | 656 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; |
753 | link->io.NumPorts1 = 64; | 657 | link->io.NumPorts1 = 64; |
754 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; | 658 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; |
755 | link->io.NumPorts2 = 8; | 659 | link->io.NumPorts2 = 8; |
@@ -794,41 +698,31 @@ static int osi_load_firmware(struct pcmcia_device *link) | |||
794 | return err; | 698 | return err; |
795 | } | 699 | } |
796 | 700 | ||
797 | static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid) | 701 | static int pcmcia_osi_mac(struct pcmcia_device *p_dev, |
702 | tuple_t *tuple, | ||
703 | void *priv) | ||
798 | { | 704 | { |
799 | struct net_device *dev = link->priv; | 705 | struct net_device *dev = priv; |
800 | struct smc_cfg_mem *cfg_mem; | 706 | int i; |
801 | tuple_t *tuple; | ||
802 | u_char *buf; | ||
803 | int i, rc; | ||
804 | 707 | ||
805 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | 708 | if (tuple->TupleDataLen < 8) |
806 | if (!cfg_mem) | 709 | return -EINVAL; |
807 | return -1; | 710 | if (tuple->TupleData[0] != 0x04) |
711 | return -EINVAL; | ||
712 | for (i = 0; i < 6; i++) | ||
713 | dev->dev_addr[i] = tuple->TupleData[i+2]; | ||
714 | return 0; | ||
715 | }; | ||
808 | 716 | ||
809 | tuple = &cfg_mem->tuple; | ||
810 | buf = cfg_mem->buf; | ||
811 | 717 | ||
812 | tuple->Attributes = TUPLE_RETURN_COMMON; | 718 | static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid) |
813 | tuple->TupleData = (cisdata_t *)buf; | 719 | { |
814 | tuple->TupleDataMax = 255; | 720 | struct net_device *dev = link->priv; |
815 | tuple->TupleOffset = 0; | 721 | int rc; |
816 | 722 | ||
817 | /* Read the station address from tuple 0x90, subtuple 0x04 */ | 723 | /* Read the station address from tuple 0x90, subtuple 0x04 */ |
818 | tuple->DesiredTuple = 0x90; | 724 | if (pcmcia_loop_tuple(link, 0x90, pcmcia_osi_mac, dev)) |
819 | i = pcmcia_get_first_tuple(link, tuple); | 725 | return -1; |
820 | while (i == 0) { | ||
821 | i = pcmcia_get_tuple_data(link, tuple); | ||
822 | if ((i != 0) || (buf[0] == 0x04)) | ||
823 | break; | ||
824 | i = pcmcia_get_next_tuple(link, tuple); | ||
825 | } | ||
826 | if (i != 0) { | ||
827 | rc = -1; | ||
828 | goto free_cfg_mem; | ||
829 | } | ||
830 | for (i = 0; i < 6; i++) | ||
831 | dev->dev_addr[i] = buf[i+2]; | ||
832 | 726 | ||
833 | if (((manfid == MANFID_OSITECH) && | 727 | if (((manfid == MANFID_OSITECH) && |
834 | (cardid == PRODID_OSITECH_SEVEN)) || | 728 | (cardid == PRODID_OSITECH_SEVEN)) || |
@@ -836,20 +730,17 @@ static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid) | |||
836 | (cardid == PRODID_PSION_NET100))) { | 730 | (cardid == PRODID_PSION_NET100))) { |
837 | rc = osi_load_firmware(link); | 731 | rc = osi_load_firmware(link); |
838 | if (rc) | 732 | if (rc) |
839 | goto free_cfg_mem; | 733 | return rc; |
840 | } else if (manfid == MANFID_OSITECH) { | 734 | } else if (manfid == MANFID_OSITECH) { |
841 | /* Make sure both functions are powered up */ | 735 | /* Make sure both functions are powered up */ |
842 | set_bits(0x300, link->io.BasePort1 + OSITECH_AUI_PWR); | 736 | set_bits(0x300, link->io.BasePort1 + OSITECH_AUI_PWR); |
843 | /* Now, turn on the interrupt for both card functions */ | 737 | /* Now, turn on the interrupt for both card functions */ |
844 | set_bits(0x300, link->io.BasePort1 + OSITECH_RESET_ISR); | 738 | set_bits(0x300, link->io.BasePort1 + OSITECH_RESET_ISR); |
845 | DEBUG(2, "AUI/PWR: %4.4x RESET/ISR: %4.4x\n", | 739 | dev_dbg(&link->dev, "AUI/PWR: %4.4x RESET/ISR: %4.4x\n", |
846 | inw(link->io.BasePort1 + OSITECH_AUI_PWR), | 740 | inw(link->io.BasePort1 + OSITECH_AUI_PWR), |
847 | inw(link->io.BasePort1 + OSITECH_RESET_ISR)); | 741 | inw(link->io.BasePort1 + OSITECH_RESET_ISR)); |
848 | } | 742 | } |
849 | rc = 0; | 743 | return 0; |
850 | free_cfg_mem: | ||
851 | kfree(cfg_mem); | ||
852 | return rc; | ||
853 | } | 744 | } |
854 | 745 | ||
855 | static int smc91c92_suspend(struct pcmcia_device *link) | 746 | static int smc91c92_suspend(struct pcmcia_device *link) |
@@ -959,12 +850,6 @@ static int check_sig(struct pcmcia_device *link) | |||
959 | 850 | ||
960 | ======================================================================*/ | 851 | ======================================================================*/ |
961 | 852 | ||
962 | #define CS_EXIT_TEST(ret, svc, label) \ | ||
963 | if (ret != 0) { \ | ||
964 | cs_error(link, svc, ret); \ | ||
965 | goto label; \ | ||
966 | } | ||
967 | |||
968 | static int smc91c92_config(struct pcmcia_device *link) | 853 | static int smc91c92_config(struct pcmcia_device *link) |
969 | { | 854 | { |
970 | struct net_device *dev = link->priv; | 855 | struct net_device *dev = link->priv; |
@@ -974,7 +859,7 @@ static int smc91c92_config(struct pcmcia_device *link) | |||
974 | unsigned int ioaddr; | 859 | unsigned int ioaddr; |
975 | u_long mir; | 860 | u_long mir; |
976 | 861 | ||
977 | DEBUG(0, "smc91c92_config(0x%p)\n", link); | 862 | dev_dbg(&link->dev, "smc91c92_config\n"); |
978 | 863 | ||
979 | smc->manfid = link->manf_id; | 864 | smc->manfid = link->manf_id; |
980 | smc->cardid = link->card_id; | 865 | smc->cardid = link->card_id; |
@@ -990,12 +875,15 @@ static int smc91c92_config(struct pcmcia_device *link) | |||
990 | } else { | 875 | } else { |
991 | i = smc_config(link); | 876 | i = smc_config(link); |
992 | } | 877 | } |
993 | CS_EXIT_TEST(i, RequestIO, config_failed); | 878 | if (i) |
879 | goto config_failed; | ||
994 | 880 | ||
995 | i = pcmcia_request_irq(link, &link->irq); | 881 | i = pcmcia_request_irq(link, &link->irq); |
996 | CS_EXIT_TEST(i, RequestIRQ, config_failed); | 882 | if (i) |
883 | goto config_failed; | ||
997 | i = pcmcia_request_configuration(link, &link->conf); | 884 | i = pcmcia_request_configuration(link, &link->conf); |
998 | CS_EXIT_TEST(i, RequestConfiguration, config_failed); | 885 | if (i) |
886 | goto config_failed; | ||
999 | 887 | ||
1000 | if (smc->manfid == MANFID_MOTOROLA) | 888 | if (smc->manfid == MANFID_MOTOROLA) |
1001 | mot_config(link); | 889 | mot_config(link); |
@@ -1074,7 +962,7 @@ static int smc91c92_config(struct pcmcia_device *link) | |||
1074 | } | 962 | } |
1075 | 963 | ||
1076 | link->dev_node = &smc->node; | 964 | link->dev_node = &smc->node; |
1077 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); | 965 | SET_NETDEV_DEV(dev, &link->dev); |
1078 | 966 | ||
1079 | if (register_netdev(dev) != 0) { | 967 | if (register_netdev(dev) != 0) { |
1080 | printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n"); | 968 | printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n"); |
@@ -1100,7 +988,7 @@ static int smc91c92_config(struct pcmcia_device *link) | |||
1100 | 988 | ||
1101 | if (smc->cfg & CFG_MII_SELECT) { | 989 | if (smc->cfg & CFG_MII_SELECT) { |
1102 | if (smc->mii_if.phy_id != -1) { | 990 | if (smc->mii_if.phy_id != -1) { |
1103 | DEBUG(0, " MII transceiver at index %d, status %x.\n", | 991 | dev_dbg(&link->dev, " MII transceiver at index %d, status %x.\n", |
1104 | smc->mii_if.phy_id, j); | 992 | smc->mii_if.phy_id, j); |
1105 | } else { | 993 | } else { |
1106 | printk(KERN_NOTICE " No MII transceivers found!\n"); | 994 | printk(KERN_NOTICE " No MII transceivers found!\n"); |
@@ -1110,7 +998,7 @@ static int smc91c92_config(struct pcmcia_device *link) | |||
1110 | 998 | ||
1111 | config_undo: | 999 | config_undo: |
1112 | unregister_netdev(dev); | 1000 | unregister_netdev(dev); |
1113 | config_failed: /* CS_EXIT_TEST() calls jump to here... */ | 1001 | config_failed: |
1114 | smc91c92_release(link); | 1002 | smc91c92_release(link); |
1115 | return -ENODEV; | 1003 | return -ENODEV; |
1116 | } /* smc91c92_config */ | 1004 | } /* smc91c92_config */ |
@@ -1125,7 +1013,7 @@ config_failed: /* CS_EXIT_TEST() calls jump to here... */ | |||
1125 | 1013 | ||
1126 | static void smc91c92_release(struct pcmcia_device *link) | 1014 | static void smc91c92_release(struct pcmcia_device *link) |
1127 | { | 1015 | { |
1128 | DEBUG(0, "smc91c92_release(0x%p)\n", link); | 1016 | dev_dbg(&link->dev, "smc91c92_release\n"); |
1129 | if (link->win) { | 1017 | if (link->win) { |
1130 | struct net_device *dev = link->priv; | 1018 | struct net_device *dev = link->priv; |
1131 | struct smc_private *smc = netdev_priv(dev); | 1019 | struct smc_private *smc = netdev_priv(dev); |
@@ -1222,10 +1110,10 @@ static int smc_open(struct net_device *dev) | |||
1222 | struct smc_private *smc = netdev_priv(dev); | 1110 | struct smc_private *smc = netdev_priv(dev); |
1223 | struct pcmcia_device *link = smc->p_dev; | 1111 | struct pcmcia_device *link = smc->p_dev; |
1224 | 1112 | ||
1225 | #ifdef PCMCIA_DEBUG | 1113 | dev_dbg(&link->dev, "%s: smc_open(%p), ID/Window %4.4x.\n", |
1226 | DEBUG(0, "%s: smc_open(%p), ID/Window %4.4x.\n", | ||
1227 | dev->name, dev, inw(dev->base_addr + BANK_SELECT)); | 1114 | dev->name, dev, inw(dev->base_addr + BANK_SELECT)); |
1228 | if (pc_debug > 1) smc_dump(dev); | 1115 | #ifdef PCMCIA_DEBUG |
1116 | smc_dump(dev); | ||
1229 | #endif | 1117 | #endif |
1230 | 1118 | ||
1231 | /* Check that the PCMCIA card is still here. */ | 1119 | /* Check that the PCMCIA card is still here. */ |
@@ -1260,7 +1148,7 @@ static int smc_close(struct net_device *dev) | |||
1260 | struct pcmcia_device *link = smc->p_dev; | 1148 | struct pcmcia_device *link = smc->p_dev; |
1261 | unsigned int ioaddr = dev->base_addr; | 1149 | unsigned int ioaddr = dev->base_addr; |
1262 | 1150 | ||
1263 | DEBUG(0, "%s: smc_close(), status %4.4x.\n", | 1151 | dev_dbg(&link->dev, "%s: smc_close(), status %4.4x.\n", |
1264 | dev->name, inw(ioaddr + BANK_SELECT)); | 1152 | dev->name, inw(ioaddr + BANK_SELECT)); |
1265 | 1153 | ||
1266 | netif_stop_queue(dev); | 1154 | netif_stop_queue(dev); |
@@ -1327,7 +1215,7 @@ static void smc_hardware_send_packet(struct net_device * dev) | |||
1327 | u_char *buf = skb->data; | 1215 | u_char *buf = skb->data; |
1328 | u_int length = skb->len; /* The chip will pad to ethernet min. */ | 1216 | u_int length = skb->len; /* The chip will pad to ethernet min. */ |
1329 | 1217 | ||
1330 | DEBUG(2, "%s: Trying to xmit packet of length %d.\n", | 1218 | pr_debug("%s: Trying to xmit packet of length %d.\n", |
1331 | dev->name, length); | 1219 | dev->name, length); |
1332 | 1220 | ||
1333 | /* send the packet length: +6 for status word, length, and ctl */ | 1221 | /* send the packet length: +6 for status word, length, and ctl */ |
@@ -1382,7 +1270,7 @@ static netdev_tx_t smc_start_xmit(struct sk_buff *skb, | |||
1382 | 1270 | ||
1383 | netif_stop_queue(dev); | 1271 | netif_stop_queue(dev); |
1384 | 1272 | ||
1385 | DEBUG(2, "%s: smc_start_xmit(length = %d) called," | 1273 | pr_debug("%s: smc_start_xmit(length = %d) called," |
1386 | " status %4.4x.\n", dev->name, skb->len, inw(ioaddr + 2)); | 1274 | " status %4.4x.\n", dev->name, skb->len, inw(ioaddr + 2)); |
1387 | 1275 | ||
1388 | if (smc->saved_skb) { | 1276 | if (smc->saved_skb) { |
@@ -1429,7 +1317,7 @@ static netdev_tx_t smc_start_xmit(struct sk_buff *skb, | |||
1429 | } | 1317 | } |
1430 | 1318 | ||
1431 | /* Otherwise defer until the Tx-space-allocated interrupt. */ | 1319 | /* Otherwise defer until the Tx-space-allocated interrupt. */ |
1432 | DEBUG(2, "%s: memory allocation deferred.\n", dev->name); | 1320 | pr_debug("%s: memory allocation deferred.\n", dev->name); |
1433 | outw((IM_ALLOC_INT << 8) | (ir & 0xff00), ioaddr + INTERRUPT); | 1321 | outw((IM_ALLOC_INT << 8) | (ir & 0xff00), ioaddr + INTERRUPT); |
1434 | spin_unlock_irqrestore(&smc->lock, flags); | 1322 | spin_unlock_irqrestore(&smc->lock, flags); |
1435 | 1323 | ||
@@ -1494,7 +1382,7 @@ static void smc_eph_irq(struct net_device *dev) | |||
1494 | 1382 | ||
1495 | SMC_SELECT_BANK(0); | 1383 | SMC_SELECT_BANK(0); |
1496 | ephs = inw(ioaddr + EPH); | 1384 | ephs = inw(ioaddr + EPH); |
1497 | DEBUG(2, "%s: Ethernet protocol handler interrupt, status" | 1385 | pr_debug("%s: Ethernet protocol handler interrupt, status" |
1498 | " %4.4x.\n", dev->name, ephs); | 1386 | " %4.4x.\n", dev->name, ephs); |
1499 | /* Could be a counter roll-over warning: update stats. */ | 1387 | /* Could be a counter roll-over warning: update stats. */ |
1500 | card_stats = inw(ioaddr + COUNTER); | 1388 | card_stats = inw(ioaddr + COUNTER); |
@@ -1534,7 +1422,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id) | |||
1534 | 1422 | ||
1535 | ioaddr = dev->base_addr; | 1423 | ioaddr = dev->base_addr; |
1536 | 1424 | ||
1537 | DEBUG(3, "%s: SMC91c92 interrupt %d at %#x.\n", dev->name, | 1425 | pr_debug("%s: SMC91c92 interrupt %d at %#x.\n", dev->name, |
1538 | irq, ioaddr); | 1426 | irq, ioaddr); |
1539 | 1427 | ||
1540 | spin_lock(&smc->lock); | 1428 | spin_lock(&smc->lock); |
@@ -1543,7 +1431,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id) | |||
1543 | if ((saved_bank & 0xff00) != 0x3300) { | 1431 | if ((saved_bank & 0xff00) != 0x3300) { |
1544 | /* The device does not exist -- the card could be off-line, or | 1432 | /* The device does not exist -- the card could be off-line, or |
1545 | maybe it has been ejected. */ | 1433 | maybe it has been ejected. */ |
1546 | DEBUG(1, "%s: SMC91c92 interrupt %d for non-existent" | 1434 | pr_debug("%s: SMC91c92 interrupt %d for non-existent" |
1547 | "/ejected device.\n", dev->name, irq); | 1435 | "/ejected device.\n", dev->name, irq); |
1548 | handled = 0; | 1436 | handled = 0; |
1549 | goto irq_done; | 1437 | goto irq_done; |
@@ -1557,7 +1445,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id) | |||
1557 | 1445 | ||
1558 | do { /* read the status flag, and mask it */ | 1446 | do { /* read the status flag, and mask it */ |
1559 | status = inw(ioaddr + INTERRUPT) & 0xff; | 1447 | status = inw(ioaddr + INTERRUPT) & 0xff; |
1560 | DEBUG(3, "%s: Status is %#2.2x (mask %#2.2x).\n", dev->name, | 1448 | pr_debug("%s: Status is %#2.2x (mask %#2.2x).\n", dev->name, |
1561 | status, mask); | 1449 | status, mask); |
1562 | if ((status & mask) == 0) { | 1450 | if ((status & mask) == 0) { |
1563 | if (bogus_cnt == INTR_WORK) | 1451 | if (bogus_cnt == INTR_WORK) |
@@ -1602,7 +1490,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id) | |||
1602 | smc_eph_irq(dev); | 1490 | smc_eph_irq(dev); |
1603 | } while (--bogus_cnt); | 1491 | } while (--bogus_cnt); |
1604 | 1492 | ||
1605 | DEBUG(3, " Restoring saved registers mask %2.2x bank %4.4x" | 1493 | pr_debug(" Restoring saved registers mask %2.2x bank %4.4x" |
1606 | " pointer %4.4x.\n", mask, saved_bank, saved_pointer); | 1494 | " pointer %4.4x.\n", mask, saved_bank, saved_pointer); |
1607 | 1495 | ||
1608 | /* restore state register */ | 1496 | /* restore state register */ |
@@ -1610,7 +1498,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id) | |||
1610 | outw(saved_pointer, ioaddr + POINTER); | 1498 | outw(saved_pointer, ioaddr + POINTER); |
1611 | SMC_SELECT_BANK(saved_bank); | 1499 | SMC_SELECT_BANK(saved_bank); |
1612 | 1500 | ||
1613 | DEBUG(3, "%s: Exiting interrupt IRQ%d.\n", dev->name, irq); | 1501 | pr_debug("%s: Exiting interrupt IRQ%d.\n", dev->name, irq); |
1614 | 1502 | ||
1615 | irq_done: | 1503 | irq_done: |
1616 | 1504 | ||
@@ -1661,7 +1549,7 @@ static void smc_rx(struct net_device *dev) | |||
1661 | rx_status = inw(ioaddr + DATA_1); | 1549 | rx_status = inw(ioaddr + DATA_1); |
1662 | packet_length = inw(ioaddr + DATA_1) & 0x07ff; | 1550 | packet_length = inw(ioaddr + DATA_1) & 0x07ff; |
1663 | 1551 | ||
1664 | DEBUG(2, "%s: Receive status %4.4x length %d.\n", | 1552 | pr_debug("%s: Receive status %4.4x length %d.\n", |
1665 | dev->name, rx_status, packet_length); | 1553 | dev->name, rx_status, packet_length); |
1666 | 1554 | ||
1667 | if (!(rx_status & RS_ERRORS)) { | 1555 | if (!(rx_status & RS_ERRORS)) { |
@@ -1672,7 +1560,7 @@ static void smc_rx(struct net_device *dev) | |||
1672 | skb = dev_alloc_skb(packet_length+2); | 1560 | skb = dev_alloc_skb(packet_length+2); |
1673 | 1561 | ||
1674 | if (skb == NULL) { | 1562 | if (skb == NULL) { |
1675 | DEBUG(1, "%s: Low memory, packet dropped.\n", dev->name); | 1563 | pr_debug("%s: Low memory, packet dropped.\n", dev->name); |
1676 | dev->stats.rx_dropped++; | 1564 | dev->stats.rx_dropped++; |
1677 | outw(MC_RELEASE, ioaddr + MMU_CMD); | 1565 | outw(MC_RELEASE, ioaddr + MMU_CMD); |
1678 | return; | 1566 | return; |
@@ -1832,7 +1720,7 @@ static void smc_reset(struct net_device *dev) | |||
1832 | struct smc_private *smc = netdev_priv(dev); | 1720 | struct smc_private *smc = netdev_priv(dev); |
1833 | int i; | 1721 | int i; |
1834 | 1722 | ||
1835 | DEBUG(0, "%s: smc91c92 reset called.\n", dev->name); | 1723 | pr_debug("%s: smc91c92 reset called.\n", dev->name); |
1836 | 1724 | ||
1837 | /* The first interaction must be a write to bring the chip out | 1725 | /* The first interaction must be a write to bring the chip out |
1838 | of sleep mode. */ | 1726 | of sleep mode. */ |
@@ -2149,18 +2037,6 @@ static u32 smc_get_link(struct net_device *dev) | |||
2149 | return ret; | 2037 | return ret; |
2150 | } | 2038 | } |
2151 | 2039 | ||
2152 | #ifdef PCMCIA_DEBUG | ||
2153 | static u32 smc_get_msglevel(struct net_device *dev) | ||
2154 | { | ||
2155 | return pc_debug; | ||
2156 | } | ||
2157 | |||
2158 | static void smc_set_msglevel(struct net_device *dev, u32 val) | ||
2159 | { | ||
2160 | pc_debug = val; | ||
2161 | } | ||
2162 | #endif | ||
2163 | |||
2164 | static int smc_nway_reset(struct net_device *dev) | 2040 | static int smc_nway_reset(struct net_device *dev) |
2165 | { | 2041 | { |
2166 | struct smc_private *smc = netdev_priv(dev); | 2042 | struct smc_private *smc = netdev_priv(dev); |
@@ -2184,10 +2060,6 @@ static const struct ethtool_ops ethtool_ops = { | |||
2184 | .get_settings = smc_get_settings, | 2060 | .get_settings = smc_get_settings, |
2185 | .set_settings = smc_set_settings, | 2061 | .set_settings = smc_set_settings, |
2186 | .get_link = smc_get_link, | 2062 | .get_link = smc_get_link, |
2187 | #ifdef PCMCIA_DEBUG | ||
2188 | .get_msglevel = smc_get_msglevel, | ||
2189 | .set_msglevel = smc_set_msglevel, | ||
2190 | #endif | ||
2191 | .nway_reset = smc_nway_reset, | 2063 | .nway_reset = smc_nway_reset, |
2192 | }; | 2064 | }; |
2193 | 2065 | ||