ar71xx: add dummy debugfs support for the ag71xx driver
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Mon, 4 Jan 2010 14:28:25 +0000 (14:28 +0000)
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Mon, 4 Jan 2010 14:28:25 +0000 (14:28 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19031 3c298f89-4303-0410-b956-a3cf2f4a3e73

12 files changed:
target/linux/ar71xx/config-2.6.30
target/linux/ar71xx/config-2.6.31
target/linux/ar71xx/config-2.6.32
target/linux/ar71xx/files/drivers/net/ag71xx/Kconfig
target/linux/ar71xx/files/drivers/net/ag71xx/Makefile
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar8216.c
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c [new file with mode: 0644]
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ethtool.c
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_mdio.c
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c

index 56c1d2f87edc75f431f9d38fc4c596c6840357be..c309ea4b06e1d9bccd108b1c45d6a0c88ad123bd 100644 (file)
@@ -3,6 +3,7 @@ CONFIG_32BIT=y
 CONFIG_AG71XX=y
 CONFIG_AG71XX_AR8216_SUPPORT=y
 # CONFIG_AG71XX_DEBUG is not set
+# CONFIG_AG71XX_DEBUG_FS is not set
 CONFIG_AR71XX_DEV_AP91_PCI=y
 CONFIG_AR71XX_DEV_AP94_PCI=y
 CONFIG_AR71XX_DEV_AR913X_WMAC=y
index 9e4db5089d506afdd2a86fb0e07a932ad92a06b1..9146217fdc527c1e6c3be94eb5aba3809ba35f5c 100644 (file)
@@ -3,6 +3,7 @@ CONFIG_32BIT=y
 CONFIG_AG71XX=y
 CONFIG_AG71XX_AR8216_SUPPORT=y
 # CONFIG_AG71XX_DEBUG is not set
+# CONFIG_AG71XX_DEBUG_FS is not set
 # CONFIG_ALCHEMY_GPIO_INDIRECT is not set
 # CONFIG_AR7 is not set
 CONFIG_AR71XX_DEV_AP91_PCI=y
index 2de99830987fdf5fee072de4a827e16b9b474466..35a846856d82c764afeaeb711ab47b50704af586 100644 (file)
@@ -3,6 +3,7 @@ CONFIG_32BIT=y
 CONFIG_AG71XX=y
 CONFIG_AG71XX_AR8216_SUPPORT=y
 # CONFIG_AG71XX_DEBUG is not set
+# CONFIG_AG71XX_DEBUG_FS is not set
 # CONFIG_ALCHEMY_GPIO_INDIRECT is not set
 # CONFIG_AR7 is not set
 CONFIG_AR71XX_DEV_AP91_PCI=y
index 801fcaf9d7157902cd1a3df871d2f3545997d323..15983f4ea44a9b264db94ac5e367fca5de3b0833 100644 (file)
@@ -13,6 +13,14 @@ config AG71XX_DEBUG
        help
          Atheros AR71xx built-in ethernet driver debugging messages.
 
+config AG71XX_DEBUG_FS
+       bool "Atheros AR71xx built-in ethernet driver debugfs support"
+       depends on AG71XX && DEBUG_FS
+       default n
+       help
+         Say Y, if you need access to various statistics provided by
+         the ag71xx driver.
+
 config AG71XX_AR8216_SUPPORT
        bool "special support for the Atheros AR8216 switch"
        depends on AG71XX
index aa1798d1957d965d6728954235432f7a421e0a17..3485ab385dcdd19fd4a12add63f8515fbae1ed48 100644 (file)
@@ -2,12 +2,13 @@
 # Makefile for the Atheros AR71xx built-in ethernet macs
 #
 
-ag71xx-y       += ag71xx_main.o 
-ag71xx-y       += ag71xx_ethtool.o 
-ag71xx-y       += ag71xx_phy.o 
+ag71xx-y       += ag71xx_main.o
+ag71xx-y       += ag71xx_ethtool.o
+ag71xx-y       += ag71xx_phy.o
 ag71xx-y       += ag71xx_mdio.o
 
-ag71xx-$(CONFIG_AG71XX_AR8216_SUPPORT) += ag71xx_ar8216.o
+ag71xx-$(CONFIG_AG71XX_DEBUG_FS)       += ag71xx_debugfs.o
+ag71xx-$(CONFIG_AG71XX_AR8216_SUPPORT) += ag71xx_ar8216.o
 
 obj-$(CONFIG_AG71XX)   += ag71xx.o
 
index ac52896ab2e9a136f10fc83420359010cb371fa0..b2f710edecf744ebfc976bf81f58580cb25c672b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Atheros AR71xx built-in ethernet mac driver
  *
- *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  *
  *  Based on Atheros' AG7100 driver
@@ -109,6 +109,10 @@ struct ag71xx_mdio {
        struct ag71xx_mdio_platform_data *pdata;
 };
 
+struct ag71xx_debug {
+       struct dentry           *debugfs_dir;
+};
+
 struct ag71xx {
        void __iomem            *mac_base;
        void __iomem            *mii_ctrl;
@@ -131,6 +135,10 @@ struct ag71xx {
 
        struct work_struct      restart_work;
        struct timer_list       oom_timer;
+
+#ifdef CONFIG_AG71XX_DEBUG_FS
+       struct ag71xx_debug     debug;
+#endif
 };
 
 extern struct ethtool_ops ag71xx_ethtool_ops;
@@ -450,4 +458,16 @@ static inline int ag71xx_remove_ar8216_header(struct ag71xx *ag,
 }
 #endif
 
+#ifdef CONFIG_AG71XX_DEBUG_FS
+int ag71xx_debugfs_root_init(void);
+void ag71xx_debugfs_root_exit(void);
+int ag71xx_debugfs_init(struct ag71xx *ag);
+void ag71xx_debugfs_exit(struct ag71xx *ag);
+#else
+static inline int ag71xx_debugfs_root_init(void) { return 0; }
+static inline void ag71xx_debugfs_root_exit(void) {}
+static inline int ag71xx_debugfs_init(struct ag71xx *ag) { return 0; }
+static inline void ag71xx_debugfs_exit(struct ag71xx *ag) {}
+#endif /* CONFIG_AG71XX_DEBUG_FS */
+
 #endif /* _AG71XX_H */
index 39221ad62cde7b5f77addf8e5980b30a81df9e71..5b3722651f311dc7eb6487b251ac06359ef8a5cb 100644 (file)
@@ -2,7 +2,7 @@
  *  Atheros AR71xx built-in ethernet mac driver
  *  Special support for the Atheros ar8216 switch chip
  *
- *  Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  *
  *  Based on Atheros' AG7100 driver
  *
diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c
new file mode 100644 (file)
index 0000000..88101e4
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  Atheros AR71xx built-in ethernet mac driver
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
+ *
+ *  Based on Atheros' AG7100 driver
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/debugfs.h>
+
+#include "ag71xx.h"
+
+static struct dentry *ag71xx_debugfs_root;
+
+int ag71xx_debugfs_root_init(void)
+{
+       if (ag71xx_debugfs_root)
+               return -EBUSY;
+
+       ag71xx_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
+       if (!ag71xx_debugfs_root)
+               return -ENOENT;
+
+       return 0;
+}
+
+void ag71xx_debugfs_root_exit(void)
+{
+       debugfs_remove(ag71xx_debugfs_root);
+       ag71xx_debugfs_root = NULL;
+}
+
+void ag71xx_debugfs_exit(struct ag71xx *ag)
+{
+       debugfs_remove(ag->debug.debugfs_dir);
+}
+
+int ag71xx_debugfs_init(struct ag71xx *ag)
+{
+       ag->debug.debugfs_dir = debugfs_create_dir(ag->dev->name,
+                                                  ag71xx_debugfs_root);
+       if (!ag->debug.debugfs_dir)
+               goto err;
+
+       return 0;
+
+ err:
+       ag71xx_debugfs_exit(ag);
+       return -ENOMEM;
+}
index 3ac347f6b0dbd1e8d779784934cba7099a1fafc0..1f1c6aa77686c49bc1d01349c9b5dd81716c691c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Atheros AR71xx built-in ethernet mac driver
  *
- *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  *
  *  Based on Atheros' AG7100 driver
index c8c61dead617bdabbf68b133ea27ff5eab63e54a..869373aaf1a7f153864946e60fffe802a4af1378 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Atheros AR71xx built-in ethernet mac driver
  *
- *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  *
  *  Based on Atheros' AG7100 driver
@@ -922,10 +922,16 @@ static int __init ag71xx_probe(struct platform_device *pdev)
        if (err)
                goto err_unregister_netdev;
 
+       err = ag71xx_debugfs_init(ag);
+       if (err)
+               goto err_phy_disconnect;
+
        platform_set_drvdata(pdev, dev);
 
        return 0;
 
+ err_phy_disconnect:
+       ag71xx_phy_disconnect(ag);
  err_unregister_netdev:
        unregister_netdev(dev);
  err_free_irq:
@@ -948,6 +954,7 @@ static int __exit ag71xx_remove(struct platform_device *pdev)
        if (dev) {
                struct ag71xx *ag = netdev_priv(dev);
 
+               ag71xx_debugfs_exit(ag);
                ag71xx_phy_disconnect(ag);
                unregister_netdev(dev);
                free_irq(dev->irq, dev);
@@ -972,10 +979,14 @@ static int __init ag71xx_module_init(void)
 {
        int ret;
 
-       ret = ag71xx_mdio_driver_init();
+       ret = ag71xx_debugfs_root_init();
        if (ret)
                goto err_out;
 
+       ret = ag71xx_mdio_driver_init();
+       if (ret)
+               goto err_debugfs_exit;
+
        ret = platform_driver_register(&ag71xx_driver);
        if (ret)
                goto err_mdio_exit;
@@ -984,6 +995,8 @@ static int __init ag71xx_module_init(void)
 
  err_mdio_exit:
        ag71xx_mdio_driver_exit();
+ err_debugfs_exit:
+       ag71xx_debugfs_root_exit();
  err_out:
        return ret;
 }
@@ -992,6 +1005,7 @@ static void __exit ag71xx_module_exit(void)
 {
        platform_driver_unregister(&ag71xx_driver);
        ag71xx_mdio_driver_exit();
+       ag71xx_debugfs_root_exit();
 }
 
 module_init(ag71xx_module_init);
index 6bc858cf8d631e09fccceff5204fde08d0e40eff..3984840e0322a16526dd52648bdcdac107fa4be8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Atheros AR71xx built-in ethernet mac driver
  *
- *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  *
  *  Based on Atheros' AG7100 driver
index 4233152aec6117b266b0d6454af27ade7047952a..3e3d3832650859fd275f385f7a0ccbec57096c96 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Atheros AR71xx built-in ethernet mac driver
  *
- *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  *
  *  Based on Atheros' AG7100 driver