cleanup: remove pppoe_ioctl() declaration.
[safe/jmp/linux-2.6] / drivers / net / smsc911x.c
index b60639b..89f35f9 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/netdevice.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/bug.h>
 #include <linux/bitops.h>
@@ -50,6 +49,7 @@
 #include <linux/swab.h>
 #include <linux/phy.h>
 #include <linux/smsc911x.h>
+#include <linux/device.h>
 #include "smsc911x.h"
 
 #define SMSC_CHIPNAME          "smsc911x"
@@ -747,8 +747,8 @@ static void smsc911x_phy_adjust_link(struct net_device *dev)
                         * usage is 10/100 indicator */
                        pdata->gpio_setting = smsc911x_reg_read(pdata,
                                GPIO_CFG);
-                       if ((pdata->gpio_setting & GPIO_CFG_LED1_EN_)
-                           && (!pdata->using_extphy)) {
+                       if ((pdata->gpio_setting & GPIO_CFG_LED1_EN_) &&
+                           (!pdata->using_extphy)) {
                                /* Force 10/100 LED off, after saving
                                 * orginal GPIO configuration */
                                pdata->gpio_orig_setting = pdata->gpio_setting;
@@ -769,29 +769,25 @@ static int smsc911x_mii_probe(struct net_device *dev)
 {
        struct smsc911x_data *pdata = netdev_priv(dev);
        struct phy_device *phydev = NULL;
-       int phy_addr;
+       int ret;
 
        /* find the first phy */
-       for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
-               if (pdata->mii_bus->phy_map[phy_addr]) {
-                       phydev = pdata->mii_bus->phy_map[phy_addr];
-                       SMSC_TRACE(PROBE, "PHY %d: addr %d, phy_id 0x%08X",
-                               phy_addr, phydev->addr, phydev->phy_id);
-                       break;
-               }
-       }
-
+       phydev = phy_find_first(pdata->mii_bus);
        if (!phydev) {
                pr_err("%s: no PHY found\n", dev->name);
                return -ENODEV;
        }
 
-       phydev = phy_connect(dev, dev_name(&phydev->dev),
-               &smsc911x_phy_adjust_link, 0, pdata->config.phy_interface);
+       SMSC_TRACE(PROBE, "PHY %d: addr %d, phy_id 0x%08X",
+                       phy_addr, phydev->addr, phydev->phy_id);
 
-       if (IS_ERR(phydev)) {
+       ret = phy_connect_direct(dev, phydev,
+                       &smsc911x_phy_adjust_link, 0,
+                       pdata->config.phy_interface);
+
+       if (ret) {
                pr_err("%s: Could not attach to PHY\n", dev->name);
-               return PTR_ERR(phydev);
+               return ret;
        }
 
        pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
@@ -815,7 +811,7 @@ static int smsc911x_mii_probe(struct net_device *dev)
        SMSC_TRACE(HW, "Passed Loop Back Test");
 #endif                         /* USE_PHY_WORK_AROUND */
 
-       SMSC_TRACE(HW, "phy initialised succesfully");
+       SMSC_TRACE(HW, "phy initialised successfully");
        return 0;
 }
 
@@ -985,7 +981,7 @@ static int smsc911x_poll(struct napi_struct *napi, int budget)
        struct net_device *dev = pdata->dev;
        int npackets = 0;
 
-       while (likely(netif_running(dev)) && (npackets < budget)) {
+       while (npackets < budget) {
                unsigned int pktlength;
                unsigned int pktwords;
                struct sk_buff *skb;
@@ -1046,7 +1042,6 @@ static int smsc911x_poll(struct napi_struct *napi, int budget)
                /* Update counters */
                dev->stats.rx_packets++;
                dev->stats.rx_bytes += (pktlength - 4);
-               dev->last_rx = jiffies;
        }
 
        /* Return total received packets */
@@ -1340,7 +1335,6 @@ static int smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
        smsc911x_tx_writefifo(pdata, (unsigned int *)bufp, wrsz);
        freespace -= (skb->len + 32);
        dev_kfree_skb(skb);
-       dev->trans_start = jiffies;
 
        if (unlikely(smsc911x_tx_get_txstatcount(pdata) >= 30))
                smsc911x_tx_update_txcounters(dev);
@@ -1383,33 +1377,24 @@ static void smsc911x_set_multicast_list(struct net_device *dev)
                pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_HPFILT_);
                pdata->hashhi = 0;
                pdata->hashlo = 0;
-       } else if (dev->mc_count > 0) {
+       } else if (!netdev_mc_empty(dev)) {
                /* Enabling specific multicast addresses */
                unsigned int hash_high = 0;
                unsigned int hash_low = 0;
-               unsigned int count = 0;
-               struct dev_mc_list *mc_list = dev->mc_list;
+               struct netdev_hw_addr *ha;
 
                pdata->set_bits_mask = MAC_CR_HPFILT_;
                pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_MCPAS_);
 
-               while (mc_list) {
-                       count++;
-                       if ((mc_list->dmi_addrlen) == ETH_ALEN) {
-                               unsigned int bitnum =
-                                   smsc911x_hash(mc_list->dmi_addr);
-                               unsigned int mask = 0x01 << (bitnum & 0x1F);
-                               if (bitnum & 0x20)
-                                       hash_high |= mask;
-                               else
-                                       hash_low |= mask;
-                       } else {
-                               SMSC_WARNING(DRV, "dmi_addrlen != 6");
-                       }
-                       mc_list = mc_list->next;
+               netdev_for_each_mc_addr(ha, dev) {
+                       unsigned int bitnum = smsc911x_hash(ha->addr);
+                       unsigned int mask = 0x01 << (bitnum & 0x1F);
+
+                       if (bitnum & 0x20)
+                               hash_high |= mask;
+                       else
+                               hash_low |= mask;
                }
-               if (count != (unsigned int)dev->mc_count)
-                       SMSC_WARNING(DRV, "mc_count != dev->mc_count");
 
                pdata->hashhi = hash_high;
                pdata->hashlo = hash_low;
@@ -1779,6 +1764,7 @@ static const struct net_device_ops smsc911x_netdev_ops = {
        .ndo_get_stats          = smsc911x_get_stats,
        .ndo_set_multicast_list = smsc911x_set_multicast_list,
        .ndo_do_ioctl           = smsc911x_do_ioctl,
+       .ndo_change_mtu         = eth_change_mtu,
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_set_mac_address    = smsc911x_set_mac_address,
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1938,7 +1924,7 @@ static int __devexit smsc911x_drv_remove(struct platform_device *pdev)
        if (!res)
                res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-       release_mem_region(res->start, res->end - res->start);
+       release_mem_region(res->start, resource_size(res));
 
        iounmap(pdata->ioaddr);
 
@@ -1976,7 +1962,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
                retval = -ENODEV;
                goto out_0;
        }
-       res_size = res->end - res->start + 1;
+       res_size = resource_size(res);
 
        irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        if (!irq_res) {
@@ -2070,6 +2056,9 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
        if (is_valid_ether_addr(dev->dev_addr)) {
                smsc911x_set_hw_mac_address(pdata, dev->dev_addr);
                SMSC_TRACE(PROBE, "MAC Address is specified by configuration");
+       } else if (is_valid_ether_addr(pdata->config.mac)) {
+               memcpy(dev->dev_addr, pdata->config.mac, 6);
+               SMSC_TRACE(PROBE, "MAC Address specified by platform data");
        } else {
                /* Try reading mac address from device. if EEPROM is present
                 * it will already have been set */
@@ -2104,7 +2093,7 @@ out_unmap_io_3:
 out_free_netdev_2:
        free_netdev(dev);
 out_release_io_1:
-       release_mem_region(res->start, res->end - res->start);
+       release_mem_region(res->start, resource_size(res));
 out_0:
        return retval;
 }
@@ -2113,10 +2102,12 @@ out_0:
 /* This implementation assumes the devices remains powered on its VDDVARIO
  * pins during suspend. */
 
-static int smsc911x_suspend(struct platform_device *pdev, pm_message_t state)
+/* TODO: implement freeze/thaw callbacks for hibernation.*/
+
+static int smsc911x_suspend(struct device *dev)
 {
-       struct net_device *dev = platform_get_drvdata(pdev);
-       struct smsc911x_data *pdata = netdev_priv(dev);
+       struct net_device *ndev = dev_get_drvdata(dev);
+       struct smsc911x_data *pdata = netdev_priv(ndev);
 
        /* enable wake on LAN, energy detection and the external PME
         * signal. */
@@ -2127,10 +2118,10 @@ static int smsc911x_suspend(struct platform_device *pdev, pm_message_t state)
        return 0;
 }
 
-static int smsc911x_resume(struct platform_device *pdev)
+static int smsc911x_resume(struct device *dev)
 {
-       struct net_device *dev = platform_get_drvdata(pdev);
-       struct smsc911x_data *pdata = netdev_priv(dev);
+       struct net_device *ndev = dev_get_drvdata(dev);
+       struct smsc911x_data *pdata = netdev_priv(ndev);
        unsigned int to = 100;
 
        /* Note 3.11 from the datasheet:
@@ -2148,19 +2139,25 @@ static int smsc911x_resume(struct platform_device *pdev)
        return (to == 0) ? -EIO : 0;
 }
 
+static const struct dev_pm_ops smsc911x_pm_ops = {
+       .suspend        = smsc911x_suspend,
+       .resume         = smsc911x_resume,
+};
+
+#define SMSC911X_PM_OPS (&smsc911x_pm_ops)
+
 #else
-#define smsc911x_suspend       NULL
-#define smsc911x_resume                NULL
+#define SMSC911X_PM_OPS NULL
 #endif
 
 static struct platform_driver smsc911x_driver = {
        .probe = smsc911x_drv_probe,
        .remove = __devexit_p(smsc911x_drv_remove),
        .driver = {
-               .name = SMSC_CHIPNAME,
+               .name   = SMSC_CHIPNAME,
+               .owner  = THIS_MODULE,
+               .pm     = SMSC911X_PM_OPS,
        },
-       .suspend = smsc911x_suspend,
-       .resume = smsc911x_resume,
 };
 
 /* Entry point for loading the module */