~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/staging/brcm80211/sys/wlc_event.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2010 Broadcom Corporation
3
 
 *
4
 
 * Permission to use, copy, modify, and/or distribute this software for any
5
 
 * purpose with or without fee is hereby granted, provided that the above
6
 
 * copyright notice and this permission notice appear in all copies.
7
 
 *
8
 
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
 
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
 
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11
 
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
 
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13
 
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14
 
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
 
 */
16
 
 
17
 
#include <linux/kernel.h>
18
 
#include <bcmdefs.h>
19
 
#include <linux/module.h>
20
 
#include <linux/pci.h>
21
 
#include <osl.h>
22
 
#include <bcmutils.h>
23
 
#include <siutils.h>
24
 
#include <sbhndpio.h>
25
 
#include <sbhnddma.h>
26
 
#include <wlioctl.h>
27
 
#include <wlc_cfg.h>
28
 
#include <wlc_pub.h>
29
 
#include <wlc_key.h>
30
 
#include <wl_export.h>
31
 
#include <wlc_event.h>
32
 
 
33
 
#include <d11.h>
34
 
#include <wlc_rate.h>
35
 
#include <wlc_mac80211.h>
36
 
#ifdef MSGTRACE
37
 
#include <msgtrace.h>
38
 
#endif
39
 
#include <wl_dbg.h>
40
 
 
41
 
/* Local prototypes */
42
 
static void wlc_timer_cb(void *arg);
43
 
 
44
 
/* Private data structures */
45
 
struct wlc_eventq {
46
 
        wlc_event_t *head;
47
 
        wlc_event_t *tail;
48
 
        struct wlc_info *wlc;
49
 
        void *wl;
50
 
        struct wlc_pub *pub;
51
 
        bool tpending;
52
 
        bool workpending;
53
 
        struct wl_timer *timer;
54
 
        wlc_eventq_cb_t cb;
55
 
        u8 event_inds_mask[broken_roundup(WLC_E_LAST, NBBY) / NBBY];
56
 
};
57
 
 
58
 
/*
59
 
 * Export functions
60
 
 */
61
 
wlc_eventq_t *wlc_eventq_attach(struct wlc_pub *pub, struct wlc_info *wlc,
62
 
                                void *wl,
63
 
                                wlc_eventq_cb_t cb)
64
 
{
65
 
        wlc_eventq_t *eq;
66
 
 
67
 
        eq = kzalloc(sizeof(wlc_eventq_t), GFP_ATOMIC);
68
 
        if (eq == NULL)
69
 
                return NULL;
70
 
 
71
 
        eq->cb = cb;
72
 
        eq->wlc = wlc;
73
 
        eq->wl = wl;
74
 
        eq->pub = pub;
75
 
 
76
 
        eq->timer = wl_init_timer(eq->wl, wlc_timer_cb, eq, "eventq");
77
 
        if (!eq->timer) {
78
 
                WL_ERROR("wl%d: wlc_eventq_attach: timer failed\n",
79
 
                         pub->unit);
80
 
                kfree(eq);
81
 
                return NULL;
82
 
        }
83
 
 
84
 
        return eq;
85
 
}
86
 
 
87
 
int wlc_eventq_detach(wlc_eventq_t *eq)
88
 
{
89
 
        /* Clean up pending events */
90
 
        wlc_eventq_down(eq);
91
 
 
92
 
        if (eq->timer) {
93
 
                if (eq->tpending) {
94
 
                        wl_del_timer(eq->wl, eq->timer);
95
 
                        eq->tpending = false;
96
 
                }
97
 
                wl_free_timer(eq->wl, eq->timer);
98
 
                eq->timer = NULL;
99
 
        }
100
 
 
101
 
        ASSERT(wlc_eventq_avail(eq) == false);
102
 
        kfree(eq);
103
 
        return 0;
104
 
}
105
 
 
106
 
int wlc_eventq_down(wlc_eventq_t *eq)
107
 
