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