Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: chromeos/drivers/ath6kl/bmi/src/bmi.c

Issue 3579004: ath6kl: Bringing in the upstream version (Closed) Base URL: http://git.chromium.org/git/kernel.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/drivers/ath6kl/bmi/include/bmi_internal.h ('k') | chromeos/drivers/ath6kl/bmi/src/makefile » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/drivers/ath6kl/bmi/src/bmi.c
diff --git a/chromeos/drivers/ath6kl/bmi/src/bmi.c b/chromeos/drivers/ath6kl/bmi/src/bmi.c
index 0004508e8f09c03f98f6a6d26cc546a19e761555..f17f5636f5b212326d1d552450c21448a7aecba1 100644
--- a/chromeos/drivers/ath6kl/bmi/src/bmi.c
+++ b/chromeos/drivers/ath6kl/bmi/src/bmi.c
@@ -1,15 +1,19 @@
//------------------------------------------------------------------------------
// <copyright file="bmi.c" company="Atheros">
-// Copyright (c) 2004-2008 Atheros Corporation. All rights reserved.
+// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved.
//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation;
//
-// Software distributed under the License is distributed on an "AS
-// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
//
//------------------------------------------------------------------------------
@@ -19,12 +23,16 @@
//==============================================================================
+#ifdef THREAD_X
+#include <string.h>
+#endif
+
#include "hif.h"
#include "bmi.h"
#include "htc_api.h"
#include "bmi_internal.h"
-#ifdef DEBUG
+#ifdef ATH_DEBUG_MODULE
static ATH_DEBUG_MASK_DESCRIPTION bmi_debug_desc[] = {
{ ATH_DEBUG_BMI , "BMI Tracing"},
};
@@ -83,6 +91,20 @@ BMIInit(void)
A_REGISTER_MODULE_DEBUG_INFO(bmi);
}
+void
+BMICleanup(void)
+{
+ if (pBMICmdCredits) {
+ A_FREE(pBMICmdCredits);
+ pBMICmdCredits = NULL;
+ }
+
+ if (pBMICmdBuf) {
+ A_FREE(pBMICmdBuf);
+ pBMICmdBuf = NULL;
+ }
+}
+
A_STATUS
BMIDone(HIF_DEVICE *device)
{
@@ -170,14 +192,6 @@ BMIGetTargetInfo(HIF_DEVICE *device, struct bmi_target_info *targ_info)
targ_info->target_info_byte_count));
return A_ERROR;
}
- } else {
- /*
- * Target must be an AR6001 whose firmware does not
- * support BMI_GET_TARGET_INFO. Construct the data
- * that it would have sent.
- */
- targ_info->target_info_byte_count=sizeof(*targ_info);
- targ_info->target_type=TARGET_TYPE_AR6001;
}
AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Exit (ver: 0x%x type: 0x%x)\n",
@@ -253,7 +267,9 @@ BMIWriteMemory(HIF_DEVICE *device,
A_UINT32 offset;
A_UINT32 remaining, txlen;
const A_UINT32 header = sizeof(cid) + sizeof(address) + sizeof(length);
-
+ A_UCHAR alignedBuffer[BMI_DATASZ_MAX];
+ A_UCHAR *src;
+
A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + header));
memset (pBMICmdBuf, 0, BMI_DATASZ_MAX + header);
@@ -271,8 +287,18 @@ BMIWriteMemory(HIF_DEVICE *device,
remaining = length;
while (remaining)
{
- txlen = (remaining < (BMI_DATASZ_MAX - header)) ?
- remaining : (BMI_DATASZ_MAX - header);
+ src = &buffer[length - remaining];
+ if (remaining < (BMI_DATASZ_MAX - header)) {
+ if (remaining & 3) {
+ /* align it with 4 bytes */
+ remaining = remaining + (4 - (remaining & 3));
+ memcpy(alignedBuffer, src, remaining);
+ src = alignedBuffer;
+ }
+ txlen = remaining;
+ } else {
+ txlen = (BMI_DATASZ_MAX - header);
+ }
offset = 0;
A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid));
offset += sizeof(cid);
@@ -280,7 +306,7 @@ BMIWriteMemory(HIF_DEVICE *device,
offset += sizeof(address);
A_MEMCPY(&(pBMICmdBuf[offset]), &txlen, sizeof(txlen));
offset += sizeof(txlen);
- A_MEMCPY(&(pBMICmdBuf[offset]), &buffer[length - remaining], txlen);
+ A_MEMCPY(&(pBMICmdBuf[offset]), src, txlen);
offset += txlen;
status = bmiBufferSend(device, pBMICmdBuf, offset);
if (status != A_OK) {
« no previous file with comments | « chromeos/drivers/ath6kl/bmi/include/bmi_internal.h ('k') | chromeos/drivers/ath6kl/bmi/src/makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698