.. | .. |
---|
127 | 127 | #include "typhoon.h" |
---|
128 | 128 | |
---|
129 | 129 | MODULE_AUTHOR("David Dillow <dave@thedillows.org>"); |
---|
130 | | -MODULE_VERSION("1.0"); |
---|
131 | 130 | MODULE_LICENSE("GPL"); |
---|
132 | 131 | MODULE_FIRMWARE(FIRMWARE_NAME); |
---|
133 | 132 | MODULE_DESCRIPTION("3Com Typhoon Family (3C990, 3CR990, and variants)"); |
---|
.. | .. |
---|
311 | 310 | * cannot pass a read, so this forces current writes to post. |
---|
312 | 311 | */ |
---|
313 | 312 | #define typhoon_post_pci_writes(x) \ |
---|
314 | | - do { if(likely(use_mmio)) ioread32(x+TYPHOON_REG_HEARTBEAT); } while(0) |
---|
| 313 | + do { if (likely(use_mmio)) ioread32(x+TYPHOON_REG_HEARTBEAT); } while (0) |
---|
315 | 314 | |
---|
316 | 315 | /* We'll wait up to six seconds for a reset, and half a second normally. |
---|
317 | 316 | */ |
---|
.. | .. |
---|
381 | 380 | int i, err = 0; |
---|
382 | 381 | int timeout; |
---|
383 | 382 | |
---|
384 | | - if(wait_type == WaitNoSleep) |
---|
| 383 | + if (wait_type == WaitNoSleep) |
---|
385 | 384 | timeout = TYPHOON_RESET_TIMEOUT_NOSLEEP; |
---|
386 | 385 | else |
---|
387 | 386 | timeout = TYPHOON_RESET_TIMEOUT_SLEEP; |
---|
.. | .. |
---|
394 | 393 | udelay(1); |
---|
395 | 394 | iowrite32(TYPHOON_RESET_NONE, ioaddr + TYPHOON_REG_SOFT_RESET); |
---|
396 | 395 | |
---|
397 | | - if(wait_type != NoWait) { |
---|
398 | | - for(i = 0; i < timeout; i++) { |
---|
399 | | - if(ioread32(ioaddr + TYPHOON_REG_STATUS) == |
---|
| 396 | + if (wait_type != NoWait) { |
---|
| 397 | + for (i = 0; i < timeout; i++) { |
---|
| 398 | + if (ioread32(ioaddr + TYPHOON_REG_STATUS) == |
---|
400 | 399 | TYPHOON_STATUS_WAITING_FOR_HOST) |
---|
401 | 400 | goto out; |
---|
402 | 401 | |
---|
403 | | - if(wait_type == WaitSleep) |
---|
| 402 | + if (wait_type == WaitSleep) |
---|
404 | 403 | schedule_timeout_uninterruptible(1); |
---|
405 | 404 | else |
---|
406 | 405 | udelay(TYPHOON_UDELAY); |
---|
.. | .. |
---|
423 | 422 | * which should be enough (I've see it work well at 100us, but still |
---|
424 | 423 | * saw occasional problems.) |
---|
425 | 424 | */ |
---|
426 | | - if(wait_type == WaitSleep) |
---|
| 425 | + if (wait_type == WaitSleep) |
---|
427 | 426 | msleep(5); |
---|
428 | 427 | else |
---|
429 | 428 | udelay(500); |
---|
.. | .. |
---|
435 | 434 | { |
---|
436 | 435 | int i, err = 0; |
---|
437 | 436 | |
---|
438 | | - for(i = 0; i < TYPHOON_WAIT_TIMEOUT; i++) { |
---|
439 | | - if(ioread32(ioaddr + TYPHOON_REG_STATUS) == wait_value) |
---|
| 437 | + for (i = 0; i < TYPHOON_WAIT_TIMEOUT; i++) { |
---|
| 438 | + if (ioread32(ioaddr + TYPHOON_REG_STATUS) == wait_value) |
---|
440 | 439 | goto out; |
---|
441 | 440 | udelay(TYPHOON_UDELAY); |
---|
442 | 441 | } |
---|
.. | .. |
---|
450 | 449 | static inline void |
---|
451 | 450 | typhoon_media_status(struct net_device *dev, struct resp_desc *resp) |
---|
452 | 451 | { |
---|
453 | | - if(resp->parm1 & TYPHOON_MEDIA_STAT_NO_LINK) |
---|
| 452 | + if (resp->parm1 & TYPHOON_MEDIA_STAT_NO_LINK) |
---|
454 | 453 | netif_carrier_off(dev); |
---|
455 | 454 | else |
---|
456 | 455 | netif_carrier_on(dev); |
---|
.. | .. |
---|
466 | 465 | * card in a long while. If the lock is held, then we're in the |
---|
467 | 466 | * process of issuing a command, so we don't need to respond. |
---|
468 | 467 | */ |
---|
469 | | - if(spin_trylock(&tp->command_lock)) { |
---|
| 468 | + if (spin_trylock(&tp->command_lock)) { |
---|
470 | 469 | cmd = (struct cmd_desc *)(ring->ringBase + ring->lastWrite); |
---|
471 | 470 | typhoon_inc_cmd_index(&ring->lastWrite, 1); |
---|
472 | 471 | |
---|
.. | .. |
---|
490 | 489 | |
---|
491 | 490 | cleared = le32_to_cpu(indexes->respCleared); |
---|
492 | 491 | ready = le32_to_cpu(indexes->respReady); |
---|
493 | | - while(cleared != ready) { |
---|
| 492 | + while (cleared != ready) { |
---|
494 | 493 | resp = (struct resp_desc *)(base + cleared); |
---|
495 | 494 | count = resp->numDesc + 1; |
---|
496 | | - if(resp_save && resp->seqNo) { |
---|
497 | | - if(count > resp_size) { |
---|
| 495 | + if (resp_save && resp->seqNo) { |
---|
| 496 | + if (count > resp_size) { |
---|
498 | 497 | resp_save->flags = TYPHOON_RESP_ERROR; |
---|
499 | 498 | goto cleanup; |
---|
500 | 499 | } |
---|
501 | 500 | |
---|
502 | 501 | wrap_len = 0; |
---|
503 | 502 | len = count * sizeof(*resp); |
---|
504 | | - if(unlikely(cleared + len > RESPONSE_RING_SIZE)) { |
---|
| 503 | + if (unlikely(cleared + len > RESPONSE_RING_SIZE)) { |
---|
505 | 504 | wrap_len = cleared + len - RESPONSE_RING_SIZE; |
---|
506 | 505 | len = RESPONSE_RING_SIZE - cleared; |
---|
507 | 506 | } |
---|
508 | 507 | |
---|
509 | 508 | memcpy(resp_save, resp, len); |
---|
510 | | - if(unlikely(wrap_len)) { |
---|
| 509 | + if (unlikely(wrap_len)) { |
---|
511 | 510 | resp_save += len / sizeof(*resp); |
---|
512 | 511 | memcpy(resp_save, base, wrap_len); |
---|
513 | 512 | } |
---|
514 | 513 | |
---|
515 | 514 | resp_save = NULL; |
---|
516 | | - } else if(resp->cmd == TYPHOON_CMD_READ_MEDIA_STATUS) { |
---|
| 515 | + } else if (resp->cmd == TYPHOON_CMD_READ_MEDIA_STATUS) { |
---|
517 | 516 | typhoon_media_status(tp->dev, resp); |
---|
518 | | - } else if(resp->cmd == TYPHOON_CMD_HELLO_RESP) { |
---|
| 517 | + } else if (resp->cmd == TYPHOON_CMD_HELLO_RESP) { |
---|
519 | 518 | typhoon_hello(tp); |
---|
520 | 519 | } else { |
---|
521 | 520 | netdev_err(tp->dev, |
---|
.. | .. |
---|
589 | 588 | freeCmd = typhoon_num_free_cmd(tp); |
---|
590 | 589 | freeResp = typhoon_num_free_resp(tp); |
---|
591 | 590 | |
---|
592 | | - if(freeCmd < num_cmd || freeResp < num_resp) { |
---|
| 591 | + if (freeCmd < num_cmd || freeResp < num_resp) { |
---|
593 | 592 | netdev_err(tp->dev, "no descs for cmd, had (needed) %d (%d) cmd, %d (%d) resp\n", |
---|
594 | 593 | freeCmd, num_cmd, freeResp, num_resp); |
---|
595 | 594 | err = -ENOMEM; |
---|
596 | 595 | goto out; |
---|
597 | 596 | } |
---|
598 | 597 | |
---|
599 | | - if(cmd->flags & TYPHOON_CMD_RESPOND) { |
---|
| 598 | + if (cmd->flags & TYPHOON_CMD_RESPOND) { |
---|
600 | 599 | /* If we're expecting a response, but the caller hasn't given |
---|
601 | 600 | * us a place to put it, we'll provide one. |
---|
602 | 601 | */ |
---|
603 | 602 | tp->awaiting_resp = 1; |
---|
604 | | - if(resp == NULL) { |
---|
| 603 | + if (resp == NULL) { |
---|
605 | 604 | resp = &local_resp; |
---|
606 | 605 | num_resp = 1; |
---|
607 | 606 | } |
---|
.. | .. |
---|
609 | 608 | |
---|
610 | 609 | wrap_len = 0; |
---|
611 | 610 | len = num_cmd * sizeof(*cmd); |
---|
612 | | - if(unlikely(ring->lastWrite + len > COMMAND_RING_SIZE)) { |
---|
| 611 | + if (unlikely(ring->lastWrite + len > COMMAND_RING_SIZE)) { |
---|
613 | 612 | wrap_len = ring->lastWrite + len - COMMAND_RING_SIZE; |
---|
614 | 613 | len = COMMAND_RING_SIZE - ring->lastWrite; |
---|
615 | 614 | } |
---|
616 | 615 | |
---|
617 | 616 | memcpy(ring->ringBase + ring->lastWrite, cmd, len); |
---|
618 | | - if(unlikely(wrap_len)) { |
---|
| 617 | + if (unlikely(wrap_len)) { |
---|
619 | 618 | struct cmd_desc *wrap_ptr = cmd; |
---|
620 | 619 | wrap_ptr += len / sizeof(*cmd); |
---|
621 | 620 | memcpy(ring->ringBase, wrap_ptr, wrap_len); |
---|
.. | .. |
---|
629 | 628 | iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY); |
---|
630 | 629 | typhoon_post_pci_writes(tp->ioaddr); |
---|
631 | 630 | |
---|
632 | | - if((cmd->flags & TYPHOON_CMD_RESPOND) == 0) |
---|
| 631 | + if ((cmd->flags & TYPHOON_CMD_RESPOND) == 0) |
---|
633 | 632 | goto out; |
---|
634 | 633 | |
---|
635 | 634 | /* Ugh. We'll be here about 8ms, spinning our thumbs, unable to |
---|
.. | .. |
---|
649 | 648 | * wait here. |
---|
650 | 649 | */ |
---|
651 | 650 | got_resp = 0; |
---|
652 | | - for(i = 0; i < TYPHOON_WAIT_TIMEOUT && !got_resp; i++) { |
---|
653 | | - if(indexes->respCleared != indexes->respReady) |
---|
| 651 | + for (i = 0; i < TYPHOON_WAIT_TIMEOUT && !got_resp; i++) { |
---|
| 652 | + if (indexes->respCleared != indexes->respReady) |
---|
654 | 653 | got_resp = typhoon_process_response(tp, num_resp, |
---|
655 | 654 | resp); |
---|
656 | 655 | udelay(TYPHOON_UDELAY); |
---|
657 | 656 | } |
---|
658 | 657 | |
---|
659 | | - if(!got_resp) { |
---|
| 658 | + if (!got_resp) { |
---|
660 | 659 | err = -ETIMEDOUT; |
---|
661 | 660 | goto out; |
---|
662 | 661 | } |
---|
.. | .. |
---|
664 | 663 | /* Collect the error response even if we don't care about the |
---|
665 | 664 | * rest of the response |
---|
666 | 665 | */ |
---|
667 | | - if(resp->flags & TYPHOON_RESP_ERROR) |
---|
| 666 | + if (resp->flags & TYPHOON_RESP_ERROR) |
---|
668 | 667 | err = -EIO; |
---|
669 | 668 | |
---|
670 | 669 | out: |
---|
671 | | - if(tp->awaiting_resp) { |
---|
| 670 | + if (tp->awaiting_resp) { |
---|
672 | 671 | tp->awaiting_resp = 0; |
---|
673 | 672 | smp_wmb(); |
---|
674 | 673 | |
---|
.. | .. |
---|
679 | 678 | * time. So, check for it, and interrupt ourselves if this |
---|
680 | 679 | * is the case. |
---|
681 | 680 | */ |
---|
682 | | - if(indexes->respCleared != indexes->respReady) |
---|
| 681 | + if (indexes->respCleared != indexes->respReady) |
---|
683 | 682 | iowrite32(1, tp->ioaddr + TYPHOON_REG_SELF_INTERRUPT); |
---|
684 | 683 | } |
---|
685 | 684 | |
---|
.. | .. |
---|
749 | 748 | * between marking the queue awake and updating the cleared index. |
---|
750 | 749 | * Just loop and it will appear. This comes from the acenic driver. |
---|
751 | 750 | */ |
---|
752 | | - while(unlikely(typhoon_num_free_tx(txRing) < (numDesc + 2))) |
---|
| 751 | + while (unlikely(typhoon_num_free_tx(txRing) < (numDesc + 2))) |
---|
753 | 752 | smp_rmb(); |
---|
754 | 753 | |
---|
755 | 754 | first_txd = (struct tx_desc *) (txRing->ringBase + txRing->lastWrite); |
---|
.. | .. |
---|
761 | 760 | first_txd->tx_addr = (u64)((unsigned long) skb); |
---|
762 | 761 | first_txd->processFlags = 0; |
---|
763 | 762 | |
---|
764 | | - if(skb->ip_summed == CHECKSUM_PARTIAL) { |
---|
| 763 | + if (skb->ip_summed == CHECKSUM_PARTIAL) { |
---|
765 | 764 | /* The 3XP will figure out if this is UDP/TCP */ |
---|
766 | 765 | first_txd->processFlags |= TYPHOON_TX_PF_TCP_CHKSUM; |
---|
767 | 766 | first_txd->processFlags |= TYPHOON_TX_PF_UDP_CHKSUM; |
---|
.. | .. |
---|
789 | 788 | /* No need to worry about padding packet -- the firmware pads |
---|
790 | 789 | * it with zeros to ETH_ZLEN for us. |
---|
791 | 790 | */ |
---|
792 | | - if(skb_shinfo(skb)->nr_frags == 0) { |
---|
793 | | - skb_dma = pci_map_single(tp->tx_pdev, skb->data, skb->len, |
---|
794 | | - PCI_DMA_TODEVICE); |
---|
| 791 | + if (skb_shinfo(skb)->nr_frags == 0) { |
---|
| 792 | + skb_dma = dma_map_single(&tp->tx_pdev->dev, skb->data, |
---|
| 793 | + skb->len, DMA_TO_DEVICE); |
---|
795 | 794 | txd->flags = TYPHOON_FRAG_DESC | TYPHOON_DESC_VALID; |
---|
796 | 795 | txd->len = cpu_to_le16(skb->len); |
---|
797 | 796 | txd->frag.addr = cpu_to_le32(skb_dma); |
---|
.. | .. |
---|
801 | 800 | int i, len; |
---|
802 | 801 | |
---|
803 | 802 | len = skb_headlen(skb); |
---|
804 | | - skb_dma = pci_map_single(tp->tx_pdev, skb->data, len, |
---|
805 | | - PCI_DMA_TODEVICE); |
---|
| 803 | + skb_dma = dma_map_single(&tp->tx_pdev->dev, skb->data, len, |
---|
| 804 | + DMA_TO_DEVICE); |
---|
806 | 805 | txd->flags = TYPHOON_FRAG_DESC | TYPHOON_DESC_VALID; |
---|
807 | 806 | txd->len = cpu_to_le16(len); |
---|
808 | 807 | txd->frag.addr = cpu_to_le32(skb_dma); |
---|
.. | .. |
---|
819 | 818 | |
---|
820 | 819 | len = skb_frag_size(frag); |
---|
821 | 820 | frag_addr = skb_frag_address(frag); |
---|
822 | | - skb_dma = pci_map_single(tp->tx_pdev, frag_addr, len, |
---|
823 | | - PCI_DMA_TODEVICE); |
---|
| 821 | + skb_dma = dma_map_single(&tp->tx_pdev->dev, frag_addr, |
---|
| 822 | + len, DMA_TO_DEVICE); |
---|
824 | 823 | txd->flags = TYPHOON_FRAG_DESC | TYPHOON_DESC_VALID; |
---|
825 | 824 | txd->len = cpu_to_le16(len); |
---|
826 | 825 | txd->frag.addr = cpu_to_le32(skb_dma); |
---|
.. | .. |
---|
841 | 840 | */ |
---|
842 | 841 | numDesc = MAX_SKB_FRAGS + TSO_NUM_DESCRIPTORS + 1; |
---|
843 | 842 | |
---|
844 | | - if(typhoon_num_free_tx(txRing) < (numDesc + 2)) { |
---|
| 843 | + if (typhoon_num_free_tx(txRing) < (numDesc + 2)) { |
---|
845 | 844 | netif_stop_queue(dev); |
---|
846 | 845 | |
---|
847 | 846 | /* A Tx complete IRQ could have gotten between, making |
---|
848 | 847 | * the ring free again. Only need to recheck here, since |
---|
849 | 848 | * Tx is serialized. |
---|
850 | 849 | */ |
---|
851 | | - if(typhoon_num_free_tx(txRing) >= (numDesc + 2)) |
---|
| 850 | + if (typhoon_num_free_tx(txRing) >= (numDesc + 2)) |
---|
852 | 851 | netif_wake_queue(dev); |
---|
853 | 852 | } |
---|
854 | 853 | |
---|
.. | .. |
---|
864 | 863 | __le16 filter; |
---|
865 | 864 | |
---|
866 | 865 | filter = TYPHOON_RX_FILTER_DIRECTED | TYPHOON_RX_FILTER_BROADCAST; |
---|
867 | | - if(dev->flags & IFF_PROMISC) { |
---|
| 866 | + if (dev->flags & IFF_PROMISC) { |
---|
868 | 867 | filter |= TYPHOON_RX_FILTER_PROMISCOUS; |
---|
869 | 868 | } else if ((netdev_mc_count(dev) > multicast_filter_limit) || |
---|
870 | 869 | (dev->flags & IFF_ALLMULTI)) { |
---|
.. | .. |
---|
906 | 905 | |
---|
907 | 906 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_STATS); |
---|
908 | 907 | err = typhoon_issue_command(tp, 1, &xp_cmd, 7, xp_resp); |
---|
909 | | - if(err < 0) |
---|
| 908 | + if (err < 0) |
---|
910 | 909 | return err; |
---|
911 | 910 | |
---|
912 | 911 | /* 3Com's Linux driver uses txMultipleCollisions as it's |
---|
.. | .. |
---|
954 | 953 | struct net_device_stats *saved = &tp->stats_saved; |
---|
955 | 954 | |
---|
956 | 955 | smp_rmb(); |
---|
957 | | - if(tp->card_state == Sleeping) |
---|
| 956 | + if (tp->card_state == Sleeping) |
---|
958 | 957 | return saved; |
---|
959 | 958 | |
---|
960 | | - if(typhoon_do_get_stats(tp) < 0) { |
---|
| 959 | + if (typhoon_do_get_stats(tp) < 0) { |
---|
961 | 960 | netdev_err(dev, "error getting stats\n"); |
---|
962 | 961 | return saved; |
---|
963 | 962 | } |
---|
.. | .. |
---|
974 | 973 | struct resp_desc xp_resp[3]; |
---|
975 | 974 | |
---|
976 | 975 | smp_rmb(); |
---|
977 | | - if(tp->card_state == Sleeping) { |
---|
| 976 | + if (tp->card_state == Sleeping) { |
---|
978 | 977 | strlcpy(info->fw_version, "Sleep image", |
---|
979 | 978 | sizeof(info->fw_version)); |
---|
980 | 979 | } else { |
---|
981 | 980 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS); |
---|
982 | | - if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) { |
---|
| 981 | + if (typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) { |
---|
983 | 982 | strlcpy(info->fw_version, "Unknown runtime", |
---|
984 | 983 | sizeof(info->fw_version)); |
---|
985 | 984 | } else { |
---|
.. | .. |
---|
1026 | 1025 | break; |
---|
1027 | 1026 | } |
---|
1028 | 1027 | |
---|
1029 | | - if(tp->capabilities & TYPHOON_FIBER) { |
---|
| 1028 | + if (tp->capabilities & TYPHOON_FIBER) { |
---|
1030 | 1029 | supported |= SUPPORTED_FIBRE; |
---|
1031 | 1030 | advertising |= ADVERTISED_FIBRE; |
---|
1032 | 1031 | cmd->base.port = PORT_FIBRE; |
---|
.. | .. |
---|
1043 | 1042 | cmd->base.speed = tp->speed; |
---|
1044 | 1043 | cmd->base.duplex = tp->duplex; |
---|
1045 | 1044 | cmd->base.phy_address = 0; |
---|
1046 | | - if(tp->xcvr_select == TYPHOON_XCVR_AUTONEG) |
---|
| 1045 | + if (tp->xcvr_select == TYPHOON_XCVR_AUTONEG) |
---|
1047 | 1046 | cmd->base.autoneg = AUTONEG_ENABLE; |
---|
1048 | 1047 | else |
---|
1049 | 1048 | cmd->base.autoneg = AUTONEG_DISABLE; |
---|
.. | .. |
---|
1091 | 1090 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_XCVR_SELECT); |
---|
1092 | 1091 | xp_cmd.parm1 = xcvr; |
---|
1093 | 1092 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1094 | | - if(err < 0) |
---|
| 1093 | + if (err < 0) |
---|
1095 | 1094 | goto out; |
---|
1096 | 1095 | |
---|
1097 | 1096 | tp->xcvr_select = xcvr; |
---|
.. | .. |
---|
1114 | 1113 | |
---|
1115 | 1114 | wol->supported = WAKE_PHY | WAKE_MAGIC; |
---|
1116 | 1115 | wol->wolopts = 0; |
---|
1117 | | - if(tp->wol_events & TYPHOON_WAKE_LINK_EVENT) |
---|
| 1116 | + if (tp->wol_events & TYPHOON_WAKE_LINK_EVENT) |
---|
1118 | 1117 | wol->wolopts |= WAKE_PHY; |
---|
1119 | | - if(tp->wol_events & TYPHOON_WAKE_MAGIC_PKT) |
---|
| 1118 | + if (tp->wol_events & TYPHOON_WAKE_MAGIC_PKT) |
---|
1120 | 1119 | wol->wolopts |= WAKE_MAGIC; |
---|
1121 | 1120 | memset(&wol->sopass, 0, sizeof(wol->sopass)); |
---|
1122 | 1121 | } |
---|
.. | .. |
---|
1126 | 1125 | { |
---|
1127 | 1126 | struct typhoon *tp = netdev_priv(dev); |
---|
1128 | 1127 | |
---|
1129 | | - if(wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) |
---|
| 1128 | + if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) |
---|
1130 | 1129 | return -EINVAL; |
---|
1131 | 1130 | |
---|
1132 | 1131 | tp->wol_events = 0; |
---|
1133 | | - if(wol->wolopts & WAKE_PHY) |
---|
| 1132 | + if (wol->wolopts & WAKE_PHY) |
---|
1134 | 1133 | tp->wol_events |= TYPHOON_WAKE_LINK_EVENT; |
---|
1135 | | - if(wol->wolopts & WAKE_MAGIC) |
---|
| 1134 | + if (wol->wolopts & WAKE_MAGIC) |
---|
1136 | 1135 | tp->wol_events |= TYPHOON_WAKE_MAGIC_PKT; |
---|
1137 | 1136 | |
---|
1138 | 1137 | return 0; |
---|
.. | .. |
---|
1163 | 1162 | { |
---|
1164 | 1163 | int i, err = 0; |
---|
1165 | 1164 | |
---|
1166 | | - for(i = 0; i < TYPHOON_WAIT_TIMEOUT; i++) { |
---|
1167 | | - if(ioread32(ioaddr + TYPHOON_REG_INTR_STATUS) & |
---|
| 1165 | + for (i = 0; i < TYPHOON_WAIT_TIMEOUT; i++) { |
---|
| 1166 | + if (ioread32(ioaddr + TYPHOON_REG_INTR_STATUS) & |
---|
1168 | 1167 | TYPHOON_INTR_BOOTCMD) |
---|
1169 | 1168 | goto out; |
---|
1170 | 1169 | udelay(TYPHOON_UDELAY); |
---|
.. | .. |
---|
1350 | 1349 | image_data = typhoon_fw->data; |
---|
1351 | 1350 | fHdr = (struct typhoon_file_header *) image_data; |
---|
1352 | 1351 | |
---|
1353 | | - /* Cannot just map the firmware image using pci_map_single() as |
---|
| 1352 | + /* Cannot just map the firmware image using dma_map_single() as |
---|
1354 | 1353 | * the firmware is vmalloc()'d and may not be physically contiguous, |
---|
1355 | | - * so we allocate some consistent memory to copy the sections into. |
---|
| 1354 | + * so we allocate some coherent memory to copy the sections into. |
---|
1356 | 1355 | */ |
---|
1357 | 1356 | err = -ENOMEM; |
---|
1358 | | - dpage = pci_alloc_consistent(pdev, PAGE_SIZE, &dpage_dma); |
---|
1359 | | - if(!dpage) { |
---|
| 1357 | + dpage = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, &dpage_dma, GFP_ATOMIC); |
---|
| 1358 | + if (!dpage) { |
---|
1360 | 1359 | netdev_err(tp->dev, "no DMA mem for firmware\n"); |
---|
1361 | 1360 | goto err_out; |
---|
1362 | 1361 | } |
---|
.. | .. |
---|
1369 | 1368 | ioaddr + TYPHOON_REG_INTR_MASK); |
---|
1370 | 1369 | |
---|
1371 | 1370 | err = -ETIMEDOUT; |
---|
1372 | | - if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
---|
| 1371 | + if (typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
---|
1373 | 1372 | netdev_err(tp->dev, "card ready timeout\n"); |
---|
1374 | 1373 | goto err_out_irq; |
---|
1375 | 1374 | } |
---|
.. | .. |
---|
1398 | 1397 | * last write to the command register to post, so |
---|
1399 | 1398 | * we don't need a typhoon_post_pci_writes() after it. |
---|
1400 | 1399 | */ |
---|
1401 | | - for(i = 0; i < numSections; i++) { |
---|
| 1400 | + for (i = 0; i < numSections; i++) { |
---|
1402 | 1401 | sHdr = (struct typhoon_section_header *) image_data; |
---|
1403 | 1402 | image_data += sizeof(struct typhoon_section_header); |
---|
1404 | 1403 | load_addr = le32_to_cpu(sHdr->startAddr); |
---|
1405 | 1404 | section_len = le32_to_cpu(sHdr->len); |
---|
1406 | 1405 | |
---|
1407 | | - while(section_len) { |
---|
| 1406 | + while (section_len) { |
---|
1408 | 1407 | len = min_t(u32, section_len, PAGE_SIZE); |
---|
1409 | 1408 | |
---|
1410 | | - if(typhoon_wait_interrupt(ioaddr) < 0 || |
---|
| 1409 | + if (typhoon_wait_interrupt(ioaddr) < 0 || |
---|
1411 | 1410 | ioread32(ioaddr + TYPHOON_REG_STATUS) != |
---|
1412 | 1411 | TYPHOON_STATUS_WAITING_FOR_SEGMENT) { |
---|
1413 | 1412 | netdev_err(tp->dev, "segment ready timeout\n"); |
---|
.. | .. |
---|
1420 | 1419 | * the checksum, we can do this once, at the end. |
---|
1421 | 1420 | */ |
---|
1422 | 1421 | csum = csum_fold(csum_partial_copy_nocheck(image_data, |
---|
1423 | | - dpage, len, |
---|
1424 | | - 0)); |
---|
| 1422 | + dpage, len)); |
---|
1425 | 1423 | |
---|
1426 | 1424 | iowrite32(len, ioaddr + TYPHOON_REG_BOOT_LENGTH); |
---|
1427 | 1425 | iowrite32(le16_to_cpu((__force __le16)csum), |
---|
.. | .. |
---|
1440 | 1438 | } |
---|
1441 | 1439 | } |
---|
1442 | 1440 | |
---|
1443 | | - if(typhoon_wait_interrupt(ioaddr) < 0 || |
---|
| 1441 | + if (typhoon_wait_interrupt(ioaddr) < 0 || |
---|
1444 | 1442 | ioread32(ioaddr + TYPHOON_REG_STATUS) != |
---|
1445 | 1443 | TYPHOON_STATUS_WAITING_FOR_SEGMENT) { |
---|
1446 | 1444 | netdev_err(tp->dev, "final segment ready timeout\n"); |
---|
.. | .. |
---|
1449 | 1447 | |
---|
1450 | 1448 | iowrite32(TYPHOON_BOOTCMD_DNLD_COMPLETE, ioaddr + TYPHOON_REG_COMMAND); |
---|
1451 | 1449 | |
---|
1452 | | - if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_BOOT) < 0) { |
---|
| 1450 | + if (typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_BOOT) < 0) { |
---|
1453 | 1451 | netdev_err(tp->dev, "boot ready timeout, status 0x%0x\n", |
---|
1454 | 1452 | ioread32(ioaddr + TYPHOON_REG_STATUS)); |
---|
1455 | 1453 | goto err_out_irq; |
---|
.. | .. |
---|
1461 | 1459 | iowrite32(irqMasked, ioaddr + TYPHOON_REG_INTR_MASK); |
---|
1462 | 1460 | iowrite32(irqEnabled, ioaddr + TYPHOON_REG_INTR_ENABLE); |
---|
1463 | 1461 | |
---|
1464 | | - pci_free_consistent(pdev, PAGE_SIZE, dpage, dpage_dma); |
---|
| 1462 | + dma_free_coherent(&pdev->dev, PAGE_SIZE, dpage, dpage_dma); |
---|
1465 | 1463 | |
---|
1466 | 1464 | err_out: |
---|
1467 | 1465 | return err; |
---|
.. | .. |
---|
1472 | 1470 | { |
---|
1473 | 1471 | void __iomem *ioaddr = tp->ioaddr; |
---|
1474 | 1472 | |
---|
1475 | | - if(typhoon_wait_status(ioaddr, initial_status) < 0) { |
---|
| 1473 | + if (typhoon_wait_status(ioaddr, initial_status) < 0) { |
---|
1476 | 1474 | netdev_err(tp->dev, "boot ready timeout\n"); |
---|
1477 | 1475 | goto out_timeout; |
---|
1478 | 1476 | } |
---|
.. | .. |
---|
1483 | 1481 | iowrite32(TYPHOON_BOOTCMD_REG_BOOT_RECORD, |
---|
1484 | 1482 | ioaddr + TYPHOON_REG_COMMAND); |
---|
1485 | 1483 | |
---|
1486 | | - if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_RUNNING) < 0) { |
---|
| 1484 | + if (typhoon_wait_status(ioaddr, TYPHOON_STATUS_RUNNING) < 0) { |
---|
1487 | 1485 | netdev_err(tp->dev, "boot finish timeout (status 0x%x)\n", |
---|
1488 | 1486 | ioread32(ioaddr + TYPHOON_REG_STATUS)); |
---|
1489 | 1487 | goto out_timeout; |
---|
.. | .. |
---|
1513 | 1511 | int dma_len; |
---|
1514 | 1512 | int type; |
---|
1515 | 1513 | |
---|
1516 | | - while(lastRead != le32_to_cpu(*index)) { |
---|
| 1514 | + while (lastRead != le32_to_cpu(*index)) { |
---|
1517 | 1515 | tx = (struct tx_desc *) (txRing->ringBase + lastRead); |
---|
1518 | 1516 | type = tx->flags & TYPHOON_TYPE_MASK; |
---|
1519 | 1517 | |
---|
1520 | | - if(type == TYPHOON_TX_DESC) { |
---|
| 1518 | + if (type == TYPHOON_TX_DESC) { |
---|
1521 | 1519 | /* This tx_desc describes a packet. |
---|
1522 | 1520 | */ |
---|
1523 | 1521 | unsigned long ptr = tx->tx_addr; |
---|
1524 | 1522 | struct sk_buff *skb = (struct sk_buff *) ptr; |
---|
1525 | 1523 | dev_kfree_skb_irq(skb); |
---|
1526 | | - } else if(type == TYPHOON_FRAG_DESC) { |
---|
| 1524 | + } else if (type == TYPHOON_FRAG_DESC) { |
---|
1527 | 1525 | /* This tx_desc describes a memory mapping. Free it. |
---|
1528 | 1526 | */ |
---|
1529 | 1527 | skb_dma = (dma_addr_t) le32_to_cpu(tx->frag.addr); |
---|
1530 | 1528 | dma_len = le16_to_cpu(tx->len); |
---|
1531 | | - pci_unmap_single(tp->pdev, skb_dma, dma_len, |
---|
1532 | | - PCI_DMA_TODEVICE); |
---|
| 1529 | + dma_unmap_single(&tp->pdev->dev, skb_dma, dma_len, |
---|
| 1530 | + DMA_TO_DEVICE); |
---|
1533 | 1531 | } |
---|
1534 | 1532 | |
---|
1535 | 1533 | tx->flags = 0; |
---|
.. | .. |
---|
1548 | 1546 | |
---|
1549 | 1547 | /* This will need changing if we start to use the Hi Tx ring. */ |
---|
1550 | 1548 | lastRead = typhoon_clean_tx(tp, txRing, index); |
---|
1551 | | - if(netif_queue_stopped(tp->dev) && typhoon_num_free(txRing->lastWrite, |
---|
| 1549 | + if (netif_queue_stopped(tp->dev) && typhoon_num_free(txRing->lastWrite, |
---|
1552 | 1550 | lastRead, TXLO_ENTRIES) > (numDesc + 2)) |
---|
1553 | 1551 | netif_wake_queue(tp->dev); |
---|
1554 | 1552 | |
---|
.. | .. |
---|
1564 | 1562 | struct basic_ring *ring = &tp->rxBuffRing; |
---|
1565 | 1563 | struct rx_free *r; |
---|
1566 | 1564 | |
---|
1567 | | - if((ring->lastWrite + sizeof(*r)) % (RXFREE_ENTRIES * sizeof(*r)) == |
---|
| 1565 | + if ((ring->lastWrite + sizeof(*r)) % (RXFREE_ENTRIES * sizeof(*r)) == |
---|
1568 | 1566 | le32_to_cpu(indexes->rxBuffCleared)) { |
---|
1569 | 1567 | /* no room in ring, just drop the skb |
---|
1570 | 1568 | */ |
---|
.. | .. |
---|
1595 | 1593 | |
---|
1596 | 1594 | rxb->skb = NULL; |
---|
1597 | 1595 | |
---|
1598 | | - if((ring->lastWrite + sizeof(*r)) % (RXFREE_ENTRIES * sizeof(*r)) == |
---|
| 1596 | + if ((ring->lastWrite + sizeof(*r)) % (RXFREE_ENTRIES * sizeof(*r)) == |
---|
1599 | 1597 | le32_to_cpu(indexes->rxBuffCleared)) |
---|
1600 | 1598 | return -ENOMEM; |
---|
1601 | 1599 | |
---|
1602 | 1600 | skb = netdev_alloc_skb(tp->dev, PKT_BUF_SZ); |
---|
1603 | | - if(!skb) |
---|
| 1601 | + if (!skb) |
---|
1604 | 1602 | return -ENOMEM; |
---|
1605 | 1603 | |
---|
1606 | 1604 | #if 0 |
---|
.. | .. |
---|
1610 | 1608 | skb_reserve(skb, 2); |
---|
1611 | 1609 | #endif |
---|
1612 | 1610 | |
---|
1613 | | - dma_addr = pci_map_single(tp->pdev, skb->data, |
---|
1614 | | - PKT_BUF_SZ, PCI_DMA_FROMDEVICE); |
---|
| 1611 | + dma_addr = dma_map_single(&tp->pdev->dev, skb->data, PKT_BUF_SZ, |
---|
| 1612 | + DMA_FROM_DEVICE); |
---|
1615 | 1613 | |
---|
1616 | 1614 | /* Since no card does 64 bit DAC, the high bits will never |
---|
1617 | 1615 | * change from zero. |
---|
.. | .. |
---|
1647 | 1645 | received = 0; |
---|
1648 | 1646 | local_ready = le32_to_cpu(*ready); |
---|
1649 | 1647 | rxaddr = le32_to_cpu(*cleared); |
---|
1650 | | - while(rxaddr != local_ready && budget > 0) { |
---|
| 1648 | + while (rxaddr != local_ready && budget > 0) { |
---|
1651 | 1649 | rx = (struct rx_desc *) (rxRing->ringBase + rxaddr); |
---|
1652 | 1650 | idx = rx->addr; |
---|
1653 | 1651 | rxb = &tp->rxbuffers[idx]; |
---|
.. | .. |
---|
1656 | 1654 | |
---|
1657 | 1655 | typhoon_inc_rx_index(&rxaddr, 1); |
---|
1658 | 1656 | |
---|
1659 | | - if(rx->flags & TYPHOON_RX_ERROR) { |
---|
| 1657 | + if (rx->flags & TYPHOON_RX_ERROR) { |
---|
1660 | 1658 | typhoon_recycle_rx_skb(tp, idx); |
---|
1661 | 1659 | continue; |
---|
1662 | 1660 | } |
---|
1663 | 1661 | |
---|
1664 | 1662 | pkt_len = le16_to_cpu(rx->frameLen); |
---|
1665 | 1663 | |
---|
1666 | | - if(pkt_len < rx_copybreak && |
---|
| 1664 | + if (pkt_len < rx_copybreak && |
---|
1667 | 1665 | (new_skb = netdev_alloc_skb(tp->dev, pkt_len + 2)) != NULL) { |
---|
1668 | 1666 | skb_reserve(new_skb, 2); |
---|
1669 | | - pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, |
---|
1670 | | - PKT_BUF_SZ, |
---|
1671 | | - PCI_DMA_FROMDEVICE); |
---|
| 1667 | + dma_sync_single_for_cpu(&tp->pdev->dev, dma_addr, |
---|
| 1668 | + PKT_BUF_SZ, DMA_FROM_DEVICE); |
---|
1672 | 1669 | skb_copy_to_linear_data(new_skb, skb->data, pkt_len); |
---|
1673 | | - pci_dma_sync_single_for_device(tp->pdev, dma_addr, |
---|
1674 | | - PKT_BUF_SZ, |
---|
1675 | | - PCI_DMA_FROMDEVICE); |
---|
| 1670 | + dma_sync_single_for_device(&tp->pdev->dev, dma_addr, |
---|
| 1671 | + PKT_BUF_SZ, |
---|
| 1672 | + DMA_FROM_DEVICE); |
---|
1676 | 1673 | skb_put(new_skb, pkt_len); |
---|
1677 | 1674 | typhoon_recycle_rx_skb(tp, idx); |
---|
1678 | 1675 | } else { |
---|
1679 | 1676 | new_skb = skb; |
---|
1680 | 1677 | skb_put(new_skb, pkt_len); |
---|
1681 | | - pci_unmap_single(tp->pdev, dma_addr, PKT_BUF_SZ, |
---|
1682 | | - PCI_DMA_FROMDEVICE); |
---|
| 1678 | + dma_unmap_single(&tp->pdev->dev, dma_addr, PKT_BUF_SZ, |
---|
| 1679 | + DMA_FROM_DEVICE); |
---|
1683 | 1680 | typhoon_alloc_rx_skb(tp, idx); |
---|
1684 | 1681 | } |
---|
1685 | 1682 | new_skb->protocol = eth_type_trans(new_skb, tp->dev); |
---|
1686 | 1683 | csum_bits = rx->rxStatus & (TYPHOON_RX_IP_CHK_GOOD | |
---|
1687 | 1684 | TYPHOON_RX_UDP_CHK_GOOD | TYPHOON_RX_TCP_CHK_GOOD); |
---|
1688 | | - if(csum_bits == |
---|
| 1685 | + if (csum_bits == |
---|
1689 | 1686 | (TYPHOON_RX_IP_CHK_GOOD | TYPHOON_RX_TCP_CHK_GOOD) || |
---|
1690 | 1687 | csum_bits == |
---|
1691 | 1688 | (TYPHOON_RX_IP_CHK_GOOD | TYPHOON_RX_UDP_CHK_GOOD)) { |
---|
.. | .. |
---|
1711 | 1708 | { |
---|
1712 | 1709 | u32 i; |
---|
1713 | 1710 | |
---|
1714 | | - for(i = 0; i < RXENT_ENTRIES; i++) { |
---|
| 1711 | + for (i = 0; i < RXENT_ENTRIES; i++) { |
---|
1715 | 1712 | struct rxbuff_ent *rxb = &tp->rxbuffers[i]; |
---|
1716 | | - if(rxb->skb) |
---|
| 1713 | + if (rxb->skb) |
---|
1717 | 1714 | continue; |
---|
1718 | | - if(typhoon_alloc_rx_skb(tp, i) < 0) |
---|
| 1715 | + if (typhoon_alloc_rx_skb(tp, i) < 0) |
---|
1719 | 1716 | break; |
---|
1720 | 1717 | } |
---|
1721 | 1718 | } |
---|
.. | .. |
---|
1728 | 1725 | int work_done; |
---|
1729 | 1726 | |
---|
1730 | 1727 | rmb(); |
---|
1731 | | - if(!tp->awaiting_resp && indexes->respReady != indexes->respCleared) |
---|
| 1728 | + if (!tp->awaiting_resp && indexes->respReady != indexes->respCleared) |
---|
1732 | 1729 | typhoon_process_response(tp, 0, NULL); |
---|
1733 | 1730 | |
---|
1734 | | - if(le32_to_cpu(indexes->txLoCleared) != tp->txLoRing.lastRead) |
---|
| 1731 | + if (le32_to_cpu(indexes->txLoCleared) != tp->txLoRing.lastRead) |
---|
1735 | 1732 | typhoon_tx_complete(tp, &tp->txLoRing, &indexes->txLoCleared); |
---|
1736 | 1733 | |
---|
1737 | 1734 | work_done = 0; |
---|
1738 | 1735 | |
---|
1739 | | - if(indexes->rxHiCleared != indexes->rxHiReady) { |
---|
| 1736 | + if (indexes->rxHiCleared != indexes->rxHiReady) { |
---|
1740 | 1737 | work_done += typhoon_rx(tp, &tp->rxHiRing, &indexes->rxHiReady, |
---|
1741 | 1738 | &indexes->rxHiCleared, budget); |
---|
1742 | 1739 | } |
---|
1743 | 1740 | |
---|
1744 | | - if(indexes->rxLoCleared != indexes->rxLoReady) { |
---|
| 1741 | + if (indexes->rxLoCleared != indexes->rxLoReady) { |
---|
1745 | 1742 | work_done += typhoon_rx(tp, &tp->rxLoRing, &indexes->rxLoReady, |
---|
1746 | 1743 | &indexes->rxLoCleared, budget - work_done); |
---|
1747 | 1744 | } |
---|
1748 | 1745 | |
---|
1749 | | - if(le32_to_cpu(indexes->rxBuffCleared) == tp->rxBuffRing.lastWrite) { |
---|
| 1746 | + if (le32_to_cpu(indexes->rxBuffCleared) == tp->rxBuffRing.lastWrite) { |
---|
1750 | 1747 | /* rxBuff ring is empty, try to fill it. */ |
---|
1751 | 1748 | typhoon_fill_free_ring(tp); |
---|
1752 | 1749 | } |
---|
.. | .. |
---|
1770 | 1767 | u32 intr_status; |
---|
1771 | 1768 | |
---|
1772 | 1769 | intr_status = ioread32(ioaddr + TYPHOON_REG_INTR_STATUS); |
---|
1773 | | - if(!(intr_status & TYPHOON_INTR_HOST_INT)) |
---|
| 1770 | + if (!(intr_status & TYPHOON_INTR_HOST_INT)) |
---|
1774 | 1771 | return IRQ_NONE; |
---|
1775 | 1772 | |
---|
1776 | 1773 | iowrite32(intr_status, ioaddr + TYPHOON_REG_INTR_STATUS); |
---|
.. | .. |
---|
1790 | 1787 | { |
---|
1791 | 1788 | u32 i; |
---|
1792 | 1789 | |
---|
1793 | | - for(i = 0; i < RXENT_ENTRIES; i++) { |
---|
| 1790 | + for (i = 0; i < RXENT_ENTRIES; i++) { |
---|
1794 | 1791 | struct rxbuff_ent *rxb = &tp->rxbuffers[i]; |
---|
1795 | | - if(rxb->skb) { |
---|
1796 | | - pci_unmap_single(tp->pdev, rxb->dma_addr, PKT_BUF_SZ, |
---|
1797 | | - PCI_DMA_FROMDEVICE); |
---|
| 1792 | + if (rxb->skb) { |
---|
| 1793 | + dma_unmap_single(&tp->pdev->dev, rxb->dma_addr, |
---|
| 1794 | + PKT_BUF_SZ, DMA_FROM_DEVICE); |
---|
1798 | 1795 | dev_kfree_skb(rxb->skb); |
---|
1799 | 1796 | rxb->skb = NULL; |
---|
1800 | 1797 | } |
---|
.. | .. |
---|
1802 | 1799 | } |
---|
1803 | 1800 | |
---|
1804 | 1801 | static int |
---|
1805 | | -typhoon_sleep(struct typhoon *tp, pci_power_t state, __le16 events) |
---|
| 1802 | +typhoon_sleep_early(struct typhoon *tp, __le16 events) |
---|
1806 | 1803 | { |
---|
1807 | | - struct pci_dev *pdev = tp->pdev; |
---|
1808 | 1804 | void __iomem *ioaddr = tp->ioaddr; |
---|
1809 | 1805 | struct cmd_desc xp_cmd; |
---|
1810 | 1806 | int err; |
---|
.. | .. |
---|
1812 | 1808 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_ENABLE_WAKE_EVENTS); |
---|
1813 | 1809 | xp_cmd.parm1 = events; |
---|
1814 | 1810 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1815 | | - if(err < 0) { |
---|
| 1811 | + if (err < 0) { |
---|
1816 | 1812 | netdev_err(tp->dev, "typhoon_sleep(): wake events cmd err %d\n", |
---|
1817 | 1813 | err); |
---|
1818 | 1814 | return err; |
---|
.. | .. |
---|
1820 | 1816 | |
---|
1821 | 1817 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_GOTO_SLEEP); |
---|
1822 | 1818 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1823 | | - if(err < 0) { |
---|
| 1819 | + if (err < 0) { |
---|
1824 | 1820 | netdev_err(tp->dev, "typhoon_sleep(): sleep cmd err %d\n", err); |
---|
1825 | 1821 | return err; |
---|
1826 | 1822 | } |
---|
1827 | 1823 | |
---|
1828 | | - if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_SLEEPING) < 0) |
---|
| 1824 | + if (typhoon_wait_status(ioaddr, TYPHOON_STATUS_SLEEPING) < 0) |
---|
1829 | 1825 | return -ETIMEDOUT; |
---|
1830 | 1826 | |
---|
1831 | 1827 | /* Since we cannot monitor the status of the link while sleeping, |
---|
.. | .. |
---|
1833 | 1829 | */ |
---|
1834 | 1830 | netif_carrier_off(tp->dev); |
---|
1835 | 1831 | |
---|
| 1832 | + return 0; |
---|
| 1833 | +} |
---|
| 1834 | + |
---|
| 1835 | +static int |
---|
| 1836 | +typhoon_sleep(struct typhoon *tp, pci_power_t state, __le16 events) |
---|
| 1837 | +{ |
---|
| 1838 | + int err; |
---|
| 1839 | + |
---|
| 1840 | + err = typhoon_sleep_early(tp, events); |
---|
| 1841 | + |
---|
| 1842 | + if (err) |
---|
| 1843 | + return err; |
---|
| 1844 | + |
---|
1836 | 1845 | pci_enable_wake(tp->pdev, state, 1); |
---|
1837 | | - pci_disable_device(pdev); |
---|
1838 | | - return pci_set_power_state(pdev, state); |
---|
| 1846 | + pci_disable_device(tp->pdev); |
---|
| 1847 | + return pci_set_power_state(tp->pdev, state); |
---|
1839 | 1848 | } |
---|
1840 | 1849 | |
---|
1841 | 1850 | static int |
---|
1842 | 1851 | typhoon_wakeup(struct typhoon *tp, int wait_type) |
---|
1843 | 1852 | { |
---|
1844 | | - struct pci_dev *pdev = tp->pdev; |
---|
1845 | 1853 | void __iomem *ioaddr = tp->ioaddr; |
---|
1846 | | - |
---|
1847 | | - pci_set_power_state(pdev, PCI_D0); |
---|
1848 | | - pci_restore_state(pdev); |
---|
1849 | 1854 | |
---|
1850 | 1855 | /* Post 2.x.x versions of the Sleep Image require a reset before |
---|
1851 | 1856 | * we can download the Runtime Image. But let's not make users of |
---|
1852 | 1857 | * the old firmware pay for the reset. |
---|
1853 | 1858 | */ |
---|
1854 | 1859 | iowrite32(TYPHOON_BOOTCMD_WAKEUP, ioaddr + TYPHOON_REG_COMMAND); |
---|
1855 | | - if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_HOST) < 0 || |
---|
| 1860 | + if (typhoon_wait_status(ioaddr, TYPHOON_STATUS_WAITING_FOR_HOST) < 0 || |
---|
1856 | 1861 | (tp->capabilities & TYPHOON_WAKEUP_NEEDS_RESET)) |
---|
1857 | 1862 | return typhoon_reset(ioaddr, wait_type); |
---|
1858 | 1863 | |
---|
.. | .. |
---|
1871 | 1876 | typhoon_fill_free_ring(tp); |
---|
1872 | 1877 | |
---|
1873 | 1878 | err = typhoon_download_firmware(tp); |
---|
1874 | | - if(err < 0) { |
---|
| 1879 | + if (err < 0) { |
---|
1875 | 1880 | netdev_err(tp->dev, "cannot load runtime on 3XP\n"); |
---|
1876 | 1881 | goto error_out; |
---|
1877 | 1882 | } |
---|
1878 | 1883 | |
---|
1879 | | - if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_BOOT) < 0) { |
---|
| 1884 | + if (typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_BOOT) < 0) { |
---|
1880 | 1885 | netdev_err(tp->dev, "cannot boot 3XP\n"); |
---|
1881 | 1886 | err = -EIO; |
---|
1882 | 1887 | goto error_out; |
---|
.. | .. |
---|
1885 | 1890 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_MAX_PKT_SIZE); |
---|
1886 | 1891 | xp_cmd.parm1 = cpu_to_le16(PKT_BUF_SZ); |
---|
1887 | 1892 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1888 | | - if(err < 0) |
---|
| 1893 | + if (err < 0) |
---|
1889 | 1894 | goto error_out; |
---|
1890 | 1895 | |
---|
1891 | 1896 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_MAC_ADDRESS); |
---|
1892 | 1897 | xp_cmd.parm1 = cpu_to_le16(ntohs(*(__be16 *)&dev->dev_addr[0])); |
---|
1893 | 1898 | xp_cmd.parm2 = cpu_to_le32(ntohl(*(__be32 *)&dev->dev_addr[2])); |
---|
1894 | 1899 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1895 | | - if(err < 0) |
---|
| 1900 | + if (err < 0) |
---|
1896 | 1901 | goto error_out; |
---|
1897 | 1902 | |
---|
1898 | 1903 | /* Disable IRQ coalescing -- we can reenable it when 3Com gives |
---|
.. | .. |
---|
1901 | 1906 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_IRQ_COALESCE_CTRL); |
---|
1902 | 1907 | xp_cmd.parm1 = 0; |
---|
1903 | 1908 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1904 | | - if(err < 0) |
---|
| 1909 | + if (err < 0) |
---|
1905 | 1910 | goto error_out; |
---|
1906 | 1911 | |
---|
1907 | 1912 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_XCVR_SELECT); |
---|
1908 | 1913 | xp_cmd.parm1 = tp->xcvr_select; |
---|
1909 | 1914 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1910 | | - if(err < 0) |
---|
| 1915 | + if (err < 0) |
---|
1911 | 1916 | goto error_out; |
---|
1912 | 1917 | |
---|
1913 | 1918 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_VLAN_TYPE_WRITE); |
---|
1914 | 1919 | xp_cmd.parm1 = cpu_to_le16(ETH_P_8021Q); |
---|
1915 | 1920 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1916 | | - if(err < 0) |
---|
| 1921 | + if (err < 0) |
---|
1917 | 1922 | goto error_out; |
---|
1918 | 1923 | |
---|
1919 | 1924 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_OFFLOAD_TASKS); |
---|
1920 | 1925 | xp_cmd.parm2 = tp->offload; |
---|
1921 | 1926 | xp_cmd.parm3 = tp->offload; |
---|
1922 | 1927 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1923 | | - if(err < 0) |
---|
| 1928 | + if (err < 0) |
---|
1924 | 1929 | goto error_out; |
---|
1925 | 1930 | |
---|
1926 | 1931 | typhoon_set_rx_mode(dev); |
---|
1927 | 1932 | |
---|
1928 | 1933 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_TX_ENABLE); |
---|
1929 | 1934 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1930 | | - if(err < 0) |
---|
| 1935 | + if (err < 0) |
---|
1931 | 1936 | goto error_out; |
---|
1932 | 1937 | |
---|
1933 | 1938 | INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_RX_ENABLE); |
---|
1934 | 1939 | err = typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1935 | | - if(err < 0) |
---|
| 1940 | + if (err < 0) |
---|
1936 | 1941 | goto error_out; |
---|
1937 | 1942 | |
---|
1938 | 1943 | tp->card_state = Running; |
---|
.. | .. |
---|
1972 | 1977 | /* Wait 1/2 sec for any outstanding transmits to occur |
---|
1973 | 1978 | * We'll cleanup after the reset if this times out. |
---|
1974 | 1979 | */ |
---|
1975 | | - for(i = 0; i < TYPHOON_WAIT_TIMEOUT; i++) { |
---|
1976 | | - if(indexes->txLoCleared == cpu_to_le32(txLo->lastWrite)) |
---|
| 1980 | + for (i = 0; i < TYPHOON_WAIT_TIMEOUT; i++) { |
---|
| 1981 | + if (indexes->txLoCleared == cpu_to_le32(txLo->lastWrite)) |
---|
1977 | 1982 | break; |
---|
1978 | 1983 | udelay(TYPHOON_UDELAY); |
---|
1979 | 1984 | } |
---|
1980 | 1985 | |
---|
1981 | | - if(i == TYPHOON_WAIT_TIMEOUT) |
---|
| 1986 | + if (i == TYPHOON_WAIT_TIMEOUT) |
---|
1982 | 1987 | netdev_err(tp->dev, "halt timed out waiting for Tx to complete\n"); |
---|
1983 | 1988 | |
---|
1984 | 1989 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_TX_DISABLE); |
---|
.. | .. |
---|
1995 | 2000 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_HALT); |
---|
1996 | 2001 | typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL); |
---|
1997 | 2002 | |
---|
1998 | | - if(typhoon_wait_status(ioaddr, TYPHOON_STATUS_HALTED) < 0) |
---|
| 2003 | + if (typhoon_wait_status(ioaddr, TYPHOON_STATUS_HALTED) < 0) |
---|
1999 | 2004 | netdev_err(tp->dev, "timed out waiting for 3XP to halt\n"); |
---|
2000 | 2005 | |
---|
2001 | | - if(typhoon_reset(ioaddr, wait_type) < 0) { |
---|
| 2006 | + if (typhoon_reset(ioaddr, wait_type) < 0) { |
---|
2002 | 2007 | netdev_err(tp->dev, "unable to reset 3XP\n"); |
---|
2003 | 2008 | return -ETIMEDOUT; |
---|
2004 | 2009 | } |
---|
2005 | 2010 | |
---|
2006 | 2011 | /* cleanup any outstanding Tx packets */ |
---|
2007 | | - if(indexes->txLoCleared != cpu_to_le32(txLo->lastWrite)) { |
---|
| 2012 | + if (indexes->txLoCleared != cpu_to_le32(txLo->lastWrite)) { |
---|
2008 | 2013 | indexes->txLoCleared = cpu_to_le32(txLo->lastWrite); |
---|
2009 | 2014 | typhoon_clean_tx(tp, &tp->txLoRing, &indexes->txLoCleared); |
---|
2010 | 2015 | } |
---|
.. | .. |
---|
2013 | 2018 | } |
---|
2014 | 2019 | |
---|
2015 | 2020 | static void |
---|
2016 | | -typhoon_tx_timeout(struct net_device *dev) |
---|
| 2021 | +typhoon_tx_timeout(struct net_device *dev, unsigned int txqueue) |
---|
2017 | 2022 | { |
---|
2018 | 2023 | struct typhoon *tp = netdev_priv(dev); |
---|
2019 | 2024 | |
---|
2020 | | - if(typhoon_reset(tp->ioaddr, WaitNoSleep) < 0) { |
---|
| 2025 | + if (typhoon_reset(tp->ioaddr, WaitNoSleep) < 0) { |
---|
2021 | 2026 | netdev_warn(dev, "could not reset in tx timeout\n"); |
---|
2022 | 2027 | goto truly_dead; |
---|
2023 | 2028 | } |
---|
.. | .. |
---|
2026 | 2031 | typhoon_clean_tx(tp, &tp->txLoRing, &tp->indexes->txLoCleared); |
---|
2027 | 2032 | typhoon_free_rx_rings(tp); |
---|
2028 | 2033 | |
---|
2029 | | - if(typhoon_start_runtime(tp) < 0) { |
---|
| 2034 | + if (typhoon_start_runtime(tp) < 0) { |
---|
2030 | 2035 | netdev_err(dev, "could not start runtime in tx timeout\n"); |
---|
2031 | 2036 | goto truly_dead; |
---|
2032 | 2037 | } |
---|
.. | .. |
---|
2050 | 2055 | if (err) |
---|
2051 | 2056 | goto out; |
---|
2052 | 2057 | |
---|
| 2058 | + pci_set_power_state(tp->pdev, PCI_D0); |
---|
| 2059 | + pci_restore_state(tp->pdev); |
---|
| 2060 | + |
---|
2053 | 2061 | err = typhoon_wakeup(tp, WaitSleep); |
---|
2054 | | - if(err < 0) { |
---|
| 2062 | + if (err < 0) { |
---|
2055 | 2063 | netdev_err(dev, "unable to wakeup device\n"); |
---|
2056 | 2064 | goto out_sleep; |
---|
2057 | 2065 | } |
---|
2058 | 2066 | |
---|
2059 | 2067 | err = request_irq(dev->irq, typhoon_interrupt, IRQF_SHARED, |
---|
2060 | 2068 | dev->name, dev); |
---|
2061 | | - if(err < 0) |
---|
| 2069 | + if (err < 0) |
---|
2062 | 2070 | goto out_sleep; |
---|
2063 | 2071 | |
---|
2064 | 2072 | napi_enable(&tp->napi); |
---|
2065 | 2073 | |
---|
2066 | 2074 | err = typhoon_start_runtime(tp); |
---|
2067 | | - if(err < 0) { |
---|
| 2075 | + if (err < 0) { |
---|
2068 | 2076 | napi_disable(&tp->napi); |
---|
2069 | 2077 | goto out_irq; |
---|
2070 | 2078 | } |
---|
.. | .. |
---|
2076 | 2084 | free_irq(dev->irq, dev); |
---|
2077 | 2085 | |
---|
2078 | 2086 | out_sleep: |
---|
2079 | | - if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
---|
| 2087 | + if (typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
---|
2080 | 2088 | netdev_err(dev, "unable to reboot into sleep img\n"); |
---|
2081 | 2089 | typhoon_reset(tp->ioaddr, NoWait); |
---|
2082 | 2090 | goto out; |
---|
2083 | 2091 | } |
---|
2084 | 2092 | |
---|
2085 | | - if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) |
---|
| 2093 | + if (typhoon_sleep(tp, PCI_D3hot, 0) < 0) |
---|
2086 | 2094 | netdev_err(dev, "unable to go back to sleep\n"); |
---|
2087 | 2095 | |
---|
2088 | 2096 | out: |
---|
.. | .. |
---|
2097 | 2105 | netif_stop_queue(dev); |
---|
2098 | 2106 | napi_disable(&tp->napi); |
---|
2099 | 2107 | |
---|
2100 | | - if(typhoon_stop_runtime(tp, WaitSleep) < 0) |
---|
| 2108 | + if (typhoon_stop_runtime(tp, WaitSleep) < 0) |
---|
2101 | 2109 | netdev_err(dev, "unable to stop runtime\n"); |
---|
2102 | 2110 | |
---|
2103 | 2111 | /* Make sure there is no irq handler running on a different CPU. */ |
---|
.. | .. |
---|
2106 | 2114 | typhoon_free_rx_rings(tp); |
---|
2107 | 2115 | typhoon_init_rings(tp); |
---|
2108 | 2116 | |
---|
2109 | | - if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) |
---|
| 2117 | + if (typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) |
---|
2110 | 2118 | netdev_err(dev, "unable to boot sleep image\n"); |
---|
2111 | 2119 | |
---|
2112 | | - if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) |
---|
| 2120 | + if (typhoon_sleep(tp, PCI_D3hot, 0) < 0) |
---|
2113 | 2121 | netdev_err(dev, "unable to put card to sleep\n"); |
---|
2114 | 2122 | |
---|
2115 | 2123 | return 0; |
---|
2116 | 2124 | } |
---|
2117 | 2125 | |
---|
2118 | | -#ifdef CONFIG_PM |
---|
2119 | | -static int |
---|
2120 | | -typhoon_resume(struct pci_dev *pdev) |
---|
| 2126 | +static int __maybe_unused |
---|
| 2127 | +typhoon_resume(struct device *dev_d) |
---|
2121 | 2128 | { |
---|
2122 | | - struct net_device *dev = pci_get_drvdata(pdev); |
---|
| 2129 | + struct net_device *dev = dev_get_drvdata(dev_d); |
---|
2123 | 2130 | struct typhoon *tp = netdev_priv(dev); |
---|
2124 | 2131 | |
---|
2125 | 2132 | /* If we're down, resume when we are upped. |
---|
2126 | 2133 | */ |
---|
2127 | | - if(!netif_running(dev)) |
---|
| 2134 | + if (!netif_running(dev)) |
---|
2128 | 2135 | return 0; |
---|
2129 | 2136 | |
---|
2130 | | - if(typhoon_wakeup(tp, WaitNoSleep) < 0) { |
---|
| 2137 | + if (typhoon_wakeup(tp, WaitNoSleep) < 0) { |
---|
2131 | 2138 | netdev_err(dev, "critical: could not wake up in resume\n"); |
---|
2132 | 2139 | goto reset; |
---|
2133 | 2140 | } |
---|
2134 | 2141 | |
---|
2135 | | - if(typhoon_start_runtime(tp) < 0) { |
---|
| 2142 | + if (typhoon_start_runtime(tp) < 0) { |
---|
2136 | 2143 | netdev_err(dev, "critical: could not start runtime in resume\n"); |
---|
2137 | 2144 | goto reset; |
---|
2138 | 2145 | } |
---|
.. | .. |
---|
2145 | 2152 | return -EBUSY; |
---|
2146 | 2153 | } |
---|
2147 | 2154 | |
---|
2148 | | -static int |
---|
2149 | | -typhoon_suspend(struct pci_dev *pdev, pm_message_t state) |
---|
| 2155 | +static int __maybe_unused |
---|
| 2156 | +typhoon_suspend(struct device *dev_d) |
---|
2150 | 2157 | { |
---|
| 2158 | + struct pci_dev *pdev = to_pci_dev(dev_d); |
---|
2151 | 2159 | struct net_device *dev = pci_get_drvdata(pdev); |
---|
2152 | 2160 | struct typhoon *tp = netdev_priv(dev); |
---|
2153 | 2161 | struct cmd_desc xp_cmd; |
---|
2154 | 2162 | |
---|
2155 | 2163 | /* If we're down, we're already suspended. |
---|
2156 | 2164 | */ |
---|
2157 | | - if(!netif_running(dev)) |
---|
| 2165 | + if (!netif_running(dev)) |
---|
2158 | 2166 | return 0; |
---|
2159 | 2167 | |
---|
2160 | 2168 | /* TYPHOON_OFFLOAD_VLAN is always on now, so this doesn't work */ |
---|
2161 | | - if(tp->wol_events & TYPHOON_WAKE_MAGIC_PKT) |
---|
| 2169 | + if (tp->wol_events & TYPHOON_WAKE_MAGIC_PKT) |
---|
2162 | 2170 | netdev_warn(dev, "cannot do WAKE_MAGIC with VLAN offloading\n"); |
---|
2163 | 2171 | |
---|
2164 | 2172 | netif_device_detach(dev); |
---|
2165 | 2173 | |
---|
2166 | | - if(typhoon_stop_runtime(tp, WaitNoSleep) < 0) { |
---|
| 2174 | + if (typhoon_stop_runtime(tp, WaitNoSleep) < 0) { |
---|
2167 | 2175 | netdev_err(dev, "unable to stop runtime\n"); |
---|
2168 | 2176 | goto need_resume; |
---|
2169 | 2177 | } |
---|
.. | .. |
---|
2171 | 2179 | typhoon_free_rx_rings(tp); |
---|
2172 | 2180 | typhoon_init_rings(tp); |
---|
2173 | 2181 | |
---|
2174 | | - if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
---|
| 2182 | + if (typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) { |
---|
2175 | 2183 | netdev_err(dev, "unable to boot sleep image\n"); |
---|
2176 | 2184 | goto need_resume; |
---|
2177 | 2185 | } |
---|
.. | .. |
---|
2179 | 2187 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_MAC_ADDRESS); |
---|
2180 | 2188 | xp_cmd.parm1 = cpu_to_le16(ntohs(*(__be16 *)&dev->dev_addr[0])); |
---|
2181 | 2189 | xp_cmd.parm2 = cpu_to_le32(ntohl(*(__be32 *)&dev->dev_addr[2])); |
---|
2182 | | - if(typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL) < 0) { |
---|
| 2190 | + if (typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL) < 0) { |
---|
2183 | 2191 | netdev_err(dev, "unable to set mac address in suspend\n"); |
---|
2184 | 2192 | goto need_resume; |
---|
2185 | 2193 | } |
---|
2186 | 2194 | |
---|
2187 | 2195 | INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_SET_RX_FILTER); |
---|
2188 | 2196 | xp_cmd.parm1 = TYPHOON_RX_FILTER_DIRECTED | TYPHOON_RX_FILTER_BROADCAST; |
---|
2189 | | - if(typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL) < 0) { |
---|
| 2197 | + if (typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL) < 0) { |
---|
2190 | 2198 | netdev_err(dev, "unable to set rx filter in suspend\n"); |
---|
2191 | 2199 | goto need_resume; |
---|
2192 | 2200 | } |
---|
2193 | 2201 | |
---|
2194 | | - if(typhoon_sleep(tp, pci_choose_state(pdev, state), tp->wol_events) < 0) { |
---|
| 2202 | + if (typhoon_sleep_early(tp, tp->wol_events) < 0) { |
---|
2195 | 2203 | netdev_err(dev, "unable to put card to sleep\n"); |
---|
2196 | 2204 | goto need_resume; |
---|
2197 | 2205 | } |
---|
2198 | 2206 | |
---|
| 2207 | + device_wakeup_enable(dev_d); |
---|
| 2208 | + |
---|
2199 | 2209 | return 0; |
---|
2200 | 2210 | |
---|
2201 | 2211 | need_resume: |
---|
2202 | | - typhoon_resume(pdev); |
---|
| 2212 | + typhoon_resume(dev_d); |
---|
2203 | 2213 | return -EBUSY; |
---|
2204 | 2214 | } |
---|
2205 | | -#endif |
---|
2206 | 2215 | |
---|
2207 | 2216 | static int |
---|
2208 | 2217 | typhoon_test_mmio(struct pci_dev *pdev) |
---|
.. | .. |
---|
2211 | 2220 | int mode = 0; |
---|
2212 | 2221 | u32 val; |
---|
2213 | 2222 | |
---|
2214 | | - if(!ioaddr) |
---|
| 2223 | + if (!ioaddr) |
---|
2215 | 2224 | goto out; |
---|
2216 | 2225 | |
---|
2217 | | - if(ioread32(ioaddr + TYPHOON_REG_STATUS) != |
---|
| 2226 | + if (ioread32(ioaddr + TYPHOON_REG_STATUS) != |
---|
2218 | 2227 | TYPHOON_STATUS_WAITING_FOR_HOST) |
---|
2219 | 2228 | goto out_unmap; |
---|
2220 | 2229 | |
---|
.. | .. |
---|
2227 | 2236 | * The 50usec delay is arbitrary -- it could probably be smaller. |
---|
2228 | 2237 | */ |
---|
2229 | 2238 | val = ioread32(ioaddr + TYPHOON_REG_INTR_STATUS); |
---|
2230 | | - if((val & TYPHOON_INTR_SELF) == 0) { |
---|
| 2239 | + if ((val & TYPHOON_INTR_SELF) == 0) { |
---|
2231 | 2240 | iowrite32(1, ioaddr + TYPHOON_REG_SELF_INTERRUPT); |
---|
2232 | 2241 | ioread32(ioaddr + TYPHOON_REG_INTR_STATUS); |
---|
2233 | 2242 | udelay(50); |
---|
2234 | 2243 | val = ioread32(ioaddr + TYPHOON_REG_INTR_STATUS); |
---|
2235 | | - if(val & TYPHOON_INTR_SELF) |
---|
| 2244 | + if (val & TYPHOON_INTR_SELF) |
---|
2236 | 2245 | mode = 1; |
---|
2237 | 2246 | } |
---|
2238 | 2247 | |
---|
.. | .. |
---|
2245 | 2254 | pci_iounmap(pdev, ioaddr); |
---|
2246 | 2255 | |
---|
2247 | 2256 | out: |
---|
2248 | | - if(!mode) |
---|
| 2257 | + if (!mode) |
---|
2249 | 2258 | pr_info("%s: falling back to port IO\n", pci_name(pdev)); |
---|
2250 | 2259 | return mode; |
---|
2251 | 2260 | } |
---|
.. | .. |
---|
2276 | 2285 | const char *err_msg; |
---|
2277 | 2286 | |
---|
2278 | 2287 | dev = alloc_etherdev(sizeof(*tp)); |
---|
2279 | | - if(dev == NULL) { |
---|
| 2288 | + if (dev == NULL) { |
---|
2280 | 2289 | err_msg = "unable to alloc new net device"; |
---|
2281 | 2290 | err = -ENOMEM; |
---|
2282 | 2291 | goto error_out; |
---|
.. | .. |
---|
2284 | 2293 | SET_NETDEV_DEV(dev, &pdev->dev); |
---|
2285 | 2294 | |
---|
2286 | 2295 | err = pci_enable_device(pdev); |
---|
2287 | | - if(err < 0) { |
---|
| 2296 | + if (err < 0) { |
---|
2288 | 2297 | err_msg = "unable to enable device"; |
---|
2289 | 2298 | goto error_out_dev; |
---|
2290 | 2299 | } |
---|
2291 | 2300 | |
---|
2292 | 2301 | err = pci_set_mwi(pdev); |
---|
2293 | | - if(err < 0) { |
---|
| 2302 | + if (err < 0) { |
---|
2294 | 2303 | err_msg = "unable to set MWI"; |
---|
2295 | 2304 | goto error_out_disable; |
---|
2296 | 2305 | } |
---|
2297 | 2306 | |
---|
2298 | | - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
---|
2299 | | - if(err < 0) { |
---|
| 2307 | + err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
---|
| 2308 | + if (err < 0) { |
---|
2300 | 2309 | err_msg = "No usable DMA configuration"; |
---|
2301 | 2310 | goto error_out_mwi; |
---|
2302 | 2311 | } |
---|
2303 | 2312 | |
---|
2304 | 2313 | /* sanity checks on IO and MMIO BARs |
---|
2305 | 2314 | */ |
---|
2306 | | - if(!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) { |
---|
| 2315 | + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) { |
---|
2307 | 2316 | err_msg = "region #1 not a PCI IO resource, aborting"; |
---|
2308 | 2317 | err = -ENODEV; |
---|
2309 | 2318 | goto error_out_mwi; |
---|
2310 | 2319 | } |
---|
2311 | | - if(pci_resource_len(pdev, 0) < 128) { |
---|
| 2320 | + if (pci_resource_len(pdev, 0) < 128) { |
---|
2312 | 2321 | err_msg = "Invalid PCI IO region size, aborting"; |
---|
2313 | 2322 | err = -ENODEV; |
---|
2314 | 2323 | goto error_out_mwi; |
---|
2315 | 2324 | } |
---|
2316 | | - if(!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { |
---|
| 2325 | + if (!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { |
---|
2317 | 2326 | err_msg = "region #1 not a PCI MMIO resource, aborting"; |
---|
2318 | 2327 | err = -ENODEV; |
---|
2319 | 2328 | goto error_out_mwi; |
---|
2320 | 2329 | } |
---|
2321 | | - if(pci_resource_len(pdev, 1) < 128) { |
---|
| 2330 | + if (pci_resource_len(pdev, 1) < 128) { |
---|
2322 | 2331 | err_msg = "Invalid PCI MMIO region size, aborting"; |
---|
2323 | 2332 | err = -ENODEV; |
---|
2324 | 2333 | goto error_out_mwi; |
---|
2325 | 2334 | } |
---|
2326 | 2335 | |
---|
2327 | 2336 | err = pci_request_regions(pdev, KBUILD_MODNAME); |
---|
2328 | | - if(err < 0) { |
---|
| 2337 | + if (err < 0) { |
---|
2329 | 2338 | err_msg = "could not request regions"; |
---|
2330 | 2339 | goto error_out_mwi; |
---|
2331 | 2340 | } |
---|
2332 | 2341 | |
---|
2333 | 2342 | /* map our registers |
---|
2334 | 2343 | */ |
---|
2335 | | - if(use_mmio != 0 && use_mmio != 1) |
---|
| 2344 | + if (use_mmio != 0 && use_mmio != 1) |
---|
2336 | 2345 | use_mmio = typhoon_test_mmio(pdev); |
---|
2337 | 2346 | |
---|
2338 | 2347 | ioaddr = pci_iomap(pdev, use_mmio, 128); |
---|
.. | .. |
---|
2344 | 2353 | |
---|
2345 | 2354 | /* allocate pci dma space for rx and tx descriptor rings |
---|
2346 | 2355 | */ |
---|
2347 | | - shared = pci_alloc_consistent(pdev, sizeof(struct typhoon_shared), |
---|
2348 | | - &shared_dma); |
---|
2349 | | - if(!shared) { |
---|
| 2356 | + shared = dma_alloc_coherent(&pdev->dev, sizeof(struct typhoon_shared), |
---|
| 2357 | + &shared_dma, GFP_KERNEL); |
---|
| 2358 | + if (!shared) { |
---|
2350 | 2359 | err_msg = "could not allocate DMA memory"; |
---|
2351 | 2360 | err = -ENOMEM; |
---|
2352 | 2361 | goto error_out_remap; |
---|
.. | .. |
---|
2426 | 2435 | * seem to need a little extra help to get started. Since we don't |
---|
2427 | 2436 | * know how to nudge it along, just kick it. |
---|
2428 | 2437 | */ |
---|
2429 | | - if(xp_resp[0].numDesc != 0) |
---|
| 2438 | + if (xp_resp[0].numDesc != 0) |
---|
2430 | 2439 | tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET; |
---|
2431 | 2440 | |
---|
2432 | 2441 | err = typhoon_sleep(tp, PCI_D3hot, 0); |
---|
.. | .. |
---|
2471 | 2480 | /* xp_resp still contains the response to the READ_VERSIONS command. |
---|
2472 | 2481 | * For debugging, let the user know what version he has. |
---|
2473 | 2482 | */ |
---|
2474 | | - if(xp_resp[0].numDesc == 0) { |
---|
| 2483 | + if (xp_resp[0].numDesc == 0) { |
---|
2475 | 2484 | /* This is the Typhoon 1.0 type Sleep Image, last 16 bits |
---|
2476 | 2485 | * of version is Month/Day of build. |
---|
2477 | 2486 | */ |
---|
2478 | 2487 | u16 monthday = le32_to_cpu(xp_resp[0].parm2) & 0xffff; |
---|
2479 | 2488 | netdev_info(dev, "Typhoon 1.0 Sleep Image built %02u/%02u/2000\n", |
---|
2480 | 2489 | monthday >> 8, monthday & 0xff); |
---|
2481 | | - } else if(xp_resp[0].numDesc == 2) { |
---|
| 2490 | + } else if (xp_resp[0].numDesc == 2) { |
---|
2482 | 2491 | /* This is the Typhoon 1.1+ type Sleep Image |
---|
2483 | 2492 | */ |
---|
2484 | 2493 | u32 sleep_ver = le32_to_cpu(xp_resp[0].parm2); |
---|
.. | .. |
---|
2498 | 2507 | typhoon_reset(ioaddr, NoWait); |
---|
2499 | 2508 | |
---|
2500 | 2509 | error_out_dma: |
---|
2501 | | - pci_free_consistent(pdev, sizeof(struct typhoon_shared), |
---|
2502 | | - shared, shared_dma); |
---|
| 2510 | + dma_free_coherent(&pdev->dev, sizeof(struct typhoon_shared), shared, |
---|
| 2511 | + shared_dma); |
---|
2503 | 2512 | error_out_remap: |
---|
2504 | 2513 | pci_iounmap(pdev, ioaddr); |
---|
2505 | 2514 | error_out_regions: |
---|
.. | .. |
---|
2526 | 2535 | pci_restore_state(pdev); |
---|
2527 | 2536 | typhoon_reset(tp->ioaddr, NoWait); |
---|
2528 | 2537 | pci_iounmap(pdev, tp->ioaddr); |
---|
2529 | | - pci_free_consistent(pdev, sizeof(struct typhoon_shared), |
---|
2530 | | - tp->shared, tp->shared_dma); |
---|
| 2538 | + dma_free_coherent(&pdev->dev, sizeof(struct typhoon_shared), |
---|
| 2539 | + tp->shared, tp->shared_dma); |
---|
2531 | 2540 | pci_release_regions(pdev); |
---|
2532 | 2541 | pci_clear_mwi(pdev); |
---|
2533 | 2542 | pci_disable_device(pdev); |
---|
2534 | 2543 | free_netdev(dev); |
---|
2535 | 2544 | } |
---|
2536 | 2545 | |
---|
| 2546 | +static SIMPLE_DEV_PM_OPS(typhoon_pm_ops, typhoon_suspend, typhoon_resume); |
---|
| 2547 | + |
---|
2537 | 2548 | static struct pci_driver typhoon_driver = { |
---|
2538 | 2549 | .name = KBUILD_MODNAME, |
---|
2539 | 2550 | .id_table = typhoon_pci_tbl, |
---|
2540 | 2551 | .probe = typhoon_init_one, |
---|
2541 | 2552 | .remove = typhoon_remove_one, |
---|
2542 | | -#ifdef CONFIG_PM |
---|
2543 | | - .suspend = typhoon_suspend, |
---|
2544 | | - .resume = typhoon_resume, |
---|
2545 | | -#endif |
---|
| 2553 | + .driver.pm = &typhoon_pm_ops, |
---|
2546 | 2554 | }; |
---|
2547 | 2555 | |
---|
2548 | 2556 | static int __init |
---|