diff options
Diffstat (limited to 'net/rfkill')
-rw-r--r-- | net/rfkill/Kconfig | 24 | ||||
-rw-r--r-- | net/rfkill/Makefile | 2 | ||||
-rw-r--r-- | net/rfkill/core.c | 17 | ||||
-rw-r--r-- | net/rfkill/input.c | 2 | ||||
-rw-r--r-- | net/rfkill/rfkill-gpio.c | 227 | ||||
-rw-r--r-- | net/rfkill/rfkill-regulator.c | 164 |
6 files changed, 418 insertions, 18 deletions
diff --git a/net/rfkill/Kconfig b/net/rfkill/Kconfig index eaf765876458..78efe895b663 100644 --- a/net/rfkill/Kconfig +++ b/net/rfkill/Kconfig | |||
@@ -18,7 +18,27 @@ config RFKILL_LEDS | |||
18 | default y | 18 | default y |
19 | 19 | ||
20 | config RFKILL_INPUT | 20 | config RFKILL_INPUT |
21 | bool "RF switch input support" if EMBEDDED | 21 | bool "RF switch input support" if EXPERT |
22 | depends on RFKILL | 22 | depends on RFKILL |
23 | depends on INPUT = y || RFKILL = INPUT | 23 | depends on INPUT = y || RFKILL = INPUT |
24 | default y if !EMBEDDED | 24 | default y if !EXPERT |
25 | |||
26 | config RFKILL_REGULATOR | ||
27 | tristate "Generic rfkill regulator driver" | ||
28 | depends on RFKILL || !RFKILL | ||
29 | depends on REGULATOR | ||
30 | help | ||
31 | This options enable controlling radio transmitters connected to | ||
32 | voltage regulator using the regulator framework. | ||
33 | |||
34 | To compile this driver as a module, choose M here: the module will | ||
35 | be called rfkill-regulator. | ||
36 | |||
37 | config RFKILL_GPIO | ||
38 | tristate "GPIO RFKILL driver" | ||
39 | depends on RFKILL && GPIOLIB && HAVE_CLK | ||
40 | default n | ||
41 | help | ||
42 | If you say yes here you get support of a generic gpio RFKILL | ||
43 | driver. The platform should fill in the appropriate fields in the | ||
44 | rfkill_gpio_platform_data structure and pass that to the driver. | ||
diff --git a/net/rfkill/Makefile b/net/rfkill/Makefile index 662105352691..311768783f4a 100644 --- a/net/rfkill/Makefile +++ b/net/rfkill/Makefile | |||
@@ -5,3 +5,5 @@ | |||
5 | rfkill-y += core.o | 5 | rfkill-y += core.o |
6 | rfkill-$(CONFIG_RFKILL_INPUT) += input.o | 6 | rfkill-$(CONFIG_RFKILL_INPUT) += input.o |
7 | obj-$(CONFIG_RFKILL) += rfkill.o | 7 | obj-$(CONFIG_RFKILL) += rfkill.o |
8 | obj-$(CONFIG_RFKILL_REGULATOR) += rfkill-regulator.o | ||
9 | obj-$(CONFIG_RFKILL_GPIO) += rfkill-gpio.o | ||
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 51875a0c5d48..be90640a2774 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
@@ -149,20 +149,6 @@ static void rfkill_led_trigger_activate(struct led_classdev *led) | |||
149 | rfkill_led_trigger_event(rfkill); | 149 | rfkill_led_trigger_event(rfkill); |
150 | } | 150 | } |
151 | 151 | ||
152 | const char *rfkill_get_led_trigger_name(struct rfkill *rfkill) | ||
153 | { | ||
154 | return rfkill->led_trigger.name; | ||
155 | } | ||
156 | EXPORT_SYMBOL(rfkill_get_led_trigger_name); | ||
157 | |||
158 | void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name) | ||
159 | { | ||
160 | BUG_ON(!rfkill); | ||
161 | |||
162 | rfkill->ledtrigname = name; | ||
163 | } | ||
164 | EXPORT_SYMBOL(rfkill_set_led_trigger_name); | ||
165 | |||
166 | static int rfkill_led_trigger_register(struct rfkill *rfkill) | 152 | static int rfkill_led_trigger_register(struct rfkill *rfkill) |
167 | { | 153 | { |
168 | rfkill->led_trigger.name = rfkill->ledtrigname | 154 | rfkill->led_trigger.name = rfkill->ledtrigname |
@@ -1038,7 +1024,6 @@ static int rfkill_fop_open(struct inode *inode, struct file *file) | |||
1038 | * start getting events from elsewhere but hold mtx to get | 1024 | * start getting events from elsewhere but hold mtx to get |
1039 | * startup events added first | 1025 | * startup events added first |
1040 | */ | 1026 | */ |
1041 | list_add(&data->list, &rfkill_fds); | ||
1042 | 1027 | ||
1043 | list_for_each_entry(rfkill, &rfkill_list, node) { | 1028 | list_for_each_entry(rfkill, &rfkill_list, node) { |
1044 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); | 1029 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); |
@@ -1047,6 +1032,7 @@ static int rfkill_fop_open(struct inode *inode, struct file *file) | |||
1047 | rfkill_fill_event(&ev->ev, rfkill, RFKILL_OP_ADD); | 1032 | rfkill_fill_event(&ev->ev, rfkill, RFKILL_OP_ADD); |
1048 | list_add_tail(&ev->list, &data->events); | 1033 | list_add_tail(&ev->list, &data->events); |
1049 | } | 1034 | } |
1035 | list_add(&data->list, &rfkill_fds); | ||
1050 | mutex_unlock(&data->mtx); | 1036 | mutex_unlock(&data->mtx); |
1051 | mutex_unlock(&rfkill_global_mutex); | 1037 | mutex_unlock(&rfkill_global_mutex); |
1052 | 1038 | ||
@@ -1241,6 +1227,7 @@ static const struct file_operations rfkill_fops = { | |||
1241 | .unlocked_ioctl = rfkill_fop_ioctl, | 1227 | .unlocked_ioctl = rfkill_fop_ioctl, |
1242 | .compat_ioctl = rfkill_fop_ioctl, | 1228 | .compat_ioctl = rfkill_fop_ioctl, |
1243 | #endif | 1229 | #endif |
1230 | .llseek = no_llseek, | ||
1244 | }; | 1231 | }; |
1245 | 1232 | ||
1246 | static struct miscdevice rfkill_miscdev = { | 1233 | static struct miscdevice rfkill_miscdev = { |
diff --git a/net/rfkill/input.c b/net/rfkill/input.c index 3713d7ecab96..1bca6d49ec96 100644 --- a/net/rfkill/input.c +++ b/net/rfkill/input.c | |||
@@ -142,7 +142,7 @@ static unsigned long rfkill_last_scheduled; | |||
142 | static unsigned long rfkill_ratelimit(const unsigned long last) | 142 | static unsigned long rfkill_ratelimit(const unsigned long last) |
143 | { | 143 | { |
144 | const unsigned long delay = msecs_to_jiffies(RFKILL_OPS_DELAY); | 144 | const unsigned long delay = msecs_to_jiffies(RFKILL_OPS_DELAY); |
145 | return (time_after(jiffies, last + delay)) ? 0 : delay; | 145 | return time_after(jiffies, last + delay) ? 0 : delay; |
146 | } | 146 | } |
147 | 147 | ||
148 | static void rfkill_schedule_ratelimited(void) | 148 | static void rfkill_schedule_ratelimited(void) |
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c new file mode 100644 index 000000000000..256c5ddd2d72 --- /dev/null +++ b/net/rfkill/rfkill-gpio.c | |||
@@ -0,0 +1,227 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011, NVIDIA Corporation. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/gpio.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/rfkill.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/clk.h> | ||
26 | #include <linux/slab.h> | ||
27 | |||
28 | #include <linux/rfkill-gpio.h> | ||
29 | |||
30 | enum rfkill_gpio_clk_state { | ||
31 | UNSPECIFIED = 0, | ||
32 | PWR_ENABLED, | ||
33 | PWR_DISABLED | ||
34 | }; | ||
35 | |||
36 | #define PWR_CLK_SET(_RF, _EN) \ | ||
37 | ((_RF)->pwr_clk_enabled = (!(_EN) ? PWR_ENABLED : PWR_DISABLED)) | ||
38 | #define PWR_CLK_ENABLED(_RF) ((_RF)->pwr_clk_enabled == PWR_ENABLED) | ||
39 | #define PWR_CLK_DISABLED(_RF) ((_RF)->pwr_clk_enabled != PWR_ENABLED) | ||
40 | |||
41 | struct rfkill_gpio_data { | ||
42 | struct rfkill_gpio_platform_data *pdata; | ||
43 | struct rfkill *rfkill_dev; | ||
44 | char *reset_name; | ||
45 | char *shutdown_name; | ||
46 | enum rfkill_gpio_clk_state pwr_clk_enabled; | ||
47 | struct clk *pwr_clk; | ||
48 | }; | ||
49 | |||
50 | static int rfkill_gpio_set_power(void *data, bool blocked) | ||
51 | { | ||
52 | struct rfkill_gpio_data *rfkill = data; | ||
53 | |||
54 | if (blocked) { | ||
55 | if (gpio_is_valid(rfkill->pdata->shutdown_gpio)) | ||
56 | gpio_direction_output(rfkill->pdata->shutdown_gpio, 0); | ||
57 | if (gpio_is_valid(rfkill->pdata->reset_gpio)) | ||
58 | gpio_direction_output(rfkill->pdata->reset_gpio, 0); | ||
59 | if (rfkill->pwr_clk && PWR_CLK_ENABLED(rfkill)) | ||
60 | clk_disable(rfkill->pwr_clk); | ||
61 | } else { | ||
62 | if (rfkill->pwr_clk && PWR_CLK_DISABLED(rfkill)) | ||
63 | clk_enable(rfkill->pwr_clk); | ||
64 | if (gpio_is_valid(rfkill->pdata->reset_gpio)) | ||
65 | gpio_direction_output(rfkill->pdata->reset_gpio, 1); | ||
66 | if (gpio_is_valid(rfkill->pdata->shutdown_gpio)) | ||
67 | gpio_direction_output(rfkill->pdata->shutdown_gpio, 1); | ||
68 | } | ||
69 | |||
70 | if (rfkill->pwr_clk) | ||
71 | PWR_CLK_SET(rfkill, blocked); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static const struct rfkill_ops rfkill_gpio_ops = { | ||
77 | .set_block = rfkill_gpio_set_power, | ||
78 | }; | ||
79 | |||
80 | static int rfkill_gpio_probe(struct platform_device *pdev) | ||
81 | { | ||
82 | struct rfkill_gpio_data *rfkill; | ||
83 | struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data; | ||
84 | int ret = 0; | ||
85 | int len = 0; | ||
86 | |||
87 | if (!pdata) { | ||
88 | pr_warn("%s: No platform data specified\n", __func__); | ||
89 | return -EINVAL; | ||
90 | } | ||
91 | |||
92 | /* make sure at-least one of the GPIO is defined and that | ||
93 | * a name is specified for this instance */ | ||
94 | if (!pdata->name || (!gpio_is_valid(pdata->reset_gpio) && | ||
95 | !gpio_is_valid(pdata->shutdown_gpio))) { | ||
96 | pr_warn("%s: invalid platform data\n", __func__); | ||
97 | return -EINVAL; | ||
98 | } | ||
99 | |||
100 | rfkill = kzalloc(sizeof(*rfkill), GFP_KERNEL); | ||
101 | if (!rfkill) | ||
102 | return -ENOMEM; | ||
103 | |||
104 | rfkill->pdata = pdata; | ||
105 | |||
106 | len = strlen(pdata->name); | ||
107 | rfkill->reset_name = kzalloc(len + 7, GFP_KERNEL); | ||
108 | if (!rfkill->reset_name) { | ||
109 | ret = -ENOMEM; | ||
110 | goto fail_alloc; | ||
111 | } | ||
112 | |||
113 | rfkill->shutdown_name = kzalloc(len + 10, GFP_KERNEL); | ||
114 | if (!rfkill->shutdown_name) { | ||
115 | ret = -ENOMEM; | ||
116 | goto fail_reset_name; | ||
117 | } | ||
118 | |||
119 | snprintf(rfkill->reset_name, len + 6 , "%s_reset", pdata->name); | ||
120 | snprintf(rfkill->shutdown_name, len + 9, "%s_shutdown", pdata->name); | ||
121 | |||
122 | if (pdata->power_clk_name) { | ||
123 | rfkill->pwr_clk = clk_get(&pdev->dev, pdata->power_clk_name); | ||
124 | if (IS_ERR(rfkill->pwr_clk)) { | ||
125 | pr_warn("%s: can't find pwr_clk.\n", __func__); | ||
126 | goto fail_shutdown_name; | ||
127 | } | ||
128 | } | ||
129 | |||
130 | if (gpio_is_valid(pdata->reset_gpio)) { | ||
131 | ret = gpio_request(pdata->reset_gpio, rfkill->reset_name); | ||
132 | if (ret) { | ||
133 | pr_warn("%s: failed to get reset gpio.\n", __func__); | ||
134 | goto fail_clock; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | if (gpio_is_valid(pdata->shutdown_gpio)) { | ||
139 | ret = gpio_request(pdata->shutdown_gpio, rfkill->shutdown_name); | ||
140 | if (ret) { | ||
141 | pr_warn("%s: failed to get shutdown gpio.\n", __func__); | ||
142 | goto fail_reset; | ||
143 | } | ||
144 | } | ||
145 | |||
146 | rfkill->rfkill_dev = rfkill_alloc(pdata->name, &pdev->dev, pdata->type, | ||
147 | &rfkill_gpio_ops, rfkill); | ||
148 | if (!rfkill->rfkill_dev) | ||
149 | goto fail_shutdown; | ||
150 | |||
151 | ret = rfkill_register(rfkill->rfkill_dev); | ||
152 | if (ret < 0) | ||
153 | goto fail_rfkill; | ||
154 | |||
155 | platform_set_drvdata(pdev, rfkill); | ||
156 | |||
157 | dev_info(&pdev->dev, "%s device registered.\n", pdata->name); | ||
158 | |||
159 | return 0; | ||
160 | |||
161 | fail_rfkill: | ||
162 | rfkill_destroy(rfkill->rfkill_dev); | ||
163 | fail_shutdown: | ||
164 | if (gpio_is_valid(pdata->shutdown_gpio)) | ||
165 | gpio_free(pdata->shutdown_gpio); | ||
166 | fail_reset: | ||
167 | if (gpio_is_valid(pdata->reset_gpio)) | ||
168 | gpio_free(pdata->reset_gpio); | ||
169 | fail_clock: | ||
170 | if (rfkill->pwr_clk) | ||
171 | clk_put(rfkill->pwr_clk); | ||
172 | fail_shutdown_name: | ||
173 | kfree(rfkill->shutdown_name); | ||
174 | fail_reset_name: | ||
175 | kfree(rfkill->reset_name); | ||
176 | fail_alloc: | ||
177 | kfree(rfkill); | ||
178 | |||
179 | return ret; | ||
180 | } | ||
181 | |||
182 | static int rfkill_gpio_remove(struct platform_device *pdev) | ||
183 | { | ||
184 | struct rfkill_gpio_data *rfkill = platform_get_drvdata(pdev); | ||
185 | |||
186 | rfkill_unregister(rfkill->rfkill_dev); | ||
187 | rfkill_destroy(rfkill->rfkill_dev); | ||
188 | if (gpio_is_valid(rfkill->pdata->shutdown_gpio)) | ||
189 | gpio_free(rfkill->pdata->shutdown_gpio); | ||
190 | if (gpio_is_valid(rfkill->pdata->reset_gpio)) | ||
191 | gpio_free(rfkill->pdata->reset_gpio); | ||
192 | if (rfkill->pwr_clk && PWR_CLK_ENABLED(rfkill)) | ||
193 | clk_disable(rfkill->pwr_clk); | ||
194 | if (rfkill->pwr_clk) | ||
195 | clk_put(rfkill->pwr_clk); | ||
196 | kfree(rfkill->shutdown_name); | ||
197 | kfree(rfkill->reset_name); | ||
198 | kfree(rfkill); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static struct platform_driver rfkill_gpio_driver = { | ||
204 | .probe = rfkill_gpio_probe, | ||
205 | .remove = __devexit_p(rfkill_gpio_remove), | ||
206 | .driver = { | ||
207 | .name = "rfkill_gpio", | ||
208 | .owner = THIS_MODULE, | ||
209 | }, | ||
210 | }; | ||
211 | |||
212 | static int __init rfkill_gpio_init(void) | ||
213 | { | ||
214 | return platform_driver_register(&rfkill_gpio_driver); | ||
215 | } | ||
216 | |||
217 | static void __exit rfkill_gpio_exit(void) | ||
218 | { | ||
219 | platform_driver_unregister(&rfkill_gpio_driver); | ||
220 | } | ||
221 | |||
222 | module_init(rfkill_gpio_init); | ||
223 | module_exit(rfkill_gpio_exit); | ||
224 | |||
225 | MODULE_DESCRIPTION("gpio rfkill"); | ||
226 | MODULE_AUTHOR("NVIDIA"); | ||
227 | MODULE_LICENSE("GPL"); | ||
diff --git a/net/rfkill/rfkill-regulator.c b/net/rfkill/rfkill-regulator.c new file mode 100644 index 000000000000..18dc512a10f3 --- /dev/null +++ b/net/rfkill/rfkill-regulator.c | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * rfkill-regulator.c - Regulator consumer driver for rfkill | ||
3 | * | ||
4 | * Copyright (C) 2009 Guiming Zhuo <gmzhuo@gmail.com> | ||
5 | * Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it> | ||
6 | * | ||
7 | * Implementation inspired by leds-regulator driver. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/regulator/consumer.h> | ||
20 | #include <linux/rfkill.h> | ||
21 | #include <linux/rfkill-regulator.h> | ||
22 | |||
23 | struct rfkill_regulator_data { | ||
24 | struct rfkill *rf_kill; | ||
25 | bool reg_enabled; | ||
26 | |||
27 | struct regulator *vcc; | ||
28 | }; | ||
29 | |||
30 | static int rfkill_regulator_set_block(void *data, bool blocked) | ||
31 | { | ||
32 | struct rfkill_regulator_data *rfkill_data = data; | ||
33 | |||
34 | pr_debug("%s: blocked: %d\n", __func__, blocked); | ||
35 | |||
36 | if (blocked) { | ||
37 | if (rfkill_data->reg_enabled) { | ||
38 | regulator_disable(rfkill_data->vcc); | ||
39 | rfkill_data->reg_enabled = 0; | ||
40 | } | ||
41 | } else { | ||
42 | if (!rfkill_data->reg_enabled) { | ||
43 | regulator_enable(rfkill_data->vcc); | ||
44 | rfkill_data->reg_enabled = 1; | ||
45 | } | ||
46 | } | ||
47 | |||
48 | pr_debug("%s: regulator_is_enabled after set_block: %d\n", __func__, | ||
49 | regulator_is_enabled(rfkill_data->vcc)); | ||
50 | |||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | struct rfkill_ops rfkill_regulator_ops = { | ||
55 | .set_block = rfkill_regulator_set_block, | ||
56 | }; | ||
57 | |||
58 | static int __devinit rfkill_regulator_probe(struct platform_device *pdev) | ||
59 | { | ||
60 | struct rfkill_regulator_platform_data *pdata = pdev->dev.platform_data; | ||
61 | struct rfkill_regulator_data *rfkill_data; | ||
62 | struct regulator *vcc; | ||
63 | struct rfkill *rf_kill; | ||
64 | int ret = 0; | ||
65 | |||
66 | if (pdata == NULL) { | ||
67 | dev_err(&pdev->dev, "no platform data\n"); | ||
68 | return -ENODEV; | ||
69 | } | ||
70 | |||
71 | if (pdata->name == NULL || pdata->type == 0) { | ||
72 | dev_err(&pdev->dev, "invalid name or type in platform data\n"); | ||
73 | return -EINVAL; | ||
74 | } | ||
75 | |||
76 | vcc = regulator_get_exclusive(&pdev->dev, "vrfkill"); | ||
77 | if (IS_ERR(vcc)) { | ||
78 | dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name); | ||
79 | ret = PTR_ERR(vcc); | ||
80 | goto out; | ||
81 | } | ||
82 | |||
83 | rfkill_data = kzalloc(sizeof(*rfkill_data), GFP_KERNEL); | ||
84 | if (rfkill_data == NULL) { | ||
85 | ret = -ENOMEM; | ||
86 | goto err_data_alloc; | ||
87 | } | ||
88 | |||
89 | rf_kill = rfkill_alloc(pdata->name, &pdev->dev, | ||
90 | pdata->type, | ||
91 | &rfkill_regulator_ops, rfkill_data); | ||
92 | if (rf_kill == NULL) { | ||
93 | dev_err(&pdev->dev, "Cannot alloc rfkill device\n"); | ||
94 | ret = -ENOMEM; | ||
95 | goto err_rfkill_alloc; | ||
96 | } | ||
97 | |||
98 | if (regulator_is_enabled(vcc)) { | ||
99 | dev_dbg(&pdev->dev, "Regulator already enabled\n"); | ||
100 | rfkill_data->reg_enabled = 1; | ||
101 | } | ||
102 | rfkill_data->vcc = vcc; | ||
103 | rfkill_data->rf_kill = rf_kill; | ||
104 | |||
105 | ret = rfkill_register(rf_kill); | ||
106 | if (ret) { | ||
107 | dev_err(&pdev->dev, "Cannot register rfkill device\n"); | ||
108 | goto err_rfkill_register; | ||
109 | } | ||
110 | |||
111 | platform_set_drvdata(pdev, rfkill_data); | ||
112 | dev_info(&pdev->dev, "%s initialized\n", pdata->name); | ||
113 | |||
114 | return 0; | ||
115 | |||
116 | err_rfkill_register: | ||
117 | rfkill_destroy(rf_kill); | ||
118 | err_rfkill_alloc: | ||
119 | kfree(rfkill_data); | ||
120 | err_data_alloc: | ||
121 | regulator_put(vcc); | ||
122 | out: | ||
123 | return ret; | ||
124 | } | ||
125 | |||
126 | static int __devexit rfkill_regulator_remove(struct platform_device *pdev) | ||
127 | { | ||
128 | struct rfkill_regulator_data *rfkill_data = platform_get_drvdata(pdev); | ||
129 | struct rfkill *rf_kill = rfkill_data->rf_kill; | ||
130 | |||
131 | rfkill_unregister(rf_kill); | ||
132 | rfkill_destroy(rf_kill); | ||
133 | regulator_put(rfkill_data->vcc); | ||
134 | kfree(rfkill_data); | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | static struct platform_driver rfkill_regulator_driver = { | ||
140 | .probe = rfkill_regulator_probe, | ||
141 | .remove = __devexit_p(rfkill_regulator_remove), | ||
142 | .driver = { | ||
143 | .name = "rfkill-regulator", | ||
144 | .owner = THIS_MODULE, | ||
145 | }, | ||
146 | }; | ||
147 | |||
148 | static int __init rfkill_regulator_init(void) | ||
149 | { | ||
150 | return platform_driver_register(&rfkill_regulator_driver); | ||
151 | } | ||
152 | module_init(rfkill_regulator_init); | ||
153 | |||
154 | static void __exit rfkill_regulator_exit(void) | ||
155 | { | ||
156 | platform_driver_unregister(&rfkill_regulator_driver); | ||
157 | } | ||
158 | module_exit(rfkill_regulator_exit); | ||
159 | |||
160 | MODULE_AUTHOR("Guiming Zhuo <gmzhuo@gmail.com>"); | ||
161 | MODULE_AUTHOR("Antonio Ospite <ospite@studenti.unina.it>"); | ||
162 | MODULE_DESCRIPTION("Regulator consumer driver for rfkill"); | ||
163 | MODULE_LICENSE("GPL"); | ||
164 | MODULE_ALIAS("platform:rfkill-regulator"); | ||