printk removal, receive reordering bugfix
[cor_2_6_31.git] / drivers / uwb / pal.c
blob99a19c199095fd817ceb519922389a6a424abba9
1 /*
2 * UWB PAL support.
4 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include <linux/kernel.h>
19 #include <linux/debugfs.h>
20 #include <linux/uwb.h>
22 #include "uwb-internal.h"
24 /**
25 * uwb_pal_init - initialize a UWB PAL
26 * @pal: the PAL to initialize
28 void uwb_pal_init(struct uwb_pal *pal)
30 INIT_LIST_HEAD(&pal->node);
32 EXPORT_SYMBOL_GPL(uwb_pal_init);
34 /**
35 * uwb_pal_register - register a UWB PAL
36 * @pal: the PAL
38 * The PAL must be initialized with uwb_pal_init().
40 int uwb_pal_register(struct uwb_pal *pal)
42 struct uwb_rc *rc = pal->rc;
43 int ret;
45 if (pal->device) {
46 ret = sysfs_create_link(&pal->device->kobj,
47 &rc->uwb_dev.dev.kobj, "uwb_rc");
48 if (ret < 0)
49 return ret;
50 ret = sysfs_create_link(&rc->uwb_dev.dev.kobj,
51 &pal->device->kobj, pal->name);
52 if (ret < 0) {
53 sysfs_remove_link(&pal->device->kobj, "uwb_rc");
54 return ret;
58 pal->debugfs_dir = uwb_dbg_create_pal_dir(pal);
60 mutex_lock(&rc->uwb_dev.mutex);
61 list_add(&pal->node, &rc->pals);
62 mutex_unlock(&rc->uwb_dev.mutex);
64 return 0;
66 EXPORT_SYMBOL_GPL(uwb_pal_register);
68 /**
69 * uwb_pal_register - unregister a UWB PAL
70 * @pal: the PAL
72 void uwb_pal_unregister(struct uwb_pal *pal)
74 struct uwb_rc *rc = pal->rc;
76 uwb_radio_stop(pal);
78 mutex_lock(&rc->uwb_dev.mutex);
79 list_del(&pal->node);
80 mutex_unlock(&rc->uwb_dev.mutex);
82 debugfs_remove(pal->debugfs_dir);
84 if (pal->device) {
85 sysfs_remove_link(&rc->uwb_dev.dev.kobj, pal->name);
86 sysfs_remove_link(&pal->device->kobj, "uwb_rc");
89 EXPORT_SYMBOL_GPL(uwb_pal_unregister);
91 /**
92 * uwb_rc_pal_init - initialize the PAL related parts of a radio controller
93 * @rc: the radio controller
95 void uwb_rc_pal_init(struct uwb_rc *rc)
97 INIT_LIST_HEAD(&rc->pals);