ext4: reduce contention on s_orphan_lock
[linux/fpc-iii.git] / drivers / staging / vt6656 / int.c
blobcca56b2f243dd83c0bc78dd2b82d8a7f19537119
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * File: int.c
22 * Purpose: Handle USB interrupt endpoint
24 * Author: Jerry Chen
26 * Date: Apr. 2, 2004
28 * Functions:
30 * Revision History:
31 * 04-02-2004 Jerry Chen: Initial release
35 #include "int.h"
36 #include "tmacro.h"
37 #include "mac.h"
38 #include "power.h"
39 #include "bssdb.h"
40 #include "usbpipe.h"
42 static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
44 /*+
46 * Function: InterruptPollingThread
48 * Synopsis: Thread running at IRQL PASSIVE_LEVEL.
50 * Arguments: Device Extension
52 * Returns:
54 * Algorithm: Call USBD for input data;
56 * History: dd-mm-yyyy Author Comment
59 * Notes:
61 * USB reads are by nature 'Blocking', and when in a read, the device looks
62 * like it's in a 'stall' condition, so we deliberately time out every second
63 * if we've gotten no data
65 -*/
66 void INTvWorkItem(struct vnt_private *pDevice)
68 int ntStatus;
70 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
72 spin_lock_irq(&pDevice->lock);
74 ntStatus = PIPEnsInterruptRead(pDevice);
76 spin_unlock_irq(&pDevice->lock);
79 void INTnsProcessData(struct vnt_private *priv)
81 struct vnt_interrupt_data *int_data;
82 struct vnt_manager *mgmt = &priv->vnt_mgmt;
83 struct net_device_stats *stats = &priv->stats;
85 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
87 int_data = (struct vnt_interrupt_data *)priv->int_buf.data_buf;
89 if (int_data->tsr0 & TSR_VALID) {
90 if (int_data->tsr0 & (TSR_TMO | TSR_RETRYTMO))
91 priv->wstats.discard.retries++;
92 else
93 stats->tx_packets++;
95 BSSvUpdateNodeTxCounter(priv,
96 int_data->tsr0,
97 int_data->pkt0);
100 if (int_data->tsr1 & TSR_VALID) {
101 if (int_data->tsr1 & (TSR_TMO | TSR_RETRYTMO))
102 priv->wstats.discard.retries++;
103 else
104 stats->tx_packets++;
107 BSSvUpdateNodeTxCounter(priv,
108 int_data->tsr1,
109 int_data->pkt1);
112 if (int_data->tsr2 & TSR_VALID) {
113 if (int_data->tsr2 & (TSR_TMO | TSR_RETRYTMO))
114 priv->wstats.discard.retries++;
115 else
116 stats->tx_packets++;
118 BSSvUpdateNodeTxCounter(priv,
119 int_data->tsr2,
120 int_data->pkt2);
123 if (int_data->tsr3 & TSR_VALID) {
124 if (int_data->tsr3 & (TSR_TMO | TSR_RETRYTMO))
125 priv->wstats.discard.retries++;
126 else
127 stats->tx_packets++;
129 BSSvUpdateNodeTxCounter(priv,
130 int_data->tsr3,
131 int_data->pkt3);
134 if (int_data->isr0 != 0) {
135 if (int_data->isr0 & ISR_BNTX) {
136 if (priv->op_mode == NL80211_IFTYPE_AP) {
137 if (mgmt->byDTIMCount > 0) {
138 mgmt->byDTIMCount--;
139 mgmt->sNodeDBTable[0].bRxPSPoll =
140 false;
141 } else if (mgmt->byDTIMCount == 0) {
142 /* check if multicast tx buffering */
143 mgmt->byDTIMCount =
144 mgmt->byDTIMPeriod-1;
145 mgmt->sNodeDBTable[0].bRxPSPoll = true;
146 if (mgmt->sNodeDBTable[0].bPSEnable)
147 bScheduleCommand((void *) priv,
148 WLAN_CMD_RX_PSPOLL,
149 NULL);
151 bScheduleCommand((void *) priv,
152 WLAN_CMD_BECON_SEND,
153 NULL);
155 priv->bBeaconSent = true;
156 } else {
157 priv->bBeaconSent = false;
160 if (int_data->isr0 & ISR_TBTT) {
161 if (priv->bEnablePSMode)
162 bScheduleCommand((void *) priv,
163 WLAN_CMD_TBTT_WAKEUP,
164 NULL);
165 if (priv->bChannelSwitch) {
166 priv->byChannelSwitchCount--;
167 if (priv->byChannelSwitchCount == 0)
168 bScheduleCommand((void *) priv,
169 WLAN_CMD_11H_CHSW,
170 NULL);
173 priv->qwCurrTSF = le64_to_cpu(int_data->tsf);
176 if (int_data->isr1 != 0)
177 if (int_data->isr1 & ISR_GPIO3)
178 bScheduleCommand((void *) priv,
179 WLAN_CMD_RADIO,
180 NULL);
182 priv->int_buf.in_use = false;
184 stats->tx_errors = priv->wstats.discard.retries;
185 stats->tx_dropped = priv->wstats.discard.retries;