blob: 8ecf4c6c28740243979920dd98ea7bdc638e5172 [file] [log] [blame]
Bing Zhaofb784f02009-06-02 14:29:37 -07001/**
2 * Marvell Bluetooth driver: debugfs related functions
3 *
4 * Copyright (C) 2009, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 *
15 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
17 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
18 * this warranty disclaimer.
19 **/
20
21#include <linux/debugfs.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090022#include <linux/slab.h>
Bing Zhaofb784f02009-06-02 14:29:37 -070023
24#include <net/bluetooth/bluetooth.h>
25#include <net/bluetooth/hci_core.h>
26
27#include "btmrvl_drv.h"
28
29struct btmrvl_debugfs_data {
Marcel Holtmannb914a252010-02-08 16:47:04 +010030 struct dentry *config_dir;
31 struct dentry *status_dir;
Bing Zhaofb784f02009-06-02 14:29:37 -070032
33 /* config */
Bing Zhaofb784f02009-06-02 14:29:37 -070034 struct dentry *psmode;
35 struct dentry *pscmd;
36 struct dentry *hsmode;
37 struct dentry *hscmd;
38 struct dentry *gpiogap;
39 struct dentry *hscfgcmd;
40
41 /* status */
42 struct dentry *curpsmode;
43 struct dentry *hsstate;
44 struct dentry *psstate;
45 struct dentry *txdnldready;
46};
47
48static int btmrvl_open_generic(struct inode *inode, struct file *file)
49{
50 file->private_data = inode->i_private;
51 return 0;
52}
53
54static ssize_t btmrvl_hscfgcmd_write(struct file *file,
Marcel Holtmann54239902009-06-09 15:48:35 +020055 const char __user *ubuf, size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -070056{
Marcel Holtmann54239902009-06-09 15:48:35 +020057 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -070058 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +020059 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -070060
61 memset(buf, 0, sizeof(buf));
62
Marcel Holtmann54239902009-06-09 15:48:35 +020063 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -070064 return -EFAULT;
65
66 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -040067 if (ret)
68 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -070069
70 priv->btmrvl_dev.hscfgcmd = result;
71
72 if (priv->btmrvl_dev.hscfgcmd) {
73 btmrvl_prepare_command(priv);
74 wake_up_interruptible(&priv->main_thread.wait_q);
75 }
76
77 return count;
78}
79
Marcel Holtmann54239902009-06-09 15:48:35 +020080static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf,
81 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -070082{
Marcel Holtmann54239902009-06-09 15:48:35 +020083 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -070084 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +020085 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -070086
87 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +020088 priv->btmrvl_dev.hscfgcmd);
Bing Zhaofb784f02009-06-02 14:29:37 -070089
90 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
91}
92
93static const struct file_operations btmrvl_hscfgcmd_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +020094 .read = btmrvl_hscfgcmd_read,
95 .write = btmrvl_hscfgcmd_write,
96 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +020097 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -070098};
99
100static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200101 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700102{
Marcel Holtmann54239902009-06-09 15:48:35 +0200103 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700104 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200105 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700106
107 memset(buf, 0, sizeof(buf));
108
Marcel Holtmann54239902009-06-09 15:48:35 +0200109 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700110 return -EFAULT;
111
112 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400113 if (ret)
114 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700115
116 priv->btmrvl_dev.psmode = result;
117
118 return count;
119}
120
Marcel Holtmann54239902009-06-09 15:48:35 +0200121static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf,
122 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700123{
Marcel Holtmann54239902009-06-09 15:48:35 +0200124 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700125 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200126 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700127
128 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200129 priv->btmrvl_dev.psmode);
Bing Zhaofb784f02009-06-02 14:29:37 -0700130
131 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
132}
133
134static const struct file_operations btmrvl_psmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200135 .read = btmrvl_psmode_read,
136 .write = btmrvl_psmode_write,
137 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200138 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700139};
140
141static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200142 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700143{
Marcel Holtmann54239902009-06-09 15:48:35 +0200144 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700145 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200146 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700147
148 memset(buf, 0, sizeof(buf));
149
Marcel Holtmann54239902009-06-09 15:48:35 +0200150 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700151 return -EFAULT;
152
153 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400154 if (ret)
155 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700156
157 priv->btmrvl_dev.pscmd = result;
158
159 if (priv->btmrvl_dev.pscmd) {
160 btmrvl_prepare_command(priv);
161 wake_up_interruptible(&priv->main_thread.wait_q);
162 }
163
164 return count;
165
166}
167
Marcel Holtmann54239902009-06-09 15:48:35 +0200168static ssize_t btmrvl_pscmd_read(struct file *file, char __user *userbuf,
169 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700170{
Marcel Holtmann54239902009-06-09 15:48:35 +0200171 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700172 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200173 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700174
175 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.pscmd);
176
177 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
178}
179
180static const struct file_operations btmrvl_pscmd_fops = {
181 .read = btmrvl_pscmd_read,
182 .write = btmrvl_pscmd_write,
183 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200184 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700185};
186
187static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200188 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700189{
Marcel Holtmann54239902009-06-09 15:48:35 +0200190 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700191 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200192 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700193
194 memset(buf, 0, sizeof(buf));
195
Marcel Holtmann54239902009-06-09 15:48:35 +0200196 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700197 return -EFAULT;
198
199 ret = strict_strtol(buf, 16, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400200 if (ret)
201 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700202
203 priv->btmrvl_dev.gpio_gap = result;
204
205 return count;
206}
207
Marcel Holtmann54239902009-06-09 15:48:35 +0200208static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf,
209 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700210{
Marcel Holtmann54239902009-06-09 15:48:35 +0200211 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700212 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200213 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700214
215 ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200216 priv->btmrvl_dev.gpio_gap);
Bing Zhaofb784f02009-06-02 14:29:37 -0700217
218 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
219}
220
221static const struct file_operations btmrvl_gpiogap_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200222 .read = btmrvl_gpiogap_read,
223 .write = btmrvl_gpiogap_write,
224 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200225 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700226};
227
228static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200229 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700230{
Joe Perchesbe60b942010-07-12 13:49:57 -0700231 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700232 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200233 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700234
235 memset(buf, 0, sizeof(buf));
236
Marcel Holtmann54239902009-06-09 15:48:35 +0200237 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700238 return -EFAULT;
239
240 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400241 if (ret)
242 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700243
244 priv->btmrvl_dev.hscmd = result;
245 if (priv->btmrvl_dev.hscmd) {
246 btmrvl_prepare_command(priv);
247 wake_up_interruptible(&priv->main_thread.wait_q);
248 }
249
250 return count;
251}
252
Marcel Holtmann54239902009-06-09 15:48:35 +0200253static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf,
254 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700255{
Marcel Holtmann54239902009-06-09 15:48:35 +0200256 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700257 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200258 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700259
260 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hscmd);
261
262 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
263}
264
265static const struct file_operations btmrvl_hscmd_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200266 .read = btmrvl_hscmd_read,
267 .write = btmrvl_hscmd_write,
268 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200269 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700270};
271
272static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200273 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700274{
Marcel Holtmann54239902009-06-09 15:48:35 +0200275 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700276 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200277 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700278
279 memset(buf, 0, sizeof(buf));
280
Marcel Holtmann54239902009-06-09 15:48:35 +0200281 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700282 return -EFAULT;
283
284 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400285 if (ret)
286 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700287
288 priv->btmrvl_dev.hsmode = result;
289
290 return count;
291}
292
293static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200294 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700295{
Marcel Holtmann54239902009-06-09 15:48:35 +0200296 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700297 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200298 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700299
Marcel Holtmann54239902009-06-09 15:48:35 +0200300 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hsmode);
Bing Zhaofb784f02009-06-02 14:29:37 -0700301
302 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
303}
304
305static const struct file_operations btmrvl_hsmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200306 .read = btmrvl_hsmode_read,
307 .write = btmrvl_hsmode_write,
308 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200309 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700310};
311
Marcel Holtmann54239902009-06-09 15:48:35 +0200312static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
313 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700314{
Marcel Holtmann54239902009-06-09 15:48:35 +0200315 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700316 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200317 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700318
319 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->psmode);
320
321 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
322}
323
324static const struct file_operations btmrvl_curpsmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200325 .read = btmrvl_curpsmode_read,
326 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200327 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700328};
329
330static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200331 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700332{
Marcel Holtmann54239902009-06-09 15:48:35 +0200333 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700334 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200335 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700336
Marcel Holtmann54239902009-06-09 15:48:35 +0200337 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->ps_state);
Bing Zhaofb784f02009-06-02 14:29:37 -0700338
339 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
340}
341
342static const struct file_operations btmrvl_psstate_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200343 .read = btmrvl_psstate_read,
344 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200345 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700346};
347
Marcel Holtmann54239902009-06-09 15:48:35 +0200348static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
349 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700350{
Marcel Holtmann54239902009-06-09 15:48:35 +0200351 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700352 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200353 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700354
Marcel Holtmann54239902009-06-09 15:48:35 +0200355 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->hs_state);
Bing Zhaofb784f02009-06-02 14:29:37 -0700356
357 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
358}
359
360static const struct file_operations btmrvl_hsstate_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200361 .read = btmrvl_hsstate_read,
362 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200363 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700364};
365
Marcel Holtmann54239902009-06-09 15:48:35 +0200366static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
367 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700368{
Marcel Holtmann54239902009-06-09 15:48:35 +0200369 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700370 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200371 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700372
373 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200374 priv->btmrvl_dev.tx_dnld_rdy);
Bing Zhaofb784f02009-06-02 14:29:37 -0700375
376 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
377}
378
379static const struct file_operations btmrvl_txdnldready_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200380 .read = btmrvl_txdnldready_read,
381 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200382 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700383};
384
385void btmrvl_debugfs_init(struct hci_dev *hdev)
386{
Marcel Holtmann54239902009-06-09 15:48:35 +0200387 struct btmrvl_private *priv = hdev->driver_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700388 struct btmrvl_debugfs_data *dbg;
389
Marcel Holtmannb914a252010-02-08 16:47:04 +0100390 if (!hdev->debugfs)
391 return;
392
Bing Zhaofb784f02009-06-02 14:29:37 -0700393 dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
394 priv->debugfs_data = dbg;
395
396 if (!dbg) {
397 BT_ERR("Can not allocate memory for btmrvl_debugfs_data.");
398 return;
399 }
400
Marcel Holtmannb914a252010-02-08 16:47:04 +0100401 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs);
Bing Zhaofb784f02009-06-02 14:29:37 -0700402
403 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir,
Marcel Holtmann54239902009-06-09 15:48:35 +0200404 hdev->driver_data, &btmrvl_psmode_fops);
405 dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700406 hdev->driver_data, &btmrvl_pscmd_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200407 dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700408 hdev->driver_data, &btmrvl_gpiogap_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200409 dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700410 hdev->driver_data, &btmrvl_hsmode_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200411 dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700412 hdev->driver_data, &btmrvl_hscmd_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200413 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700414 hdev->driver_data, &btmrvl_hscfgcmd_fops);
415
Marcel Holtmannb914a252010-02-08 16:47:04 +0100416 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs);
Bing Zhaofb784f02009-06-02 14:29:37 -0700417 dbg->curpsmode = debugfs_create_file("curpsmode", 0444,
418 dbg->status_dir,
419 hdev->driver_data,
420 &btmrvl_curpsmode_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200421 dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700422 hdev->driver_data, &btmrvl_psstate_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200423 dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700424 hdev->driver_data, &btmrvl_hsstate_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200425 dbg->txdnldready = debugfs_create_file("txdnldready", 0444,
426 dbg->status_dir,
427 hdev->driver_data,
428 &btmrvl_txdnldready_fops);
Bing Zhaofb784f02009-06-02 14:29:37 -0700429}
430
431void btmrvl_debugfs_remove(struct hci_dev *hdev)
432{
Marcel Holtmann54239902009-06-09 15:48:35 +0200433 struct btmrvl_private *priv = hdev->driver_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700434 struct btmrvl_debugfs_data *dbg = priv->debugfs_data;
435
436 if (!dbg)
437 return;
438
439 debugfs_remove(dbg->psmode);
440 debugfs_remove(dbg->pscmd);
441 debugfs_remove(dbg->gpiogap);
442 debugfs_remove(dbg->hsmode);
443 debugfs_remove(dbg->hscmd);
444 debugfs_remove(dbg->hscfgcmd);
445 debugfs_remove(dbg->config_dir);
446
447 debugfs_remove(dbg->curpsmode);
448 debugfs_remove(dbg->psstate);
449 debugfs_remove(dbg->hsstate);
450 debugfs_remove(dbg->txdnldready);
451 debugfs_remove(dbg->status_dir);
452
Bing Zhaofb784f02009-06-02 14:29:37 -0700453 kfree(dbg);
454}