All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath9k: create a common debugfs_root for all device instances
@ 2009-03-05 15:55 ` Gabor Juhos
  0 siblings, 0 replies; 6+ messages in thread
From: Gabor Juhos @ 2009-03-05 15:55 UTC (permalink / raw)
  To: John W. Linville; +Cc: ath9k-devel, linux-wireless, Gabor Juhos, Imre Kaloz

The driver are trying to create an 'ath9k' directory in debugfs for each
device currently. If there are more than one device in the system, the
second try will always fail.

Changes-licensed-under: ISC

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
---
 drivers/net/wireless/ath9k/debug.c |   24 ++++++++++++++++++------
 drivers/net/wireless/ath9k/debug.h |   12 +++++++++++-
 drivers/net/wireless/ath9k/main.c  |   13 ++++++++++++-
 3 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath9k/debug.c b/drivers/net/wireless/ath9k/debug.c
index 0c422c5..3b645ee 100644
--- a/drivers/net/wireless/ath9k/debug.c
+++ b/drivers/net/wireless/ath9k/debug.c
@@ -19,6 +19,8 @@
 static unsigned int ath9k_debug = DBG_DEFAULT;
 module_param_named(debug, ath9k_debug, uint, 0);
 
+static struct dentry *ath9k_debugfs_root;
+
 void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
 {
 	if (!sc)
@@ -334,12 +336,8 @@ int ath9k_init_debug(struct ath_softc *sc)
 {
 	sc->debug.debug_mask = ath9k_debug;
 
-	sc->debug.debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!sc->debug.debugfs_root)
-		goto err;
-
 	sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
-						      sc->debug.debugfs_root);
+						      ath9k_debugfs_root);
 	if (!sc->debug.debugfs_phy)
 		goto err;
 
@@ -374,5 +372,19 @@ void ath9k_exit_debug(struct ath_softc *sc)
 	debugfs_remove(sc->debug.debugfs_interrupt);
 	debugfs_remove(sc->debug.debugfs_dma);
 	debugfs_remove(sc->debug.debugfs_phy);
-	debugfs_remove(sc->debug.debugfs_root);
+}
+
+int ath9k_debug_create_root(void)
+{
+	ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
+	if (!ath9k_debugfs_root)
+		return -ENOENT;
+
+	return 0;
+}
+
+void ath9k_debug_remove_root(void)
+{
+	debugfs_remove(ath9k_debugfs_root);
+	ath9k_debugfs_root = NULL;
 }
diff --git a/drivers/net/wireless/ath9k/debug.h b/drivers/net/wireless/ath9k/debug.h
index 01681f2..89ba818 100644
--- a/drivers/net/wireless/ath9k/debug.h
+++ b/drivers/net/wireless/ath9k/debug.h
@@ -102,7 +102,6 @@ struct ath_stats {
 
 struct ath9k_debug {
 	int debug_mask;
-	struct dentry *debugfs_root;
 	struct dentry *debugfs_phy;
 	struct dentry *debugfs_dma;
 	struct dentry *debugfs_interrupt;
@@ -113,6 +112,8 @@ struct ath9k_debug {
 void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
 int ath9k_init_debug(struct ath_softc *sc);
 void ath9k_exit_debug(struct ath_softc *sc);
+int ath9k_debug_create_root(void);
+void ath9k_debug_remove_root(void);
 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
 void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
 void ath_debug_stat_retries(struct ath_softc *sc, int rix,
@@ -134,6 +135,15 @@ static inline void ath9k_exit_debug(struct ath_softc *sc)
 {
 }
 
+static inline int ath9k_debug_create_root(void)
+{
+	return 0;
+}
+
+static inline void ath9k_debug_remove_root(void)
+{
+}
+
 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
 					    enum ath9k_int status)
 {
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 28200ce..d37924a 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -2712,12 +2712,20 @@ static int __init ath9k_init(void)
 		goto err_out;
 	}
 
+	error = ath9k_debug_create_root();
+	if (error) {
+		printk(KERN_ERR
+			"ath9k: Unable to create debugfs root: %d\n",
+			error);
+		goto err_rate_unregister;
+	}
+
 	error = ath_pci_init();
 	if (error < 0) {
 		printk(KERN_ERR
 			"ath9k: No PCI devices found, driver not installed.\n");
 		error = -ENODEV;
-		goto err_rate_unregister;
+		goto err_remove_root;
 	}
 
 	error = ath_ahb_init();
@@ -2731,6 +2739,8 @@ static int __init ath9k_init(void)
  err_pci_exit:
 	ath_pci_exit();
 
+ err_remove_root:
+	ath9k_debug_remove_root();
  err_rate_unregister:
 	ath_rate_control_unregister();
  err_out:
@@ -2742,6 +2752,7 @@ static void __exit ath9k_exit(void)
 {
 	ath_ahb_exit();
 	ath_pci_exit();
+	ath9k_debug_remove_root();
 	ath_rate_control_unregister();
 	printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
 }
-- 
1.5.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [ath9k-devel] [PATCH] ath9k: create a common debugfs_root for all device instances
@ 2009-03-05 15:55 ` Gabor Juhos
  0 siblings, 0 replies; 6+ messages in thread
