Skip to contentSkip to conversation

staging:rtl8192u: Coding style changes

PATCH In review John Whitmore 2 participants 18 messages Jul 29, 2018 – Jul 30, 2018 Staging

lore
Share & tools
lore
#0 lore raw

v2 cover staging:rtl8192u: Coding style changes

Second attempt correcting my initial attempt where I left '_t' and '_e' trailing the structures defined. These have now been corrected.

John Whitmore (15):
staging:rtl8192u: Remove typedef of struct cmpk_txfb_t - Style staging:rtl8192u: Remove unused CMPK_TX_SET_CONFIG_SIZE - Style staging:rtl8192u: Removed unused CMPK_RX_DBG_MSG_SIZE - Style staging:rtl8192u: Correct spelling in comments - style staging:rtl8192u: Remove typedef of cmpk_intr_sta_t - Style staging:rtl8192u: Remove typedef of cmpk_set_cfg_t - Style staging:rtl8192u: Refactor use of enum dm_dig_sta_e - Style staging:rtl8192u: Refactor enum dm_ratr_sta_e usage - Style staging:rtl8192u: Remove enum dm_dig_op_e - Style staging:rtl8192u: Refactor enum dm_dig_alg_e - Style staging:rtl8192u: Remove unused enum dm_dig_dbg_e - Style staging:rtl8192u: Refactor dm_dig_connect_e - Style staging:rtl8192u: Refactor enum dm_dig_pd_th_e - Style staging:rtl8192u: Refactor enum dm_dig_cs_ratio_e - Style staging:rtl8192u: Refactor enum DM_CCK_Rx_Path_Method - Style

 drivers/staging/rtl8192u/r8192U.h        |  10 +-
 drivers/staging/rtl8192u/r8192U_dm.c     |  91 -----------------
 drivers/staging/rtl8192u/r8192U_dm.h     | 122 ++++++++---------------
 drivers/staging/rtl8192u/r819xU_cmdpkt.c |  16 +--
 drivers/staging/rtl8192u/r819xU_cmdpkt.h |  24 ++---
 5 files changed, 70 insertions(+), 193 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH v2 1/15 staging:rtl8192u: Remove typedef of struct cmpk_txfb_t - Style

Remove the typedef of the structure cmpk_txfb_t. This clears the checkpatch issue with defining new types.

Additionally the type is renamed from cmpk_txfb_t to cmd_pkt_tx_feedback removing the '_t' as the typedef has been removed.

These changes are purely coding style in nature and should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 8 ++++----
 drivers/staging/rtl8192u/r819xU_cmdpkt.h | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8192u/r819xU_cmdpkt.c +4 -4
index 3140b3413f91..630cf612f265 100644
@@ -66,7 +66,7 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen)
  * Overview:
  *
  * Input:       PADAPTER	pAdapter
- *              CMPK_TXFB_T	*psTx_FB
+ *              STRUCT CMD_PKT_TX_FEEDBACK	*psTx_FB
  *
  * Output:      NONE
  *
@@ -78,7 +78,7 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen)
  *
  *---------------------------------------------------------------------------
  */
-static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb)
+static void cmpk_count_txstatistic(struct net_device *dev, struct cmd_pkt_tx_feedback *pstx_fb)
 {
 	struct r8192_priv *priv = ieee80211_priv(dev);
 #ifdef ENABLE_PS
@@ -163,7 +163,7 @@ static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb)
 static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg)
 {
 	struct r8192_priv *priv = ieee80211_priv(dev);
-	cmpk_txfb_t		rx_tx_fb;
+	struct cmd_pkt_tx_feedback rx_tx_fb;
 
 	priv->stats.txfeedback++;
 
@@ -173,7 +173,7 @@ static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg)
 	 * endian type before copy the message copy.
 	 */
 	/* Use pointer to transfer structure memory. */
-	memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t));
+	memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(struct cmd_pkt_tx_feedback));
 	/* 2. Use tx feedback info to count TX statistics. */
 	cmpk_count_txstatistic(dev, &rx_tx_fb);
 	/* Comment previous method for TX statistic function. */
drivers/staging/rtl8192u/r819xU_cmdpkt.h +3 -3
index 0eb6b2321c9c..756e08bd341a 100644
@@ -2,7 +2,7 @@
 #ifndef R819XUSB_CMDPKT_H
 #define R819XUSB_CMDPKT_H
 /* Different command packet have dedicated message length and definition. */
-#define		CMPK_RX_TX_FB_SIZE		sizeof(cmpk_txfb_t)	/* 20 */
+#define		CMPK_RX_TX_FB_SIZE		sizeof(struct cmd_pkt_tx_feedback)	/* 20 */
 #define		CMPK_TX_SET_CONFIG_SIZE		sizeof(cmpk_set_cfg_t)	/* 16 */
 #define		CMPK_BOTH_QUERY_CONFIG_SIZE	sizeof(cmpk_set_cfg_t)	/* 16 */
 #define		CMPK_RX_TX_STS_SIZE		sizeof(cmpk_tx_status_t)
@@ -19,7 +19,7 @@
 /*------------------------------Define structure----------------------------*/
 /* Define different command packet structure. */
 /* 1. RX side: TX feedback packet. */
