rfkill: always call get_state() hook on resume
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / uwb / pal.c
blob1afb38eacb9a295d55e6356b0ab3b3f8692ce28a
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/uwb.h>
21 #include "uwb-internal.h"
23 /**
24 * uwb_pal_init - initialize a UWB PAL
25 * @pal: the PAL to initialize
27 void uwb_pal_init(struct uwb_pal *pal)
29 INIT_LIST_HEAD(&pal->node);
31 EXPORT_SYMBOL_GPL(uwb_pal_init);
33 /**
34 * uwb_pal_register - register a UWB PAL
35 * @rc: the radio controller the PAL will be using
36 * @pal: the PAL
38 * The PAL must be initialized with uwb_pal_init().
40 int uwb_pal_register(struct uwb_rc *rc, struct uwb_pal *pal)
42 int ret;
44 if (pal->device) {
45 ret = sysfs_create_link(&pal->device->kobj,
46 &rc->uwb_dev.dev.kobj, "uwb_rc");
47 if (ret < 0)
48 return ret;
49 ret = sysfs_create_link(&rc->uwb_dev.dev.kobj,
50 &pal->device->kobj, pal->name);
51 if (ret < 0) {
52 sysfs_remove_link(&pal->device->kobj, "uwb_rc");
53 return ret;
57 spin_lock(&rc->pal_lock);
58 list_add(&pal->node, &rc->pals);
59 spin_unlock(&rc->pal_lock);
61 return 0;
63 EXPORT_SYMBOL_GPL(uwb_pal_register);
65 /**
66 * uwb_pal_register - unregister a UWB PAL
67 * @rc: the radio controller the PAL was using
68 * @pal: the PAL
70 void uwb_pal_unregister(struct uwb_rc *rc, struct uwb_pal *pal)
72 spin_lock(&rc->pal_lock);
73 list_del(&pal->node);
74 spin_unlock(&rc->pal_lock);
76 if (pal->device) {
77 sysfs_remove_link(&rc->uwb_dev.dev.kobj, pal->name);
78 sysfs_remove_link(&pal->device->kobj, "uwb_rc");
81 EXPORT_SYMBOL_GPL(uwb_pal_unregister);
83 /**
84 * uwb_rc_pal_init - initialize the PAL related parts of a radio controller
85 * @rc: the radio controller
87 void uwb_rc_pal_init(struct uwb_rc *rc)
89 spin_lock_init(&rc->pal_lock);
90 INIT_LIST_HEAD(&rc->pals);