blob: 428dbb7574bd75aa43d84ba5af353a134d1abfd3 [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
Bing Zhaofb784f02009-06-02 14:29:37 -070048static ssize_t btmrvl_hscfgcmd_write(struct file *file,
Marcel Holtmann54239902009-06-09 15:48:35 +020049 const char __user *ubuf, size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -070050{
Marcel Holtmann54239902009-06-09 15:48:35 +020051 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -070052 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +020053 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -070054
55 memset(buf, 0, sizeof(buf));
56
Marcel Holtmann54239902009-06-09 15:48:35 +020057 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -070058 return -EFAULT;
59
60 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -040061 if (ret)
62 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -070063
64 priv->btmrvl_dev.hscfgcmd = result;
65
66 if (priv->btmrvl_dev.hscfgcmd) {
67 btmrvl_prepare_command(priv);
68 wake_up_interruptible(&priv->main_thread.wait_q);
69 }
70
71 return count;
72}
73
Marcel Holtmann54239902009-06-09 15:48:35 +020074static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf,
75 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -070076{
Marcel Holtmann54239902009-06-09 15:48:35 +020077 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -070078 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +020079 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -070080
81 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +020082 priv->btmrvl_dev.hscfgcmd);
Bing Zhaofb784f02009-06-02 14:29:37 -070083
84 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
85}
86
87static const struct file_operations btmrvl_hscfgcmd_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +020088 .read = btmrvl_hscfgcmd_read,
89 .write = btmrvl_hscfgcmd_write,
Stephen Boyd234e3402012-04-05 14:25:11 -070090 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +020091 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -070092};
93
94static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +020095 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -070096{
Marcel Holtmann54239902009-06-09 15:48:35 +020097 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -070098 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +020099 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700100
101 memset(buf, 0, sizeof(buf));
102
Marcel Holtmann54239902009-06-09 15:48:35 +0200103 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700104 return -EFAULT;
105
106 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400107 if (ret)
108 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700109
110 priv->btmrvl_dev.psmode = result;
111
112 return count;
113}
114
Marcel Holtmann54239902009-06-09 15:48:35 +0200115static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf,
116 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700117{
Marcel Holtmann54239902009-06-09 15:48:35 +0200118 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700119 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200120 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700121
122 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200123 priv->btmrvl_dev.psmode);
Bing Zhaofb784f02009-06-02 14:29:37 -0700124
125 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
126}
127
128static const struct file_operations btmrvl_psmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200129 .read = btmrvl_psmode_read,
130 .write = btmrvl_psmode_write,
Stephen Boyd234e3402012-04-05 14:25:11 -0700131 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200132 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700133};
134
135static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200136 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700137{
Marcel Holtmann54239902009-06-09 15:48:35 +0200138 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700139 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200140 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700141
142 memset(buf, 0, sizeof(buf));
143
Marcel Holtmann54239902009-06-09 15:48:35 +0200144 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700145 return -EFAULT;
146
147 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400148 if (ret)
149 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700150
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,
Stephen Boyd234e3402012-04-05 14:25:11 -0700177 .open = simple_open,
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);
David Miller26e7acf2011-05-19 17:37:45 -0400194 if (ret)
195 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700196
197 priv->btmrvl_dev.gpio_gap = result;
198
199 return count;
200}
201
Marcel Holtmann54239902009-06-09 15:48:35 +0200202static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf,
203 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700204{
Marcel Holtmann54239902009-06-09 15:48:35 +0200205 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700206 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200207 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700208
209 ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200210 priv->btmrvl_dev.gpio_gap);
Bing Zhaofb784f02009-06-02 14:29:37 -0700211
212 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
213}
214
215static const struct file_operations btmrvl_gpiogap_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200216 .read = btmrvl_gpiogap_read,
217 .write = btmrvl_gpiogap_write,
Stephen Boyd234e3402012-04-05 14:25:11 -0700218 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200219 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700220};
221
222static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200223 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700224{
Joe Perchesbe60b942010-07-12 13:49:57 -0700225 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700226 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200227 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700228
229 memset(buf, 0, sizeof(buf));
230
Marcel Holtmann54239902009-06-09 15:48:35 +0200231 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700232 return -EFAULT;
233
234 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400235 if (ret)
236 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700237
238 priv->btmrvl_dev.hscmd = result;
239 if (priv->btmrvl_dev.hscmd) {
240 btmrvl_prepare_command(priv);
241 wake_up_interruptible(&priv->main_thread.wait_q);
242 }
243
244 return count;
245}
246
Marcel Holtmann54239902009-06-09 15:48:35 +0200247static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf,
248 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700249{
Marcel Holtmann54239902009-06-09 15:48:35 +0200250 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700251 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200252 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700253
254 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hscmd);
255
256 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
257}
258
259static const struct file_operations btmrvl_hscmd_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200260 .read = btmrvl_hscmd_read,
261 .write = btmrvl_hscmd_write,
Stephen Boyd234e3402012-04-05 14:25:11 -0700262 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200263 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700264};
265
266static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200267 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700268{
Marcel Holtmann54239902009-06-09 15:48:35 +0200269 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700270 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200271 long result, ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700272
273 memset(buf, 0, sizeof(buf));
274
Marcel Holtmann54239902009-06-09 15:48:35 +0200275 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Bing Zhaofb784f02009-06-02 14:29:37 -0700276 return -EFAULT;
277
278 ret = strict_strtol(buf, 10, &result);
David Miller26e7acf2011-05-19 17:37:45 -0400279 if (ret)
280 return ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700281
282 priv->btmrvl_dev.hsmode = result;
283
284 return count;
285}
286
287static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200288 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700289{
Marcel Holtmann54239902009-06-09 15:48:35 +0200290 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700291 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200292 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700293
Marcel Holtmann54239902009-06-09 15:48:35 +0200294 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hsmode);
Bing Zhaofb784f02009-06-02 14:29:37 -0700295
296 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
297}
298
299static const struct file_operations btmrvl_hsmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200300 .read = btmrvl_hsmode_read,
301 .write = btmrvl_hsmode_write,
Stephen Boyd234e3402012-04-05 14:25:11 -0700302 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200303 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700304};
305
Marcel Holtmann54239902009-06-09 15:48:35 +0200306static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
307 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700308{
Marcel Holtmann54239902009-06-09 15:48:35 +0200309 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700310 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200311 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700312
313 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->psmode);
314
315 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
316}
317
318static const struct file_operations btmrvl_curpsmode_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200319 .read = btmrvl_curpsmode_read,
Stephen Boyd234e3402012-04-05 14:25:11 -0700320 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200321 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700322};
323
324static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
Marcel Holtmann54239902009-06-09 15:48:35 +0200325 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700326{
Marcel Holtmann54239902009-06-09 15:48:35 +0200327 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700328 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200329 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700330
Marcel Holtmann54239902009-06-09 15:48:35 +0200331 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->ps_state);
Bing Zhaofb784f02009-06-02 14:29:37 -0700332
333 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
334}
335
336static const struct file_operations btmrvl_psstate_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200337 .read = btmrvl_psstate_read,
Stephen Boyd234e3402012-04-05 14:25:11 -0700338 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200339 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700340};
341
Marcel Holtmann54239902009-06-09 15:48:35 +0200342static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
343 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700344{
Marcel Holtmann54239902009-06-09 15:48:35 +0200345 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700346 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200347 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700348
Marcel Holtmann54239902009-06-09 15:48:35 +0200349 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->hs_state);
Bing Zhaofb784f02009-06-02 14:29:37 -0700350
351 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
352}
353
354static const struct file_operations btmrvl_hsstate_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200355 .read = btmrvl_hsstate_read,
Stephen Boyd234e3402012-04-05 14:25:11 -0700356 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200357 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700358};
359
Marcel Holtmann54239902009-06-09 15:48:35 +0200360static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
361 size_t count, loff_t *ppos)
Bing Zhaofb784f02009-06-02 14:29:37 -0700362{
Marcel Holtmann54239902009-06-09 15:48:35 +0200363 struct btmrvl_private *priv = file->private_data;
Bing Zhaofb784f02009-06-02 14:29:37 -0700364 char buf[16];
Marcel Holtmann54239902009-06-09 15:48:35 +0200365 int ret;
Bing Zhaofb784f02009-06-02 14:29:37 -0700366
367 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
Marcel Holtmann54239902009-06-09 15:48:35 +0200368 priv->btmrvl_dev.tx_dnld_rdy);
Bing Zhaofb784f02009-06-02 14:29:37 -0700369
370 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
371}
372
373static const struct file_operations btmrvl_txdnldready_fops = {
Marcel Holtmann54239902009-06-09 15:48:35 +0200374 .read = btmrvl_txdnldready_read,
Stephen Boyd234e3402012-04-05 14:25:11 -0700375 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200376 .llseek = default_llseek,
Bing Zhaofb784f02009-06-02 14:29:37 -0700377};
378
379void btmrvl_debugfs_init(struct hci_dev *hdev)
380{
David Herrmann155961e2012-02-09 21:58:32 +0100381 struct btmrvl_private *priv = hci_get_drvdata(hdev);
Bing Zhaofb784f02009-06-02 14:29:37 -0700382 struct btmrvl_debugfs_data *dbg;
383
Marcel Holtmannb914a252010-02-08 16:47:04 +0100384 if (!hdev->debugfs)
385 return;
386
Bing Zhaofb784f02009-06-02 14:29:37 -0700387 dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
388 priv->debugfs_data = dbg;
389
390 if (!dbg) {
391 BT_ERR("Can not allocate memory for btmrvl_debugfs_data.");
392 return;
393 }
394
Marcel Holtmannb914a252010-02-08 16:47:04 +0100395 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs);
Bing Zhaofb784f02009-06-02 14:29:37 -0700396
397 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300398 priv, &btmrvl_psmode_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200399 dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300400 priv, &btmrvl_pscmd_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200401 dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300402 priv, &btmrvl_gpiogap_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200403 dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300404 priv, &btmrvl_hsmode_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200405 dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300406 priv, &btmrvl_hscmd_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200407 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300408 priv, &btmrvl_hscfgcmd_fops);
Bing Zhaofb784f02009-06-02 14:29:37 -0700409
Marcel Holtmannb914a252010-02-08 16:47:04 +0100410 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs);
Bing Zhaofb784f02009-06-02 14:29:37 -0700411 dbg->curpsmode = debugfs_create_file("curpsmode", 0444,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300412 dbg->status_dir, priv,
413 &btmrvl_curpsmode_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200414 dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300415 priv, &btmrvl_psstate_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200416 dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300417 priv, &btmrvl_hsstate_fops);
Marcel Holtmann54239902009-06-09 15:48:35 +0200418 dbg->txdnldready = debugfs_create_file("txdnldready", 0444,
Gustavo F. Padovan04124682012-03-08 01:25:00 -0300419 dbg->status_dir, priv,
420 &btmrvl_txdnldready_fops);
Bing Zhaofb784f02009-06-02 14:29:37 -0700421}
422
423void btmrvl_debugfs_remove(struct hci_dev *hdev)
424{
David Herrmann155961e2012-02-09 21:58:32 +0100425 struct btmrvl_private *priv = hci_get_drvdata(hdev);
Bing Zhaofb784f02009-06-02 14:29:37 -0700426 struct btmrvl_debugfs_data *dbg = priv->debugfs_data;
427
428 if (!dbg)
429 return;
430
431 debugfs_remove(dbg->psmode);
432 debugfs_remove(dbg->pscmd);
433 debugfs_remove(dbg->gpiogap);
434 debugfs_remove(dbg->hsmode);
435 debugfs_remove(dbg->hscmd);
436 debugfs_remove(dbg->hscfgcmd);
437 debugfs_remove(dbg->config_dir);
438
439 debugfs_remove(dbg->curpsmode);
440 debugfs_remove(dbg->psstate);
441 debugfs_remove(dbg->hsstate);
442 debugfs_remove(dbg->txdnldready);
443 debugfs_remove(dbg->status_dir);
444
Bing Zhaofb784f02009-06-02 14:29:37 -0700445 kfree(dbg);
446}