blob: fd6305bf953e4084c9b7557a26acb002deb101fe [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);
67
68 priv->btmrvl_dev.hscfgcmd = result;
69
70 if (priv->btmrvl_dev.hscfgcmd) {
71 btmrvl_prepare_command(priv);
72 wake_up_interruptible(&priv->main_thread.wait_q);
73 }
74
75 return count;
76}
77
Marcel Holtmann54239902009-06-09 15:48:35 +020078static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf,
79 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -070080{
Marcel Holtmann54239902009-06-09 15:48:35 +020081 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -070082 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +020083 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -070084
85 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +020086 priv->btmrvl_dev.hscfgcmd);
Bing Zhaofb784f02009-06-02 14:29:37 -070087
88 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
89}
90
91static const struct file_operations btmrvl_hscfgcmd_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +020092 .read = btmrvl_hscfgcmd_read,
93 .write = btmrvl_hscfgcmd_write,
94 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +020095 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -070096};
97
98static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +020099 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700100{
Marcel Holtmann54239902009-06-09 15:48:35 +0200101 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700102 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200103 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700104
105 memset(buf, 0, sizeof(buf));
106
Marcel Holtmann54239902009-06-09 15:48:35 +0200107 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700108 return -EFAULT;
109
110 ret = strict_strtol(buf, 10, &result);
111
112 priv->btmrvl_dev.psmode = result;
113
114 return count;
115}
116
Marcel Holtmann54239902009-06-09 15:48:35 +0200117static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf,
118 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700119{
Marcel Holtmann54239902009-06-09 15:48:35 +0200120 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700121 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200122 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700123
124 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200125 priv->btmrvl_dev.psmode);
Bing Zhaofb784f02009-06-02 14:29:37 -0700126
127 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
128}
129
130static const struct file_operations btmrvl_psmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200131 .read = btmrvl_psmode_read,
132 .write = btmrvl_psmode_write,
133 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200134 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700135};
136
137static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200138 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700139{
Marcel Holtmann54239902009-06-09 15:48:35 +0200140 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700141 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200142 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700143
144 memset(buf, 0, sizeof(buf));
145
Marcel Holtmann54239902009-06-09 15:48:35 +0200146 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700147 return -EFAULT;
148
149 ret = strict_strtol(buf, 10, &result);
150
151 priv->btmrvl_dev.pscmd = result;
152
153 if (priv->btmrvl_dev.pscmd) {
154 btmrvl_prepare_command(priv);
155 wake_up_interruptible(&priv->main_thread.wait_q);
156 }
157
158 return count;
159
160}
161
Marcel Holtmann54239902009-06-09 15:48:35 +0200162static ssize_t btmrvl_pscmd_read(struct file *file, char __user *userbuf,
163 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700164{
Marcel Holtmann54239902009-06-09 15:48:35 +0200165 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700166 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200167 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700168
169 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.pscmd);
170
171 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
172}
173
174static const struct file_operations btmrvl_pscmd_fops = {
175 .read = btmrvl_pscmd_read,
176 .write = btmrvl_pscmd_write,
177 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200178 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700179};
180
181static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200182 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700183{
Marcel Holtmann54239902009-06-09 15:48:35 +0200184 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700185 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200186 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700187
188 memset(buf, 0, sizeof(buf));
189
Marcel Holtmann54239902009-06-09 15:48:35 +0200190 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700191 return -EFAULT;
192
193 ret = strict_strtol(buf, 16, &result);
194
195 priv->btmrvl_dev.gpio_gap = result;
196
197 return count;
198}
199
Marcel Holtmann54239902009-06-09 15:48:35 +0200200static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf,
201 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700202{
Marcel Holtmann54239902009-06-09 15:48:35 +0200203 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700204 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200205 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700206
207 ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200208 priv->btmrvl_dev.gpio_gap);
Bing Zhaofb784f02009-06-02 14:29:37 -0700209
210 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
211}
212
213static const struct file_operations btmrvl_gpiogap_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200214 .read = btmrvl_gpiogap_read,
215 .write = btmrvl_gpiogap_write,
216 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200217 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700218};
219
220static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200221 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700222{
Joe Perchesbe60b942010-07-12 13:49:57 -0700223 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700224 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200225 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700226
227 memset(buf, 0, sizeof(buf));
228
Marcel Holtmann54239902009-06-09 15:48:35 +0200229 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700230 return -EFAULT;
231
232 ret = strict_strtol(buf, 10, &result);
233
234 priv->btmrvl_dev.hscmd = result;
235 if (priv->btmrvl_dev.hscmd) {
236 btmrvl_prepare_command(priv);
237 wake_up_interruptible(&priv->main_thread.wait_q);
238 }
239
240 return count;
241}
242
Marcel Holtmann54239902009-06-09 15:48:35 +0200243static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf,
244 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700245{
Marcel Holtmann54239902009-06-09 15:48:35 +0200246 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700247 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200248 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700249
250 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hscmd);
251
252 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
253}
254
255static const struct file_operations btmrvl_hscmd_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200256 .read = btmrvl_hscmd_read,
257 .write = btmrvl_hscmd_write,
258 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200259 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700260};
261
262static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200263 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700264{
Marcel Holtmann54239902009-06-09 15:48:35 +0200265 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700266 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200267 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700268
269 memset(buf, 0, sizeof(buf));
270
Marcel Holtmann54239902009-06-09 15:48:35 +0200271 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700272 return -EFAULT;
273
274 ret = strict_strtol(buf, 10, &result);
275
276 priv->btmrvl_dev.hsmode = result;
277
278 return count;
279}
280
281static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200282 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700283{
Marcel Holtmann54239902009-06-09 15:48:35 +0200284 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700285 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200286 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700287
Marcel Holtmann54239902009-06-09 15:48:35 +0200288 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hsmode);
Bing Zhaofb784f02009-06-02 14:29:37 -0700289
290 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
291}
292
293static const struct file_operations btmrvl_hsmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200294 .read = btmrvl_hsmode_read,
295 .write = btmrvl_hsmode_write,
296 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200297 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700298};
299
Marcel Holtmann54239902009-06-09 15:48:35 +0200300static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
301 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700302{
Marcel Holtmann54239902009-06-09 15:48:35 +0200303 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700304 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200305 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700306
307 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->psmode);
308
309 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
310}
311
312static const struct file_operations btmrvl_curpsmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200313 .read = btmrvl_curpsmode_read,
314 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200315 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700316};
317
318static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200319 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700320{
Marcel Holtmann54239902009-06-09 15:48:35 +0200321 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700322 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200323 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700324
Marcel Holtmann54239902009-06-09 15:48:35 +0200325 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->ps_state);
Bing Zhaofb784f02009-06-02 14:29:37 -0700326
327 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
328}
329
330static const struct file_operations btmrvl_psstate_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200331 .read = btmrvl_psstate_read,
332 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200333 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700334};
335
Marcel Holtmann54239902009-06-09 15:48:35 +0200336static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
337 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700338{
Marcel Holtmann54239902009-06-09 15:48:35 +0200339 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700340 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200341 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700342
Marcel Holtmann54239902009-06-09 15:48:35 +0200343 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->hs_state);
Bing Zhaofb784f02009-06-02 14:29:37 -0700344
345 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
346}
347
348static const struct file_operations btmrvl_hsstate_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200349 .read = btmrvl_hsstate_read,
350 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200351 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700352};
353
Marcel Holtmann54239902009-06-09 15:48:35 +0200354static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
355 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700356{
Marcel Holtmann54239902009-06-09 15:48:35 +0200357 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700358 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200359 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700360
361 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200362 priv->btmrvl_dev.tx_dnld_rdy);
Bing Zhaofb784f02009-06-02 14:29:37 -0700363
364 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
365}
366
367static const struct file_operations btmrvl_txdnldready_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200368 .read = btmrvl_txdnldready_read,
369 .open = btmrvl_open_generic,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200370 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700371};
372
373void btmrvl_debugfs_init(struct hci_dev *hdev)
374{
Marcel Holtmann54239902009-06-09 15:48:35 +0200375 struct btmrvl_private *priv = hdev->driver_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700376 struct btmrvl_debugfs_data *dbg;
377
Marcel Holtmannb914a252010-02-08 16:47:04 +0100378 if (!hdev->debugfs)
379 return;
380
Bing Zhaofb784f02009-06-02 14:29:37 -0700381 dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
382 priv->debugfs_data = dbg;
383
384 if (!dbg) {
385 BT_ERR("Can not allocate memory for btmrvl_debugfs_data.");
386 return;
387 }
388
Marcel Holtmannb914a252010-02-08 16:47:04 +0100389 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs);
Bing Zhaofb784f02009-06-02 14:29:37 -0700390
391 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir,
Marcel Holtmann54239902009-06-09 15:48:35 +0200392 hdev->driver_data, &btmrvl_psmode_fops);
393 dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700394 hdev->driver_data, &btmrvl_pscmd_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200395 dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700396 hdev->driver_data, &btmrvl_gpiogap_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200397 dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700398 hdev->driver_data, &btmrvl_hsmode_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200399 dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700400 hdev->driver_data, &btmrvl_hscmd_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200401 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700402 hdev->driver_data, &btmrvl_hscfgcmd_fops);
403
Marcel Holtmannb914a252010-02-08 16:47:04 +0100404 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs);
Bing Zhaofb784f02009-06-02 14:29:37 -0700405 dbg->curpsmode = debugfs_create_file("curpsmode", 0444,
406 dbg->status_dir,
407 hdev->driver_data,
408 &btmrvl_curpsmode_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200409 dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700410 hdev->driver_data, &btmrvl_psstate_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200411 dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir,
Bing Zhaofb784f02009-06-02 14:29:37 -0700412 hdev->driver_data, &btmrvl_hsstate_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200413 dbg->txdnldready = debugfs_create_file("txdnldready", 0444,
414 dbg->status_dir,
415 hdev->driver_data,
416 &btmrvl_txdnldready_fops);
Bing Zhaofb784f02009-06-02 14:29:37 -0700417}
418
419void btmrvl_debugfs_remove(struct hci_dev *hdev)
420{
Marcel Holtmann54239902009-06-09 15:48:35 +0200421 struct btmrvl_private *priv = hdev->driver_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700422 struct btmrvl_debugfs_data *dbg = priv->debugfs_data;
423
424 if (!dbg)
425 return;
426
427 debugfs_remove(dbg->psmode);
428 debugfs_remove(dbg->pscmd);
429 debugfs_remove(dbg->gpiogap);
430 debugfs_remove(dbg->hsmode);
431 debugfs_remove(dbg->hscmd);
432 debugfs_remove(dbg->hscfgcmd);
433 debugfs_remove(dbg->config_dir);
434
435 debugfs_remove(dbg->curpsmode);
436 debugfs_remove(dbg->psstate);
437 debugfs_remove(dbg->hsstate);
438 debugfs_remove(dbg->txdnldready);
439 debugfs_remove(dbg->status_dir);
440
Bing Zhaofb784f02009-06-02 14:29:37 -0700441 kfree(dbg);
442}