Skip to contentSkip to conversation

staging: wlags49_h2: DBG cleanups

PATCH New David Kilroy 1 participant 4 messages Oct 1, 2011 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: wlags49_h2: DBG cleanups

While testing some preliminary WPA patches, some issues with the DBG machinery cropped up. This series just addresses those.

David Kilroy (3):
staging: wlags49_h2: Use C99 __func__
staging: wlags49_h2: Remove unused debug function
staging: wlags49_h2: Remove bad debug message

 drivers/staging/wlags49_h2/debug.h     |   61 ++++++++++--------
 drivers/staging/wlags49_h2/wl_cs.c     |  114 --------------------------------
 drivers/staging/wlags49_h2/wl_netdev.c |    2 +-
 drivers/staging/wlags49_h2/wl_wext.c   |    1 -
 4 files changed, 35 insertions(+), 143 deletions(-)
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/3 staging: wlags49_h2: Use C99 __func__

in DBG machinery so you don't have to declare DBG_FUNC at the start of all functions.

This just makes it easy to add DBG conforming to existing code.

The patch reformats the changed #defines to satisfy checkstyle.pl

---
 drivers/staging/wlags49_h2/debug.h     |   61 ++++++++++++++++++--------------
 drivers/staging/wlags49_h2/wl_netdev.c |    2 +-
 2 files changed, 35 insertions(+), 28 deletions(-)
drivers/staging/wlags49_h2/debug.h +34 -27
index 2c3dd14..8d5dddf 100644
@@ -129,11 +129,15 @@
 #define _LEAVE_STR          "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
 
 
-#define _DBG_ENTER(A)       DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), ++DBG_LEVEL(A), _ENTER_STR, __FUNC__)
-#define _DBG_LEAVE(A)       DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), DBG_LEVEL(A)--, _LEAVE_STR, __FUNC__)
+#define _DBG_ENTER(A)						\
+	DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), ++DBG_LEVEL(A),	\
+		  _ENTER_STR, __func__)
+#define _DBG_LEAVE(A)						\
+	DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), DBG_LEVEL(A)--,	\
+		  _LEAVE_STR, __func__)
 
 
-#define DBG_FUNC(F)         static const char *__FUNC__ = F;
+#define DBG_FUNC(F)
 
 #define DBG_ENTER(A)        {if (DBG_FLAGS(A) & DBG_TRACE_ON) \
 				_DBG_ENTER(A); }
@@ -145,29 +149,33 @@
 				DBG_PRINT("  %s -- "F"\n", N, S); }
 
 
-#define DBG_ERROR(A, S...)   {if (DBG_FLAGS(A) & DBG_ERROR_ON) {\
-				DBG_PRINT("%s:ERROR:%s ", DBG_NAME(A), __FUNC__);\
-				DBG_PRINTC(S); \
-				DBG_TRAP; \
-				} \
-				}
+#define DBG_ERROR(A, S...) do {						\
+		if (DBG_FLAGS(A) & DBG_ERROR_ON) {			\
+			DBG_PRINT("%s:ERROR:%s ", DBG_NAME(A), __func__); \
+			DBG_PRINTC(S);					\
+			DBG_TRAP;					\
+		} } while (0)
 
 
-#define DBG_WARNING(A, S...) {if (DBG_FLAGS(A) & DBG_WARNING_ON) {\
-				DBG_PRINT("%s:WARNING:%s ", DBG_NAME(A), __FUNC__);\
-				DBG_PRINTC(S); } }
+#define DBG_WARNING(A, S...) do {					\
+		if (DBG_FLAGS(A) & DBG_WARNING_ON) {			\
+			DBG_PRINT("%s:WARNING:%s ", DBG_NAME(A), __func__); \
+			DBG_PRINTC(S);					\
+		} } while (0)
 
 
-#define DBG_NOTICE(A, S...)  {if (DBG_FLAGS(A) & DBG_NOTICE_ON) {\
-				DBG_PRINT("%s:NOTICE:%s ", DBG_NAME(A), __FUNC__);\
-				DBG_PRINTC(S); \
-				} \
-				}
+#define DBG_NOTICE(A, S...)  do {					\
+		if (DBG_FLAGS(A) & DBG_NOTICE_ON) {			\
+			DBG_PRINT("%s:NOTICE:%s ", DBG_NAME(A), __func__); \
+			DBG_PRINTC(S);					\
+		} } while (0)
 
 
-#define DBG_TRACE(A, S...)   do {if (DBG_FLAGS(A) & DBG_TRACE_ON) {\
-				DBG_PRINT("%s:%s ", DBG_NAME(A), __FUNC__);\
-				DBG_PRINTC(S); } } while (0)
+#define DBG_TRACE(A, S...)   do { \
+		if (DBG_FLAGS(A) & DBG_TRACE_ON) {			\
+			DBG_PRINT("%s:%s ", DBG_NAME(A), __func__);	\
+			DBG_PRINTC(S);					\
+		} } while (0)
 
 
 #define DBG_RX(A, S...)      {if (DBG_FLAGS(A) & DBG_RX_ON) {\
