net: usb: raw-ip: Fix autopm / system suspend issues.
[linux-2.6.git] / drivers / net / sunhme.c
index 905df35..856e05b 100644 (file)
@@ -855,7 +855,7 @@ static void happy_meal_timer(unsigned long data)
                hp->timer_ticks = 0;
                hp->timer_state = asleep; /* foo on you */
                break;
-       };
+       }
 
        if (restart_timer) {
                hp->happy_timer.expires = jiffies + ((12 * HZ)/10); /* 1.2 sec. */
@@ -1383,7 +1383,7 @@ force_link:
                if (ep == NULL || ep->autoneg == AUTONEG_ENABLE) {
                        hp->sw_bmcr = BMCR_SPEED100;
                } else {
-                       if (ep->speed == SPEED_100)
+                       if (ethtool_cmd_speed(ep) == SPEED_100)
                                hp->sw_bmcr = BMCR_SPEED100;
                        else
                                hp->sw_bmcr = 0;
@@ -1409,7 +1409,7 @@ force_link:
        hp->timer_ticks = 0;
        hp->happy_timer.expires = jiffies + (12 * HZ)/10;  /* 1.2 sec. */
        hp->happy_timer.data = (unsigned long) hp;
-       hp->happy_timer.function = &happy_meal_timer;
+       hp->happy_timer.function = happy_meal_timer;
        add_timer(&hp->happy_timer);
 }
 
@@ -1488,7 +1488,7 @@ static int happy_meal_init(struct happy_meal *hp)
                HMD(("external, disable MII, "));
                hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB);
                break;
-       };
+       }
 
        if (happy_meal_tcvr_reset(hp, tregs))
                return -EAGAIN;
