aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uwb/pal.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/uwb/pal.c')
-rw-r--r--drivers/uwb/pal.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/uwb/pal.c b/drivers/uwb/pal.c
index 1afb38eacb9a..99a19c199095 100644
--- a/drivers/uwb/pal.c
+++ b/drivers/uwb/pal.c
@@ -16,6 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/debugfs.h>
19#include <linux/uwb.h> 20#include <linux/uwb.h>
20 21
21#include "uwb-internal.h" 22#include "uwb-internal.h"
@@ -32,13 +33,13 @@ EXPORT_SYMBOL_GPL(uwb_pal_init);
32 33
33/** 34/**
34 * uwb_pal_register - register a UWB PAL 35 * uwb_pal_register - register a UWB PAL
35 * @rc: the radio controller the PAL will be using
36 * @pal: the PAL 36 * @pal: the PAL
37 * 37 *
38 * The PAL must be initialized with uwb_pal_init(). 38 * The PAL must be initialized with uwb_pal_init().
39 */ 39 */
40int uwb_pal_register(struct uwb_rc *rc, struct uwb_pal *pal) 40int uwb_pal_register(struct uwb_pal *pal)
41{ 41{
42 struct uwb_rc *rc = pal->rc;
42 int ret; 43 int ret;
43 44
44 if (pal->device) { 45 if (pal->device) {
@@ -54,9 +55,11 @@ int uwb_pal_register(struct uwb_rc *rc, struct uwb_pal *pal)
54 } 55 }
55 } 56 }
56 57
57 spin_lock(&rc->pal_lock); 58 pal->debugfs_dir = uwb_dbg_create_pal_dir(pal);
59
60 mutex_lock(&rc->uwb_dev.mutex);
58 list_add(&pal->node, &rc->pals); 61 list_add(&pal->node, &rc->pals);
59 spin_unlock(&rc->pal_lock); 62 mutex_unlock(&rc->uwb_dev.mutex);
60 63
61 return 0; 64 return 0;
62} 65}
@@ -64,14 +67,19 @@ EXPORT_SYMBOL_GPL(uwb_pal_register);
64 67
65/** 68/**
66 * uwb_pal_register - unregister a UWB PAL 69 * uwb_pal_register - unregister a UWB PAL
67 * @rc: the radio controller the PAL was using
68 * @pal: the PAL 70 * @pal: the PAL
69 */ 71 */
70void uwb_pal_unregister(struct uwb_rc *rc, struct uwb_pal *pal) 72void uwb_pal_unregister(struct uwb_pal *pal)
71{ 73{
72 spin_lock(&rc->pal_lock); 74 struct uwb_rc *rc = pal->rc;
75
76 uwb_radio_stop(pal);
77
78 mutex_lock(&rc->uwb_dev.mutex);
73 list_del(&pal->node); 79 list_del(&pal->node);
74 spin_unlock(&rc->pal_lock); 80 mutex_unlock(&rc->uwb_dev.mutex);
81
82 debugfs_remove(pal->debugfs_dir);
75 83
76 if (pal->device) { 84 if (pal->device) {
77 sysfs_remove_link(&rc->uwb_dev.dev.kobj, pal->name); 85 sysfs_remove_link(&rc->uwb_dev.dev.kobj, pal->name);
@@ -86,6 +94,5 @@ EXPORT_SYMBOL_GPL(uwb_pal_unregister);
86 */ 94 */
87void uwb_rc_pal_init(struct uwb_rc *rc) 95void uwb_rc_pal_init(struct uwb_rc *rc)
88{ 96{
89 spin_lock_init(&rc->pal_lock);
90 INIT_LIST_HEAD(&rc->pals); 97 INIT_LIST_HEAD(&rc->pals);
91} 98}