diff options
| author | Bing Zhao <bzhao@marvell.com> | 2009-06-02 17:29:37 -0400 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2009-08-22 17:25:32 -0400 |
| commit | fb784f0508d5aa39a23e72879a8dfb517c6f6e7f (patch) | |
| tree | f8e105589bc592467e8bb306aadade361b4f5412 | |
| parent | 789221ecc870117b77e354d488d5d29f15410de8 (diff) | |
Bluetooth: Add debugfs support to btmrvl driver
/debug/btmrvl/config/
/debug/btmrvl/status/
See Documentation/btmrvl.txt for details.
This patch incorporates a lot of comments given by
Nicolas Pitre <nico@marvell.com>. Many thanks to Nicolas Pitre.
Signed-off-by: Rahul Tank <rahult@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
| -rw-r--r-- | drivers/bluetooth/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/bluetooth/Makefile | 2 | ||||
| -rw-r--r-- | drivers/bluetooth/btmrvl_debugfs.c | 469 | ||||
| -rw-r--r-- | drivers/bluetooth/btmrvl_drv.h | 8 | ||||
| -rw-r--r-- | drivers/bluetooth/btmrvl_main.c | 8 |
5 files changed, 487 insertions, 1 deletions
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index 8c89bd4abbf6..5f04014b62a1 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig | |||
| @@ -173,6 +173,7 @@ config BT_HCIVHCI | |||
| 173 | config BT_MRVL | 173 | config BT_MRVL |
| 174 | tristate "Marvell Bluetooth driver support" | 174 | tristate "Marvell Bluetooth driver support" |
| 175 | select FW_LOADER | 175 | select FW_LOADER |
| 176 | select DEBUG_FS | ||
| 176 | help | 177 | help |
| 177 | The core driver to support Marvell Bluetooth devices. | 178 | The core driver to support Marvell Bluetooth devices. |
| 178 | 179 | ||
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile index 2dc12e7d0155..75f70e0e3e53 100644 --- a/drivers/bluetooth/Makefile +++ b/drivers/bluetooth/Makefile | |||
| @@ -15,7 +15,7 @@ obj-$(CONFIG_BT_HCIBTUART) += btuart_cs.o | |||
| 15 | obj-$(CONFIG_BT_HCIBTUSB) += btusb.o | 15 | obj-$(CONFIG_BT_HCIBTUSB) += btusb.o |
| 16 | obj-$(CONFIG_BT_HCIBTSDIO) += btsdio.o | 16 | obj-$(CONFIG_BT_HCIBTSDIO) += btsdio.o |
| 17 | 17 | ||
| 18 | btmrvl-objs := btmrvl_main.o | 18 | btmrvl-objs := btmrvl_main.o btmrvl_debugfs.o |
| 19 | obj-$(CONFIG_BT_MRVL) += btmrvl.o | 19 | obj-$(CONFIG_BT_MRVL) += btmrvl.o |
| 20 | obj-$(CONFIG_BT_MRVL_SDIO) += btmrvl_sdio.o | 20 | obj-$(CONFIG_BT_MRVL_SDIO) += btmrvl_sdio.o |
| 21 | 21 | ||
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c new file mode 100644 index 000000000000..747bb0c723c3 --- /dev/null +++ b/drivers/bluetooth/btmrvl_debugfs.c | |||
| @@ -0,0 +1,469 @@ | |||
| 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, | ||
| 54 | const char __user *ubuf, | ||
| 55 | size_t count, | ||
| 56 | loff_t *ppos) | ||
| 57 | { | ||
| 58 | struct btmrvl_private *priv = | ||
| 59 | (struct btmrvl_private *) file->private_data; | ||
| 60 | |||
| 61 | long result, ret; | ||
| 62 | char buf[16]; | ||
| 63 | |||
| 64 | memset(buf, 0, sizeof(buf)); | ||
| 65 | |||
| 66 | if (copy_from_user(&buf, ubuf, | ||
| 67 | min_t(size_t, sizeof(buf) - 1, count))) | ||
| 68 | return -EFAULT; | ||
| 69 | |||
| 70 | ret = strict_strtol(buf, 10, &result); | ||
| 71 | |||
| 72 | priv->btmrvl_dev.hscfgcmd = result; | ||
| 73 | |||
| 74 | if (priv->btmrvl_dev.hscfgcmd) { | ||
| 75 | btmrvl_prepare_command(priv); | ||
| 76 | wake_up_interruptible(&priv->main_thread.wait_q); | ||
| 77 | } | ||
| 78 | |||
| 79 | return count; | ||
| 80 | } | ||
| 81 | |||
| 82 | static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user * userbuf, | ||
| 83 | size_t count, loff_t *ppos) | ||
| 84 | { | ||
| 85 | struct btmrvl_private *priv = | ||
| 86 | (struct btmrvl_private *) file->private_data; | ||
| 87 | int ret; | ||
| 88 | char buf[16]; | ||
| 89 | |||
| 90 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", | ||
| 91 | priv->btmrvl_dev.hscfgcmd); | ||
| 92 | |||
| 93 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); | ||
| 94 | } | ||
| 95 | |||
| 96 | static const struct file_operations btmrvl_hscfgcmd_fops = { | ||
| 97 | .read = btmrvl_hscfgcmd_read, | ||
| 98 | .write = btmrvl_hscfgcmd_write, | ||
| 99 | .open = btmrvl_open_generic, | ||
| 100 | }; | ||
| 101 | |||
| 102 | static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf, | ||
| 103 | size_t count, loff_t *ppos) | ||
| 104 | { | ||
| 105 | struct btmrvl_private *priv = | ||
| 106 | (struct btmrvl_private *) file->private_data; | ||
| 107 | long result, ret; | ||
| 108 | char buf[16]; | ||
| 109 | |||
| 110 | memset(buf, 0, sizeof(buf)); | ||
| 111 | |||
| 112 | if (copy_from_user(&buf, ubuf, | ||
| 113 | min_t(size_t, sizeof(buf) - 1, count))) | ||
| 114 | return -EFAULT; | ||
| 115 | |||
| 116 | ret = strict_strtol(buf, 10, &result); | ||
| 117 | |||
| 118 | priv->btmrvl_dev.psmode = result; | ||
| 119 | |||
| 120 | return count; | ||
| 121 | } | ||
| 122 | |||
| 123 | static ssize_t btmrvl_psmode_read(struct file *file, char __user * userbuf, | ||
| 124 | size_t count, loff_t *ppos) | ||
| 125 | { | ||
| 126 | struct btmrvl_private *priv = | ||
| 127 | (struct btmrvl_private *) file->private_data; | ||
| 128 | int ret; | ||
| 129 | char buf[16]; | ||
| 130 | |||
| 131 | ret = snprintf(buf, sizeof(buf) - 1, "%d\n", | ||
| 132 | priv->btmrvl_dev.psmode); | ||
| 133 | |||
| 134 | return simple_read_from_buffer(userbuf, count, ppos, buf, ret); | ||
| 135 | } | ||
| 136 | |||
| 137 | static const struct file_operations btmrvl_psmode_fops = { | ||
| 138 | .read = btmrvl_psmode_read, | ||
| 139 | .write = btmrvl_psmode_write, | ||
| 140 | .open = btmrvl_open_generic, | ||
| 141 | }; | ||
| 142 | |||
| 143 | static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, | ||
| 144 | size_t count, loff_t *ppos) | ||
| 145 | { | ||
| 146 | struct btmrvl_private *priv = | ||
| 147 | (struct btmrvl_private *) file->private_data; | ||
| 148 | long result, ret; | ||
| 149 | char buf[16]; | ||
| 150 | |||
| 151 | memset(buf, 0, sizeof(buf)); | ||
| 152 | |||
| 153 | if (copy_from_user(&buf, ubuf, | ||
| 154 | min_t(size_t, sizeof(buf) - 1, count))) | ||
| 155 | return -EFAULT; | ||
| 156 | |||
| 157 | ret = strict_strtol(buf, 10, &result); | ||
| 158 | |||
| 159 | priv->btmrvl_dev.pscmd = result; | ||
| 160 | |||
| 161 | if (priv->btmrvl_dev.pscmd) { | ||