@@ -1523,22 +1523,12 @@ static int happy_meal_init(struct happy_meal *hp)
                hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff);
        } else if ((hp->dev->flags & IFF_PROMISC) == 0) {
                u16 hash_table[4];
-               struct dev_mc_list *dmi = hp->dev->mc_list;
-               char *addrs;
-               int i;
+               struct netdev_hw_addr *ha;
                u32 crc;
 
-               for (i = 0; i < 4; i++)
-                       hash_table[i] = 0;
-
-               for (i = 0; i < netdev_mc_count(hp->dev); i++) {
-                       addrs = dmi->dmi_addr;
-                       dmi = dmi->next;
-
-                       if (!(*addrs & 1))
-                               continue;
-
-                       crc = ether_crc_le(6, addrs);
+               memset(hash_table, 0, sizeof(hash_table));
+               netdev_for_each_mc_addr(ha, hp->dev) {
+                       crc = ether_crc_le(6, ha->addr);
                        crc >>= 26;
                        hash_table[crc >> 4] |= 1 << (crc & 0xf);
                }
@@ -1595,7 +1585,7 @@ static int happy_meal_init(struct happy_meal *hp)
                 */
 #ifdef CONFIG_SBUS
                if ((hp->happy_flags & HFLAG_PCI) == 0) {
-                       struct of_device *op = hp->happy_dev;
+                       struct platform_device *op = hp->happy_dev;
                        if (sbus_can_dma_64bit()) {
                                sbus_set_sbus64(&op->dev,
                                                hp->happy_bursts);
@@ -1738,7 +1728,7 @@ static void happy_meal_set_initial_advertisement(struct happy_meal *hp)
        case external:
                hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB);
                break;
-       };
+       }
        if (happy_meal_tcvr_reset(hp, tregs))
                return;
 
@@ -2270,7 +2260,7 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
 
        tx_flags = TXFLAG_OWN;
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               const u32 csum_start_off = skb_transport_offset(skb);
+               const u32 csum_start_off = skb_checksum_start_offset(skb);
                const u32 csum_stuff_off = csum_start_off + skb->csum_offset;
 
                tx_flags = (TXFLAG_OWN | TXFLAG_CSENABLE |
@@ -2345,8 +2335,6 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
 
        spin_unlock_irq(&hp->happy_lock);
 
-       dev->trans_start = jiffies;
-
        tx_add_log(hp, TXLOG_ACTION_TXMIT, 0);
        return NETDEV_TX_OK;
 }
@@ -2366,9 +2354,7 @@ static void happy_meal_set_multicast(struct net_device *dev)
 {
        struct happy_meal *hp = netdev_priv(dev);
        void __iomem *bregs = hp->bigmacregs;
-       struct dev_mc_list *dmi = dev->mc_list;
-       char *addrs;
-       int i;
+       struct netdev_hw_addr *ha;
        u32 crc;
 
        spin_lock_irq(&hp->happy_lock);
@@ -2384,17 +2370,9 @@ static void happy_meal_set_multicast(struct net_device *dev)
        } else {
                u16 hash_table[4];
 
-               for (i = 0; i < 4; i++)
-                       hash_table[i] = 0;
-
-               for (i = 0; i < netdev_mc_count(dev); i++) {
-                       addrs = dmi->dmi_addr;
-                       dmi = dmi->next;
-
-                       if (!(*addrs & 1))
-                               continue;
-
-                       crc = ether_crc_le(6, addrs);
+               memset(hash_table, 0, sizeof(hash_table));
+               netdev_for_each_mc_addr(ha, dev) {
+                       crc = ether_crc_le(6, ha->addr);
                        crc >>= 26;
                        hash_table[crc >> 4] |= 1 << (crc & 0xf);
                }
@@ -2411,6 +2389,7 @@ static void happy_meal_set_multicast(struct net_device *dev)
 static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct happy_meal *hp = netdev_priv(dev);
+       u32 speed;
 
        cmd->supported =
                (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
@@ -2430,10 +2409,9 @@ static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
        if (hp->sw_bmcr & BMCR_ANENABLE) {
                cmd->autoneg = AUTONEG_ENABLE;
-               cmd->speed =
-                       (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
-                       SPEED_100 : SPEED_10;
-               if (cmd->speed == SPEED_100)
+               speed = ((hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
+                        SPEED_100 : SPEED_10);
+               if (speed == SPEED_100)
                        cmd->duplex =
                                (hp->sw_lpa & (LPA_100FULL)) ?
                                DUPLEX_FULL : DUPLEX_HALF;
@@ -2443,13 +2421,12 @@ static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                                DUPLEX_FULL : DUPLEX_HALF;
        } else {
                cmd->autoneg = AUTONEG_DISABLE;
-               cmd->speed =
-                       (hp->sw_bmcr & BMCR_SPEED100) ?
-                       SPEED_100 : SPEED_10;
+               speed = (hp->sw_bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
                cmd->duplex =
                        (hp->sw_bmcr & BMCR_FULLDPLX) ?
                        DUPLEX_FULL : DUPLEX_HALF;
        }
+       ethtool_cmd_speed_set(cmd, speed);
        return 0;
 }
 
@@ -2462,8 +2439,8 @@ static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
            cmd->autoneg != AUTONEG_DISABLE)
                return -EINVAL;
        if (cmd->autoneg == AUTONEG_DISABLE &&
-           ((cmd->speed != SPEED_100 &&
-             cmd->speed != SPEED_10) ||
+           ((ethtool_cmd_speed(cmd) != SPEED_100 &&
+             ethtool_cmd_speed(cmd) != SPEED_10) ||
             (cmd->duplex != DUPLEX_HALF &&
              cmd->duplex != DUPLEX_FULL)))
                return -EINVAL;
@@ -2490,8 +2467,8 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
 #ifdef CONFIG_SBUS
        else {
                const struct linux_prom_registers *regs;
-               struct of_device *op = hp->happy_dev;
-               regs = of_get_property(op->node, "regs", NULL);
+               struct platform_device *op = hp->happy_dev;
+               regs = of_get_property(op->dev.of_node, "regs", NULL);
                if (regs)
                        sprintf(info->bus_info, "SBUS:%d",
                                regs->which_io);
@@ -2507,7 +2484,7 @@ static u32 hme_get_link(struct net_device *dev)
        hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
        spin_unlock_irq(&hp->happy_lock);
 
-       return (hp->sw_bmsr & BMSR_LSTATUS);
+       return hp->sw_bmsr & BMSR_LSTATUS;
 }
 
 static const struct ethtool_ops hme_ethtool_ops = {
@@ -2525,13 +2502,13 @@ static int hme_version_printed;
  *
  * Return NULL on failure.
  */
-static struct quattro * __devinit quattro_sbus_find(struct of_device *child)
+static struct quattro * __devinit quattro_sbus_find(struct platform_device *child)
 {
        struct device *parent = child->dev.parent;
-       struct of_device *op;
+       struct platform_device *op;
        struct quattro *qp;
 
-       op = to_of_device(parent);
+       op = to_platform_device(parent);
        qp = dev_get_drvdata(&op->dev);
        if (qp)
                return qp;
@@ -2561,7 +2538,7 @@ static int __init quattro_sbus_register_irqs(void)
        struct quattro *qp;
 
        for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) {
-               struct of_device *op = qp->quattro_dev;
+               struct platform_device *op = qp->quattro_dev;
                int err, qfe_slot, skip = 0;
 
                for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) {
@@ -2571,7 +2548,7 @@ static int __init quattro_sbus_register_irqs(void)
                if (skip)
                        continue;
 
-               err = request_irq(op->irqs[0],
+               err = request_irq(op->archdata.irqs[0],
                                  quattro_sbus_interrupt,
                                  IRQF_SHARED, "Quattro",
                                  qp);
@@ -2590,7 +2567,7 @@ static void quattro_sbus_free_irqs(void)
        struct quattro *qp;
 
        for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) {
-               struct of_device *op = qp->quattro_dev;
+               struct platform_device *op = qp->quattro_dev;
                int qfe_slot, skip = 0;
 
                for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) {
@@ -2600,7 +2577,7 @@ static void quattro_sbus_free_irqs(void)
                if (skip)
                        continue;
 
-               free_irq(op->irqs[0], qp);
+               free_irq(op->archdata.irqs[0], qp);
        }
 }
 #endif /* CONFIG_SBUS */
@@ -2649,16 +2626,16 @@ static const struct net_device_ops hme_netdev_ops = {
 };
 
 #ifdef CONFIG_SBUS
-static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
+static int __devinit happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe)
 {
-       struct device_node *dp = op->node, *sbus_dp;
+       struct device_node *dp = op->dev.of_node, *sbus_dp;
        struct quattro *qp = NULL;
        struct happy_meal *hp;
        struct net_device *dev;
        int i, qfe_slot = -1;
        int err = -ENODEV;
 
-       sbus_dp = to_of_device(op->dev.parent)->node;
+       sbus_dp = op->dev.parent->of_node;
 
        /* We can match PCI devices too, do not accept those here. */
        if (strcmp(sbus_dp->name, "sbus"))
@@ -2798,9 +2775,10 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
        dev->ethtool_ops = &hme_ethtool_ops;
 
        /* Happy Meal can do it all... */
-       dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
+       dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM;
+       dev->features |= dev->hw_features | NETIF_F_RXCSUM;
 
-       dev->irq = op->irqs[0];
+       dev->irq = op->archdata.irqs[0];
 
 #if defined(CONFIG_SBUS) && defined(CONFIG_PCI)
        /* Hook up SBUS register/descriptor accessors. */
@@ -2818,7 +2796,8 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
        happy_meal_set_initial_advertisement(hp);
        spin_unlock_irq(&hp->happy_lock);
 
-       if (register_netdev(hp->dev)) {
+       err = register_netdev(hp->dev);
+       if (err) {
                printk(KERN_ERR "happymeal: Cannot register net device, "
                       "aborting.\n");
                goto err_out_free_coherent;
@@ -2953,7 +2932,6 @@ static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr)
        dev_addr[1] = 0x00;
        dev_addr[2] = 0x20;
        get_random_bytes(&dev_addr[3], 3);
-       return;
 }
 #endif /* !(CONFIG_SPARC) */
 
@@ -3012,7 +2990,6 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
        dev->base_addr = (long) pdev;
 
        hp = netdev_priv(dev);
-       memset(hp, 0, sizeof(*hp));
 
        hp->happy_dev = pdev;
        hp->dma_dev = &pdev->dev;
@@ -3124,7 +3101,8 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
        dev->dma = 0;
 
        /* Happy Meal can do it all... */
-       dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
+       dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM;
+       dev->features |= dev->hw_features | NETIF_F_RXCSUM;
 
 #if defined(CONFIG_SBUS) && defined(CONFIG_PCI)
        /* Hook up PCI register/descriptor accessors. */
@@ -3142,7 +3120,8 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
        happy_meal_set_initial_advertisement(hp);
        spin_unlock_irq(&hp->happy_lock);
 
-       if (register_netdev(hp->dev)) {
+       err = register_netdev(hp->dev);
+       if (err) {
                printk(KERN_ERR "happymeal(PCI): Cannot register net device, "
                       "aborting.\n");
                goto err_out_iounmap;
@@ -3247,11 +3226,18 @@ static void happy_meal_pci_exit(void)
 #endif
 
 #ifdef CONFIG_SBUS
-static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device_id *match)
+static const struct of_device_id hme_sbus_match[];
+static int __devinit hme_sbus_probe(struct platform_device *op)
 {
-       struct device_node *dp = op->node;
+       const struct of_device_id *match;
+       struct device_node *dp = op->dev.of_node;
        const char *model = of_get_property(dp, "model", NULL);
-       int is_qfe = (match->data != NULL);
+       int is_qfe;
+
+       match = of_match_device(hme_sbus_match, &op->dev);
+       if (!match)
+               return -EINVAL;
+       is_qfe = (match->data != NULL);
 
        if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe"))
                is_qfe = 1;
@@ -3259,7 +3245,7 @@ static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device
        return happy_meal_sbus_probe_one(op, is_qfe);
 }
 
-static int __devexit hme_sbus_remove(struct of_device *op)
+static int __devexit hme_sbus_remove(struct platform_device *op)
 {
        struct happy_meal *hp = dev_get_drvdata(&op->dev);
        struct net_device *net_dev = hp->dev;
@@ -3302,9 +3288,12 @@ static const struct of_device_id hme_sbus_match[] = {
 
 MODULE_DEVICE_TABLE(of, hme_sbus_match);
 
-static struct of_platform_driver hme_sbus_driver = {
-       .name           = "hme",
-       .match_table    = hme_sbus_match,
+static struct platform_driver hme_sbus_driver = {
+       .driver = {
+               .name = "hme",
+               .owner = THIS_MODULE,
+               .of_match_table = hme_sbus_match,
+       },
        .probe          = hme_sbus_probe,
        .remove         = __devexit_p(hme_sbus_remove),
 };
@@ -3313,7 +3302,7 @@ static int __init happy_meal_sbus_init(void)
 {
        int err;
 
-       err = of_register_driver(&hme_sbus_driver, &of_bus_type);
+       err = platform_driver_register(&hme_sbus_driver);
        if (!err)
                err = quattro_sbus_register_irqs();
 
@@ -3322,7 +3311,7 @@ static int __init happy_meal_sbus_init(void)
 
 static void happy_meal_sbus_exit(void)
 {
-       of_unregister_driver(&hme_sbus_driver);
+       platform_driver_unregister(&hme_sbus_driver);
        quattro_sbus_free_irqs();
 
        while (qfe_sbus_list) {