aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2013-04-23 05:53:46 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-04-23 19:44:26 -0400
commit9da226c7919aaed40e0195f0b7c7713ed00e380f (patch)
tree7884ead233ee8c2702797773ff212a211d28e127 /drivers/bluetooth
parent72f78356a4a688d7286ac18c1b57d5507f68eefe (diff)
Bluetooth: btmrvl: use native helpers for debugfs
Clean up the code by using native debugfs helpers, instead of implementing them ourselves: debugfs_create_u8() debugfs_create_x16() debugfs_create_file() debugfs_remove_recursive() Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/btmrvl_debugfs.c266
1 files changed, 22 insertions, 244 deletions
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index 428dbb7574bd..db2c3c305df8 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -29,20 +29,6 @@
29struct btmrvl_debugfs_data { 29struct btmrvl_debugfs_data {
30 struct dentry *config_dir; 30 struct dentry *config_dir;
31 struct dentry *status_dir; 31 struct dentry *status_dir;
32
33 /* config */
34 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}; 32};
47 33
48static ssize_t btmrvl_hscfgcmd_write(struct file *file, 34static ssize_t btmrvl_hscfgcmd_write(struct file *file,
@@ -91,47 +77,6 @@ static const struct file_operations btmrvl_hscfgcmd_fops = {
91 .llseek = default_llseek, 77 .llseek = default_llseek,
92}; 78};
93 79
94static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
95 size_t count, loff_t *ppos)
96{
97 struct btmrvl_private *priv = file->private_data;
98 char buf[16];
99 long result, ret;
100
101 memset(buf, 0, sizeof(buf));
102
103 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
104 return -EFAULT;
105
106 ret = strict_strtol(buf, 10, &result);
107 if (ret)
108 return ret;
109
110 priv->btmrvl_dev.psmode = result;
111
112 return count;
113}
114
115static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf,
116 size_t count, loff_t *ppos)
117{
118 struct btmrvl_private *priv = file->private_data;
119 char buf[16];
120 int ret;
121
122 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
123 priv->btmrvl_dev.psmode);
124
125 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
126}
127
128static const struct file_operations btmrvl_psmode_fops = {
129 .read = btmrvl_psmode_read,
130 .write = btmrvl_psmode_write,
131 .open = simple_open,
132 .llseek = default_llseek,
133};
134
135static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, 80static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
136 size_t count, loff_t *ppos) 81 size_t count, loff_t *ppos)
137{ 82{
@@ -178,47 +123,6 @@ static const struct file_operations btmrvl_pscmd_fops = {
178 .llseek = default_llseek, 123 .llseek = default_llseek,
179}; 124};
180 125
181static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf,
182 size_t count, loff_t *ppos)
183{
184 struct btmrvl_private *priv = file->private_data;
185 char buf[16];
186 long result, ret;
187
188 memset(buf, 0, sizeof(buf));
189
190 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
191 return -EFAULT;
192
193 ret = strict_strtol(buf, 16, &result);
194 if (ret)
195 return ret;
196
197 priv->btmrvl_dev.gpio_gap = result;
198
199 return count;
200}
201
202static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf,
203 size_t count, loff_t *ppos)
204{
205 struct btmrvl_private *priv = file->private_data;
206 char buf[16];
207 int ret;
208
209 ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n",
210 priv->btmrvl_dev.gpio_gap);
211
212 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
213}
214
215static const struct file_operations btmrvl_gpiogap_fops = {
216 .read = btmrvl_gpiogap_read,
217 .write = btmrvl_gpiogap_write,
218 .open = simple_open,
219 .llseek = default_llseek,
220};
221
222static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, 126static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
223 size_t count, loff_t *ppos) 127 size_t count, loff_t *ppos)
224{ 128{
@@ -263,119 +167,6 @@ static const struct file_operations btmrvl_hscmd_fops = {
263 .llseek = default_llseek, 167 .llseek = default_llseek,
264}; 168};
265 169
266static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
267 size_t count, loff_t *ppos)
268{
269 struct btmrvl_private *priv = file->private_data;
270 char buf[16];
271 long result, ret;
272
273 memset(buf, 0, sizeof(buf));
274
275 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
276 return -EFAULT;
277
278 ret = strict_strtol(buf, 10, &result);
279 if (ret)
280 return ret;
281
282 priv->btmrvl_dev.hsmode = result;
283
284 return count;
285}
286
287static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf,
288 size_t count, loff_t *ppos)
289{
290 struct btmrvl_private *priv = file->private_data;
291 char buf[16];
292 int ret;
293
294 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hsmode);
295
296 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
297}
298
299static const struct file_operations btmrvl_hsmode_fops = {
300 .read = btmrvl_hsmode_read,
301 .write = btmrvl_hsmode_write,
302 .open = simple_open,
303 .llseek = default_llseek,
304};
305
306static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
307 size_t count, loff_t *ppos)
308{
309 struct btmrvl_private *priv = file->private_data;
310 char buf[16];
311 int ret;
312
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 = {
319 .read = btmrvl_curpsmode_read,
320 .open = simple_open,
321 .llseek = default_llseek,
322};
323
324static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
325 size_t count, loff_t *ppos)
326{
327 struct btmrvl_private *priv = file->private_data;
328 char buf[16];
329 int ret;
330
331 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->ps_state);
332
333 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
334}
335
336static const struct file_operations btmrvl_psstate_fops = {
337 .read = btmrvl_psstate_read,
338 .open = simple_open,
339 .llseek = default_llseek,
340};
341
342static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
343 size_t count, loff_t *ppos)
344{
345 struct btmrvl_private *priv = file->private_data;
346 char buf[16];
347 int ret;
348
349 ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->hs_state);
350
351 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
352}
353
354static const struct file_operations btmrvl_hsstate_fops = {
355 .read = btmrvl_hsstate_read,
356 .open = simple_open,
357 .llseek = default_llseek,
358};
359
360static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
361 size_t count, loff_t *ppos)
362{
363 struct btmrvl_private *priv = file->private_data;
364 char buf[16];
365 int ret;
366
367 ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
368 priv->btmrvl_dev.tx_dnld_rdy);
369
370 return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
371}
372
373static const struct file_operations btmrvl_txdnldready_fops = {
374 .read = btmrvl_txdnldready_read,
375 .open = simple_open,
376 .llseek = default_llseek,
377};
378
379void btmrvl_debugfs_init(struct hci_dev *hdev) 170void btmrvl_debugfs_init(struct hci_dev *hdev)
380{ 171{
381 struct btmrvl_private *priv = hci_get_drvdata(hdev); 172 struct btmrvl_private *priv = hci_get_drvdata(hdev);
@@ -394,30 +185,28 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
394 185
395 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs); 186 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs);
396 187
397 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, 188 debugfs_create_u8("psmode", 0644, dbg->config_dir,
398 priv, &btmrvl_psmode_fops); 189 &priv->btmrvl_dev.psmode);
399 dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir, 190 debugfs_create_file("pscmd", 0644, dbg->config_dir,
400 priv, &btmrvl_pscmd_fops); 191 priv, &btmrvl_pscmd_fops);
401 dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir, 192 debugfs_create_x16("gpiogap", 0644, dbg->config_dir,
402 priv, &btmrvl_gpiogap_fops); 193 &priv->btmrvl_dev.gpio_gap);
403 dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir, 194 debugfs_create_u8("hsmode", 0644, dbg->config_dir,
404 priv, &btmrvl_hsmode_fops); 195 &priv->btmrvl_dev.hsmode);
405 dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir, 196 debugfs_create_file("hscmd", 0644, dbg->config_dir,
406 priv, &btmrvl_hscmd_fops); 197 priv, &btmrvl_hscmd_fops);
407 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, 198 debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
408 priv, &btmrvl_hscfgcmd_fops); 199 priv, &btmrvl_hscfgcmd_fops);
409 200
410 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs); 201 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs);
411 dbg->curpsmode = debugfs_create_file("curpsmode", 0444, 202 debugfs_create_u8("curpsmode", 0444, dbg->status_dir,
412 dbg->status_dir, priv, 203 &priv->adapter->psmode);
413 &btmrvl_curpsmode_fops); 204 debugfs_create_u8("psstate", 0444, dbg->status_dir,
414 dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir, 205 &priv->adapter->ps_state);
415 priv, &btmrvl_psstate_fops); 206 debugfs_create_u8("hsstate", 0444, dbg->status_dir,
416 dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir, 207 &priv->adapter->hs_state);
417 priv, &btmrvl_hsstate_fops); 208 debugfs_create_u8("txdnldready", 0444, dbg->status_dir,
418 dbg->txdnldready = debugfs_create_file("txdnldready", 0444, 209 &priv->btmrvl_dev.tx_dnld_rdy);
419 dbg->status_dir, priv,
420 &btmrvl_txdnldready_fops);
421} 210}
422 211
423void btmrvl_debugfs_remove(struct hci_dev *hdev) 212void btmrvl_debugfs_remove(struct hci_dev *hdev)
@@ -428,19 +217,8 @@ void btmrvl_debugfs_remove(struct hci_dev *hdev)
428 if (!dbg) 217 if (!dbg)
429 return; 218 return;
430 219
431 debugfs_remove(dbg->psmode); 220 debugfs_remove_recursive(dbg->config_dir);
432 debugfs_remove(dbg->pscmd); 221 debugfs_remove_recursive(dbg->status_dir);
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 222
445 kfree(dbg); 223 kfree(dbg);
446} 224}