{
108
 
        int callbacks = 0;
109
 
        if (eq->tpending && !eq->workpending) {
110
 
                if (!wl_del_timer(eq->wl, eq->timer))
111
 
                        callbacks++;
112
 
 
113
 
                ASSERT(wlc_eventq_avail(eq) == true);
114
 
                ASSERT(eq->workpending == false);
115
 
                eq->workpending = true;
116
 
                if (eq->cb)
117
 
                        eq->cb(eq->wlc);
118
 
 
119
 
                ASSERT(eq->workpending == true);
120
 
                eq->workpending = false;
121
 
                eq->tpending = false;
122
 
        } else {
123
 
                ASSERT(eq->workpending || wlc_eventq_avail(eq) == false);
124
 
        }
125
 
        return callbacks;
126
 
}
127
 
 
128
 
wlc_event_t *wlc_event_alloc(wlc_eventq_t *eq)
129
 
{
130
 
        wlc_event_t *e;
131
 
 
132
 
        e = kzalloc(sizeof(wlc_event_t), GFP_ATOMIC);
133
 
 
134
 
        if (e == NULL)
135
 
                return NULL;
136
 
 
137
 
        return e;
138
 
}
139
 
 
140
 
void wlc_event_free(wlc_eventq_t *eq, wlc_event_t *e)
141
 
{
142
 
        ASSERT(e->data == NULL);
143
 
        ASSERT(e->next == NULL);
144
 
        kfree(e);
145
 
}
146
 
 
147
 
void wlc_eventq_enq(wlc_eventq_t *eq, wlc_event_t *e)
148
 
{
149
 
        ASSERT(e->next == NULL);
150
 
        e->next = NULL;
151
 
 
152
 
        if (eq->tail) {
153
 
                eq->tail->next = e;
154
 
                eq->tail = e;
155
 
        } else
156
 
                eq->head = eq->tail = e;
157
 
 
158
 
        if (!eq->tpending) {
159
 
                eq->tpending = true;
160
 
                /* Use a zero-delay timer to trigger
161
 
                 * delayed processing of the event.
162
 
                 */
163
 
                wl_add_timer(eq->wl, eq->timer, 0, 0);
164
 
        }
165
 
}
166
 
 
167
 
wlc_event_t *wlc_eventq_deq(wlc_eventq_t *eq)
168
 
{
169
 
        wlc_event_t *e;
170
 
 
171
 
        e = eq->head;
172
 
        if (e) {
173
 
                eq->head = e->next;
174
 
                e->next = NULL;
175
 
 
176
 
                if (eq->head == NULL)
177
 
                        eq->tail = eq->head;
178
 
        }
179
 
        return e;
180
 
}
181
 
 
182
 
wlc_event_t *wlc_eventq_next(wlc_eventq_t *eq, wlc_event_t *e)
183
 
{
184
 
#ifdef BCMDBG
185
 
        wlc_event_t *etmp;
186
 
 
187
 
        for (etmp = eq->head; etmp; etmp = etmp->next) {
188
 
                if (etmp == e)
189
 
                        break;
190
 
        }
191
 
        ASSERT(etmp != NULL);
192
 
#endif
193
 
 
194
 
        return e->next;
195
 
}
196
 
 
197
 
int wlc_eventq_cnt(wlc_eventq_t *eq)
198
 
{
199
 
        wlc_event_t *etmp;
200
 
        int cnt = 0;
201
 
 
202
 
        for (etmp = eq->head; etmp; etmp = etmp->next)
203
 
                cnt++;
204
 
 
205
 
        return cnt;
206
 
}
207
 
 
208
 
bool wlc_eventq_avail(wlc_eventq_t *eq)
209
 
{
210
 
        return (eq->head != NULL);
211
 
}
212
 
 
213
 
/*
214
 
 * Local Functions
215
 
 */
216
 
static void wlc_timer_cb(void *arg)
217
 
{
218
 
        struct wlc_eventq *eq = (struct wlc_eventq *)arg;
219
 
 
220
 
        ASSERT(eq->tpending == true);
221
 
        ASSERT(wlc_eventq_avail(eq) == true);
222
 
        ASSERT(eq->workpending == false);
223
 
        eq->workpending = true;
224
 
 
225
 
        if (eq->cb)
226
 
                eq->cb(eq->wlc);
227
 
 
228
 
        ASSERT(wlc_eventq_avail(eq) == false);
229
 
        ASSERT(eq->tpending == true);
230
 
        eq->workpending = false;
231
 
        eq->tpending = false;
232
 
}