wl1251: add reset handling
[pandora-wifi.git] / patches / 03-rfkill.patch
1 rfkill was re-implemented on 2.6.31. We port it to
2 older kernels with a simple hack, just rename the
3 module as a new one rfkill_backport, and every
4 exported symbol gets redefined with a _backport
5 postfix through compat-2.6.31.h. The changes below
6 are the ones we could not do through compat-2.6.31.h
7
8 Do older kernels have /dev/rfkill ? I not then we can
9 just keep /dev/rfkill and not /dev/rfkill_backport.
10
11 Note that 2.6.31 added netdevice notifier upon interface
12 dev_open() which on cfg80211 will check if checks to see
13 if rfkill is enabled (or if the mode of operation is not
14 supported) on the  cfg80211_netdev_notifier_call() and if
15 so deny bringing the interface up. This was added via
16 commit:
17
18 3b8bcfd5d31ea0fec58681d035544ace707d2536
19
20 Since older kernels will not have the notifier call
21 on dev_open() if we *really want* to port this we could have
22 mac80211's subif_open() call :
23
24         ret = call_netdevice_notifiers(NETDEV_PRE_UP, dev);
25         ret = notifier_to_errno(ret);
26         if (ret)
27                 return ret;
28
29 This would do the policing from within mac80211.
30
31 --- a/net/rfkill/Makefile
32 +++ b/net/rfkill/Makefile
33 @@ -2,6 +2,6 @@
34  # Makefile for the RF switch subsystem.
35  #
36  
37 -rfkill-y                       += core.o
38 -rfkill-$(CONFIG_RFKILL_INPUT)  += input.o
39 -obj-$(CONFIG_RFKILL)           += rfkill.o
40 +rfkill_backport-y                      += core.o
41 +rfkill_backport-$(CONFIG_RFKILL_BACKPORT_INPUT)        += input.o
42 +obj-$(CONFIG_RFKILL_BACKPORT)          += rfkill_backport.o
43 --- a/net/rfkill/input.c
44 +++ b/net/rfkill/input.c
45 @@ -17,7 +17,11 @@
46  #include <linux/slab.h>
47  #include <linux/workqueue.h>
48  #include <linux/init.h>
49 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
50  #include <linux/rfkill.h>
51 +#else
52 +#include <linux/rfkill_backport.h>
53 +#endif
54  #include <linux/sched.h>
55  
56  #include "rfkill.h"
57 @@ -229,7 +233,7 @@ static int rfkill_connect(struct input_h
58  
59         handle->dev = dev;
60         handle->handler = handler;
61 -       handle->name = "rfkill";
62 +       handle->name = "rfkill_backport";
63  
64         /* causes rfkill_start() to be called */
65         error = input_register_handle(handle);
66 --- a/net/rfkill/core.c
67 +++ b/net/rfkill/core.c
68 @@ -26,7 +26,7 @@
69  #include <linux/capability.h>
70  #include <linux/list.h>
71  #include <linux/mutex.h>
72 -#include <linux/rfkill.h>
73 +#include <linux/rfkill_backport.h>
74  #include <linux/sched.h>
75  #include <linux/spinlock.h>
76  #include <linux/miscdevice.h>
77 @@ -62,7 +62,7 @@ struct rfkill {
78         const struct rfkill_ops *ops;
79         void                    *data;
80  
81 -#ifdef CONFIG_RFKILL_LEDS
82 +#ifdef CONFIG_RFKILL_BACKPORT_LEDS
83         struct led_trigger      led_trigger;
84         const char              *ledtrigname;
85  #endif
86 @@ -123,7 +123,7 @@ static struct {
87  static bool rfkill_epo_lock_active;
88  
89  
90 -#ifdef CONFIG_RFKILL_LEDS
91 +#ifdef CONFIG_RFKILL_BACKPORT_LEDS
92  static void rfkill_led_trigger_event(struct rfkill *rfkill)
93  {
94         struct led_trigger *trigger;
95 @@ -317,7 +317,7 @@ static void rfkill_set_block(struct rfki
96         rfkill_event(rfkill);
97  }
98  
99 -#ifdef CONFIG_RFKILL_INPUT
100 +#ifdef CONFIG_RFKILL_BACKPORT_INPUT
101  static atomic_t rfkill_input_disabled = ATOMIC_INIT(0);
102  
103  /**
104 @@ -779,7 +779,7 @@ static int rfkill_resume(struct device *
105  }
106  
107  static struct class rfkill_class = {
108 -       .name           = "rfkill",
109 +       .name           = "rfkill_backport",
110         .dev_release    = rfkill_release,
111         .dev_attrs      = rfkill_dev_attrs,
112         .dev_uevent     = rfkill_dev_uevent,
113 @@ -925,7 +925,7 @@ int __must_check rfkill_register(struct 
114         if (!rfkill->persistent || rfkill_epo_lock_active) {
115                 schedule_work(&rfkill->sync_work);
116         } else {
117 -#ifdef CONFIG_RFKILL_INPUT
118 +#ifdef CONFIG_RFKILL_BACKPORT_INPUT
119                 bool soft_blocked = !!(rfkill->state & RFKILL_BLOCK_SW);
120  
121                 if (!atomic_read(&rfkill_input_disabled))
122 @@ -1153,7 +1153,7 @@ static int rfkill_fop_release(struct ino
123         list_for_each_entry_safe(ev, tmp, &data->events, list)
124                 kfree(ev);
125  
126 -#ifdef CONFIG_RFKILL_INPUT
127 +#ifdef CONFIG_RFKILL_BACKPORT_INPUT
128         if (data->input_handler)
129                 if (atomic_dec_return(&rfkill_input_disabled) == 0)
130                         printk(KERN_DEBUG "rfkill: input handler enabled\n");
131 @@ -1164,7 +1164,7 @@ static int rfkill_fop_release(struct ino
132         return 0;
133  }
134  
135 -#ifdef CONFIG_RFKILL_INPUT
136 +#ifdef CONFIG_RFKILL_BACKPORT_INPUT
137  static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
138                              unsigned long arg)
139  {
140 @@ -1197,7 +1197,7 @@ static const struct file_operations rfki
141         .write          = rfkill_fop_write,
142         .poll           = rfkill_fop_poll,
143         .release        = rfkill_fop_release,
144 -#ifdef CONFIG_RFKILL_INPUT
145 +#ifdef CONFIG_RFKILL_BACKPORT_INPUT
146         .unlocked_ioctl = rfkill_fop_ioctl,
147         .compat_ioctl   = rfkill_fop_ioctl,
148  #endif
149 @@ -1227,7 +1227,7 @@ static int __init rfkill_init(void)
150                 goto out;
151         }
152  
153 -#ifdef CONFIG_RFKILL_INPUT
154 +#ifdef CONFIG_RFKILL_BACKPORT_INPUT
155         error = rfkill_handler_init();
156         if (error) {
157                 misc_deregister(&rfkill_miscdev);
158 @@ -1243,7 +1243,7 @@ subsys_initcall(rfkill_init);
159  
160  static void __exit rfkill_exit(void)
161  {
162 -#ifdef CONFIG_RFKILL_INPUT
163 +#ifdef CONFIG_RFKILL_BACKPORT_INPUT
164         rfkill_handler_exit();
165  #endif
166         misc_deregister(&rfkill_miscdev);
167 --- a/include/linux/rfkill_backport.h
168 +++ b/include/linux/rfkill_backport.h
169 @@ -20,6 +20,7 @@
170   */
171  
172  #include <linux/types.h>
173 +#include <linux/compat-2.6.h>
174  
175  /* define userspace visible states */
176  #define RFKILL_STATE_SOFT_BLOCKED      0
177 @@ -148,7 +149,7 @@ struct rfkill_ops {
178         int     (*set_block)(void *data, bool blocked);
179  };
180  
181 -#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
182 +#if defined(CONFIG_RFKILL_BACKPORT) || defined(CONFIG_RFKILL_BACKPORT_MODULE)
183  /**
184   * rfkill_alloc - allocate rfkill structure
185   * @name: name of the struct -- the string is not copied internally
186 @@ -355,7 +356,7 @@ static inline bool rfkill_blocked(struct
187  #endif /* RFKILL || RFKILL_MODULE */
188  
189  
190 -#ifdef CONFIG_RFKILL_LEDS
191 +#ifdef CONFIG_RFKILL_BACKPORT_LEDS
192  /**
193   * rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED.
194   * This function might return a NULL pointer if registering of the
195 --- a/net/wireless/core.h
196 +++ b/net/wireless/core.h
197 @@ -11,7 +11,11 @@
198  #include <linux/kref.h>
199  #include <linux/rbtree.h>
200  #include <linux/debugfs.h>
201 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
202  #include <linux/rfkill.h>
203 +#else
204 +#include <linux/rfkill_backport.h>
205 +#endif
206  #include <linux/workqueue.h>
207  #include <net/genetlink.h>
208  #include <net/cfg80211.h>
209 --- a/drivers/net/wireless/ath/ath9k/hw.c
210 +++ b/drivers/net/wireless/ath/ath9k/hw.c
211 @@ -3224,7 +3224,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw
212  
213         pCap->hw_caps |= ATH9K_HW_CAP_ENHANCEDPM;
214  
215 -#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
216 +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)) || ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) && defined(CONFIG_RFKILL_BACKPORT) || defined(CONFIG_RFKILL_BACKPORT_MODULE))
217         ah->rfsilent = ah->eep_ops->get_eeprom(ah, EEP_RF_SILENT);
218         if (ah->rfsilent & EEP_RFSILENT_ENABLED) {
219                 ah->rfkill_gpio =
220 --- a/drivers/net/wireless/ath/ath5k/base.h
221 +++ b/drivers/net/wireless/ath/ath5k/base.h
222 @@ -46,7 +46,11 @@
223  #include <linux/wireless.h>
224  #include <linux/if_ether.h>
225  #include <linux/leds.h>
226 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
227  #include <linux/rfkill.h>
228 +#else
229 +#include <linux/rfkill_backport.h>
230 +#endif
231  
232  #include "ath5k.h"
233  #include "debug.h"