-typedef struct tag_cmd_pkt_tx_feedback {
+struct cmd_pkt_tx_feedback {
 	/* DWORD 0 */
 	u8	element_id;			/* Command packet type. */
 	u8	length;				/* Command packet length. */
@@ -52,7 +52,7 @@ typedef struct tag_cmd_pkt_tx_feedback {
 	/* DWORD 5 */
 	u16	reserve3;
 	u16	duration;
-} cmpk_txfb_t;
+};
 
 /* 2. RX side: Interrupt status packet. It includes Beacon State,
  * Beacon Timer Interrupt and other useful informations in MAC ISR Reg.
Signature · 1 line
2.18.0
maintainer
#2 lore raw

Re: [PATCH v2 01/15] staging:rtl8192u: Remove typedef of struct cmpk_txfb_t - Style

Quoted 20 lines · John Whitmore

Remove the typedef of the structure cmpk_txfb_t. This clears the checkpatch issue with defining new types.

Additionally the type is renamed from cmpk_txfb_t to cmd_pkt_tx_feedback removing the '_t' as the typedef has been removed.

These changes are purely coding style in nature and should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 8 ++++----
 drivers/staging/rtl8192u/r819xU_cmdpkt.h | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8192u/r819xU_cmdpkt.c +0 -0
index 3140b3413f91..630cf612f265 100644

drivers/staging/rtl8192u/r819xU_cmdpkt.c rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) · line 69

Quoted 5 lines
drivers/staging/rtl8192u/r819xU_cmdpkt.c +1 -1
@@ -66,7 +66,7 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen)
  * Overview:
  *
  * Input:       PADAPTER	pAdapter
- *              CMPK_TXFB_T	*psTx_FB
+ *              STRUCT CMD_PKT_TX_FEEDBACK	*psTx_FB

nit, this should all be in lowercase now right?

Anyway, these function comments need to all go anyway, they are horrid :)

Something for future patches, look at the ones for the gasket driver sent yesterday as an example of what to do.

thanks,

greg k-h

#3 lore raw

Re: [PATCH v2 01/15] staging:rtl8192u: Remove typedef of struct cmpk_txfb_t - Style

Quoted 29 lines · Greg KH
Quoted 20 lines · John Whitmore

Remove the typedef of the structure cmpk_txfb_t. This clears the checkpatch issue with defining new types.

Additionally the type is renamed from cmpk_txfb_t to cmd_pkt_tx_feedback removing the '_t' as the typedef has been removed.

These changes are purely coding style in nature and should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 8 ++++----
 drivers/staging/rtl8192u/r819xU_cmdpkt.h | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8192u/r819xU_cmdpkt.c +0 -0
index 3140b3413f91..630cf612f265 100644

drivers/staging/rtl8192u/r819xU_cmdpkt.c rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) · line 69

Quoted 5 lines
drivers/staging/rtl8192u/r819xU_cmdpkt.c +1 -1
@@ -66,7 +66,7 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen)
  * Overview:
  *
  * Input:       PADAPTER	pAdapter
- *              CMPK_TXFB_T	*psTx_FB
+ *              STRUCT CMD_PKT_TX_FEEDBACK	*psTx_FB

nit, this should all be in lowercase now right?

Quoted 8 lines

Anyway, these function comments need to all go anyway, they are horrid :)

Something for future patches, look at the ones for the gasket driver sent yesterday as an example of what to do.

thanks,

greg k-h

Thanks for the pointer to gasket driver. I didn't like to start into horrid comments, thinking that maybe they do convey some information to somebody, or they're in that format for a reson. The code is easier. Anyhow thanks for that pointer, and I will change comments in future. Sure all that can happen is you'll reject some/all, but sure I might learn the style required.

jwhitmore

#4 lore raw

PATCH v2 2/15 staging:rtl8192u: Remove unused CMPK_TX_SET_CONFIG_SIZE - Style

In reply to John Whitmore

Remove the unused macro CMPK_TX_SET_CONFIG_SIZE. This is a coding style change which should not impact runtime code execution.

---
 drivers/staging/rtl8192u/r819xU_cmdpkt.h | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/rtl8192u/r819xU_cmdpkt.h +0 -1
index 756e08bd341a..fab982668b44 100644
@@ -3,7 +3,6 @@
 #define R819XUSB_CMDPKT_H
 /* Different command packet have dedicated message length and definition. */
 #define		CMPK_RX_TX_FB_SIZE		sizeof(struct cmd_pkt_tx_feedback)	/* 20 */
-#define		CMPK_TX_SET_CONFIG_SIZE		sizeof(cmpk_set_cfg_t)	/* 16 */
 #define		CMPK_BOTH_QUERY_CONFIG_SIZE	sizeof(cmpk_set_cfg_t)	/* 16 */
 #define		CMPK_RX_TX_STS_SIZE		sizeof(cmpk_tx_status_t)
 #define		CMPK_RX_DBG_MSG_SIZE		sizeof(cmpk_rx_dbginfo_t)
Signature · 1 line
2.18.0
#5 lore raw

PATCH v2 3/15 staging:rtl8192u: Removed unused CMPK_RX_DBG_MSG_SIZE - Style

In reply to John Whitmore

Remove the unused macro definition CMPK_RX_DBG_MSG_SIZE. This is a coding style change which should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r819xU_cmdpkt.h | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/rtl8192u/r819xU_cmdpkt.h +0 -1
index fab982668b44..50218d9a406b 100644
@@ -5,7 +5,6 @@
 #define		CMPK_RX_TX_FB_SIZE		sizeof(struct cmd_pkt_tx_feedback)	/* 20 */
 #define		CMPK_BOTH_QUERY_CONFIG_SIZE	sizeof(cmpk_set_cfg_t)	/* 16 */
 #define		CMPK_RX_TX_STS_SIZE		sizeof(cmpk_tx_status_t)
-#define		CMPK_RX_DBG_MSG_SIZE		sizeof(cmpk_rx_dbginfo_t)
 #define		CMPK_TX_RAHIS_SIZE		sizeof(cmpk_tx_rahis_t)
 
 /* 2008/05/08 amy For USB constant. */
Signature · 1 line
2.18.0
#6 lore raw

PATCH v2 4/15 staging:rtl8192u: Correct spelling in comments - style

In reply to John Whitmore

Correct the spelling of a number of comments, which cause a checkpatch issue. This is purely a coding style change which should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r819xU_cmdpkt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192u/r819xU_cmdpkt.h +2 -2
index 50218d9a406b..d2e07b0ff30b 100644
@@ -53,7 +53,7 @@ struct cmd_pkt_tx_feedback {
 };
 
 /* 2. RX side: Interrupt status packet. It includes Beacon State,
- * Beacon Timer Interrupt and other useful informations in MAC ISR Reg.
+ * Beacon Timer Interrupt and other useful information in MAC ISR Reg.
  */
 typedef struct tag_cmd_pkt_interrupt_status {
 	u8	element_id;			/* Command packet type. */
@@ -80,7 +80,7 @@ typedef struct tag_cmd_pkt_set_configuration {
 	u32	mask;
 } cmpk_set_cfg_t;
 
-/* 4. Both side : TX/RX query configuraton packet. The query structure is the
+/* 4. Both side : TX/RX query configuration packet. The query structure is the
  *    same as set configuration.
  */
 #define		cmpk_query_cfg_t	cmpk_set_cfg_t
Signature · 1 line
2.18.0
#7 lore raw

PATCH v2 5/15 staging:rtl8192u: Remove typedef of cmpk_intr_sta_t - Style

In reply to John Whitmore

Remove the typedef of struct cmpk_intr_sta_t, the name of the structure has been left as cmd_pkt_interrupt_status. This clears the checkpatch issue with creating new types in code. The change is purely a coding style change and should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 6 +++---
 drivers/staging/rtl8192u/r819xU_cmdpkt.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8192u/r819xU_cmdpkt.c +3 -3
index 630cf612f265..c71fda0f13b2 100644
@@ -225,7 +225,7 @@ static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev)
  */
 static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg)
 {
-	cmpk_intr_sta_t		rx_intr_status;	/* */
+	struct cmd_pkt_interrupt_status	 rx_intr_status;	/* */
 	struct r8192_priv *priv = ieee80211_priv(dev);
 
 	DMESG("---> cmpk_Handle_Interrupt_Status()\n");
@@ -236,7 +236,7 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg)
 	 * endian type before copy the message copy.
 	 */
 	rx_intr_status.length = pmsg[1];
