cozybit/open80211s — pull request #36 by ctwitty (2013-09-03 19:53:16+00:00)
Title: debugfs for card reset

``` diff
From dc7f3b14ad6c9aad85e80c88ff5a8592631d10d8 Mon Sep 17 00:00:00 2001
From: Colleen Twitty
Date: Fri, 23 Aug 2013 09:50:39 -0700
Subject: [PATCH] mwl8787: add debugfs entry for card reset.

remove call to reset card in reading scratch register

writing anything to the debugfs will trigger a reset

Signed-off-by: Colleen Twitty
---
drivers/net/wireless/mwl8787/debugfs.c | 34 ++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mwl8787/debugfs.c b/drivers/net/wireless/mwl8787/debugfs.c
index b660a41..2fe1478 100644
--- a/drivers/net/wireless/mwl8787/debugfs.c
+++ b/drivers/net/wireless/mwl8787/debugfs.c
@@ -21,25 +21,51 @@ mwl8787_scratch_read(struct file *file, char __user *ubuf,
goto done;
}

-	pos += snprintf(buf, sizeof(buf), "%016llx\n", reg_value);
+	pos += scnprintf(buf, sizeof(buf), "%016llx\n", reg_value);

ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
-	priv->bus_ops->card_reset(priv);
done:
return ret;
}

+static ssize_t
+mwl8787_reset_write(struct file *file,
+	const char __user *ubuf, size_t count, loff_t *ppos)
+{
+	struct mwl8787_priv *priv =
+	(struct mwl8787_priv *) file->private_data;
+
+	priv->bus_ops->card_reset(priv);
+
+	return count;
+}
+
+static const struct file_operations mwl8787_reset_fops = {
+	.write = mwl8787_reset_write,
+	.open = simple_open,
+};
+
#define MWL8787_DFS_ADD_FILE(name) \
debugfs_create_file(#name, 0644, priv->dfs_dev_dir,	\
priv, &mwl8787_dfs_##name##_fops);	\

+#define MWL8787_DFS_FILE_WRITE_OPS(name) \
+static const struct file_operations mwl8787_dfs_##name##_fops = {	\
+	.write = mwl8787_##name##_write,	\
+	.open = simple_open,	\
+};
+
#define MWL8787_DFS_FILE_READ_OPS(name) \
static const struct file_operations mwl8787_dfs_##name##_fops = { \
.read = mwl8787_##name##_read, \
.open = simple_open, \
};

+#define MWL8787_DFS_ADD_MODE(name, mode)	\
+	debugfs_create_file(#name, mode, priv->dfs_dev_dir,	\
+	priv, &mwl8787_##name##_fops);
+
MWL8787_DFS_FILE_READ_OPS(scratch);

/*
@@ -54,7 +80,11 @@ mwl8787_dev_debugfs_init(struct mwl8787_priv *priv)
priv->dfs_dev_dir = debugfs_create_dir("mwl8787",
priv->hw->wiphy->debugfsdir);

+	if (!priv->dfs_dev_dir)
+	return;
+
MWL8787_DFS_ADD_FILE(scratch);
+	MWL8787_DFS_ADD_MODE(reset, 0200);
}

/*
--
1.7.9.5

```