There were all the 4 spaces indentation, so I fixed them using the tabs.
Signed-off-by: Sangho Yi <[email protected]>
---
drivers/staging/csr/mlme.c | 598 ++++++++++++++++++++++----------------------
1 file changed, 299 insertions(+), 299 deletions(-)
diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c
index ed767ec..a16841f 100644
--- a/drivers/staging/csr/mlme.c
+++ b/drivers/staging/csr/mlme.c
@@ -1,9 +1,9 @@
/*
* ---------------------------------------------------------------------------
- * FILE: mlme.c
+ * FILE: mlme.c
*
* PURPOSE:
- * This file provides functions to send MLME requests to the UniFi.
+ * This file provides functions to send MLME requests to the UniFi.
*
* Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
*
@@ -19,114 +19,114 @@
* ---------------------------------------------------------------------------
* unifi_mlme_wait_for_reply
*
- * Wait for a reply after sending a signal.
+ * Wait for a reply after sending a signal.
*
* Arguments:
- * priv Pointer to device private context struct
- * ul_client Pointer to linux client
- * sig_reply_id ID of the expected reply (defined in sigs.h).
- * timeout timeout in ms
+ * priv Pointer to device private context struct
+ * ul_client Pointer to linux client
+ * sig_reply_id ID of the expected reply (defined in sigs.h).
+ * timeout timeout in ms
*
* Returns:
- * 0 on success, -ve POSIX code on error.
+ * 0 on success, -ve POSIX code on error.
*
* Notes:
- * This function waits for a specific (sig_reply_id) signal from UniFi.
- * It also match the sequence number of the received (cfm) signal, with
- * the latest sequence number of the signal (req) we have sent.
- * These two number match be equal.
- * Should only be used for waiting xxx.cfm signals and only after
- * we have sent the matching xxx.req signal to UniFi.
- * If no response is received within the expected time (timeout), we assume
- * that the UniFi is busy and return an error.
- * If the wait is aborted by a kernel signal arriving, we stop waiting.
- * If a response from UniFi is not what we expected, we discard it and
- * wait again. This could be a response from an aborted request. If we
- * see several bad responses we assume we have lost synchronisation with
- * UniFi.
+ * This function waits for a specific (sig_reply_id) signal from UniFi.
+ * It also match the sequence number of the received (cfm) signal, with
+ * the latest sequence number of the signal (req) we have sent.
+ * These two number match be equal.
+ * Should only be used for waiting xxx.cfm signals and only after
+ * we have sent the matching xxx.req signal to UniFi.
+ * If no response is received within the expected time (timeout), we assume
+ * that the UniFi is busy and return an error.
+ * If the wait is aborted by a kernel signal arriving, we stop waiting.
+ * If a response from UniFi is not what we expected, we discard it and
+ * wait again. This could be a response from an aborted request. If we
+ * see several bad responses we assume we have lost synchronisation with
+ * UniFi.
* ---------------------------------------------------------------------------
*/
static int
unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_id, int timeout)
{
- int retries = 0;
- long r;
- long t = timeout;
- unsigned int sent_seq_no;
-
- /* Convert t in ms to jiffies */
- t = msecs_to_jiffies(t);
-
- do {
- /* Wait for the confirm or timeout. */
- r = wait_event_interruptible_timeout(pcli->udi_wq,
- (pcli->wake_up_wq_id) || (priv->io_aborted == 1),
- t);
- /* Check for general i/o error */
- if (priv->io_aborted) {
- unifi_error(priv, "MLME operation aborted\n");
- return -EIO;
- }
-
- /*
- * If r=0 the request has timed-out.
- * If r>0 the request has completed successfully.
- * If r=-ERESTARTSYS an event (kill signal) has interrupted the wait_event.
- */
- if ((r == 0) && (pcli->wake_up_wq_id == 0)) {
- unifi_error(priv, "mlme_wait: timed-out waiting for 0x%.4X, after %lu msec.\n",
- sig_reply_id, jiffies_to_msecs(t));
- pcli->wake_up_wq_id = 0;
- return -ETIMEDOUT;
- } else if (r == -ERESTARTSYS) {
- unifi_error(priv, "mlme_wait: waiting for 0x%.4X was aborted.\n", sig_reply_id);
- pcli->wake_up_wq_id = 0;
- return -EINTR;
- } else {
- /* Get the sequence number of the signal that we previously set. */
- if (pcli->seq_no != 0) {
- sent_seq_no = pcli->seq_no - 1;
- } else {
- sent_seq_no = 0x0F;
- }
-
- unifi_trace(priv, UDBG5, "Received 0x%.4X, seq: (r:%d, s:%d)\n",
- pcli->wake_up_wq_id,
- pcli->wake_seq_no, sent_seq_no);
-
- /* The two sequence ids must match. */
- if (pcli->wake_seq_no == sent_seq_no) {
- /* and the signal ids must match. */
- if (sig_reply_id == pcli->wake_up_wq_id) {
- /* Found the expected signal */
- break;
- } else {
- /* This should never happen ... */
- unifi_error(priv, "mlme_wait: mismatching signal id (0x%.4X - exp 0x%.4X) (seq %d)\n",
- pcli->wake_up_wq_id,
- sig_reply_id,
- pcli->wake_seq_no);
- pcli->wake_up_wq_id = 0;
- return -EIO;
- }
- }
- /* Wait for the next signal. */
- pcli->wake_up_wq_id = 0;
-
- retries ++;
- if (retries >= 3) {
- unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n",
- pcli->wake_up_wq_id,
- sig_reply_id);
- pcli->wake_up_wq_id = 0;
- return -EIO;
- }
- }
- } while (1);
-
- pcli->wake_up_wq_id = 0;
-
- return 0;
+ int retries = 0;
+ long r;
+ long t = timeout;
+ unsigned int sent_seq_no;
+
+ /* Convert t in ms to jiffies */
+ t = msecs_to_jiffies(t);
+
+ do {
+ /* Wait for the confirm or timeout. */
+ r = wait_event_interruptible_timeout(pcli->udi_wq,
+ (pcli->wake_up_wq_id) || (priv->io_aborted == 1),
+ t);
+ /* Check for general i/o error */
+ if (priv->io_aborted) {
+ unifi_error(priv, "MLME operation aborted\n");
+ return -EIO;
+ }
+
+ /*
+ * If r=0 the request has timed-out.
+ * If r>0 the request has completed successfully.
+ * If r=-ERESTARTSYS an event (kill signal) has interrupted the wait_event.
+ */
+ if ((r == 0) && (pcli->wake_up_wq_id == 0)) {
+ unifi_error(priv, "mlme_wait: timed-out waiting for 0x%.4X, after %lu msec.\n",
+ sig_reply_id, jiffies_to_msecs(t));
+ pcli->wake_up_wq_id = 0;
+ return -ETIMEDOUT;
+ } else if (r == -ERESTARTSYS) {
+ unifi_error(priv, "mlme_wait: waiting for 0x%.4X was aborted.\n", sig_reply_id);
+ pcli->wake_up_wq_id = 0;
+ return -EINTR;
+ } else {
+ /* Get the sequence number of the signal that we previously set. */
+ if (pcli->seq_no != 0) {
+ sent_seq_no = pcli->seq_no - 1;
+ } else {
+ sent_seq_no = 0x0F;
+ }
+
+ unifi_trace(priv, UDBG5, "Received 0x%.4X, seq: (r:%d, s:%d)\n",
+ pcli->wake_up_wq_id,
+ pcli->wake_seq_no, sent_seq_no);
+
+ /* The two sequence ids must match. */
+ if (pcli->wake_seq_no == sent_seq_no) {
+ /* and the signal ids must match. */
+ if (sig_reply_id == pcli->wake_up_wq_id) {
+ /* Found the expected signal */
+ break;
+ } else {
+ /* This should never happen ... */
+ unifi_error(priv, "mlme_wait: mismatching signal id (0x%.4X - exp 0x%.4X) (seq %d)\n",
+ pcli->wake_up_wq_id,
+ sig_reply_id,
+ pcli->wake_seq_no);
+ pcli->wake_up_wq_id = 0;
+ return -EIO;
+ }
+ }
+ /* Wait for the next signal. */
+ pcli->wake_up_wq_id = 0;
+
+ retries ++;
+ if (retries >= 3) {
+ unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n",
+ pcli->wake_up_wq_id,
+ sig_reply_id);
+ pcli->wake_up_wq_id = 0;
+ return -EIO;
+ }
+ }
+ } while (1);
+
+ pcli->wake_up_wq_id = 0;
+
+ return 0;
} /* unifi_mlme_wait_for_reply() */
@@ -134,73 +134,73 @@ unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_i
* ---------------------------------------------------------------------------
* unifi_mlme_blocking_request
*
- * Send a MLME request signal to UniFi.
+ * Send a MLME request signal to UniFi.
*
* Arguments:
- * priv Pointer to device private context struct
- * pcli Pointer to context of calling process
- * sig Pointer to the signal to send
- * data_ptrs Pointer to the bulk data of the signal
- * timeout The request's timeout.
+ * priv Pointer to device private context struct
+ * pcli Pointer to context of calling process
+ * sig Pointer to the signal to send
+ * data_ptrs Pointer to the bulk data of the signal
+ * timeout The request's timeout.
*
* Returns:
- * 0 on success, 802.11 result code on error.
+ * 0 on success, 802.11 result code on error.
* ---------------------------------------------------------------------------
*/
int
unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
- CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
- int timeout)
+ CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
+ int timeout)
{
- int r;
-
- func_enter();
-
- if (sig->SignalPrimitiveHeader.SignalId == 0) {
- unifi_error(priv, "unifi_mlme_blocking_request: Invalid Signal Id (0x%x)\n",
- sig->SignalPrimitiveHeader.SignalId);
- return -EINVAL;
- }
-
- down(&priv->mlme_blocking_mutex);
-
- sig->SignalPrimitiveHeader.ReceiverProcessId = 0;
- sig->SignalPrimitiveHeader.SenderProcessId = pcli->sender_id | pcli->seq_no;
-
- unifi_trace(priv, UDBG2, "Send client=%d, S:0x%04X, sig 0x%.4X\n",
- pcli->client_id,
- sig->SignalPrimitiveHeader.SenderProcessId,
- sig->SignalPrimitiveHeader.SignalId);
- /* Send the signal to UniFi */
- r = ul_send_signal_unpacked(priv, sig, data_ptrs);
- if (r) {
- up(&priv->mlme_blocking_mutex);
- unifi_error(priv, "Error queueing MLME REQUEST signal\n");
- return r;
- }
-
- unifi_trace(priv, UDBG5, "Send 0x%.4X, seq = %d\n",
- sig->SignalPrimitiveHeader.SignalId, pcli->seq_no);
-
- /*
- * Advance the sequence number of the last sent signal, only
- * if the signal has been successfully set.
- */
- pcli->seq_no++;
- if (pcli->seq_no > 0x0F) {
- pcli->seq_no = 0;
- }
-
- r = unifi_mlme_wait_for_reply(priv, pcli, (sig->SignalPrimitiveHeader.SignalId + 1), timeout);
- up(&priv->mlme_blocking_mutex);
-
- if (r) {
- unifi_error(priv, "Error waiting for MLME CONFIRM signal\n");
- return r;
- }
-
- func_exit();
- return 0;
+ int r;
+
+ func_enter();
+
+ if (sig->SignalPrimitiveHeader.SignalId == 0) {
+ unifi_error(priv, "unifi_mlme_blocking_request: Invalid Signal Id (0x%x)\n",
+ sig->SignalPrimitiveHeader.SignalId);
+ return -EINVAL;
+ }
+
+ down(&priv->mlme_blocking_mutex);
+
+ sig->SignalPrimitiveHeader.ReceiverProcessId = 0;
+ sig->SignalPrimitiveHeader.SenderProcessId = pcli->sender_id | pcli->seq_no;
+
+ unifi_trace(priv, UDBG2, "Send client=%d, S:0x%04X, sig 0x%.4X\n",
+ pcli->client_id,
+ sig->SignalPrimitiveHeader.SenderProcessId,
+ sig->SignalPrimitiveHeader.SignalId);
+ /* Send the signal to UniFi */
+ r = ul_send_signal_unpacked(priv, sig, data_ptrs);
+ if (r) {
+ up(&priv->mlme_blocking_mutex);
+ unifi_error(priv, "Error queueing MLME REQUEST signal\n");
+ return r;
+ }
+
+ unifi_trace(priv, UDBG5, "Send 0x%.4X, seq = %d\n",
+ sig->SignalPrimitiveHeader.SignalId, pcli->seq_no);
+
+ /*
+ * Advance the sequence number of the last sent signal, only
+ * if the signal has been successfully set.
+ */
+ pcli->seq_no++;
+ if (pcli->seq_no > 0x0F) {
+ pcli->seq_no = 0;
+ }
+
+ r = unifi_mlme_wait_for_reply(priv, pcli, (sig->SignalPrimitiveHeader.SignalId + 1), timeout);
+ up(&priv->mlme_blocking_mutex);
+
+ if (r) {
+ unifi_error(priv, "Error waiting for MLME CONFIRM signal\n");
+ return r;
+ }
+
+ func_exit();
+ return 0;
} /* unifi_mlme_blocking_request() */
@@ -208,44 +208,44 @@ unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
* ---------------------------------------------------------------------------
* unifi_mlme_copy_reply_and_wakeup_client
*
- * Copy the reply signal from UniFi to the client's structure
- * and wake up the waiting client.
+ * Copy the reply signal from UniFi to the client's structure
+ * and wake up the waiting client.
*
* Arguments:
- * None.
+ * None.
*
* Returns:
- * None.
+ * None.
* ---------------------------------------------------------------------------
*/
void
unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
- CSR_SIGNAL *signal, int signal_len,
- const bulk_data_param_t *bulkdata)
+ CSR_SIGNAL *signal, int signal_len,
+ const bulk_data_param_t *bulkdata)
{
- int i;
-
- /* Copy the signal to the reply */
- memcpy(pcli->reply_signal, signal, signal_len);
-
- /* Get the sequence number of the signal that woke us up. */
- pcli->wake_seq_no = pcli->reply_signal->SignalPrimitiveHeader.ReceiverProcessId & 0x0F;
-
- /* Append any bulk data */
- for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
- if (bulkdata->d[i].data_length > 0) {
- if (bulkdata->d[i].os_data_ptr) {
- memcpy(pcli->reply_bulkdata[i]->ptr, bulkdata->d[i].os_data_ptr, bulkdata->d[i].data_length);
- pcli->reply_bulkdata[i]->length = bulkdata->d[i].data_length;
- } else {
- pcli->reply_bulkdata[i]->length = 0;
- }
- }
- }
-
- /* Wake the requesting MLME function. */
- pcli->wake_up_wq_id = pcli->reply_signal->SignalPrimitiveHeader.SignalId;
- wake_up_interruptible(&pcli->udi_wq);
+ int i;
+
+ /* Copy the signal to the reply */
+ memcpy(pcli->reply_signal, signal, signal_len);
+
+ /* Get the sequence number of the signal that woke us up. */
+ pcli->wake_seq_no = pcli->reply_signal->SignalPrimitiveHeader.ReceiverProcessId & 0x0F;
+
+ /* Append any bulk data */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ if (bulkdata->d[i].data_length > 0) {
+ if (bulkdata->d[i].os_data_ptr) {
+ memcpy(pcli->reply_bulkdata[i]->ptr, bulkdata->d[i].os_data_ptr, bulkdata->d[i].data_length);
+ pcli->reply_bulkdata[i]->length = bulkdata->d[i].data_length;
+ } else {
+ pcli->reply_bulkdata[i]->length = 0;
+ }
+ }
+ }
+
+ /* Wake the requesting MLME function. */
+ pcli->wake_up_wq_id = pcli->reply_signal->SignalPrimitiveHeader.SignalId;
+ wake_up_interruptible(&pcli->udi_wq);
} /* unifi_mlme_copy_reply_and_wakeup_client() */
@@ -254,35 +254,35 @@ unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
* ---------------------------------------------------------------------------
* uf_abort_mlme
*
- * Abort any MLME operation in progress.
- * This is used in the error recovery mechanism.
+ * Abort any MLME operation in progress.
+ * This is used in the error recovery mechanism.
*
* Arguments:
- * priv Pointer to driver context.
+ * priv Pointer to driver context.
*
* Returns:
- * 0 on success.
+ * 0 on success.
* ---------------------------------------------------------------------------
*/
int
uf_abort_mlme(unifi_priv_t *priv)
{
- ul_client_t *ul_cli;
+ ul_client_t *ul_cli;
- /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
- priv->io_aborted = 1;
+ /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
+ priv->io_aborted = 1;
- ul_cli = priv->netdev_client;
- if (ul_cli) {
- wake_up_interruptible(&ul_cli->udi_wq);
- }
+ ul_cli = priv->netdev_client;
+ if (ul_cli) {
+ wake_up_interruptible(&ul_cli->udi_wq);
+ }
- ul_cli = priv->wext_client;
- if (ul_cli) {
- wake_up_interruptible(&ul_cli->udi_wq);
- }
+ ul_cli = priv->wext_client;
+ if (ul_cli) {
+ wake_up_interruptible(&ul_cli->udi_wq);
+ }
- return 0;
+ return 0;
} /* uf_abort_mlme() */
@@ -290,118 +290,118 @@ uf_abort_mlme(unifi_priv_t *priv)
/*
* ---------------------------------------------------------------------------
*
- * Human-readable decoding of Reason and Result codes.
+ * Human-readable decoding of Reason and Result codes.
*
* ---------------------------------------------------------------------------
*/
struct mlme_code {
- const char *name;
- int id;
+ const char *name;
+ int id;
};
static const struct mlme_code Result_codes[] = {
- { "Success", 0x0000 },
- { "Unspecified Failure", 0x0001 },
- /* (Reserved) 0x0002 - 0x0009 */
- { "Refused Capabilities Mismatch", 0x000A },
- /* (Reserved) 0x000B */
- { "Refused External Reason", 0x000C },
- /* (Reserved) 0x000D - 0x0010 */
- { "Refused AP Out Of Memory", 0x0011 },
- { "Refused Basic Rates Mismatch", 0x0012 },
- /* (Reserved) 0x0013 - 0x001F */
- { "Failure", 0x0020 },
- /* (Reserved) 0x0021 - 0x0024 */
- { "Refused Reason Unspecified", 0x0025 },
- { "Invalid Parameters", 0x0026 },
- { "Rejected With Suggested Changes", 0x0027 },
- /* (Reserved) 0x0028 - 0x002E */
- { "Rejected For Delay Period", 0x002F },
- { "Not Allowed", 0x0030 },
- { "Not Present", 0x0031 },
- { "Not QSTA", 0x0032 },
- /* (Reserved) 0x0033 - 0x7FFF */
- { "Timeout", 0x8000 },
- { "Too Many Simultaneous Requests", 0x8001 },
- { "BSS Already Started Or Joined", 0x8002 },
- { "Not Supported", 0x8003 },
- { "Transmission Failure", 0x8004 },
- { "Refused Not Authenticated", 0x8005 },
- { "Reset Required Before Start", 0x8006 },
- { "LM Info Unavailable", 0x8007 },
- { NULL, -1 }
+ { "Success", 0x0000 },
+ { "Unspecified Failure", 0x0001 },
+ /* (Reserved) 0x0002 - 0x0009 */
+ { "Refused Capabilities Mismatch", 0x000A },
+ /* (Reserved) 0x000B */
+ { "Refused External Reason", 0x000C },
+ /* (Reserved) 0x000D - 0x0010 */
+ { "Refused AP Out Of Memory", 0x0011 },
+ { "Refused Basic Rates Mismatch", 0x0012 },
+ /* (Reserved) 0x0013 - 0x001F */
+ { "Failure", 0x0020 },
+ /* (Reserved) 0x0021 - 0x0024 */
+ { "Refused Reason Unspecified", 0x0025 },
+ { "Invalid Parameters", 0x0026 },
+ { "Rejected With Suggested Changes", 0x0027 },
+ /* (Reserved) 0x0028 - 0x002E */
+ { "Rejected For Delay Period", 0x002F },
+ { "Not Allowed", 0x0030 },
+ { "Not Present", 0x0031 },
+ { "Not QSTA", 0x0032 },
+ /* (Reserved) 0x0033 - 0x7FFF */
+ { "Timeout", 0x8000 },
+ { "Too Many Simultaneous Requests", 0x8001 },
+ { "BSS Already Started Or Joined", 0x8002 },
+ { "Not Supported", 0x8003 },
+ { "Transmission Failure", 0x8004 },
+ { "Refused Not Authenticated", 0x8005 },
+ { "Reset Required Before Start", 0x8006 },
+ { "LM Info Unavailable", 0x8007 },
+ { NULL, -1 }
};
static const struct mlme_code Reason_codes[] = {
- /* (Reserved) 0x0000 */
- { "Unspecified Reason", 0x0001 },
- { "Authentication Not Valid", 0x0002 },
- { "Deauthenticated Leave BSS", 0x0003 },
- { "Disassociated Inactivity", 0x0004 },
- { "AP Overload", 0x0005 },
- { "Class2 Frame Error", 0x0006 },
- { "Class3 Frame Error", 0x0007 },
- { "Disassociated Leave BSS", 0x0008 },
- { "Association Not Authenticated", 0x0009 },
- { "Disassociated Power Capability", 0x000A },
- { "Disassociated Supported Channels", 0x000B },
- /* (Reserved) 0x000C */
- { "Invalid Information Element", 0x000D },
- { "Michael MIC Failure", 0x000E },
- { "Fourway Handshake Timeout", 0x000F },
- { "Group Key Update Timeout", 0x0010 },
- { "Handshake Element Different", 0x0011 },
- { "Invalid Group Cipher", 0x0012 },
- { "Invalid Pairwise Cipher", 0x0013 },
- { "Invalid AKMP", 0x0014 },
- { "Unsupported RSN IE Version", 0x0015 },
- { "Invalid RSN IE Capabilities", 0x0016 },
- { "Dot1X Auth Failed", 0x0017 },
- { "Cipher Rejected By Policy", 0x0018 },
- /* (Reserved) 0x0019 - 0x001F */
- { "QoS Unspecified Reason", 0x0020 },
- { "QoS Insufficient Bandwidth", 0x0021 },
- { "QoS Excessive Not Ack", 0x0022 },
- { "QoS TXOP Limit Exceeded", 0x0023 },
- { "QSTA Leaving", 0x0024 },
- { "End TS, End DLS, End BA", 0x0025 },
- { "Unknown TS, Unknown DLS, Unknown BA", 0x0026 },
- { "Timeout", 0x0027 },
- /* (Reserved) 0x0028 - 0x002C */
- { "STAKey Mismatch", 0x002D },
- { NULL, -1 }
+ /* (Reserved) 0x0000 */
+ { "Unspecified Reason", 0x0001 },
+ { "Authentication Not Valid", 0x0002 },
+ { "Deauthenticated Leave BSS", 0x0003 },
+ { "Disassociated Inactivity", 0x0004 },
+ { "AP Overload", 0x0005 },
+ { "Class2 Frame Error", 0x0006 },
+ { "Class3 Frame Error", 0x0007 },
+ { "Disassociated Leave BSS", 0x0008 },
+ { "Association Not Authenticated", 0x0009 },
+ { "Disassociated Power Capability", 0x000A },
+ { "Disassociated Supported Channels", 0x000B },
+ /* (Reserved) 0x000C */
+ { "Invalid Information Element", 0x000D },
+ { "Michael MIC Failure", 0x000E },
+ { "Fourway Handshake Timeout", 0x000F },
+ { "Group Key Update Timeout", 0x0010 },
+ { "Handshake Element Different", 0x0011 },
+ { "Invalid Group Cipher", 0x0012 },
+ { "Invalid Pairwise Cipher", 0x0013 },
+ { "Invalid AKMP", 0x0014 },
+ { "Unsupported RSN IE Version", 0x0015 },
+ { "Invalid RSN IE Capabilities", 0x0016 },
+ { "Dot1X Auth Failed", 0x0017 },
+ { "Cipher Rejected By Policy", 0x0018 },
+ /* (Reserved) 0x0019 - 0x001F */
+ { "QoS Unspecified Reason", 0x0020 },
+ { "QoS Insufficient Bandwidth", 0x0021 },
+ { "QoS Excessive Not Ack", 0x0022 },
+ { "QoS TXOP Limit Exceeded", 0x0023 },
+ { "QSTA Leaving", 0x0024 },
+ { "End TS, End DLS, End BA", 0x0025 },
+ { "Unknown TS, Unknown DLS, Unknown BA", 0x0026 },
+ { "Timeout", 0x0027 },
+ /* (Reserved) 0x0028 - 0x002C */
+ { "STAKey Mismatch", 0x002D },
+ { NULL, -1 }
};
static const char *
lookup_something(const struct mlme_code *n, int id)
{
- for (; n->name; n++) {
- if (n->id == id) {
- return n->name;
- }
- }
-
- /* not found */
- return NULL;
+ for (; n->name; n++) {
+ if (n->id == id) {
+ return n->name;
+ }
+ }
+
+ /* not found */
+ return NULL;
} /* lookup_something() */
const char *
lookup_result_code(int result)
{
- static char fallback[16];
- const char *str;
+ static char fallback[16];
+ const char *str;
- str = lookup_something(Result_codes, result);
+ str = lookup_something(Result_codes, result);
- if (str == NULL) {
- snprintf(fallback, 16, "%d", result);
- str = fallback;
- }
+ if (str == NULL) {
+ snprintf(fallback, 16, "%d", result);
+ str = fallback;
+ }
- return str;
+ return str;
} /* lookup_result_code() */
@@ -409,28 +409,28 @@ lookup_result_code(int result)
* ---------------------------------------------------------------------------
* lookup_reason
*
- * Return a description string for a WiFi MLME ReasonCode.
+ * Return a description string for a WiFi MLME ReasonCode.
*
* Arguments:
- * reason The ReasonCode to interpret.
+ * reason The ReasonCode to interpret.
*
* Returns:
- * Pointer to description string.
+ * Pointer to description string.
* ---------------------------------------------------------------------------
*/
const char *
lookup_reason_code(int reason)
{
- static char fallback[16];
- const char *str;
+ static char fallback[16];
+ const char *str;
- str = lookup_something(Reason_codes, reason);
+ str = lookup_something(Reason_codes, reason);
- if (str == NULL) {
- snprintf(fallback, 16, "%d", reason);
- str = fallback;
- }
+ if (str == NULL) {
+ snprintf(fallback, 16, "%d", reason);
+ str = fallback;
+ }
- return str;
+ return str;
} /* lookup_reason_code() */
--
1.7.9.5
Writing code as foo ++; is a coding style ERROR, so I modifed the code
to foo++;.
Signed-off-by: Sangho Yi <[email protected]>
---
drivers/staging/csr/mlme.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c
index e4ecdd8..25b2d1d 100644
--- a/drivers/staging/csr/mlme.c
+++ b/drivers/staging/csr/mlme.c
@@ -118,7 +118,7 @@ unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli,
/* Wait for the next signal. */
pcli->wake_up_wq_id = 0;
- retries ++;
+ retries++;
if (retries >= 3) {
unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n",
pcli->wake_up_wq_id, sig_reply_id);
--
1.7.9.5
Yes, just removed the single line covering braces from the for() and
if(), and the corresponding else statements on mlme.c.
Signed-off-by: Sangho Yi <[email protected]>
---
drivers/staging/csr/mlme.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c
index dba12b2..e4ecdd8 100644
--- a/drivers/staging/csr/mlme.c
+++ b/drivers/staging/csr/mlme.c
@@ -89,11 +89,10 @@ unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli,
} else {
/* Get the sequence number of the signal
* that we previously set. */
- if (pcli->seq_no != 0) {
+ if (pcli->seq_no != 0)
sent_seq_no = pcli->seq_no - 1;
- } else {
+ else
sent_seq_no = 0x0F;
- }
unifi_trace(priv, UDBG5,
"Received 0x%.4X, seq: (r:%d, s:%d)\n",
@@ -193,9 +192,8 @@ unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
* if the signal has been successfully set.
*/
pcli->seq_no++;
- if (pcli->seq_no > 0x0F) {
+ if (pcli->seq_no > 0x0F)
pcli->seq_no = 0;
- }
r = unifi_mlme_wait_for_reply(priv, pcli,
(sig->SignalPrimitiveHeader.SignalId + 1), timeout);
@@ -287,14 +285,12 @@ uf_abort_mlme(unifi_priv_t *priv)
priv->io_aborted = 1;
ul_cli = priv->netdev_client;
- if (ul_cli) {
+ if (ul_cli)
wake_up_interruptible(&ul_cli->udi_wq);
- }
ul_cli = priv->wext_client;
- if (ul_cli) {
+ if (ul_cli)
wake_up_interruptible(&ul_cli->udi_wq);
- }
return 0;
} /* uf_abort_mlme() */
@@ -391,11 +387,9 @@ static const struct mlme_code Reason_codes[] = {
static const char *
lookup_something(const struct mlme_code *n, int id)
{
- for (; n->name; n++) {
- if (n->id == id) {
+ for (; n->name; n++)
+ if (n->id == id)
return n->name;
- }
- }
/* not found */
return NULL;
--
1.7.9.5
Fixed most of the exceeding 80 chars on mlme.c
Signed-off-by: Sangho Yi <[email protected]>
---
drivers/staging/csr/mlme.c | 200 ++++++++++++++++++++++++--------------------
1 file changed, 107 insertions(+), 93 deletions(-)
diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c
index a16841f..dba12b2 100644
--- a/drivers/staging/csr/mlme.c
+++ b/drivers/staging/csr/mlme.c
@@ -37,7 +37,8 @@
* These two number match be equal.
* Should only be used for waiting xxx.cfm signals and only after
* we have sent the matching xxx.req signal to UniFi.
- * If no response is received within the expected time (timeout), we assume
+ * If no response is received within the expected time (timeout),
+ * we assume
* that the UniFi is busy and return an error.
* If the wait is aborted by a kernel signal arriving, we stop waiting.
* If a response from UniFi is not what we expected, we discard it and
@@ -47,7 +48,8 @@
* ---------------------------------------------------------------------------
*/
static int
-unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_id, int timeout)
+unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli,
+ int sig_reply_id, int timeout)
{
int retries = 0;
long r;
@@ -60,8 +62,7 @@ unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_i
do {
/* Wait for the confirm or timeout. */
r = wait_event_interruptible_timeout(pcli->udi_wq,
- (pcli->wake_up_wq_id) || (priv->io_aborted == 1),
- t);
+ (pcli->wake_up_wq_id) || (priv->io_aborted == 1), t);
/* Check for general i/o error */
if (priv->io_aborted) {
unifi_error(priv, "MLME operation aborted\n");
@@ -71,28 +72,33 @@ unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_i
/*
* If r=0 the request has timed-out.
* If r>0 the request has completed successfully.
- * If r=-ERESTARTSYS an event (kill signal) has interrupted the wait_event.
+ * If r=-ERESTARTSYS an event (kill signal)
+ * has interrupted the wait_event.
*/
if ((r == 0) && (pcli->wake_up_wq_id == 0)) {
unifi_error(priv, "mlme_wait: timed-out waiting for 0x%.4X, after %lu msec.\n",
- sig_reply_id, jiffies_to_msecs(t));
+ sig_reply_id, jiffies_to_msecs(t));
pcli->wake_up_wq_id = 0;
return -ETIMEDOUT;
} else if (r == -ERESTARTSYS) {
- unifi_error(priv, "mlme_wait: waiting for 0x%.4X was aborted.\n", sig_reply_id);
+ unifi_error(priv,
+ "mlme_wait: waiting for 0x%.4X was aborted.\n",
+ sig_reply_id);
pcli->wake_up_wq_id = 0;
return -EINTR;
} else {
- /* Get the sequence number of the signal that we previously set. */
+ /* Get the sequence number of the signal
+ * that we previously set. */
if (pcli->seq_no != 0) {
sent_seq_no = pcli->seq_no - 1;
} else {
sent_seq_no = 0x0F;
}
- unifi_trace(priv, UDBG5, "Received 0x%.4X, seq: (r:%d, s:%d)\n",
- pcli->wake_up_wq_id,
- pcli->wake_seq_no, sent_seq_no);
+ unifi_trace(priv, UDBG5,
+ "Received 0x%.4X, seq: (r:%d, s:%d)\n",
+ pcli->wake_up_wq_id,
+ pcli->wake_seq_no, sent_seq_no);
/* The two sequence ids must match. */
if (pcli->wake_seq_no == sent_seq_no) {
@@ -103,9 +109,9 @@ unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_i
} else {
/* This should never happen ... */
unifi_error(priv, "mlme_wait: mismatching signal id (0x%.4X - exp 0x%.4X) (seq %d)\n",
- pcli->wake_up_wq_id,
- sig_reply_id,
- pcli->wake_seq_no);
+ pcli->wake_up_wq_id,
+ sig_reply_id,
+ pcli->wake_seq_no);
pcli->wake_up_wq_id = 0;
return -EIO;
}
@@ -116,8 +122,7 @@ unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_i
retries ++;
if (retries >= 3) {
unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n",
- pcli->wake_up_wq_id,
- sig_reply_id);
+ pcli->wake_up_wq_id, sig_reply_id);
pcli->wake_up_wq_id = 0;
return -EIO;
}
@@ -149,23 +154,24 @@ unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_i
*/
int
unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
- CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
- int timeout)
+ CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs, int timeout)
{
int r;
func_enter();
if (sig->SignalPrimitiveHeader.SignalId == 0) {
- unifi_error(priv, "unifi_mlme_blocking_request: Invalid Signal Id (0x%x)\n",
- sig->SignalPrimitiveHeader.SignalId);
+ unifi_error(priv,
+ "unifi_mlme_blocking_request: Invalid Signal Id (0x%x)\n",
+ sig->SignalPrimitiveHeader.SignalId);
return -EINVAL;
}
down(&priv->mlme_blocking_mutex);
sig->SignalPrimitiveHeader.ReceiverProcessId = 0;
- sig->SignalPrimitiveHeader.SenderProcessId = pcli->sender_id | pcli->seq_no;
+ sig->SignalPrimitiveHeader.SenderProcessId =
+ pcli->sender_id | pcli->seq_no;
unifi_trace(priv, UDBG2, "Send client=%d, S:0x%04X, sig 0x%.4X\n",
pcli->client_id,
@@ -180,7 +186,7 @@ unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
}
unifi_trace(priv, UDBG5, "Send 0x%.4X, seq = %d\n",
- sig->SignalPrimitiveHeader.SignalId, pcli->seq_no);
+ sig->SignalPrimitiveHeader.SignalId, pcli->seq_no);
/*
* Advance the sequence number of the last sent signal, only
@@ -191,7 +197,8 @@ unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
pcli->seq_no = 0;
}
- r = unifi_mlme_wait_for_reply(priv, pcli, (sig->SignalPrimitiveHeader.SignalId + 1), timeout);
+ r = unifi_mlme_wait_for_reply(priv, pcli,
+ (sig->SignalPrimitiveHeader.SignalId + 1), timeout);
up(&priv->mlme_blocking_mutex);
if (r) {
@@ -220,8 +227,8 @@ unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
*/
void
unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
- CSR_SIGNAL *signal, int signal_len,
- const bulk_data_param_t *bulkdata)
+ CSR_SIGNAL *signal, int signal_len,
+ const bulk_data_param_t *bulkdata)
{
int i;
@@ -229,14 +236,19 @@ unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
memcpy(pcli->reply_signal, signal, signal_len);
/* Get the sequence number of the signal that woke us up. */
- pcli->wake_seq_no = pcli->reply_signal->SignalPrimitiveHeader.ReceiverProcessId & 0x0F;
+ pcli->wake_seq_no =
+ pcli->reply_signal->SignalPrimitiveHeader.ReceiverProcessId
+ & 0x0F;
/* Append any bulk data */
for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
if (bulkdata->d[i].data_length > 0) {
if (bulkdata->d[i].os_data_ptr) {
- memcpy(pcli->reply_bulkdata[i]->ptr, bulkdata->d[i].os_data_ptr, bulkdata->d[i].data_length);
- pcli->reply_bulkdata[i]->length = bulkdata->d[i].data_length;
+ memcpy(pcli->reply_bulkdata[i]->ptr,
+ bulkdata->d[i].os_data_ptr,
+ bulkdata->d[i].data_length);
+ pcli->reply_bulkdata[i]->length =
+ bulkdata->d[i].data_length;
} else {
pcli->reply_bulkdata[i]->length = 0;
}
@@ -244,7 +256,8 @@ unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
}
/* Wake the requesting MLME function. */
- pcli->wake_up_wq_id = pcli->reply_signal->SignalPrimitiveHeader.SignalId;
+ pcli->wake_up_wq_id =
+ pcli->reply_signal->SignalPrimitiveHeader.SignalId;
wake_up_interruptible(&pcli->udi_wq);
} /* unifi_mlme_copy_reply_and_wakeup_client() */
@@ -269,7 +282,8 @@ uf_abort_mlme(unifi_priv_t *priv)
{
ul_client_t *ul_cli;
- /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
+ /* Ensure no MLME functions are waiting on
+ * a the mlme_event semaphore. */
priv->io_aborted = 1;
ul_cli = priv->netdev_client;
@@ -301,75 +315,75 @@ struct mlme_code {
};
static const struct mlme_code Result_codes[] = {
- { "Success", 0x0000 },
- { "Unspecified Failure", 0x0001 },
- /* (Reserved) 0x0002 - 0x0009 */
- { "Refused Capabilities Mismatch", 0x000A },
- /* (Reserved) 0x000B */
- { "Refused External Reason", 0x000C },
- /* (Reserved) 0x000D - 0x0010 */
- { "Refused AP Out Of Memory", 0x0011 },
- { "Refused Basic Rates Mismatch", 0x0012 },
- /* (Reserved) 0x0013 - 0x001F */
- { "Failure", 0x0020 },
- /* (Reserved) 0x0021 - 0x0024 */
- { "Refused Reason Unspecified", 0x0025 },
- { "Invalid Parameters", 0x0026 },
- { "Rejected With Suggested Changes", 0x0027 },
- /* (Reserved) 0x0028 - 0x002E */
- { "Rejected For Delay Period", 0x002F },
- { "Not Allowed", 0x0030 },
- { "Not Present", 0x0031 },
- { "Not QSTA", 0x0032 },
- /* (Reserved) 0x0033 - 0x7FFF */
- { "Timeout", 0x8000 },
- { "Too Many Simultaneous Requests", 0x8001 },
- { "BSS Already Started Or Joined", 0x8002 },
- { "Not Supported", 0x8003 },
- { "Transmission Failure", 0x8004 },
- { "Refused Not Authenticated", 0x8005 },
- { "Reset Required Before Start", 0x8006 },
- { "LM Info Unavailable", 0x8007 },
+ { "Success", 0x0000 },
+ { "Unspecified Failure", 0x0001 },
+ /* (Reserved) 0x0002 - 0x0009 */
+ { "Refused Capabilities Mismatch", 0x000A },
+ /* (Reserved) 0x000B */
+ { "Refused External Reason", 0x000C },
+ /* (Reserved) 0x000D - 0x0010 */
+ { "Refused AP Out Of Memory", 0x0011 },
+ { "Refused Basic Rates Mismatch", 0x0012 },
+ /* (Reserved) 0x0013 - 0x001F */
+ { "Failure", 0x0020 },
+ /* (Reserved) 0x0021 - 0x0024 */
+ { "Refused Reason Unspecified", 0x0025 },
+ { "Invalid Parameters", 0x0026 },
+ { "Rejected With Suggested Changes", 0x0027 },
+ /* (Reserved) 0x0028 - 0x002E */
+ { "Rejected For Delay Period", 0x002F },
+ { "Not Allowed", 0x0030 },
+ { "Not Present", 0x0031 },
+ { "Not QSTA", 0x0032 },
+ /* (Reserved) 0x0033 - 0x7FFF */
+ { "Timeout", 0x8000 },
+ { "Too Many Simultaneous Requests", 0x8001 },
+ { "BSS Already Started Or Joined", 0x8002 },
+ { "Not Supported", 0x8003 },
+ { "Transmission Failure", 0x8004 },
+ { "Refused Not Authenticated", 0x8005 },
+ { "Reset Required Before Start", 0x8006 },
+ { "LM Info Unavailable", 0x8007 },
{ NULL, -1 }
};
static const struct mlme_code Reason_codes[] = {
- /* (Reserved) 0x0000 */
- { "Unspecified Reason", 0x0001 },
- { "Authentication Not Valid", 0x0002 },
- { "Deauthenticated Leave BSS", 0x0003 },
- { "Disassociated Inactivity", 0x0004 },
- { "AP Overload", 0x0005 },
- { "Class2 Frame Error", 0x0006 },
- { "Class3 Frame Error", 0x0007 },
- { "Disassociated Leave BSS", 0x0008 },
- { "Association Not Authenticated", 0x0009 },
- { "Disassociated Power Capability", 0x000A },
+ /* (Reserved) 0x0000 */
+ { "Unspecified Reason", 0x0001 },
+ { "Authentication Not Valid", 0x0002 },
+ { "Deauthenticated Leave BSS", 0x0003 },
+ { "Disassociated Inactivity", 0x0004 },
+ { "AP Overload", 0x0005 },
+ { "Class2 Frame Error", 0x0006 },
+ { "Class3 Frame Error", 0x0007 },
+ { "Disassociated Leave BSS", 0x0008 },
+ { "Association Not Authenticated", 0x0009 },
+ { "Disassociated Power Capability", 0x000A },
{ "Disassociated Supported Channels", 0x000B },
- /* (Reserved) 0x000C */
- { "Invalid Information Element", 0x000D },
- { "Michael MIC Failure", 0x000E },
- { "Fourway Handshake Timeout", 0x000F },
- { "Group Key Update Timeout", 0x0010 },
- { "Handshake Element Different", 0x0011 },
- { "Invalid Group Cipher", 0x0012 },
- { "Invalid Pairwise Cipher", 0x0013 },
- { "Invalid AKMP", 0x0014 },
- { "Unsupported RSN IE Version", 0x0015 },
- { "Invalid RSN IE Capabilities", 0x0016 },
- { "Dot1X Auth Failed", 0x0017 },
- { "Cipher Rejected By Policy", 0x0018 },
- /* (Reserved) 0x0019 - 0x001F */
- { "QoS Unspecified Reason", 0x0020 },
- { "QoS Insufficient Bandwidth", 0x0021 },
- { "QoS Excessive Not Ack", 0x0022 },
- { "QoS TXOP Limit Exceeded", 0x0023 },
- { "QSTA Leaving", 0x0024 },
- { "End TS, End DLS, End BA", 0x0025 },
+ /* (Reserved) 0x000C */
+ { "Invalid Information Element", 0x000D },
+ { "Michael MIC Failure", 0x000E },
+ { "Fourway Handshake Timeout", 0x000F },
+ { "Group Key Update Timeout", 0x0010 },
+ { "Handshake Element Different", 0x0011 },
+ { "Invalid Group Cipher", 0x0012 },
+ { "Invalid Pairwise Cipher", 0x0013 },
+ { "Invalid AKMP", 0x0014 },
+ { "Unsupported RSN IE Version", 0x0015 },
+ { "Invalid RSN IE Capabilities", 0x0016 },
+ { "Dot1X Auth Failed", 0x0017 },
+ { "Cipher Rejected By Policy", 0x0018 },
+ /* (Reserved) 0x0019 - 0x001F */
+ { "QoS Unspecified Reason", 0x0020 },
+ { "QoS Insufficient Bandwidth", 0x0021 },
+ { "QoS Excessive Not Ack", 0x0022 },
+ { "QoS TXOP Limit Exceeded", 0x0023 },
+ { "QSTA Leaving", 0x0024 },
+ { "End TS, End DLS, End BA", 0x0025 },
{ "Unknown TS, Unknown DLS, Unknown BA", 0x0026 },
- { "Timeout", 0x0027 },
- /* (Reserved) 0x0028 - 0x002C */
- { "STAKey Mismatch", 0x002D },
+ { "Timeout", 0x0027 },
+ /* (Reserved) 0x0028 - 0x002C */
+ { "STAKey Mismatch", 0x002D },
{ NULL, -1 }
};
--
1.7.9.5
On Wed, Oct 17, 2012 at 01:36:45AM +0900, Sangho Yi wrote:
> There were all the 4 spaces indentation, so I fixed them using the tabs.
>
> Signed-off-by: Sangho Yi <[email protected]>
> ---
> drivers/staging/csr/mlme.c | 598 ++++++++++++++++++++++----------------------
> 1 file changed, 299 insertions(+), 299 deletions(-)
>
> diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c
> index ed767ec..a16841f 100644
> --- a/drivers/staging/csr/mlme.c
> +++ b/drivers/staging/csr/mlme.c
> @@ -1,9 +1,9 @@
> /*
> * ---------------------------------------------------------------------------
> - * FILE: mlme.c
> + * FILE: mlme.c
> *
> * PURPOSE:
> - * This file provides functions to send MLME requests to the UniFi.
> + * This file provides functions to send MLME requests to the UniFi.
> *
> * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
> *
> @@ -19,114 +19,114 @@
> * ---------------------------------------------------------------------------
> * unifi_mlme_wait_for_reply
> *
> - * Wait for a reply after sending a signal.
> + * Wait for a reply after sending a signal.
> *
> * Arguments:
> - * priv Pointer to device private context struct
> - * ul_client Pointer to linux client
> - * sig_reply_id ID of the expected reply (defined in sigs.h).
> - * timeout timeout in ms
> + * priv Pointer to device private context struct
> + * ul_client Pointer to linux client
> + * sig_reply_id ID of the expected reply (defined in sigs.h).
> + * timeout timeout in ms
> *
> * Returns:
> - * 0 on success, -ve POSIX code on error.
> + * 0 on success, -ve POSIX code on error.
> *
> * Notes:
> - * This function waits for a specific (sig_reply_id) signal from UniFi.
> - * It also match the sequence number of the received (cfm) signal, with
> - * the latest sequence number of the signal (req) we have sent.
> - * These two number match be equal.
> - * Should only be used for waiting xxx.cfm signals and only after
> - * we have sent the matching xxx.req signal to UniFi.
> - * If no response is received within the expected time (timeout), we assume
> - * that the UniFi is busy and return an error.
> - * If the wait is aborted by a kernel signal arriving, we stop waiting.
> - * If a response from UniFi is not what we expected, we discard it and
> - * wait again. This could be a response from an aborted request. If we
> - * see several bad responses we assume we have lost synchronisation with
> - * UniFi.
> + * This function waits for a specific (sig_reply_id) signal from UniFi.
> + * It also match the sequence number of the received (cfm) signal, with
> + * the latest sequence number of the signal (req) we have sent.
> + * These two number match be equal.
> + * Should only be used for waiting xxx.cfm signals and only after
> + * we have sent the matching xxx.req signal to UniFi.
> + * If no response is received within the expected time (timeout), we assume
> + * that the UniFi is busy and return an error.
> + * If the wait is aborted by a kernel signal arriving, we stop waiting.
> + * If a response from UniFi is not what we expected, we discard it and
> + * wait again. This could be a response from an aborted request. If we
> + * see several bad responses we assume we have lost synchronisation with
> + * UniFi.
> * ---------------------------------------------------------------------------
> */
> static int
> unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_id, int timeout)
> {
> - int retries = 0;
> - long r;
> - long t = timeout;
> - unsigned int sent_seq_no;
> -
> - /* Convert t in ms to jiffies */
> - t = msecs_to_jiffies(t);
> -
> - do {
> - /* Wait for the confirm or timeout. */
> - r = wait_event_interruptible_timeout(pcli->udi_wq,
> - (pcli->wake_up_wq_id) || (priv->io_aborted == 1),
> - t);
> - /* Check for general i/o error */
> - if (priv->io_aborted) {
> - unifi_error(priv, "MLME operation aborted\n");
> - return -EIO;
> - }
> -
> - /*
> - * If r=0 the request has timed-out.
> - * If r>0 the request has completed successfully.
> - * If r=-ERESTARTSYS an event (kill signal) has interrupted the wait_event.
> - */
> - if ((r == 0) && (pcli->wake_up_wq_id == 0)) {
> - unifi_error(priv, "mlme_wait: timed-out waiting for 0x%.4X, after %lu msec.\n",
> - sig_reply_id, jiffies_to_msecs(t));
> - pcli->wake_up_wq_id = 0;
> - return -ETIMEDOUT;
> - } else if (r == -ERESTARTSYS) {
> - unifi_error(priv, "mlme_wait: waiting for 0x%.4X was aborted.\n", sig_reply_id);
> - pcli->wake_up_wq_id = 0;
> - return -EINTR;
> - } else {
> - /* Get the sequence number of the signal that we previously set. */
> - if (pcli->seq_no != 0) {
> - sent_seq_no = pcli->seq_no - 1;
> - } else {
> - sent_seq_no = 0x0F;
> - }
> -
> - unifi_trace(priv, UDBG5, "Received 0x%.4X, seq: (r:%d, s:%d)\n",
> - pcli->wake_up_wq_id,
> - pcli->wake_seq_no, sent_seq_no);
> -
> - /* The two sequence ids must match. */
> - if (pcli->wake_seq_no == sent_seq_no) {
> - /* and the signal ids must match. */
> - if (sig_reply_id == pcli->wake_up_wq_id) {
> - /* Found the expected signal */
> - break;
> - } else {
> - /* This should never happen ... */
> - unifi_error(priv, "mlme_wait: mismatching signal id (0x%.4X - exp 0x%.4X) (seq %d)\n",
> - pcli->wake_up_wq_id,
> - sig_reply_id,
> - pcli->wake_seq_no);
> - pcli->wake_up_wq_id = 0;
> - return -EIO;
> - }
> - }
> - /* Wait for the next signal. */
> - pcli->wake_up_wq_id = 0;
> -
> - retries ++;
> - if (retries >= 3) {
> - unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n",
> - pcli->wake_up_wq_id,
> - sig_reply_id);
> - pcli->wake_up_wq_id = 0;
> - return -EIO;
> - }
> - }
> - } while (1);
> -
> - pcli->wake_up_wq_id = 0;
> -
> - return 0;
> + int retries = 0;
> + long r;
> + long t = timeout;
> + unsigned int sent_seq_no;
> +
> + /* Convert t in ms to jiffies */
> + t = msecs_to_jiffies(t);
> +
> + do {
> + /* Wait for the confirm or timeout. */
> + r = wait_event_interruptible_timeout(pcli->udi_wq,
> + (pcli->wake_up_wq_id) || (priv->io_aborted == 1),
> + t);
What happened there?
Please be smart about your cleanups, you have to do it by hand in
places.
Care to redo this series also and resend it?
thanks,
greg k-h