diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2010-01-04 14:28:25 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2010-01-04 14:28:25 +0000 |
commit | 63a320c8f7491fe5cf23618579a48f68083497ce (patch) | |
tree | d000732b2804324fcdfe4b356a438e40235bff70 | |
parent | 8113f1ae11e5e049c9e54b4c68e700cf8d501723 (diff) | |
download | mtk-20170518-63a320c8f7491fe5cf23618579a48f68083497ce.zip mtk-20170518-63a320c8f7491fe5cf23618579a48f68083497ce.tar.gz mtk-20170518-63a320c8f7491fe5cf23618579a48f68083497ce.tar.bz2 |
ar71xx: add dummy debugfs support for the ag71xx driver
SVN-Revision: 19031
12 files changed, 112 insertions, 11 deletions
diff --git a/target/linux/ar71xx/config-2.6.30 b/target/linux/ar71xx/config-2.6.30 index 56c1d2f..c309ea4 100644 --- a/target/linux/ar71xx/config-2.6.30 +++ b/target/linux/ar71xx/config-2.6.30 @@ -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 diff --git a/target/linux/ar71xx/config-2.6.31 b/target/linux/ar71xx/config-2.6.31 index 9e4db50..9146217 100644 --- a/target/linux/ar71xx/config-2.6.31 +++ b/target/linux/ar71xx/config-2.6.31 @@ -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 diff --git a/target/linux/ar71xx/config-2.6.32 b/target/linux/ar71xx/config-2.6.32 index 2de9983..35a8468 100644 --- a/target/linux/ar71xx/config-2.6.32 +++ b/target/linux/ar71xx/config-2.6.32 @@ -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 diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/Kconfig b/target/linux/ar71xx/files/drivers/net/ag71xx/Kconfig index 801fcaf..15983f4 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/Kconfig +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/Kconfig @@ -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 diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/Makefile b/target/linux/ar71xx/files/drivers/net/ag71xx/Makefile index aa1798d..3485ab3 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/Makefile +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/Makefile @@ -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 diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h index ac52896..b2f710e 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h @@ -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 */ diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar8216.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar8216.c index 39221ad..5b37226 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar8216.c +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar8216.c @@ -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 index 0000000..88101e4 --- /dev/null +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_debugfs.c @@ -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; +} diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ethtool.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ethtool.c index 3ac347f..1f1c6aa 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ethtool.c +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ethtool.c @@ -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 diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c index c8c61de..869373a 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_main.c @@ -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); diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_mdio.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_mdio.c index 6bc858c..3984840 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_mdio.c +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_mdio.c @@ -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 diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c index 4233152..3e3d383 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c @@ -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 |