From fa269b44512a03523b164c3cebc20312748c524b Mon Sep 17 00:00:00 2001
From: Holger Freyther <zecke@openmoko.org>
Date: Wed, 6 Aug 2008 23:03:58 +0200
Subject: [PATCH] [ar6k] Build the wireless driver without DEBUG
    - Remove DEBUG from the Makefile

    - Do not send events through netlink to userspace. We might
      need to reevaluate this. But we seem to use wireless_send_event
      at the right places.
      (SEND_EVENT_TO_APP)

    - Do not report debug logs to apps
      (REPORT_DEBUG_LOGS_TO_APP)

Signed-Off-By: Holger Freyther <zecke@openmoko.org>
---
 drivers/sdio/function/wlan/ar6000/Makefile         |    4 ++--
 .../sdio/function/wlan/ar6000/ar6000/ar6000_drv.c  |   13 +++++++++++++
 .../sdio/function/wlan/ar6000/ar6000/debug_linux.h |    2 +-
 drivers/sdio/function/wlan/ar6000/hif/hif.c        |    2 +-
 drivers/sdio/function/wlan/ar6000/htc/htc_send.c   |    2 ++
 drivers/sdio/stack/busdriver/_busdriver.h          |    2 +-
 drivers/sdio/stack/busdriver/sdio_bus_misc.c       |    2 +-
 include/linux/sdio/ctsystem_linux.h                |    2 --
 8 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/sdio/function/wlan/ar6000/Makefile b/drivers/sdio/function/wlan/ar6000/Makefile
index 810dab6..4dc5109 100644
--- a/drivers/sdio/function/wlan/ar6000/Makefile
+++ b/drivers/sdio/function/wlan/ar6000/Makefile
@@ -4,8 +4,8 @@ PWD := $(shell pwd)
 
 EXTRA_CFLAGS += -I$(src)/include
 
-EXTRA_CFLAGS += -DLINUX -DDEBUG -D__KERNEL__ -DHTC_RAW_INTERFACE\
-                -DTCMD -DSEND_EVENT_TO_APP -DUSER_KEYS \
+EXTRA_CFLAGS += -DLINUX -D__KERNEL__ -DHTC_RAW_INTERFACE\
+                -DTCMD -DUSER_KEYS \
                 -DNO_SYNC_FLUSH #\
                 -DMULTIPLE_FRAMES_PER_INTERRUPT -DAR6000REV$(REV) \
                 -DBLOCK_TX_PATH_FLAG \
diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
index dacc00a..93ed978 100644
--- a/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
+++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
@@ -155,6 +155,9 @@ MODULE_PARM(txcreditintrenable, "0-3i");
 MODULE_PARM(txcreditintrenableaggregate, "0-3i");
 #endif
 
+#else
+unsigned int resetok = 1;
+
 #endif /* DEBUG */
 
 unsigned int tx_attempt[HTC_MAILBOX_NUM_MAX] = {0};
@@ -265,7 +268,9 @@ static struct ar_cookie s_ar_cookie_mem[MAX_COOKIE_NUM];
  * Flag to govern whether the debug logs should be parsed in the kernel
  * or reported to the application.
  */
+#ifdef DEBUG
 #define REPORT_DEBUG_LOGS_TO_APP
+#endif
 
 A_STATUS
 ar6000_set_host_app_area(AR_SOFTC_T *ar)
@@ -874,9 +879,11 @@ static void ar6000_target_failure(void *Instance, A_STATUS Status)
             sip = TRUE;
             errEvent.errorVal = WMI_TARGET_COM_ERR |
                                 WMI_TARGET_FATAL_ERR;
+#ifdef SEND_EVENT_TO_APP
             ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
                                      (A_UINT8 *)&errEvent,
                                      sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
+#endif
         }
     }
 }
@@ -1026,9 +1033,11 @@ static void ar6000_detect_error(unsigned long ptr)
         ar->arHBChallengeResp.seqNum = 0;
         errEvent.errorVal = WMI_TARGET_COM_ERR | WMI_TARGET_FATAL_ERR;
         AR6000_SPIN_UNLOCK(&ar->arLock, 0);
+#ifdef SEND_EVENT_TO_APP
         ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
                                  (A_UINT8 *)&errEvent,
                                  sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
+#endif
         return;
     }
 
@@ -2500,7 +2509,9 @@ ar6000_rssiThreshold_event(AR_SOFTC_T *ar,  WMI_RSSI_THRESHOLD_VAL newThreshold,
     userRssiThold.tag = rssi_map[newThreshold].tag;
     userRssiThold.rssi = rssi;
     AR_DEBUG2_PRINTF("rssi Threshold range = %d tag = %d  rssi = %d\n", newThreshold, userRssiThold.tag, rssi);
+#ifdef SEND_EVENT_TO_APP
     ar6000_send_event_to_app(ar, WMI_RSSI_THRESHOLD_EVENTID,(A_UINT8 *)&userRssiThold, sizeof(USER_RSSI_THOLD));
+#endif
 }
 
 
