]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/net/ucc_geth_ethtool.c
r8169: print errors when dma mapping fail
[linux-2.6.git] / drivers / net / ucc_geth_ethtool.c
index a755bea559b98deb9d091c95eba19db84642a732..6f92e48f02d33f5ffccd2510384976441a2a2bb2 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Limitation:
  * Can only get/set setttings of the first queue.
- * Need to re-open the interface manually after changing some paramters.
+ * Need to re-open the interface manually after changing some parameters.
  *
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General  Public License as published by the
@@ -18,7 +18,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/stddef.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
@@ -28,7 +27,6 @@
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
-#include <linux/fsl_devices.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/phy.h>
@@ -320,9 +318,13 @@ static void uec_get_ethtool_stats(struct net_device *netdev,
        int i, j = 0;
 
        if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) {
-               base = (u32 __iomem *)&ugeth->ug_regs->tx64;
+               if (ugeth->ug_regs)
+                       base = (u32 __iomem *)&ugeth->ug_regs->tx64;
+               else
+                       base = NULL;
+
                for (i = 0; i < UEC_HW_STATS_LEN; i++)
-                       data[j++] = in_be32(&base[i]);
+                       data[j++] = base ? in_be32(&base[i]) : 0;
        }
        if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) {
                base = (u32 __iomem *)ugeth->p_tx_fw_statistics_pram;
@@ -356,6 +358,44 @@ uec_get_drvinfo(struct net_device *netdev,
        drvinfo->regdump_len = uec_get_regs_len(netdev);
 }
 
+#ifdef CONFIG_PM
+
+static void uec_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
+{
+       struct ucc_geth_private *ugeth = netdev_priv(netdev);
+       struct phy_device *phydev = ugeth->phydev;
+
+       if (phydev && phydev->irq)
+               wol->supported |= WAKE_PHY;
+       if (qe_alive_during_sleep())
+               wol->supported |= WAKE_MAGIC;
+
+       wol->wolopts = ugeth->wol_en;
+}
+
+static int uec_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
+{
+       struct ucc_geth_private *ugeth = netdev_priv(netdev);
+       struct phy_device *phydev = ugeth->phydev;
+
+       if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
+               return -EINVAL;
+       else if (wol->wolopts & WAKE_PHY && (!phydev || !phydev->irq))
+               return -EINVAL;
+       else if (wol->wolopts & WAKE_MAGIC && !qe_alive_during_sleep())
+               return -EINVAL;
+
+       ugeth->wol_en = wol->wolopts;
+       device_set_wakeup_enable(&netdev->dev, ugeth->wol_en);
+
+       return 0;
+}
+
+#else
+#define uec_get_wol NULL
+#define uec_set_wol NULL
+#endif /* CONFIG_PM */
+
 static const struct ethtool_ops uec_ethtool_ops = {
        .get_settings           = uec_get_settings,
        .set_settings           = uec_set_settings,
@@ -374,6 +414,8 @@ static const struct ethtool_ops uec_ethtool_ops = {
        .get_sset_count         = uec_get_sset_count,
        .get_strings            = uec_get_strings,
        .get_ethtool_stats      = uec_get_ethtool_stats,
+       .get_wol                = uec_get_wol,
+       .set_wol                = uec_set_wol,
 };
 
 void uec_set_ethtool_ops(struct net_device *netdev)