@@ -181,13 +189,12 @@
 				DBG_PRINT(S); } }
 
 
-#define DBG_ASSERT(C)		{ \
-				if (!(C)) {\
-					DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n", \
-					#C, __FILE__, __LINE__, __FUNC__); \
-					DBG_TRAP; \
-					} \
-					}
+#define DBG_ASSERT(C) do { \
+		if (!(C)) {						\
+			DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n",		\
+				  #C, __FILE__, __LINE__, __func__);	\
+			DBG_TRAP;					\
+		} } while (0)
 
 typedef struct {
     char           *dbgName;
drivers/staging/wlags49_h2/wl_netdev.c +1 -1
index cf917e6..1c9d4d0 100644
@@ -217,7 +217,7 @@ int wl_config( struct net_device *dev, struct ifmap *map )
 
     /* The only thing we care about here is a port change. Since this not needed,
        ignore the request. */
-    DBG_TRACE( DbgInfo, "%s: %s called.\n", dev->name, __FUNC__ );
+    DBG_TRACE(DbgInfo, "%s: %s called.\n", dev->name, __func__);
 
     DBG_LEAVE( DbgInfo );
     return 0;
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 3/3 staging: wlags49_h2: Remove bad debug message

In reply to David Kilroy

The message is in the wrong place. We definitely don't want to return at this point, as we may need to turn off encryption.

---
 drivers/staging/wlags49_h2/wl_wext.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/staging/wlags49_h2/wl_wext.c +0 -1
index 764a320..89563da 100644
@@ -1214,7 +1214,6 @@ static int wireless_set_encode(struct net_device *dev, struct iw_request_info *i
 				lp->EnableEncryption    = 1;
 			} else {
 				DBG_WARNING( DbgInfo, "Problem setting the current TxKey\n" );
-				DBG_LEAVE( DbgInfo );
 				ret = -EINVAL;
 			}
 		}
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/3 staging: wlags49_h2: Remove unused debug function

In reply to David Kilroy

The function no longer compiles, so we just remove it.

---
 drivers/staging/wlags49_h2/wl_cs.c |  114 ------------------------------------
 1 files changed, 0 insertions(+), 114 deletions(-)
drivers/staging/wlags49_h2/wl_cs.c +0 -114
index a3a727c..3215802 100644
@@ -501,117 +501,3 @@ int wl_adapter_is_open(struct net_device *dev)
 	return link->open;
 } /* wl_adapter_is_open */
 /*============================================================================*/
-
-
-#if DBG
-
-/*******************************************************************************
- *	DbgEvent()
- *******************************************************************************
- *
- *  DESCRIPTION:
- *
- *      Converts the card serivces events to text for debugging.
- *
- *  PARAMETERS:
- *
- *      mask    - a integer representing the error(s) being reported by Card
- *                Services.
- *
- *  RETURNS:
- *
- *      a pointer to a string describing the error(s)
- *
- ******************************************************************************/
-const char *DbgEvent(int mask)
-{
-	static char DbgBuffer[256];
-	char *pBuf;
-	/*--------------------------------------------------------------------*/
-
-	pBuf    = DbgBuffer;
-	*pBuf   = '\0';
-
-
-	if (mask & CS_EVENT_WRITE_PROTECT)
-		strcat(pBuf, "WRITE_PROTECT ");
-
-	if (mask & CS_EVENT_CARD_LOCK)
-		strcat(pBuf, "CARD_LOCK ");
-
-	if (mask & CS_EVENT_CARD_INSERTION)
-		strcat(pBuf, "CARD_INSERTION ");
-
-	if (mask & CS_EVENT_CARD_REMOVAL)
-		strcat(pBuf, "CARD_REMOVAL ");
-
-	if (mask & CS_EVENT_BATTERY_DEAD)
-		strcat(pBuf, "BATTERY_DEAD ");
-
-	if (mask & CS_EVENT_BATTERY_LOW)
-		strcat(pBuf, "BATTERY_LOW ");
-
-	if (mask & CS_EVENT_READY_CHANGE)
-		strcat(pBuf, "READY_CHANGE ");
-
-	if (mask & CS_EVENT_CARD_DETECT)
-		strcat(pBuf, "CARD_DETECT ");
-
-	if (mask & CS_EVENT_RESET_REQUEST)
-		strcat(pBuf, "RESET_REQUEST ");
-
-	if (mask & CS_EVENT_RESET_PHYSICAL)
-		strcat(pBuf, "RESET_PHYSICAL ");
-
-	if (mask & CS_EVENT_CARD_RESET)
-		strcat(pBuf, "CARD_RESET ");
-
-	if (mask & CS_EVENT_REGISTRATION_COMPLETE)
-		strcat(pBuf, "REGISTRATION_COMPLETE ");
-
-	/* if (mask & CS_EVENT_RESET_COMPLETE)
-		strcat(pBuf, "RESET_COMPLETE "); */
-
-	if (mask & CS_EVENT_PM_SUSPEND)
-		strcat(pBuf, "PM_SUSPEND ");
-
-	if (mask & CS_EVENT_PM_RESUME)
-		strcat(pBuf, "PM_RESUME ");
-
-	if (mask & CS_EVENT_INSERTION_REQUEST)
-		strcat(pBuf, "INSERTION_REQUEST ");
-
-	if (mask & CS_EVENT_EJECTION_REQUEST)
-		strcat(pBuf, "EJECTION_REQUEST ");
-
-	if (mask & CS_EVENT_MTD_REQUEST)
-		strcat(pBuf, "MTD_REQUEST ");
-
-	if (mask & CS_EVENT_ERASE_COMPLETE)
-		strcat(pBuf, "ERASE_COMPLETE ");
-
-	if (mask & CS_EVENT_REQUEST_ATTENTION)
-		strcat(pBuf, "REQUEST_ATTENTION ");
-
-	if (mask & CS_EVENT_CB_DETECT)
-		strcat(pBuf, "CB_DETECT ");
-
-	if (mask & CS_EVENT_3VCARD)
-		strcat(pBuf, "3VCARD ");
-
-	if (mask & CS_EVENT_XVCARD)
-		strcat(pBuf, "XVCARD ");
-
-
-	if (*pBuf) {
-		pBuf[strlen(pBuf) - 1] = '\0';
-	} else {
-		if (mask != 0x0)
-			sprintf(pBuf, "<<0x%08x>>", mask);
-	}
-
-	return pBuf;
-} /* DbgEvent */
-/*============================================================================*/
-
-#endif  /* DBG */
Signature · 1 line
1.7.4.1