@@ -2509,8 +2520,10 @@ ar6000_hbChallengeResp_event(AR_SOFTC_T *ar, A_UINT32 cookie, A_UINT32 source)
 {
     if (source == APP_HB_CHALLENGE) {
         /* Report it to the app in case it wants a positive acknowledgement */
+#ifdef SEND_EVENT_TO_APP
         ar6000_send_event_to_app(ar, WMIX_HB_CHALLENGE_RESP_EVENTID,
                                  (A_UINT8 *)&cookie, sizeof(cookie));
+#endif
     } else {
         /* This would ignore the replys that come in after their due time */
         if (cookie == ar->arHBChallengeResp.seqNum) {
diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h b/drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h
index e62e960..c74e1df 100644
--- a/drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h
+++ b/drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h
@@ -77,7 +77,7 @@ enum {
 extern int debughtc;
 #else
 #define AR_DEBUG_PRINTF(flags, args)
-#define AR_DEBUG_PRINTBUF(buffer, length)
+#define AR_DEBUG_PRINTBUF(buffer, length, desc)
 #define AR_DEBUG_ASSERT(test)
 #define AR_DEBUG_LVL_CHECK(lvl) 0
 #define A_DPRINTF(f, a)
diff --git a/drivers/sdio/function/wlan/ar6000/hif/hif.c b/drivers/sdio/function/wlan/ar6000/hif/hif.c
index 3d6d792..469b5cc 100644
--- a/drivers/sdio/function/wlan/ar6000/hif/hif.c
+++ b/drivers/sdio/function/wlan/ar6000/hif/hif.c
@@ -86,9 +86,9 @@ static BUS_REQUEST *s_busRequestFreeQueue = NULL;
 OS_CRITICALSECTION lock;
 extern A_UINT32 onebitmode;
 extern A_UINT32 busspeedlow;
-extern A_UINT32 debughif;
 
 #ifdef DEBUG
+extern A_UINT32 debughif;
 #define ATH_DEBUG_ERROR 1
 #define ATH_DEBUG_WARN  2
 #define ATH_DEBUG_TRACE 3
diff --git a/drivers/sdio/function/wlan/ar6000/htc/htc_send.c b/drivers/sdio/function/wlan/ar6000/htc/htc_send.c
index 7792dd6..fd5ef6e 100644
--- a/drivers/sdio/function/wlan/ar6000/htc/htc_send.c
+++ b/drivers/sdio/function/wlan/ar6000/htc/htc_send.c
@@ -425,7 +425,9 @@ static void HTCFlushEndpointTX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_
 
 void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist)
 {
+#ifdef DEBUG
     HTC_ENDPOINT *pEndpoint = (HTC_ENDPOINT *)pEPDist->pHTCReserved;
+#endif
 
     AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("--- EP : %d  ServiceID: 0x%X    --------------\n",
                         pEPDist->Endpoint, pEPDist->ServiceID));
diff --git a/drivers/sdio/stack/busdriver/_busdriver.h b/drivers/sdio/stack/busdriver/_busdriver.h
index a85aed1..28d3960 100644
--- a/drivers/sdio/stack/busdriver/_busdriver.h
+++ b/drivers/sdio/stack/busdriver/_busdriver.h
@@ -301,7 +301,7 @@ static INLINE SDIO_STATUS CallHcdRequest(PSDHCD pHcd) {
             pHcd->pCurrentRequest->Flags |= SDREQ_FLAGS_FORCE_DEFERRED_COMPLETE;
         }
     }
- #if DEBUG
+ #ifdef DEBUG
     {
         SDIO_STATUS status;
         BOOL forceDeferred;
diff --git a/drivers/sdio/stack/busdriver/sdio_bus_misc.c b/drivers/sdio/stack/busdriver/sdio_bus_misc.c
index c5c7381..d89a596 100644
--- a/drivers/sdio/stack/busdriver/sdio_bus_misc.c
+++ b/drivers/sdio/stack/busdriver/sdio_bus_misc.c
@@ -1977,7 +1977,7 @@ SDIO_STATUS SDQuerySDMMCInfo(PSDDEVICE pDevice)
         } else {
             pDevice->pId[0].SDMMC_ManfacturerID = GET_SD_CID_MANFID(CID);
             pDevice->pId[0].SDMMC_OEMApplicationID = GET_SD_CID_OEMID(CID);
-#if DEBUG
+#ifdef DEBUG
             {
                 char pBuf[7];
 
diff --git a/include/linux/sdio/ctsystem_linux.h b/include/linux/sdio/ctsystem_linux.h
index c9e44f2..2aa4de3 100644
--- a/include/linux/sdio/ctsystem_linux.h
+++ b/include/linux/sdio/ctsystem_linux.h
@@ -202,8 +202,6 @@ typedef struct scatterlist SDDMA_DESCRIPTOR, *PSDDMA_DESCRIPTOR;
 
 #define DBG_SDIO_MASK (DBG_MASK_NONE | DBG_LEVEL_DEBUG)
 
-#define DEBUG 1
-
 #ifdef DEBUG
 
 #define DBG_ASSERT(test) \
-- 
1.5.2.3