-	if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) {
+	if (rx_intr_status.length != (sizeof(struct cmd_pkt_interrupt_status) - 2)) {
 		DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n");
 		return;
 	}
@@ -528,7 +528,7 @@ u32 cmpk_message_handle_rx(struct net_device *dev,
 
 		case RX_INTERRUPT_STATUS:
 			cmpk_handle_interrupt_status(dev, pcmd_buff);
-			cmd_length = sizeof(cmpk_intr_sta_t);
+			cmd_length = sizeof(struct cmd_pkt_interrupt_status);
 			break;
 
 		case BOTH_QUERY_CONFIG:
drivers/staging/rtl8192u/r819xU_cmdpkt.h +2 -2
index d2e07b0ff30b..d2590b00fe98 100644
@@ -55,12 +55,12 @@ struct cmd_pkt_tx_feedback {
 /* 2. RX side: Interrupt status packet. It includes Beacon State,
  * Beacon Timer Interrupt and other useful information in MAC ISR Reg.
  */
-typedef struct tag_cmd_pkt_interrupt_status {
+struct cmd_pkt_interrupt_status {
 	u8	element_id;			/* Command packet type. */
 	u8	length;				/* Command packet length. */
 	u16	reserve;
 	u32	interrupt_status;		/* Interrupt Status. */
-} cmpk_intr_sta_t;
+};
 
 /* 3. TX side: Set configuration packet. */
 typedef struct tag_cmd_pkt_set_configuration {
Signature · 1 line
2.18.0
#8 lore raw

PATCH v2 6/15 staging:rtl8192u: Remove typedef of cmpk_set_cfg_t - Style

In reply to John Whitmore

Remove the typedef from cmpk_set_cfg_t, leaving the structure as struct cmd_pkt_set_configuration. This change clears the checkpatch issue with defining new types. The change is purely a coding style change which should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 2 +-
 drivers/staging/rtl8192u/r819xU_cmdpkt.h | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8192u/r819xU_cmdpkt.c +1 -1
index c71fda0f13b2..d2293a335ed1 100644
@@ -288,7 +288,7 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg)
  */
 static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg)
 {
-	cmpk_query_cfg_t	rx_query_cfg;
+	struct cmpk_query_cfg	rx_query_cfg;
 
 	/* 1. Extract TX feedback info from RFD to temp structure buffer. */
 	/* It seems that FW use big endian(MIPS) and DRV use little endian in
drivers/staging/rtl8192u/r819xU_cmdpkt.h +4 -4
index d2590b00fe98..be45cd609d67 100644
@@ -3,7 +3,7 @@
 #define R819XUSB_CMDPKT_H
 /* Different command packet have dedicated message length and definition. */
 #define		CMPK_RX_TX_FB_SIZE		sizeof(struct cmd_pkt_tx_feedback)	/* 20 */
-#define		CMPK_BOTH_QUERY_CONFIG_SIZE	sizeof(cmpk_set_cfg_t)	/* 16 */
+#define		CMPK_BOTH_QUERY_CONFIG_SIZE	sizeof(struct cmd_pkt_set_configuration)	/* 16 */
 #define		CMPK_RX_TX_STS_SIZE		sizeof(cmpk_tx_status_t)
 #define		CMPK_TX_RAHIS_SIZE		sizeof(cmpk_tx_rahis_t)
 
@@ -63,7 +63,7 @@ struct cmd_pkt_interrupt_status {
 };
 
 /* 3. TX side: Set configuration packet. */
-typedef struct tag_cmd_pkt_set_configuration {
+struct cmd_pkt_set_configuration {
 	u8	element_id;			/* Command packet type. */
 	u8	length;				/* Command packet length. */
 	u16	reserve1;
@@ -78,12 +78,12 @@ typedef struct tag_cmd_pkt_set_configuration {
 	u8	cfg_offset;
 	u32	value;
 	u32	mask;
-} cmpk_set_cfg_t;
+};
 
 /* 4. Both side : TX/RX query configuration packet. The query structure is the
  *    same as set configuration.
  */
-#define		cmpk_query_cfg_t	cmpk_set_cfg_t
+#define		cmpk_query_cfg	cmd_pkt_set_configuration
 
 /* 5. Multi packet feedback status. */
 typedef struct tag_tx_stats_feedback {
Signature · 1 line
2.18.0
#9 lore raw

PATCH v2 7/15 staging:rtl8192u: Refactor use of enum dm_dig_sta_e - Style

In reply to John Whitmore

Refactor the use of the enumerated type dm_dig_sta_e, which is not actually used for type checking by the compiler.

The typedef of dm_dig_sta_e is removed to clear the checkpatch issue with defining new types, and the enumerated type is left with the name enum dynamic_init_gain_state

The enumerated type defines values for the enumeration, which are used by both dig_state and dig_highpwr_state, (members of the struct dig). Both of those variables were defined as being of type u8. This negates any usefulness of the use of the enumeration, (compiler type checking).

To make use of the compiler's type-checking the two member variables, dig_state and dig_highpwr_state have been changed to being of type enum dynamic_init_gain_state. The enumerated type has been moved above the struct dig definition so that the enumeration is already defined when the compiler reaches the two types using the enumerated type.

These changes, whilst convoluted, are purely coding style in nature and should not impact runtime code execution.

---
 drivers/staging/rtl8192u/r8192U_dm.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/staging/rtl8192u/r8192U_dm.h +9 -9
index e86dda99c223..078770a8c7bf 100644
@@ -64,6 +64,13 @@
 
 
 /*------------------------------Define structure----------------------------*/
+
+enum dynamic_init_gain_state {
+	DM_STA_DIG_OFF = 0,
+	DM_STA_DIG_ON,
+	DM_STA_DIG_MAX
+};
+
 /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
 struct dig {
 	u8		dig_enable_flag;
@@ -77,8 +84,8 @@ struct dig {
 	long		rssi_high_power_lowthresh;
 	long		rssi_high_power_highthresh;
 
-	u8		dig_state;
-	u8		dig_highpwr_state;
+	enum dynamic_init_gain_state		dig_state;
+	enum dynamic_init_gain_state		dig_highpwr_state;
 	u8		cur_connect_state;
 	u8		pre_connect_state;
 
@@ -98,13 +105,6 @@ struct dig {
 	long		rssi_val;
 };
 
-typedef enum tag_dynamic_init_gain_state_definition {
-	DM_STA_DIG_OFF = 0,
-	DM_STA_DIG_ON,
-	DM_STA_DIG_MAX
-} dm_dig_sta_e;
-
-
 /* 2007/10/08 MH Define RATR state. */
 typedef enum tag_dynamic_ratr_state_definition {
 	DM_RATR_STA_HIGH = 0,
Signature · 1 line
2.18.0
#10 lore raw

PATCH v2 8/15 staging:rtl8192u: Refactor enum dm_ratr_sta_e usage - Style

In reply to John Whitmore

The enumerated type dm_ratr_sta_e was defined in the file drivers/staging/rtl8192u/r8192U_dm.h but never actually used in that file. The only variable which uses this enumerated type is 'ratr_state', a member variable of the _rate_adaptive structure defined in the file drivers/staging/rtl8192u/r8192U.h.

To clarify and place the enumerated type close to where it is used the type was moved to the drivers/staging/rtl8192u/r8192U.h file.

In addition the member variable 'ratr_state' which uses the enumerated constants was declared as being of type 'u8'. This negates any advantage of the enumerated type, compiler type-checking, so that member variable's type has been changed to being of the enumerated type.

The typedef from the enumerated type has been removed to clear the checkpatch issue with defining new types. Additionally the name of the type has been left as enum dynamic_ratr_state

This is a coding style change and should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r8192U.h    | 10 +++++++++-
 drivers/staging/rtl8192u/r8192U_dm.h |  8 --------
 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/rtl8192u/r8192U.h +9 -1
index e615d9b3f6b1..94a148994069 100644
@@ -662,9 +662,17 @@ typedef enum _RT_RF_TYPE_819xU {
 	RF_PSEUDO_11N = 4,
 } RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU;
 
+/* 2007/10/08 MH Define RATR state. */
+enum dynamic_ratr_state {
+	DM_RATR_STA_HIGH = 0,
+	DM_RATR_STA_MIDDLE = 1,
+	DM_RATR_STA_LOW = 2,
+	DM_RATR_STA_MAX
+};
+
 typedef struct _rate_adaptive {
 	u8				rate_adaptive_disabled;
-	u8				ratr_state;
+	enum dynamic_ratr_state		ratr_state;
 	u16				reserve;
 
 	u32				high_rssi_thresh_for_ra;
drivers/staging/rtl8192u/r8192U_dm.h +0 -8
index 078770a8c7bf..d7bd257a7e93 100644
@@ -105,14 +105,6 @@ struct dig {
 	long		rssi_val;
 };
 
-/* 2007/10/08 MH Define RATR state. */
-typedef enum tag_dynamic_ratr_state_definition {
-	DM_RATR_STA_HIGH = 0,
-	DM_RATR_STA_MIDDLE = 1,
-	DM_RATR_STA_LOW = 2,
-	DM_RATR_STA_MAX
-} dm_ratr_sta_e;
-
 /* 2007/10/11 MH Define DIG operation type. */
 typedef enum tag_dynamic_init_gain_operation_type_definition {
 	DIG_TYPE_THRESH_HIGH	= 0,
Signature · 1 line
2.18.0
#11 lore raw

PATCH v2 9/15 staging:rtl8192u: Remove enum dm_dig_op_e - Style

In reply to John Whitmore

Remove the enumerated type dm_dig_op_e. The type is only used as a parameter to the function dm_change_dynamic_initgain_thresh(), but that function is never referenced in the code at all.

I would consider this to be a coding style change as the function is never referenced and as a result the enumeration is never used. In any case there should be no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r8192U_dm.c | 91 ----------------------------
 drivers/staging/rtl8192u/r8192U_dm.h | 20 ------
 2 files changed, 111 deletions(-)
drivers/staging/rtl8192u/r8192U_dm.c +0 -91
index c4e4e3ba394b..16dbe55d0e15 100644
@@ -1613,97 +1613,6 @@ static void dm_bb_initialgain_backup(struct net_device *dev)
 }   /* dm_BBInitialGainBakcup */
 
 #endif
-/*-----------------------------------------------------------------------------
- * Function:	dm_change_dynamic_initgain_thresh()
- *
- * Overview:
- *
- * Input:		NONE
- *
- * Output:		NONE
- *
- * Return:		NONE
- *
- * Revised History:
- *	When		Who		Remark
- *	05/29/2008	amy		Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-
-void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type,
-				       u32 dm_value)
-{
-	switch (dm_type) {
-	case DIG_TYPE_THRESH_HIGH:
-		dm_digtable.rssi_high_thresh = dm_value;
-		break;
-
-	case  DIG_TYPE_THRESH_LOW:
-		dm_digtable.rssi_low_thresh = dm_value;
-		break;
-
-	case  DIG_TYPE_THRESH_HIGHPWR_HIGH:
-		dm_digtable.rssi_high_power_highthresh = dm_value;
-		break;
-
-	case DIG_TYPE_THRESH_HIGHPWR_LOW:
-		dm_digtable.rssi_high_power_lowthresh = dm_value;
-		break;
-
-	case DIG_TYPE_ENABLE:
-		dm_digtable.dig_state		= DM_STA_DIG_MAX;
-		dm_digtable.dig_enable_flag	= true;
-		break;
-
-	case DIG_TYPE_DISABLE:
-		dm_digtable.dig_state		= DM_STA_DIG_MAX;
-		dm_digtable.dig_enable_flag	= false;
-		break;
-
-	case DIG_TYPE_DBG_MODE:
-		if (dm_value >= DM_DBG_MAX)
-			dm_value = DM_DBG_OFF;
-		dm_digtable.dbg_mode		= (u8)dm_value;
-		break;
-
-	case DIG_TYPE_RSSI:
-		if (dm_value > 100)
-			dm_value = 30;
-		dm_digtable.rssi_val			= (long)dm_value;
-		break;
-
-	case DIG_TYPE_ALGORITHM:
-		if (dm_value >= DIG_ALGO_MAX)
-			dm_value = DIG_ALGO_BY_FALSE_ALARM;
-		if (dm_digtable.dig_algorithm != (u8)dm_value)
-			dm_digtable.dig_algorithm_switch = 1;
-		dm_digtable.dig_algorithm	= (u8)dm_value;
-		break;
-
-	case DIG_TYPE_BACKOFF:
-		if (dm_value > 30)
-			dm_value = 30;
-		dm_digtable.backoff_val		= (u8)dm_value;
-		break;
-
-	case DIG_TYPE_RX_GAIN_MIN:
-		if (dm_value == 0)
-			dm_value = 0x1;
-		dm_digtable.rx_gain_range_min = (u8)dm_value;
-		break;
-
-	case DIG_TYPE_RX_GAIN_MAX:
-		if (dm_value > 0x50)
-			dm_value = 0x50;
-		dm_digtable.rx_gain_range_max = (u8)dm_value;
-		break;
-
-	default:
-		break;
-	}
-
-}	/* DM_ChangeDynamicInitGainThresh */
-
 /*-----------------------------------------------------------------------------
  * Function:	dm_dig_init()
  *
drivers/staging/rtl8192u/r8192U_dm.h +0 -20
index d7bd257a7e93..471609819e08 100644
@@ -105,24 +105,6 @@ struct dig {
 	long		rssi_val;
 };
 
-/* 2007/10/11 MH Define DIG operation type. */
-typedef enum tag_dynamic_init_gain_operation_type_definition {
-	DIG_TYPE_THRESH_HIGH	= 0,
-	DIG_TYPE_THRESH_LOW	= 1,
-	DIG_TYPE_THRESH_HIGHPWR_HIGH	= 2,
-	DIG_TYPE_THRESH_HIGHPWR_LOW	= 3,
-	DIG_TYPE_DBG_MODE				= 4,
-	DIG_TYPE_RSSI						= 5,
-	DIG_TYPE_ALGORITHM				= 6,
-	DIG_TYPE_BACKOFF					= 7,
-	DIG_TYPE_PWDB_FACTOR			= 8,
-	DIG_TYPE_RX_GAIN_MIN				= 9,
-	DIG_TYPE_RX_GAIN_MAX				= 10,
-	DIG_TYPE_ENABLE			= 20,
-	DIG_TYPE_DISABLE		= 30,
-	DIG_OP_TYPE_MAX
-} dm_dig_op_e;
-
 typedef enum tag_dig_algorithm_definition {
 	DIG_ALGO_BY_FALSE_ALARM = 0,
 	DIG_ALGO_BY_RSSI	= 1,
@@ -209,8 +191,6 @@ void init_rate_adaptive(struct net_device *dev);
 void dm_txpower_trackingcallback(struct work_struct *work);
 void dm_restore_dynamic_mechanism_state(struct net_device *dev);
 void dm_backup_dynamic_mechanism_state(struct net_device *dev);
-void dm_change_dynamic_initgain_thresh(struct net_device *dev,
-				       u32 dm_type, u32 dm_value);
 void dm_force_tx_fw_info(struct net_device *dev,
 			 u32 force_type, u32 force_value);
 void dm_init_edca_turbo(struct net_device *dev);
Signature · 1 line
2.18.0
#12 lore raw

PATCH v2 10/15 staging:rtl8192u: Refactor enum dm_dig_alg_e - Style

In reply to John Whitmore

The enumerated type dm_dig_alg_e is only used by one variable in the code, 'dig_algorithm', a member variable of the structure dig. That member variable was defined to be of type 'u8' thus negating any advantage of the use of an enumerated type, (compiler type-checking).

The type of the variable 'dig_algorithm' has been change to reflect its use of the enumeration and the enumerated type moved in the file so that it appears before it is used in the file.

Additionally the 'typedef' has been removed to clear the checkpatch issue with defining new types, and the type renamed to enum dig_algorithm.

The enumerated constant DIG_ALGO_MAX has been removed from the type since it is never used in the code.

These changes are all coding style in nature and as such should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r8192U_dm.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/staging/rtl8192u/r8192U_dm.h +6 -7
index 471609819e08..9cea9b818843 100644
@@ -65,6 +65,11 @@
 
 /*------------------------------Define structure----------------------------*/
 
+enum dig_algorithm {
+	DIG_ALGO_BY_FALSE_ALARM = 0,
+	DIG_ALGO_BY_RSSI	= 1,
+};
+
 enum dynamic_init_gain_state {
 	DM_STA_DIG_OFF = 0,
 	DM_STA_DIG_ON,
@@ -74,7 +79,7 @@ enum dynamic_init_gain_state {
 /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
 struct dig {
 	u8		dig_enable_flag;
-	u8		dig_algorithm;
+	enum dig_algorithm		dig_algorithm;
 	u8		dbg_mode;
 	u8		dig_algorithm_switch;
 
@@ -105,12 +110,6 @@ struct dig {
 	long		rssi_val;
 };
 
-typedef enum tag_dig_algorithm_definition {
-	DIG_ALGO_BY_FALSE_ALARM = 0,
-	DIG_ALGO_BY_RSSI	= 1,
-	DIG_ALGO_MAX
-} dm_dig_alg_e;
-
 typedef enum tag_dig_dbgmode_definition {
 	DIG_DBG_OFF = 0,
 	DIG_DBG_ON = 1,
Signature · 1 line
2.18.0
#13 lore raw

PATCH v2 11/15 staging:rtl8192u: Remove unused enum dm_dig_dbg_e - Style

In reply to John Whitmore

The enumerated type dm_dig_dbg_e is never used in code so has simply been removed from the source code.

this is a coding style change which should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r8192U_dm.h | 6 ------
 1 file changed, 6 deletions(-)
drivers/staging/rtl8192u/r8192U_dm.h +0 -6
index 9cea9b818843..c15faa428b1d 100644
@@ -110,12 +110,6 @@ struct dig {
 	long		rssi_val;
 };
 
-typedef enum tag_dig_dbgmode_definition {
-	DIG_DBG_OFF = 0,
-	DIG_DBG_ON = 1,
-	DIG_DBG_MAX
-} dm_dig_dbg_e;
-
 typedef enum tag_dig_connect_definition {
 	DIG_DISCONNECT = 0,
 	DIG_CONNECT = 1,
Signature · 1 line
2.18.0
#14 lore raw

PATCH v2 12/15 staging:rtl8192u: Refactor dm_dig_connect_e - Style

In reply to John Whitmore

The enumerated type dm_dig_connect_e is only used to group constant values, as the actual type is never used as the type for the variables which use the defined constants (cur_connect_state and pre_connect_state).

These two member variables have had there defined types changed to properly reflect there usage and to permit compiler type checks to be performed.

In addition the definition of the enumerated type has been moved above the structure which uses the type. The typedef of the enumerated type has been removed to clear the checkpatch issue with defining new types and the enumerated value DIG_CONNECT_MAX has been removed since it is never used in code.

The resulting changes are all coding style in nature and should not impact runtime code execution.

---
 drivers/staging/rtl8192u/r8192U_dm.h | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/staging/rtl8192u/r8192U_dm.h +7 -8
index c15faa428b1d..8de6d15fb659 100644
@@ -76,6 +76,11 @@ enum dynamic_init_gain_state {
 	DM_STA_DIG_MAX
 };
 
+enum dig_connect {
+	DIG_DISCONNECT = 0,
+	DIG_CONNECT = 1,
+};
+
 /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
 struct dig {
 	u8		dig_enable_flag;
@@ -91,8 +96,8 @@ struct dig {
 
 	enum dynamic_init_gain_state		dig_state;
 	enum dynamic_init_gain_state		dig_highpwr_state;
-	u8		cur_connect_state;
-	u8		pre_connect_state;
+	enum dig_connect		cur_connect_state;
+	enum dig_connect		pre_connect_state;
 
 	u8		curpd_thstate;
 	u8		prepd_thstate;
@@ -110,12 +115,6 @@ struct dig {
 	long		rssi_val;
 };
 
-typedef enum tag_dig_connect_definition {
-	DIG_DISCONNECT = 0,
-	DIG_CONNECT = 1,
-	DIG_CONNECT_MAX
-} dm_dig_connect_e;
-
 typedef enum tag_dig_packetdetection_threshold_definition {
 	DIG_PD_AT_LOW_POWER = 0,
 	DIG_PD_AT_NORMAL_POWER = 1,
Signature · 1 line
2.18.0
#15 lore raw

PATCH v2 13/15 staging:rtl8192u: Refactor enum dm_dig_pd_th_e - Style

In reply to John Whitmore

The enumerated type dm_dig_pd_th_e is never actually used as the type for the two variables which use the constants, which the enumeration defines. This omission removes the possibility of taking advantage of compiler type checking.

To correct this the two member variables, (curpd_thstate & prepd_thstate) have been changed to use the type enum dig_pkt_detection_threshold rather then u8.

Additionally the enum's declaration has been moved above the dig structure, where the type is used, the 'typedef' has been removed to clear the checkpatch issue with defining new types, and the value 'DIG_PD_MAX' has been removed from the enumeration, since it is never used in code.

---
 drivers/staging/rtl8192u/r8192U_dm.h | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/staging/rtl8192u/r8192U_dm.h +8 -9
index 8de6d15fb659..f9d75ad9eaee 100644
@@ -81,6 +81,12 @@ enum dig_connect {
 	DIG_CONNECT = 1,
 };
 
+enum dig_pkt_detection_threshold {
+	DIG_PD_AT_LOW_POWER = 0,
+	DIG_PD_AT_NORMAL_POWER = 1,
+	DIG_PD_AT_HIGH_POWER = 2,
+};
+
 /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
 struct dig {
 	u8		dig_enable_flag;
@@ -99,8 +105,8 @@ struct dig {
 	enum dig_connect		cur_connect_state;
 	enum dig_connect		pre_connect_state;
 
-	u8		curpd_thstate;
-	u8		prepd_thstate;
+	enum dig_pkt_detection_threshold		curpd_thstate;
+	enum dig_pkt_detection_threshold		prepd_thstate;
 	u8		curcs_ratio_state;
 	u8		precs_ratio_state;
 
@@ -115,13 +121,6 @@ struct dig {
 	long		rssi_val;
 };
 
-typedef enum tag_dig_packetdetection_threshold_definition {
-	DIG_PD_AT_LOW_POWER = 0,
-	DIG_PD_AT_NORMAL_POWER = 1,
-	DIG_PD_AT_HIGH_POWER = 2,
-	DIG_PD_MAX
-} dm_dig_pd_th_e;
-
 typedef enum tag_dig_cck_cs_ratio_state_definition {
 	DIG_CS_RATIO_LOWER = 0,
 	DIG_CS_RATIO_HIGHER = 1,
Signature · 1 line
2.18.0
#16 lore raw

PATCH v2 14/15 staging:rtl8192u: Refactor enum dm_dig_cs_ratio_e - Style

In reply to John Whitmore

The enumerated type dm_dig_cs_ratio_e is never actually used as a type, but only as a collection of related constants. This is because the variables, which use the defined constant values, are defined as being of type u8 rather then tne enumerated type. This omission negates the possibility of taking advantage of compiler type checking.

To enable the use of compiler type checking of the enumeration the two variables, (curcs_ratio_state & precs_ratio_state), which use the type's constants have their types changed from u8 to enum dig_cck_cs_ratio_state.

Additionally the types declaration has been moved above the dig structure, where the type is used. The 'typedef' keyword has been removed from the type to clear the checkpatch issue with defining new types. And the constant DIG_CS_MAX has been removed since this is never used in the code.

These changes are purely coding style changes and should not impact on runtime code execution.

---
 drivers/staging/rtl8192u/r8192U_dm.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8192u/r8192U_dm.h +7 -7
index f9d75ad9eaee..f0e259ddea5d 100644
@@ -87,6 +87,11 @@ enum dig_pkt_detection_threshold {
 	DIG_PD_AT_HIGH_POWER = 2,
 };
 
+enum dig_cck_cs_ratio_state {
+	DIG_CS_RATIO_LOWER = 0,
+	DIG_CS_RATIO_HIGHER = 1,
+};
+
 /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
 struct dig {
 	u8		dig_enable_flag;
@@ -107,8 +112,8 @@ struct dig {
 
 	enum dig_pkt_detection_threshold		curpd_thstate;
 	enum dig_pkt_detection_threshold		prepd_thstate;
-	u8		curcs_ratio_state;
-	u8		precs_ratio_state;
+	enum dig_cck_cs_ratio_state		curcs_ratio_state;
+	enum dig_cck_cs_ratio_state		precs_ratio_state;
 
 	u32		pre_ig_value;
 	u32		cur_ig_value;
@@ -121,11 +126,6 @@ struct dig {
 	long		rssi_val;
 };
 
-typedef enum tag_dig_cck_cs_ratio_state_definition {
-	DIG_CS_RATIO_LOWER = 0,
-	DIG_CS_RATIO_HIGHER = 1,
-	DIG_CS_MAX
-} dm_dig_cs_ratio_e;
 struct dynamic_rx_path_sel {
 	u8		Enable;
 	u8		DbgMode;
Signature · 1 line
2.18.0
#17 lore raw

PATCH v2 15/15 staging:rtl8192u: Refactor enum DM_CCK_Rx_Path_Method - Style

In reply to John Whitmore

The enumerated type DM_CCK_Rx_Path_Method is used as a container for constant definitions, rather then an enumerated type enabling compiler type checking. To correct this, the variable which uses the constants, defined by the enumeration, has had its type changed from a u8 to the enumeration.

Additionally the type has been moved above the structure where the type is used, to avoid compiler error. The typedef has been removed from the enumerated type to clear the checkpatch issue with defining new types. The name of the type has been changed to cck_rx_path_method to clear the checkpatch issue with CamelCase naming. And the enumerated constant CCK_Rx_Version_MAX has been removed, since it is never used in code.

The changes are all coding style in nature and so should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/r8192U_dm.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/staging/rtl8192u/r8192U_dm.h +6 -7
index f0e259ddea5d..2ba6a4208870 100644
@@ -126,10 +126,15 @@ struct dig {
 	long		rssi_val;
 };
 
+enum cck_rx_path_method {
+	CCK_Rx_Version_1 = 0,
+	CCK_Rx_Version_2 = 1,
+};
+
 struct dynamic_rx_path_sel {
 	u8		Enable;
 	u8		DbgMode;
-	u8		cck_method;
+	enum cck_rx_path_method		cck_method;
 	u8		cck_Rx_path;
 
 	u8		SS_TH_low;
@@ -142,12 +147,6 @@ struct dynamic_rx_path_sel {
 	long		cck_pwdb_sta[4];
 };
 
-typedef enum tag_CCK_Rx_Path_Method_Definition {
-	CCK_Rx_Version_1 = 0,
-	CCK_Rx_Version_2 = 1,
-	CCK_Rx_Version_MAX
-} DM_CCK_Rx_Path_Method;
-
 typedef enum tag_DM_DbgMode_Definition {
 	DM_DBG_OFF = 0,
 	DM_DBG_ON = 1,
Signature · 1 line
2.18.0