Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 1 | /** |
| 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 Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 22 | #include <linux/slab.h> |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 23 | |
| 24 | #include <net/bluetooth/bluetooth.h> |
| 25 | #include <net/bluetooth/hci_core.h> |
| 26 | |
| 27 | #include "btmrvl_drv.h" |
| 28 | |
| 29 | struct btmrvl_debugfs_data { |
Marcel Holtmann | b914a25 | 2010-02-08 16:47:04 +0100 | [diff] [blame] | 30 | struct dentry *config_dir; |
| 31 | struct dentry *status_dir; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 32 | |
| 33 | /* config */ |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 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 | }; |
| 47 | |
| 48 | static int btmrvl_open_generic(struct inode *inode, struct file *file) |
| 49 | { |
| 50 | file->private_data = inode->i_private; |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static ssize_t btmrvl_hscfgcmd_write(struct file *file, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 55 | const char __user *ubuf, size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 56 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 57 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 58 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 59 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 60 | |
| 61 | memset(buf, 0, sizeof(buf)); |
| 62 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 63 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 64 | 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 Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 78 | static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf, |
| 79 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 80 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 81 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 82 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 83 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 84 | |
| 85 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 86 | priv->btmrvl_dev.hscfgcmd); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 87 | |
| 88 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 89 | } |
| 90 | |
| 91 | static const struct file_operations btmrvl_hscfgcmd_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 92 | .read = btmrvl_hscfgcmd_read, |
| 93 | .write = btmrvl_hscfgcmd_write, |
| 94 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 95 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 99 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 100 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 101 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 102 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 103 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 104 | |
| 105 | memset(buf, 0, sizeof(buf)); |
| 106 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 107 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 108 | return -EFAULT; |
| 109 | |
| 110 | ret = strict_strtol(buf, 10, &result); |
| 111 | |
| 112 | priv->btmrvl_dev.psmode = result; |
| 113 | |
| 114 | return count; |
| 115 | } |
| 116 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 117 | static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf, |
| 118 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 119 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 120 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 121 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 122 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 123 | |
| 124 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 125 | priv->btmrvl_dev.psmode); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 126 | |
| 127 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 128 | } |
| 129 | |
| 130 | static const struct file_operations btmrvl_psmode_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 131 | .read = btmrvl_psmode_read, |
| 132 | .write = btmrvl_psmode_write, |
| 133 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 134 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 138 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 139 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 140 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 141 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 142 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 143 | |
| 144 | memset(buf, 0, sizeof(buf)); |
| 145 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 146 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 147 | 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 Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 162 | static ssize_t btmrvl_pscmd_read(struct file *file, char __user *userbuf, |
| 163 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 164 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 165 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 166 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 167 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 168 | |
| 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 | |
| 174 | static const struct file_operations btmrvl_pscmd_fops = { |
| 175 | .read = btmrvl_pscmd_read, |
| 176 | .write = btmrvl_pscmd_write, |
| 177 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 178 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 182 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 183 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 184 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 185 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 186 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 187 | |
| 188 | memset(buf, 0, sizeof(buf)); |
| 189 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 190 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 191 | 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 Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 200 | static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf, |
| 201 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 202 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 203 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 204 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 205 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 206 | |
| 207 | ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n", |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 208 | priv->btmrvl_dev.gpio_gap); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 209 | |
| 210 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 211 | } |
| 212 | |
| 213 | static const struct file_operations btmrvl_gpiogap_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 214 | .read = btmrvl_gpiogap_read, |
| 215 | .write = btmrvl_gpiogap_write, |
| 216 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 217 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 218 | }; |
| 219 | |
| 220 | static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 221 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 222 | { |
Joe Perches | be60b94 | 2010-07-12 13:49:57 -0700 | [diff] [blame] | 223 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 224 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 225 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 226 | |
| 227 | memset(buf, 0, sizeof(buf)); |
| 228 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 229 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 230 | 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 Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 243 | static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf, |
| 244 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 245 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 246 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 247 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 248 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 249 | |
| 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 | |
| 255 | static const struct file_operations btmrvl_hscmd_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 256 | .read = btmrvl_hscmd_read, |
| 257 | .write = btmrvl_hscmd_write, |
| 258 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 259 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 260 | }; |
| 261 | |
| 262 | static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 263 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 264 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 265 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 266 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 267 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 268 | |
| 269 | memset(buf, 0, sizeof(buf)); |
| 270 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 271 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 272 | return -EFAULT; |
| 273 | |
| 274 | ret = strict_strtol(buf, 10, &result); |
| 275 | |
| 276 | priv->btmrvl_dev.hsmode = result; |
| 277 | |
| 278 | return count; |
| 279 | } |
| 280 | |
| 281 | static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 282 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 283 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 284 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 285 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 286 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 287 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 288 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hsmode); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 289 | |
| 290 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 291 | } |
| 292 | |
| 293 | static const struct file_operations btmrvl_hsmode_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 294 | .read = btmrvl_hsmode_read, |
| 295 | .write = btmrvl_hsmode_write, |
| 296 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 297 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 298 | }; |
| 299 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 300 | static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf, |
| 301 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 302 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 303 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 304 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 305 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 306 | |
| 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 | |
| 312 | static const struct file_operations btmrvl_curpsmode_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 313 | .read = btmrvl_curpsmode_read, |
| 314 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 315 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 316 | }; |
| 317 | |
| 318 | static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 319 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 320 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 321 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 322 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 323 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 324 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 325 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->ps_state); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 326 | |
| 327 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 328 | } |
| 329 | |
| 330 | static const struct file_operations btmrvl_psstate_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 331 | .read = btmrvl_psstate_read, |
| 332 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 333 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 334 | }; |
| 335 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 336 | static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf, |
| 337 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 338 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 339 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 340 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 341 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 342 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 343 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->hs_state); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 344 | |
| 345 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 346 | } |
| 347 | |
| 348 | static const struct file_operations btmrvl_hsstate_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 349 | .read = btmrvl_hsstate_read, |
| 350 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 351 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 352 | }; |
| 353 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 354 | static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf, |
| 355 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 356 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 357 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 358 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 359 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 360 | |
| 361 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 362 | priv->btmrvl_dev.tx_dnld_rdy); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 363 | |
| 364 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 365 | } |
| 366 | |
| 367 | static const struct file_operations btmrvl_txdnldready_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 368 | .read = btmrvl_txdnldready_read, |
| 369 | .open = btmrvl_open_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 370 | .llseek = default_llseek, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 371 | }; |
| 372 | |
| 373 | void btmrvl_debugfs_init(struct hci_dev *hdev) |
| 374 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 375 | struct btmrvl_private *priv = hdev->driver_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 376 | struct btmrvl_debugfs_data *dbg; |
| 377 | |
Marcel Holtmann | b914a25 | 2010-02-08 16:47:04 +0100 | [diff] [blame] | 378 | if (!hdev->debugfs) |
| 379 | return; |
| 380 | |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 381 | 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 Holtmann | b914a25 | 2010-02-08 16:47:04 +0100 | [diff] [blame] | 389 | dbg->config_dir = debugfs_create_dir("config", hdev->debugfs); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 390 | |
| 391 | dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 392 | hdev->driver_data, &btmrvl_psmode_fops); |
| 393 | dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 394 | hdev->driver_data, &btmrvl_pscmd_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 395 | dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 396 | hdev->driver_data, &btmrvl_gpiogap_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 397 | dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 398 | hdev->driver_data, &btmrvl_hsmode_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 399 | dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 400 | hdev->driver_data, &btmrvl_hscmd_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 401 | dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 402 | hdev->driver_data, &btmrvl_hscfgcmd_fops); |
| 403 | |
Marcel Holtmann | b914a25 | 2010-02-08 16:47:04 +0100 | [diff] [blame] | 404 | dbg->status_dir = debugfs_create_dir("status", hdev->debugfs); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 405 | dbg->curpsmode = debugfs_create_file("curpsmode", 0444, |
| 406 | dbg->status_dir, |
| 407 | hdev->driver_data, |
| 408 | &btmrvl_curpsmode_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 409 | dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 410 | hdev->driver_data, &btmrvl_psstate_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 411 | dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 412 | hdev->driver_data, &btmrvl_hsstate_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 413 | dbg->txdnldready = debugfs_create_file("txdnldready", 0444, |
| 414 | dbg->status_dir, |
| 415 | hdev->driver_data, |
| 416 | &btmrvl_txdnldready_fops); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | void btmrvl_debugfs_remove(struct hci_dev *hdev) |
| 420 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 421 | struct btmrvl_private *priv = hdev->driver_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 422 | 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 Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 441 | kfree(dbg); |
| 442 | } |