From: ben@fluff.org.uk
To: netdev@vger.kernel.org
Cc: linux@simtec.co.uk, doong.ping@micrel.com, tristram.ha@micrel.com
Subject: [patch 5/9] KS8851: Add debugfs export for driver state
Date: Mon, 07 Dec 2009 12:15:06 +0000 [thread overview]
Message-ID: <20091207121646.881044322@fluff.org.uk> (raw)
In-Reply-To: 20091207121501.819539008@fluff.org.uk
[-- Attachment #1: ks8851-add-debugfs.patch --]
[-- Type: text/plain, Size: 3868 bytes --]
Add the ability to export the state of each network chip via debugfs
to show the cached register state and some of the network device state
information.
Signed-off-by: Ben Dooks <ben@simtec.co.uk>
---
drivers/net/ks8851.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
Index: b/drivers/net/ks8851.c
===================================================================
--- a/drivers/net/ks8851.c 2009-12-07 11:01:34.000000000 +0000
+++ b/drivers/net/ks8851.c 2009-12-07 11:01:39.000000000 +0000
@@ -21,6 +21,9 @@
#include <linux/mii.h>
#include <linux/eeprom_93cx6.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+
#include <linux/spi/spi.h>
#include "ks8851.h"
@@ -128,6 +131,9 @@ struct ks8851_net {
struct spi_transfer spi_xfer1;
struct spi_transfer spi_xfer2[2];
+ struct dentry *debug_root;
+ struct dentry *debug_file;
+
struct eeprom_93cx6 eeprom;
};
@@ -1374,6 +1380,91 @@ static int ks8851_read_selftest(struct k
return 0;
}
+/* debugfs code */
+static int state_show(struct seq_file *seq, void *v)
+{
+ struct ks8851_net *ks = seq->private;
+ struct net_device *ndev = ks->netdev;
+
+ seq_printf(seq, "Register cache:\n");
+ seq_printf(seq, "IEQ\t 0x%04x\n", ks->rc_ier);
+ seq_printf(seq, "RXQCR\t 0x%04x\n", ks->rc_rxqcr);
+ seq_printf(seq, "CCR\t 0x%04x\n", ks->rc_ccr);
+ seq_printf(seq, "RXCR1\t 0x%04x\n", ks->rxctrl.rxcr1);
+ seq_printf(seq, "RXCR2\t 0x%04x\n", ks->rxctrl.rxcr2);
+ seq_printf(seq, "MCHASH\t 0=0x%04x, 1=%04x, 2=0x%04x, 3=0x%04x\n",
+ ks->rxctrl.mchash[0], ks->rxctrl.mchash[1],
+ ks->rxctrl.mchash[2], ks->rxctrl.mchash[3]);
+
+ seq_printf(seq, "\n");
+
+ seq_printf(seq, "tx_space = 0x%04x\n", ks->tx_space);
+ seq_printf(seq, "tx fid\t= 0x%02x\n", ks->fid);
+
+ seq_printf(seq, "\n");
+
+ if (ndev->flags & IFF_MULTICAST) {
+ struct dev_mc_list *mcptr = ndev->mc_list;
+ int i;
+
+ seq_printf(seq, "MC list is %d entries\n", ndev->mc_count);
+
+ for (i = 0; i < ndev->mc_count; i++) {
+ seq_printf(seq, "\t%d: %pM\n", i, mcptr->dmi_addr);
+ mcptr = mcptr->next;
+ }
+ } else
+ seq_printf(seq, "No multicast list set\n");
+
+ return 0;
+}
+
+static int state_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, state_show, inode->i_private);
+}
+
+static const struct file_operations state_fops = {
+ .owner = THIS_MODULE,
+ .open = state_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+/**
+ * ks8851_create_debugfs - create debugfs directory and files
+ * @ks: The driver state
+ *
+ * Create the debugfs entries for the specific device.
+ */
+static void __devinit ks8851_create_debugfs(struct ks8851_net *ks)
+{
+ struct dentry *root;
+ char root_name[32];
+
+ snprintf(root_name, sizeof(root_name), "ks8851_%s",
+ dev_name(&ks->spidev->dev));
+
+ root = debugfs_create_dir(root_name, NULL);
+ if (IS_ERR(root)) {
+ ks_err(ks, "cannot create debugfs root\n");
+ return;
+ }
+
+ ks->debug_root = root;
+ ks->debug_file = debugfs_create_file("state", 0444, root,
+ ks, &state_fops);
+ if (IS_ERR(ks->debug_file))
+ ks_err(ks, "cannot create debugfs state file\n");
+}
+
+static void __devexit ks8851_delete_debugfs(struct ks8851_net *ks)
+{
+ debugfs_remove(ks->debug_file);
+ debugfs_remove(ks->debug_root);
+}
+
/* driver bus management functions */
static int __devinit ks8851_probe(struct spi_device *spi)
@@ -1482,6 +1573,8 @@ static int __devinit ks8851_probe(struct
ndev->dev_addr, ndev->irq,
ks->rc_ccr & CCR_EEPROM ? "has" : "no");
+ ks8851_create_debugfs(ks);
+
return 0;
@@ -1501,6 +1594,7 @@ static int __devexit ks8851_remove(struc
if (netif_msg_drv(priv))
dev_info(&spi->dev, "remove");
+ ks8851_delete_debugfs(priv);
unregister_netdev(priv->netdev);
free_irq(spi->irq, priv);
free_netdev(priv->netdev);
next prev parent reply other threads:[~2009-12-07 12:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20091207121501.819539008@fluff.org.uk>
2009-12-07 12:15 ` [patch 1/9] eeprom_93cx6: Add data direction control ben
2009-12-07 12:34 ` Ben Dooks
2009-12-07 12:15 ` [patch 2/9] eeprom_93cx6: Add write support ben
2009-12-07 12:15 ` [patch 3/9] KS8851: Add support for EEPROM MAC address ben
2009-12-09 4:45 ` David Miller
2009-12-07 12:15 ` [patch 4/9] KS8851: Add ethtool support for EEPROM ben
2009-12-07 12:15 ` ben [this message]
2009-12-07 12:15 ` [patch 6/9] KS8851: ks8851_mll.c: Use the ks8851.h header for device register defines ben
2009-12-07 12:15 ` [patch 7/9] KS8851: Update ks8851.h header from ks8851_mll.c ben
2009-12-07 12:15 ` [patch 8/9] KS8851: Use the ks8851.h header to hold union ks8851_tx_hdr ben
2009-12-07 12:15 ` [patch 9/9] KS8851: Add platform data to specific IRQ trigger type ben
[not found] <20091207121727.016092171@fluff.org.uk>
2009-12-07 12:17 ` [patch 5/9] KS8851: Add debugfs export for driver state Ben Dooks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091207121646.881044322@fluff.org.uk \
--to=ben@fluff.org.uk \
--cc=doong.ping@micrel.com \
--cc=linux@simtec.co.uk \
--cc=netdev@vger.kernel.org \
--cc=tristram.ha@micrel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.