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> |
| 22 | |
| 23 | #include <net/bluetooth/bluetooth.h> |
| 24 | #include <net/bluetooth/hci_core.h> |
| 25 | |
| 26 | #include "btmrvl_drv.h" |
| 27 | |
| 28 | struct btmrvl_debugfs_data { |
| 29 | struct dentry *root_dir, *config_dir, *status_dir; |
| 30 | |
| 31 | /* config */ |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 32 | struct dentry *psmode; |
| 33 | struct dentry *pscmd; |
| 34 | struct dentry *hsmode; |
| 35 | struct dentry *hscmd; |
| 36 | struct dentry *gpiogap; |
| 37 | struct dentry *hscfgcmd; |
| 38 | |
| 39 | /* status */ |
| 40 | struct dentry *curpsmode; |
| 41 | struct dentry *hsstate; |
| 42 | struct dentry *psstate; |
| 43 | struct dentry *txdnldready; |
| 44 | }; |
| 45 | |
| 46 | static int btmrvl_open_generic(struct inode *inode, struct file *file) |
| 47 | { |
| 48 | file->private_data = inode->i_private; |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | static ssize_t btmrvl_hscfgcmd_write(struct file *file, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 53 | const char __user *ubuf, size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 54 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 55 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 56 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 57 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 58 | |
| 59 | memset(buf, 0, sizeof(buf)); |
| 60 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 61 | 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] | 62 | return -EFAULT; |
| 63 | |
| 64 | ret = strict_strtol(buf, 10, &result); |
| 65 | |
| 66 | priv->btmrvl_dev.hscfgcmd = result; |
| 67 | |
| 68 | if (priv->btmrvl_dev.hscfgcmd) { |
| 69 | btmrvl_prepare_command(priv); |
| 70 | wake_up_interruptible(&priv->main_thread.wait_q); |
| 71 | } |
| 72 | |
| 73 | return count; |
| 74 | } |
| 75 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 76 | static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf, |
| 77 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 78 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 79 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 80 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 81 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 82 | |
| 83 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 84 | priv->btmrvl_dev.hscfgcmd); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 85 | |
| 86 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 87 | } |
| 88 | |
| 89 | static const struct file_operations btmrvl_hscfgcmd_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 90 | .read = btmrvl_hscfgcmd_read, |
| 91 | .write = btmrvl_hscfgcmd_write, |
| 92 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | 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] | 96 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 97 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 98 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 99 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 100 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 101 | |
| 102 | memset(buf, 0, sizeof(buf)); |
| 103 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 104 | 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] | 105 | return -EFAULT; |
| 106 | |
| 107 | ret = strict_strtol(buf, 10, &result); |
| 108 | |
| 109 | priv->btmrvl_dev.psmode = result; |
| 110 | |
| 111 | return count; |
| 112 | } |
| 113 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 114 | static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf, |
| 115 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 116 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 117 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 118 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 119 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 120 | |
| 121 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 122 | priv->btmrvl_dev.psmode); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 123 | |
| 124 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 125 | } |
| 126 | |
| 127 | static const struct file_operations btmrvl_psmode_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 128 | .read = btmrvl_psmode_read, |
| 129 | .write = btmrvl_psmode_write, |
| 130 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | 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] | 134 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 135 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 136 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 137 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 138 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 139 | |
| 140 | memset(buf, 0, sizeof(buf)); |
| 141 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 142 | 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] | 143 | return -EFAULT; |
| 144 | |
| 145 | ret = strict_strtol(buf, 10, &result); |
| 146 | |
| 147 | priv->btmrvl_dev.pscmd = result; |
| 148 | |
| 149 | if (priv->btmrvl_dev.pscmd) { |
| 150 | btmrvl_prepare_command(priv); |
| 151 | wake_up_interruptible(&priv->main_thread.wait_q); |
| 152 | } |
| 153 | |
| 154 | return count; |
| 155 | |
| 156 | } |
| 157 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 158 | static ssize_t btmrvl_pscmd_read(struct file *file, char __user *userbuf, |
| 159 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 160 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 161 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 162 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 163 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 164 | |
| 165 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.pscmd); |
| 166 | |
| 167 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 168 | } |
| 169 | |
| 170 | static const struct file_operations btmrvl_pscmd_fops = { |
| 171 | .read = btmrvl_pscmd_read, |
| 172 | .write = btmrvl_pscmd_write, |
| 173 | .open = btmrvl_open_generic, |
| 174 | }; |
| 175 | |
| 176 | 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] | 177 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 178 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 179 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 180 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 181 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 182 | |
| 183 | memset(buf, 0, sizeof(buf)); |
| 184 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 185 | 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] | 186 | return -EFAULT; |
| 187 | |
| 188 | ret = strict_strtol(buf, 16, &result); |
| 189 | |
| 190 | priv->btmrvl_dev.gpio_gap = result; |
| 191 | |
| 192 | return count; |
| 193 | } |
| 194 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 195 | static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf, |
| 196 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 197 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 198 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 199 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 200 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 201 | |
| 202 | ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n", |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 203 | priv->btmrvl_dev.gpio_gap); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 204 | |
| 205 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 206 | } |
| 207 | |
| 208 | static const struct file_operations btmrvl_gpiogap_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 209 | .read = btmrvl_gpiogap_read, |
| 210 | .write = btmrvl_gpiogap_write, |
| 211 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | 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] | 215 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 216 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 217 | struct btmrvl_private *priv = (struct btmrvl_private *) file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 218 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 219 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 220 | |
| 221 | memset(buf, 0, sizeof(buf)); |
| 222 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 223 | 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] | 224 | return -EFAULT; |
| 225 | |
| 226 | ret = strict_strtol(buf, 10, &result); |
| 227 | |
| 228 | priv->btmrvl_dev.hscmd = result; |
| 229 | if (priv->btmrvl_dev.hscmd) { |
| 230 | btmrvl_prepare_command(priv); |
| 231 | wake_up_interruptible(&priv->main_thread.wait_q); |
| 232 | } |
| 233 | |
| 234 | return count; |
| 235 | } |
| 236 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 237 | static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf, |
| 238 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 239 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 240 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 241 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 242 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 243 | |
| 244 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hscmd); |
| 245 | |
| 246 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 247 | } |
| 248 | |
| 249 | static const struct file_operations btmrvl_hscmd_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 250 | .read = btmrvl_hscmd_read, |
| 251 | .write = btmrvl_hscmd_write, |
| 252 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | 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] | 256 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 257 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 258 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 259 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 260 | long result, ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 261 | |
| 262 | memset(buf, 0, sizeof(buf)); |
| 263 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 264 | 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] | 265 | return -EFAULT; |
| 266 | |
| 267 | ret = strict_strtol(buf, 10, &result); |
| 268 | |
| 269 | priv->btmrvl_dev.hsmode = result; |
| 270 | |
| 271 | return count; |
| 272 | } |
| 273 | |
| 274 | static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 275 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 276 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 277 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 278 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 279 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 280 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 281 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hsmode); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 282 | |
| 283 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 284 | } |
| 285 | |
| 286 | static const struct file_operations btmrvl_hsmode_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 287 | .read = btmrvl_hsmode_read, |
| 288 | .write = btmrvl_hsmode_write, |
| 289 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 290 | }; |
| 291 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 292 | static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf, |
| 293 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 294 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 295 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 296 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 297 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 298 | |
| 299 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->psmode); |
| 300 | |
| 301 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 302 | } |
| 303 | |
| 304 | static const struct file_operations btmrvl_curpsmode_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 305 | .read = btmrvl_curpsmode_read, |
| 306 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 307 | }; |
| 308 | |
| 309 | static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 310 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 311 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 312 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 313 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 314 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 315 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 316 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->ps_state); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 317 | |
| 318 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 319 | } |
| 320 | |
| 321 | static const struct file_operations btmrvl_psstate_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 322 | .read = btmrvl_psstate_read, |
| 323 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 324 | }; |
| 325 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 326 | static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf, |
| 327 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 328 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 329 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 330 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 331 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 332 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 333 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->hs_state); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 334 | |
| 335 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 336 | } |
| 337 | |
| 338 | static const struct file_operations btmrvl_hsstate_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 339 | .read = btmrvl_hsstate_read, |
| 340 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 341 | }; |
| 342 | |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 343 | static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf, |
| 344 | size_t count, loff_t *ppos) |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 345 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 346 | struct btmrvl_private *priv = file->private_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 347 | char buf[16]; |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 348 | int ret; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 349 | |
| 350 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 351 | priv->btmrvl_dev.tx_dnld_rdy); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 352 | |
| 353 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 354 | } |
| 355 | |
| 356 | static const struct file_operations btmrvl_txdnldready_fops = { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 357 | .read = btmrvl_txdnldready_read, |
| 358 | .open = btmrvl_open_generic, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 359 | }; |
| 360 | |
| 361 | void btmrvl_debugfs_init(struct hci_dev *hdev) |
| 362 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 363 | struct btmrvl_private *priv = hdev->driver_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 364 | struct btmrvl_debugfs_data *dbg; |
| 365 | |
| 366 | dbg = kzalloc(sizeof(*dbg), GFP_KERNEL); |
| 367 | priv->debugfs_data = dbg; |
| 368 | |
| 369 | if (!dbg) { |
| 370 | BT_ERR("Can not allocate memory for btmrvl_debugfs_data."); |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | dbg->root_dir = debugfs_create_dir("btmrvl", NULL); |
| 375 | |
| 376 | dbg->config_dir = debugfs_create_dir("config", dbg->root_dir); |
| 377 | |
| 378 | dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 379 | hdev->driver_data, &btmrvl_psmode_fops); |
| 380 | dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 381 | hdev->driver_data, &btmrvl_pscmd_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 382 | dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 383 | hdev->driver_data, &btmrvl_gpiogap_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 384 | dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 385 | hdev->driver_data, &btmrvl_hsmode_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 386 | dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 387 | hdev->driver_data, &btmrvl_hscmd_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 388 | dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 389 | hdev->driver_data, &btmrvl_hscfgcmd_fops); |
| 390 | |
| 391 | dbg->status_dir = debugfs_create_dir("status", dbg->root_dir); |
| 392 | dbg->curpsmode = debugfs_create_file("curpsmode", 0444, |
| 393 | dbg->status_dir, |
| 394 | hdev->driver_data, |
| 395 | &btmrvl_curpsmode_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 396 | dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 397 | hdev->driver_data, &btmrvl_psstate_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 398 | dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir, |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 399 | hdev->driver_data, &btmrvl_hsstate_fops); |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 400 | dbg->txdnldready = debugfs_create_file("txdnldready", 0444, |
| 401 | dbg->status_dir, |
| 402 | hdev->driver_data, |
| 403 | &btmrvl_txdnldready_fops); |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | void btmrvl_debugfs_remove(struct hci_dev *hdev) |
| 407 | { |
Marcel Holtmann | 5423990 | 2009-06-09 15:48:35 +0200 | [diff] [blame] | 408 | struct btmrvl_private *priv = hdev->driver_data; |
Bing Zhao | fb784f0 | 2009-06-02 14:29:37 -0700 | [diff] [blame] | 409 | struct btmrvl_debugfs_data *dbg = priv->debugfs_data; |
| 410 | |
| 411 | if (!dbg) |
| 412 | return; |
| 413 | |
| 414 | debugfs_remove(dbg->psmode); |
| 415 | debugfs_remove(dbg->pscmd); |
| 416 | debugfs_remove(dbg->gpiogap); |
| 417 | debugfs_remove(dbg->hsmode); |
| 418 | debugfs_remove(dbg->hscmd); |
| 419 | debugfs_remove(dbg->hscfgcmd); |
| 420 | debugfs_remove(dbg->config_dir); |
| 421 | |
| 422 | debugfs_remove(dbg->curpsmode); |
| 423 | debugfs_remove(dbg->psstate); |
| 424 | debugfs_remove(dbg->hsstate); |
| 425 | debugfs_remove(dbg->txdnldready); |
| 426 | debugfs_remove(dbg->status_dir); |
| 427 | |
| 428 | debugfs_remove(dbg->root_dir); |
| 429 | |
| 430 | kfree(dbg); |
| 431 | } |