From: Gabor Juhos @ 2009-03-05 15:55 UTC (permalink / raw)
  To: ath9k-devel

The driver are trying to create an 'ath9k' directory in debugfs for each
device currently. If there are more than one device in the system, the
second try will always fail.

Changes-licensed-under: ISC

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
---
 drivers/net/wireless/ath9k/debug.c |   24 ++++++++++++++++++------
 drivers/net/wireless/ath9k/debug.h |   12 +++++++++++-
 drivers/net/wireless/ath9k/main.c  |   13 ++++++++++++-
 3 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath9k/debug.c b/drivers/net/wireless/ath9k/debug.c
index 0c422c5..3b645ee 100644
--- a/drivers/net/wireless/ath9k/debug.c
+++ b/drivers/net/wireless/ath9k/debug.c
@@ -19,6 +19,8 @@
 static unsigned int ath9k_debug = DBG_DEFAULT;
 module_param_named(debug, ath9k_debug, uint, 0);
 
+static struct dentry *ath9k_debugfs_root;
+
 void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
 {
 	if (!sc)
@@ -334,12 +336,8 @@ int ath9k_init_debug(struct ath_softc *sc)
 {
 	sc->debug.debug_mask = ath9k_debug;
 
-	sc->debug.debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!sc->debug.debugfs_root)
-		goto err;
-
 	sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
-						      sc->debug.debugfs_root);
+						      ath9k_debugfs_root);
 	if (!sc->debug.debugfs_phy)
 		goto err;
 
@@ -374,5 +372,19 @@ void ath9k_exit_debug(struct ath_softc *sc)
 	debugfs_remove(sc->debug.debugfs_interrupt);
 	debugfs_remove(sc->debug.debugfs_dma);
 	debugfs_remove(sc->debug.debugfs_phy);
-	debugfs_remove(sc->debug.debugfs_root);
+}
+
+int ath9k_debug_create_root(void)
+{
+	ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
+	if (!ath9k_debugfs_root)
+		return -ENOENT;
+
+	return 0;
+}
+
+void ath9k_debug_remove_root(void)
+{
+	debugfs_remove(ath9k_debugfs_root);
+	ath9k_debugfs_root = NULL;
 }
