David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Ultra Wide Band |
| 3 | * Debug support |
| 4 | * |
| 5 | * Copyright (C) 2005-2006 Intel Corporation |
| 6 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> |
David Vrabel | e43ace8 | 2008-12-22 18:27:17 +0000 | [diff] [blame] | 7 | * Copyright (C) 2008 Cambridge Silicon Radio Ltd. |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License version |
| 11 | * 2 as published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 21 | * 02110-1301, USA. |
| 22 | * |
| 23 | * |
| 24 | * FIXME: doc |
| 25 | */ |
| 26 | |
| 27 | #include <linux/spinlock.h> |
| 28 | #include <linux/module.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <linux/notifier.h> |
| 31 | #include <linux/device.h> |
| 32 | #include <linux/debugfs.h> |
| 33 | #include <linux/uaccess.h> |
| 34 | #include <linux/seq_file.h> |
| 35 | |
| 36 | #include <linux/uwb/debug-cmd.h> |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 37 | |
| 38 | #include "uwb-internal.h" |
| 39 | |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 40 | /* |
| 41 | * Debug interface |
| 42 | * |
| 43 | * Per radio controller debugfs files (in uwb/uwbN/): |
| 44 | * |
| 45 | * command: Flexible command interface (see <linux/uwb/debug-cmd.h>). |
| 46 | * |
| 47 | * reservations: information on reservations. |
| 48 | * |
| 49 | * accept: Set to true (Y or 1) to accept reservation requests from |
| 50 | * peers. |
| 51 | * |
| 52 | * drp_avail: DRP availability information. |
| 53 | */ |
| 54 | |
| 55 | struct uwb_dbg { |
| 56 | struct uwb_pal pal; |
| 57 | |
| 58 | u32 accept; |
| 59 | struct list_head rsvs; |
| 60 | |
| 61 | struct dentry *root_d; |
| 62 | struct dentry *command_f; |
| 63 | struct dentry *reservations_f; |
| 64 | struct dentry *accept_f; |
| 65 | struct dentry *drp_avail_f; |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 66 | spinlock_t list_lock; |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | static struct dentry *root_dir; |
| 70 | |
| 71 | static void uwb_dbg_rsv_cb(struct uwb_rsv *rsv) |
| 72 | { |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 73 | struct uwb_dbg *dbg = rsv->pal_priv; |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 74 | |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 75 | uwb_rsv_dump("debug", rsv); |
David Vrabel | cae1c11 | 2008-10-27 15:22:46 +0000 | [diff] [blame] | 76 | |
| 77 | if (rsv->state == UWB_RSV_STATE_NONE) { |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 78 | spin_lock(&dbg->list_lock); |
David Vrabel | cae1c11 | 2008-10-27 15:22:46 +0000 | [diff] [blame] | 79 | list_del(&rsv->pal_node); |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 80 | spin_unlock(&dbg->list_lock); |
David Vrabel | cae1c11 | 2008-10-27 15:22:46 +0000 | [diff] [blame] | 81 | uwb_rsv_destroy(rsv); |
| 82 | } |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | static int cmd_rsv_establish(struct uwb_rc *rc, |
| 86 | struct uwb_dbg_cmd_rsv_establish *cmd) |
| 87 | { |
| 88 | struct uwb_mac_addr macaddr; |
| 89 | struct uwb_rsv *rsv; |
| 90 | struct uwb_dev *target; |
| 91 | int ret; |
| 92 | |
| 93 | memcpy(&macaddr, cmd->target, sizeof(macaddr)); |
| 94 | target = uwb_dev_get_by_macaddr(rc, &macaddr); |
| 95 | if (target == NULL) |
| 96 | return -ENODEV; |
| 97 | |
David Vrabel | e4b49580f | 2008-11-26 12:47:05 +0000 | [diff] [blame] | 98 | rsv = uwb_rsv_create(rc, uwb_dbg_rsv_cb, rc->dbg); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 99 | if (rsv == NULL) { |
| 100 | uwb_dev_put(target); |
| 101 | return -ENOMEM; |
| 102 | } |
| 103 | |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 104 | rsv->target.type = UWB_RSV_TARGET_DEV; |
| 105 | rsv->target.dev = target; |
| 106 | rsv->type = cmd->type; |
| 107 | rsv->max_mas = cmd->max_mas; |
| 108 | rsv->min_mas = cmd->min_mas; |
| 109 | rsv->max_interval = cmd->max_interval; |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 110 | |
| 111 | ret = uwb_rsv_establish(rsv); |
| 112 | if (ret) |
| 113 | uwb_rsv_destroy(rsv); |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 114 | else { |
| 115 | spin_lock(&(rc->dbg)->list_lock); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 116 | list_add_tail(&rsv->pal_node, &rc->dbg->rsvs); |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 117 | spin_unlock(&(rc->dbg)->list_lock); |
| 118 | } |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 119 | return ret; |
| 120 | } |
| 121 | |
| 122 | static int cmd_rsv_terminate(struct uwb_rc *rc, |
| 123 | struct uwb_dbg_cmd_rsv_terminate *cmd) |
| 124 | { |
| 125 | struct uwb_rsv *rsv, *found = NULL; |
| 126 | int i = 0; |
| 127 | |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 128 | spin_lock(&(rc->dbg)->list_lock); |
| 129 | |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 130 | list_for_each_entry(rsv, &rc->dbg->rsvs, pal_node) { |
| 131 | if (i == cmd->index) { |
| 132 | found = rsv; |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 133 | uwb_rsv_get(found); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 134 | break; |
| 135 | } |
David Vrabel | cae1c11 | 2008-10-27 15:22:46 +0000 | [diff] [blame] | 136 | i++; |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 137 | } |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 138 | |
| 139 | spin_unlock(&(rc->dbg)->list_lock); |
| 140 | |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 141 | if (!found) |
| 142 | return -EINVAL; |
| 143 | |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 144 | uwb_rsv_terminate(found); |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 145 | uwb_rsv_put(found); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 146 | |
| 147 | return 0; |
| 148 | } |
| 149 | |
Stefano Panella | 6d5a681 | 2008-11-04 14:24:57 +0000 | [diff] [blame] | 150 | static int cmd_ie_add(struct uwb_rc *rc, struct uwb_dbg_cmd_ie *ie_to_add) |
| 151 | { |
| 152 | return uwb_rc_ie_add(rc, |
| 153 | (const struct uwb_ie_hdr *) ie_to_add->data, |
| 154 | ie_to_add->len); |
| 155 | } |
| 156 | |
| 157 | static int cmd_ie_rm(struct uwb_rc *rc, struct uwb_dbg_cmd_ie *ie_to_rm) |
| 158 | { |
| 159 | return uwb_rc_ie_rm(rc, ie_to_rm->data[0]); |
| 160 | } |
| 161 | |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 162 | static ssize_t command_write(struct file *file, const char __user *buf, |
| 163 | size_t len, loff_t *off) |
| 164 | { |
| 165 | struct uwb_rc *rc = file->private_data; |
| 166 | struct uwb_dbg_cmd cmd; |
David Vrabel | 6fae35f | 2008-11-17 15:53:42 +0000 | [diff] [blame] | 167 | int ret = 0; |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 168 | |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 169 | if (len != sizeof(struct uwb_dbg_cmd)) |
| 170 | return -EINVAL; |
| 171 | |
| 172 | if (copy_from_user(&cmd, buf, len) != 0) |
| 173 | return -EFAULT; |
| 174 | |
| 175 | switch (cmd.type) { |
| 176 | case UWB_DBG_CMD_RSV_ESTABLISH: |
| 177 | ret = cmd_rsv_establish(rc, &cmd.rsv_establish); |
| 178 | break; |
| 179 | case UWB_DBG_CMD_RSV_TERMINATE: |
| 180 | ret = cmd_rsv_terminate(rc, &cmd.rsv_terminate); |
| 181 | break; |
Stefano Panella | 6d5a681 | 2008-11-04 14:24:57 +0000 | [diff] [blame] | 182 | case UWB_DBG_CMD_IE_ADD: |
| 183 | ret = cmd_ie_add(rc, &cmd.ie_add); |
| 184 | break; |
| 185 | case UWB_DBG_CMD_IE_RM: |
| 186 | ret = cmd_ie_rm(rc, &cmd.ie_rm); |
| 187 | break; |
David Vrabel | 6fae35f | 2008-11-17 15:53:42 +0000 | [diff] [blame] | 188 | case UWB_DBG_CMD_RADIO_START: |
| 189 | ret = uwb_radio_start(&rc->dbg->pal); |
| 190 | break; |
| 191 | case UWB_DBG_CMD_RADIO_STOP: |
| 192 | uwb_radio_stop(&rc->dbg->pal); |
| 193 | break; |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 194 | default: |
| 195 | return -EINVAL; |
| 196 | } |
| 197 | |
| 198 | return ret < 0 ? ret : len; |
| 199 | } |
| 200 | |
Alexey Dobriyan | 828c095 | 2009-10-01 15:43:56 -0700 | [diff] [blame] | 201 | static const struct file_operations command_fops = { |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 202 | .open = simple_open, |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 203 | .write = command_write, |
| 204 | .read = NULL, |
| 205 | .llseek = no_llseek, |
| 206 | .owner = THIS_MODULE, |
| 207 | }; |
| 208 | |
| 209 | static int reservations_print(struct seq_file *s, void *p) |
| 210 | { |
| 211 | struct uwb_rc *rc = s->private; |
| 212 | struct uwb_rsv *rsv; |
| 213 | |
| 214 | mutex_lock(&rc->rsvs_mutex); |
| 215 | |
| 216 | list_for_each_entry(rsv, &rc->reservations, rc_node) { |
| 217 | struct uwb_dev_addr devaddr; |
| 218 | char owner[UWB_ADDR_STRSIZE], target[UWB_ADDR_STRSIZE]; |
| 219 | bool is_owner; |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 220 | |
| 221 | uwb_dev_addr_print(owner, sizeof(owner), &rsv->owner->dev_addr); |
| 222 | if (rsv->target.type == UWB_RSV_TARGET_DEV) { |
| 223 | devaddr = rsv->target.dev->dev_addr; |
| 224 | is_owner = &rc->uwb_dev == rsv->owner; |
| 225 | } else { |
| 226 | devaddr = rsv->target.devaddr; |
| 227 | is_owner = true; |
| 228 | } |
| 229 | uwb_dev_addr_print(target, sizeof(target), &devaddr); |
| 230 | |
| 231 | seq_printf(s, "%c %s -> %s: %s\n", |
| 232 | is_owner ? 'O' : 'T', |
| 233 | owner, target, uwb_rsv_state_str(rsv->state)); |
| 234 | seq_printf(s, " stream: %d type: %s\n", |
| 235 | rsv->stream, uwb_rsv_type_str(rsv->type)); |
Tejun Heo | 125918d | 2015-02-13 14:37:53 -0800 | [diff] [blame] | 236 | seq_printf(s, " %*pb\n", UWB_NUM_MAS, rsv->mas.bm); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | mutex_unlock(&rc->rsvs_mutex); |
| 240 | |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | static int reservations_open(struct inode *inode, struct file *file) |
| 245 | { |
| 246 | return single_open(file, reservations_print, inode->i_private); |
| 247 | } |
| 248 | |
Alexey Dobriyan | 828c095 | 2009-10-01 15:43:56 -0700 | [diff] [blame] | 249 | static const struct file_operations reservations_fops = { |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 250 | .open = reservations_open, |
| 251 | .read = seq_read, |
| 252 | .llseek = seq_lseek, |
| 253 | .release = single_release, |
| 254 | .owner = THIS_MODULE, |
| 255 | }; |
| 256 | |
| 257 | static int drp_avail_print(struct seq_file *s, void *p) |
| 258 | { |
| 259 | struct uwb_rc *rc = s->private; |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 260 | |
Tejun Heo | 125918d | 2015-02-13 14:37:53 -0800 | [diff] [blame] | 261 | seq_printf(s, "global: %*pb\n", UWB_NUM_MAS, rc->drp_avail.global); |
| 262 | seq_printf(s, "local: %*pb\n", UWB_NUM_MAS, rc->drp_avail.local); |
| 263 | seq_printf(s, "pending: %*pb\n", UWB_NUM_MAS, rc->drp_avail.pending); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 264 | |
| 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | static int drp_avail_open(struct inode *inode, struct file *file) |
| 269 | { |
| 270 | return single_open(file, drp_avail_print, inode->i_private); |
| 271 | } |
| 272 | |
Alexey Dobriyan | 828c095 | 2009-10-01 15:43:56 -0700 | [diff] [blame] | 273 | static const struct file_operations drp_avail_fops = { |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 274 | .open = drp_avail_open, |
| 275 | .read = seq_read, |
| 276 | .llseek = seq_lseek, |
| 277 | .release = single_release, |
| 278 | .owner = THIS_MODULE, |
| 279 | }; |
| 280 | |
David Vrabel | 6fae35f | 2008-11-17 15:53:42 +0000 | [diff] [blame] | 281 | static void uwb_dbg_channel_changed(struct uwb_pal *pal, int channel) |
| 282 | { |
David Vrabel | 6fae35f | 2008-11-17 15:53:42 +0000 | [diff] [blame] | 283 | struct device *dev = &pal->rc->uwb_dev.dev; |
| 284 | |
| 285 | if (channel > 0) |
| 286 | dev_info(dev, "debug: channel %d started\n", channel); |
| 287 | else |
| 288 | dev_info(dev, "debug: channel stopped\n"); |
| 289 | } |
| 290 | |
David Vrabel | e17be2b | 2008-11-17 15:24:14 +0000 | [diff] [blame] | 291 | static void uwb_dbg_new_rsv(struct uwb_pal *pal, struct uwb_rsv *rsv) |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 292 | { |
David Vrabel | e17be2b | 2008-11-17 15:24:14 +0000 | [diff] [blame] | 293 | struct uwb_dbg *dbg = container_of(pal, struct uwb_dbg, pal); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 294 | |
David Vrabel | e17be2b | 2008-11-17 15:24:14 +0000 | [diff] [blame] | 295 | if (dbg->accept) { |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 296 | spin_lock(&dbg->list_lock); |
David Vrabel | e17be2b | 2008-11-17 15:24:14 +0000 | [diff] [blame] | 297 | list_add_tail(&rsv->pal_node, &dbg->rsvs); |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 298 | spin_unlock(&dbg->list_lock); |
David Vrabel | e17be2b | 2008-11-17 15:24:14 +0000 | [diff] [blame] | 299 | uwb_rsv_accept(rsv, uwb_dbg_rsv_cb, dbg); |
David Vrabel | cae1c11 | 2008-10-27 15:22:46 +0000 | [diff] [blame] | 300 | } |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | /** |
| 304 | * uwb_dbg_add_rc - add a debug interface for a radio controller |
| 305 | * @rc: the radio controller |
| 306 | */ |
| 307 | void uwb_dbg_add_rc(struct uwb_rc *rc) |
| 308 | { |
| 309 | rc->dbg = kzalloc(sizeof(struct uwb_dbg), GFP_KERNEL); |
| 310 | if (rc->dbg == NULL) |
| 311 | return; |
| 312 | |
| 313 | INIT_LIST_HEAD(&rc->dbg->rsvs); |
Stefano Panella | 5b37717 | 2008-12-12 13:00:06 +0000 | [diff] [blame] | 314 | spin_lock_init(&(rc->dbg)->list_lock); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 315 | |
| 316 | uwb_pal_init(&rc->dbg->pal); |
David Vrabel | 6fae35f | 2008-11-17 15:53:42 +0000 | [diff] [blame] | 317 | rc->dbg->pal.rc = rc; |
| 318 | rc->dbg->pal.channel_changed = uwb_dbg_channel_changed; |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 319 | rc->dbg->pal.new_rsv = uwb_dbg_new_rsv; |
David Vrabel | 6fae35f | 2008-11-17 15:53:42 +0000 | [diff] [blame] | 320 | uwb_pal_register(&rc->dbg->pal); |
| 321 | |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 322 | if (root_dir) { |
| 323 | rc->dbg->root_d = debugfs_create_dir(dev_name(&rc->uwb_dev.dev), |
| 324 | root_dir); |
| 325 | rc->dbg->command_f = debugfs_create_file("command", 0200, |
| 326 | rc->dbg->root_d, rc, |
| 327 | &command_fops); |
| 328 | rc->dbg->reservations_f = debugfs_create_file("reservations", 0444, |
| 329 | rc->dbg->root_d, rc, |
| 330 | &reservations_fops); |
| 331 | rc->dbg->accept_f = debugfs_create_bool("accept", 0644, |
| 332 | rc->dbg->root_d, |
| 333 | &rc->dbg->accept); |
| 334 | rc->dbg->drp_avail_f = debugfs_create_file("drp_avail", 0444, |
| 335 | rc->dbg->root_d, rc, |
| 336 | &drp_avail_fops); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | /** |
Stefano Panella | 6d5a681 | 2008-11-04 14:24:57 +0000 | [diff] [blame] | 341 | * uwb_dbg_del_rc - remove a radio controller's debug interface |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 342 | * @rc: the radio controller |
| 343 | */ |
| 344 | void uwb_dbg_del_rc(struct uwb_rc *rc) |
| 345 | { |
| 346 | struct uwb_rsv *rsv, *t; |
| 347 | |
| 348 | if (rc->dbg == NULL) |
| 349 | return; |
| 350 | |
| 351 | list_for_each_entry_safe(rsv, t, &rc->dbg->rsvs, pal_node) { |
David Vrabel | cae1c11 | 2008-10-27 15:22:46 +0000 | [diff] [blame] | 352 | uwb_rsv_terminate(rsv); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 353 | } |
| 354 | |
David Vrabel | 6fae35f | 2008-11-17 15:53:42 +0000 | [diff] [blame] | 355 | uwb_pal_unregister(&rc->dbg->pal); |
David Vrabel | 599e8d8 | 2008-09-17 16:34:10 +0100 | [diff] [blame] | 356 | |
| 357 | if (root_dir) { |
| 358 | debugfs_remove(rc->dbg->drp_avail_f); |
| 359 | debugfs_remove(rc->dbg->accept_f); |
| 360 | debugfs_remove(rc->dbg->reservations_f); |
| 361 | debugfs_remove(rc->dbg->command_f); |
| 362 | debugfs_remove(rc->dbg->root_d); |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * uwb_dbg_exit - initialize the debug interface sub-module |
| 368 | */ |
| 369 | void uwb_dbg_init(void) |
| 370 | { |
| 371 | root_dir = debugfs_create_dir("uwb", NULL); |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * uwb_dbg_exit - clean-up the debug interface sub-module |
| 376 | */ |
| 377 | void uwb_dbg_exit(void) |
| 378 | { |
| 379 | debugfs_remove(root_dir); |
| 380 | } |
David Vrabel | dcc7461 | 2008-11-26 13:36:59 +0000 | [diff] [blame] | 381 | |
| 382 | /** |
| 383 | * uwb_dbg_create_pal_dir - create a debugfs directory for a PAL |
| 384 | * @pal: The PAL. |
| 385 | */ |
| 386 | struct dentry *uwb_dbg_create_pal_dir(struct uwb_pal *pal) |
| 387 | { |
| 388 | struct uwb_rc *rc = pal->rc; |
| 389 | |
| 390 | if (root_dir && rc->dbg && rc->dbg->root_d && pal->name) |
| 391 | return debugfs_create_dir(pal->name, rc->dbg->root_d); |
| 392 | return NULL; |
| 393 | } |