diff --git a/drivers/net/wireless/ath9k/debug.h b/drivers/net/wireless/ath9k/debug.h
index 01681f2..89ba818 100644
--- a/drivers/net/wireless/ath9k/debug.h
+++ b/drivers/net/wireless/ath9k/debug.h
@@ -102,7 +102,6 @@ struct ath_stats {
 
 struct ath9k_debug {
 	int debug_mask;
-	struct dentry *debugfs_root;
 	struct dentry *debugfs_phy;
 	struct dentry *debugfs_dma;
 	struct dentry *debugfs_interrupt;
@@ -113,6 +112,8 @@ struct ath9k_debug {
 void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
 int ath9k_init_debug(struct ath_softc *sc);
 void ath9k_exit_debug(struct ath_softc *sc);
+int ath9k_debug_create_root(void);
+void ath9k_debug_remove_root(void);
 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
 void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
 void ath_debug_stat_retries(struct ath_softc *sc, int rix,
@@ -134,6 +135,15 @@ static inline void ath9k_exit_debug(struct ath_softc *sc)
 {
 }
 
+static inline int ath9k_debug_create_root(void)
+{
+	return 0;
+}
+
+static inline void ath9k_debug_remove_root(void)
+{
+}
+
 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
 					    enum ath9k_int status)
 {
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 28200ce..d37924a 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -2712,12 +2712,20 @@ static int __init ath9k_init(void)
 		goto err_out;
 	}
 
+	error = ath9k_debug_create_root();
+	if (error) {
+		printk(KERN_ERR
+			"ath9k: Unable to create debugfs root: %d\n",
+			error);
+		goto err_rate_unregister;
+	}
+
 	error = ath_pci_init();
 	if (error < 0) {
 		printk(KERN_ERR
 			"ath9k: No PCI devices found, driver not installed.\n");
 		error = -ENODEV;
-		goto err_rate_unregister;
+		goto err_remove_root;
 	}
 
 	error = ath_ahb_init();
@@ -2731,6 +2739,8 @@ static int __init ath9k_init(void)
  err_pci_exit:
 	ath_pci_exit();
 
+ err_remove_root:
+	ath9k_debug_remove_root();
  err_rate_unregister:
 	ath_rate_control_unregister();
  err_out:
@@ -2742,6 +2752,7 @@ static void __exit ath9k_exit(void)
 {
 	ath_ahb_exit();
 	ath_pci_exit();
+	ath9k_debug_remove_root();
 	ath_rate_control_unregister();
 	printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
 }
-- 
1.5.3.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [ath9k-devel] [PATCH] ath9k: create a common debugfs_root for all device instances
  2009-03-05 15:55 ` [ath9k-devel] " Gabor Juhos
@ 2009-03-05 16:18   ` Sujith
  -1 siblings, 0 replies; 6+ messages in thread
From: Sujith @ 2009-03-05 16:18 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John W. Linville, ath9k-devel, linux-wireless

Gabor Juhos wrote:
> The driver are trying to create an 'ath9k' directory in debugfs for each
> device currently. If there are more than one device in the system, the
> second try will always fail.

Looks good. Thanks.

Also, reading 'rcstat' when the interface is down would cause a NULL
pointer dereference. Will send out a patch fixing this.

Sujith


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ath9k-devel] [PATCH] ath9k: create a common debugfs_root for all device instances
@ 2009-03-05 16:18   ` Sujith
  0 siblings, 0 replies; 6+ messages in thread
From: Sujith @ 2009-03-05 16:18 UTC (permalink / raw)
  To: ath9k-devel

Gabor Juhos wrote:
> The driver are trying to create an 'ath9k' directory in debugfs for each
> device currently. If there are more than one device in the system, the
> second try will always fail.

Looks good. Thanks.

Also, reading 'rcstat' when the interface is down would cause a NULL
pointer dereference. Will send out a patch fixing this.

Sujith

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ath9k-devel] [PATCH] ath9k: create a common debugfs_root for all device instances
  2009-03-05 16:18   ` Sujith
@ 2009-03-05 16:38     ` Gabor Juhos
  -1 siblings, 0 replies; 6+ messages in thread
From: Gabor Juhos @ 2009-03-05 16:38 UTC (permalink / raw)
  To: Sujith; +Cc: John W. Linville, ath9k-devel, linux-wireless

Sujith =EDrta:
> Gabor Juhos wrote:
>> The driver are trying to create an 'ath9k' directory in debugfs for =
each
>> device currently. If there are more than one device in the system, t=
he
>> second try will always fail.
>=20
> Looks good. Thanks.

Thank you for the review.

>=20
> Also, reading 'rcstat' when the interface is down would cause a NULL
> pointer dereference.=20

Indeed. :)

root@OpenWrt:/# cat /tmp/debug/ath9k/phy0/rcstat
CPU 0 Unable to handle kernel paging request at virtual address 0000000=
0, epc =3D=3D
c02886c8, ra =3D=3D c0288674
Oops[#1]:
Cpu 0
$ 0   : 00000000 fffffff8 00000000 00000000
$ 4   : ffffffff 00000200 c02a0000 00000005
$ 8   : 00000000 80000008 ffffffff 00000000
$12   : 82d8d080 00000000 2ab935ac 00404995
$16   : 00000017 82f30ae0 82f30ae0 00000000
$20   : 00000000 7fc3d130 00001000 82d9bf18
$24   : 00000166 c028853c
$28   : 82d9a000 82d9bab0 00000003 c0288674
Hi    : 0000025b
Lo    : 000001df
epc   : c02886c8 0xc02886c8
    Not tainted
ra    : c0288674 0xc0288674
Status: 1000f403    KERNEL EXL IE
Cause : 00800008
BadVA : 00000000
PrId  : 00019374 (MIPS 24Kc)
Modules linked in: leds_gpio nf_nat_tftp nf_conntrack_tftp nf_nat_irc
nf_conntrack_irc nf_nat_ftp nf_conntrack_ftp ipt_MASQUi
Process cat (pid: 852, threadinfo=3D82d9a000, task=3D82ddba18, tls=3D00=
000000)
Stack : 8027809c 00000000 c029b96c c029b974 83889f48 00000001 80278098 =
00000200
        00000000 2aaed0d8 20202052 61746520 20202020 20205375 63636573 =
730a0a00
        00000001 00000044 00000000 2aaed0d8 00000000 001200d2 81065c60 =
8284b2a8
        82897528 82897528 00000001 00000200 81065c60 00000000 800bee0c =
800bee0c
        82897528 82897528 82e904b4 00000000 00000001 00000005 2aaed000 =
81065c60
        ...

> Will send out a patch fixing this.

Superb.

Gabor
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ath9k-devel] [PATCH] ath9k: create a common debugfs_root for all device instances
@ 2009-03-05 16:38     ` Gabor Juhos
  0 siblings, 0 replies; 6+ messages in thread
From: Gabor Juhos @ 2009-03-05 16:38 UTC (permalink / raw)
  To: ath9k-devel

Sujith ?rta:
> Gabor Juhos wrote:
>> The driver are trying to create an 'ath9k' directory in debugfs for each
>> device currently. If there are more than one device in the system, the
>> second try will always fail.
> 
> Looks good. Thanks.

Thank you for the review.

> 
> Also, reading 'rcstat' when the interface is down would cause a NULL
> pointer dereference. 

Indeed. :)

root at OpenWrt:/# cat /tmp/debug/ath9k/phy0/rcstat
CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc ==
c02886c8, ra == c0288674
Oops[#1]:
Cpu 0
$ 0   : 00000000 fffffff8 00000000 00000000
$ 4   : ffffffff 00000200 c02a0000 00000005
$ 8   : 00000000 80000008 ffffffff 00000000
$12   : 82d8d080 00000000 2ab935ac 00404995
$16   : 00000017 82f30ae0 82f30ae0 00000000
$20   : 00000000 7fc3d130 00001000 82d9bf18
$24   : 00000166 c028853c
$28   : 82d9a000 82d9bab0 00000003 c0288674
Hi    : 0000025b
Lo    : 000001df
epc   : c02886c8 0xc02886c8
    Not tainted
ra    : c0288674 0xc0288674
Status: 1000f403    KERNEL EXL IE
Cause : 00800008
BadVA : 00000000
PrId  : 00019374 (MIPS 24Kc)
Modules linked in: leds_gpio nf_nat_tftp nf_conntrack_tftp nf_nat_irc
nf_conntrack_irc nf_nat_ftp nf_conntrack_ftp ipt_MASQUi
Process cat (pid: 852, threadinfo=82d9a000, task=82ddba18, tls=00000000)
Stack : 8027809c 00000000 c029b96c c029b974 83889f48 00000001 80278098 00000200
        00000000 2aaed0d8 20202052 61746520 20202020 20205375 63636573 730a0a00
        00000001 00000044 00000000 2aaed0d8 00000000 001200d2 81065c60 8284b2a8
        82897528 82897528 00000001 00000200 81065c60 00000000 800bee0c 800bee0c
        82897528 82897528 82e904b4 00000000 00000001 00000005 2aaed000 81065c60
        ...

> Will send out a patch fixing this.

Superb.

Gabor

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-03-05 16:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-05 15:55 [PATCH] ath9k: create a common debugfs_root for all device instances Gabor Juhos
2009-03-05 15:55 ` [ath9k-devel] " Gabor Juhos
2009-03-05 16:18 ` Sujith
2009-03-05 16:18   ` Sujith
2009-03-05 16:38   ` Gabor Juhos
2009-03-05 16:38     ` Gabor Juhos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.