linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style
@ 2018-07-27 23:28 John Whitmore
  2018-07-27 23:28 ` [PATCH 01/10] staging:rtl8192u: Remove unused DM_check_fsync_time_interval - Style John Whitmore
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, John Whitmore

What was intended as a clean up of the file
drivers/staging/rtl8192u/r8192U_dm.h turned into refactoring of most of
the enumerated types defined in the file. Most of the enumerated types
were simply used to define a collection of constants, rather then
actually using the types as enumerated types.

So the variables which used the enums were all defined as being of
type u8. This removes the ability of the compiler to do type checking
of the types used. To correct this all u8 types have been changed to
enums where appropriate.

Whilst I've called these patches refactoring they are all essentially
coding style changes.

John Whitmore (10):
  staging:rtl8192u: Remove unused DM_check_fsync_time_interval - 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
  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 | 125 +++++++++------------------
 3 files changed, 51 insertions(+), 175 deletions(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 01/10] staging:rtl8192u: Remove unused DM_check_fsync_time_interval - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-27 23:28 ` [PATCH 02/10] staging:rtl8192u: Refactor use of enum dm_dig_sta_e " John Whitmore
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, John Whitmore

Remove the unused definition for DM_check_fsync_time_interval.

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

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 8f3d618dcfdb..e86dda99c223 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -32,9 +32,6 @@
 #define		BW_AUTO_SWITCH_HIGH_LOW			25
 #define		BW_AUTO_SWITCH_LOW_HIGH			30
 
-#define		DM_check_fsync_time_interval				500
-
-
 #define		DM_DIG_BACKOFF				12
 #define		DM_DIG_MAX					0x36
 #define		DM_DIG_MIN					0x1c
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 02/10] staging:rtl8192u: Refactor use of enum dm_dig_sta_e - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
  2018-07-27 23:28 ` [PATCH 01/10] staging:rtl8192u: Remove unused DM_check_fsync_time_interval - Style John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-29  8:17   ` Greg KH
  2018-07-27 23:28 ` [PATCH 03/10] staging:rtl8192u: Refactor enum dm_ratr_sta_e usage " John Whitmore
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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 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 dm_dig_sta_e. The enumerated type has been moved above the
struct dig definition so that the enumeration is already defined when
compiler reaches the two types using the enumerated type.

In addition the 'typedef' of the enumerated type has been removed to
clear the checkpatch issue with declaring new types.

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

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index e86dda99c223..2444e1c1357b 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -64,6 +64,13 @@
 
 
 /*------------------------------Define structure----------------------------*/
+
+enum dm_dig_sta_e {
+	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 dm_dig_sta_e		dig_state;
+	enum dm_dig_sta_e		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,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 03/10] staging:rtl8192u: Refactor enum dm_ratr_sta_e usage - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
  2018-07-27 23:28 ` [PATCH 01/10] staging:rtl8192u: Remove unused DM_check_fsync_time_interval - Style John Whitmore
  2018-07-27 23:28 ` [PATCH 02/10] staging:rtl8192u: Refactor use of enum dm_dig_sta_e " John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-27 23:28 ` [PATCH 04/10] staging:rtl8192u: Remove enum dm_dig_op_e John Whitmore
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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.

Additionally the typedef from the enumerated type has been removed to
clear the checkpatch issue with defining new types.

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

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U.h    | 10 +++++++++-
 drivers/staging/rtl8192u/r8192U_dm.h |  8 --------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
index e615d9b3f6b1..b00781e1f5ee 100644
--- a/drivers/staging/rtl8192u/r8192U.h
+++ b/drivers/staging/rtl8192u/r8192U.h
@@ -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 dm_ratr_sta_e {
+	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 dm_ratr_sta_e		ratr_state;
 	u16				reserve;
 
 	u32				high_rssi_thresh_for_ra;
diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 2444e1c1357b..942e9ba8d3ad 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -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,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 04/10] staging:rtl8192u: Remove enum dm_dig_op_e
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
                   ` (2 preceding siblings ...)
  2018-07-27 23:28 ` [PATCH 03/10] staging:rtl8192u: Refactor enum dm_ratr_sta_e usage " John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-27 23:28 ` [PATCH 05/10] staging:rtl8192u: Refactor enum dm_dig_alg_e - Style John Whitmore
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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.

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.c | 91 ----------------------------
 drivers/staging/rtl8192u/r8192U_dm.h | 20 ------
 2 files changed, 111 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c
index c4e4e3ba394b..16dbe55d0e15 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -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()
  *
diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 942e9ba8d3ad..7d7eeb1cb9fc 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -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);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 05/10] staging:rtl8192u: Refactor enum dm_dig_alg_e - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
                   ` (3 preceding siblings ...)
  2018-07-27 23:28 ` [PATCH 04/10] staging:rtl8192u: Remove enum dm_dig_op_e John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-27 23:28 ` [PATCH 06/10] staging:rtl8192u: Remove unused enum dm_dig_dbg_e " John Whitmore
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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.

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

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 7d7eeb1cb9fc..22e25a5cf40a 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -65,6 +65,11 @@
 
 /*------------------------------Define structure----------------------------*/
 
+enum dm_dig_alg_e {
+	DIG_ALGO_BY_FALSE_ALARM = 0,
+	DIG_ALGO_BY_RSSI	= 1,
+};
+
 enum dm_dig_sta_e {
 	DM_STA_DIG_OFF = 0,
 	DM_STA_DIG_ON,
@@ -74,7 +79,7 @@ enum dm_dig_sta_e {
 /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
 struct dig {
 	u8		dig_enable_flag;
-	u8		dig_algorithm;
+	enum dm_dig_alg_e		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,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 06/10] staging:rtl8192u: Remove unused enum dm_dig_dbg_e - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
                   ` (4 preceding siblings ...)
  2018-07-27 23:28 ` [PATCH 05/10] staging:rtl8192u: Refactor enum dm_dig_alg_e - Style John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-27 23:28 ` [PATCH 07/10] staging:rtl8192u: Refactor dm_dig_connect_e " John Whitmore
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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.

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 22e25a5cf40a..450bcbe3095e 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -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,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 07/10] staging:rtl8192u: Refactor dm_dig_connect_e - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
                   ` (5 preceding siblings ...)
  2018-07-27 23:28 ` [PATCH 06/10] staging:rtl8192u: Remove unused enum dm_dig_dbg_e " John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-27 23:28 ` [PATCH 08/10] staging:rtl8192u: Refactor enum dm_dig_pd_th_e " John Whitmore
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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.

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.h | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 450bcbe3095e..825df06e17a8 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -76,6 +76,11 @@ enum dm_dig_sta_e {
 	DM_STA_DIG_MAX
 };
 
+enum dm_dig_connect_e {
+	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 dm_dig_sta_e		dig_state;
 	enum dm_dig_sta_e		dig_highpwr_state;
-	u8		cur_connect_state;
-	u8		pre_connect_state;
+	enum dm_dig_connect_e		cur_connect_state;
+	enum dm_dig_connect_e		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,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 08/10] staging:rtl8192u: Refactor enum dm_dig_pd_th_e - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
                   ` (6 preceding siblings ...)
  2018-07-27 23:28 ` [PATCH 07/10] staging:rtl8192u: Refactor dm_dig_connect_e " John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-27 23:28 ` [PATCH 09/10] staging:rtl8192u: Refactor enum dm_dig_cs_ratio_e " John Whitmore
  2018-07-27 23:28 ` [PATCH 10/10] staging:rtl8192u: Refactor enum DM_CCK_Rx_Path_Method " John Whitmore
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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 dm_dig_pd_th_e 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.

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.h | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 825df06e17a8..41b08211e958 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -81,6 +81,12 @@ enum dm_dig_connect_e {
 	DIG_CONNECT = 1,
 };
 
+enum dm_dig_pd_th_e {
+	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 dm_dig_connect_e		cur_connect_state;
 	enum dm_dig_connect_e		pre_connect_state;
 
-	u8		curpd_thstate;
-	u8		prepd_thstate;
+	enum dm_dig_pd_th_e		curpd_thstate;
+	enum dm_dig_pd_th_e		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,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 09/10] staging:rtl8192u: Refactor enum dm_dig_cs_ratio_e - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
                   ` (7 preceding siblings ...)
  2018-07-27 23:28 ` [PATCH 08/10] staging:rtl8192u: Refactor enum dm_dig_pd_th_e " John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  2018-07-27 23:28 ` [PATCH 10/10] staging:rtl8192u: Refactor enum DM_CCK_Rx_Path_Method " John Whitmore
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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 enum dm_dig_cs_ratio_e. 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 dm_dig_cs_ratio_e.

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.

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 41b08211e958..2aef330379cb 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -87,6 +87,11 @@ enum dm_dig_pd_th_e {
 	DIG_PD_AT_HIGH_POWER = 2,
 };
 
+enum dm_dig_cs_ratio_e {
+	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 dm_dig_pd_th_e		curpd_thstate;
 	enum dm_dig_pd_th_e		prepd_thstate;
-	u8		curcs_ratio_state;
-	u8		precs_ratio_state;
+	enum dm_dig_cs_ratio_e		curcs_ratio_state;
+	enum dm_dig_cs_ratio_e		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;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 10/10] staging:rtl8192u: Refactor enum DM_CCK_Rx_Path_Method - Style
  2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
                   ` (8 preceding siblings ...)
  2018-07-27 23:28 ` [PATCH 09/10] staging:rtl8192u: Refactor enum dm_dig_cs_ratio_e " John Whitmore
@ 2018-07-27 23:28 ` John Whitmore
  9 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-27 23:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, gregkh, 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 dm_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.

Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_dm.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
index 2aef330379cb..42effcec5277 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.h
+++ b/drivers/staging/rtl8192u/r8192U_dm.h
@@ -126,10 +126,15 @@ struct dig {
 	long		rssi_val;
 };
 
+enum dm_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 dm_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,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 02/10] staging:rtl8192u: Refactor use of enum dm_dig_sta_e - Style
  2018-07-27 23:28 ` [PATCH 02/10] staging:rtl8192u: Refactor use of enum dm_dig_sta_e " John Whitmore
@ 2018-07-29  8:17   ` Greg KH
  2018-07-29  9:50     ` John Whitmore
  0 siblings, 1 reply; 13+ messages in thread
From: Greg KH @ 2018-07-29  8:17 UTC (permalink / raw)
  To: John Whitmore; +Cc: linux-kernel, devel

On Sat, Jul 28, 2018 at 12:28:18AM +0100, John Whitmore wrote:
> Refactor the use of the enumerated type dm_dig_sta_e, which is not
> actually used for type checking by the compiler.
> 
> 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 dm_dig_sta_e. The enumerated type has been moved above the
> struct dig definition so that the enumeration is already defined when
> compiler reaches the two types using the enumerated type.
> 
> In addition the 'typedef' of the enumerated type has been removed to
> clear the checkpatch issue with declaring new types.
> 
> These changes, whilst convoluted, are purely coding style in nature and
> should not impact runtime code execution.
> 
> Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_dm.h | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
> index e86dda99c223..2444e1c1357b 100644
> --- a/drivers/staging/rtl8192u/r8192U_dm.h
> +++ b/drivers/staging/rtl8192u/r8192U_dm.h
> @@ -64,6 +64,13 @@
>  
>  
>  /*------------------------------Define structure----------------------------*/
> +
> +enum dm_dig_sta_e {

Don't end an enum with "_e", as that's not needed at all.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 02/10] staging:rtl8192u: Refactor use of enum dm_dig_sta_e - Style
  2018-07-29  8:17   ` Greg KH
@ 2018-07-29  9:50     ` John Whitmore
  0 siblings, 0 replies; 13+ messages in thread
From: John Whitmore @ 2018-07-29  9:50 UTC (permalink / raw)
  To: Greg KH; +Cc: John Whitmore, linux-kernel, devel

On Sun, Jul 29, 2018 at 10:17:26AM +0200, Greg KH wrote:
> On Sat, Jul 28, 2018 at 12:28:18AM +0100, John Whitmore wrote:
> > Refactor the use of the enumerated type dm_dig_sta_e, which is not
> > actually used for type checking by the compiler.
> > 
> > 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 dm_dig_sta_e. The enumerated type has been moved above the
> > struct dig definition so that the enumeration is already defined when
> > compiler reaches the two types using the enumerated type.
> > 
> > In addition the 'typedef' of the enumerated type has been removed to
> > clear the checkpatch issue with declaring new types.
> > 
> > These changes, whilst convoluted, are purely coding style in nature and
> > should not impact runtime code execution.
> > 
> > Signed-off-by: John Whitmore <johnfwhitmore@gmail.com>
> > ---
> >  drivers/staging/rtl8192u/r8192U_dm.h | 18 +++++++++---------
> >  1 file changed, 9 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
> > index e86dda99c223..2444e1c1357b 100644
> > --- a/drivers/staging/rtl8192u/r8192U_dm.h
> > +++ b/drivers/staging/rtl8192u/r8192U_dm.h
> > @@ -64,6 +64,13 @@
> >  
> >  
> >  /*------------------------------Define structure----------------------------*/
> > +
> > +enum dm_dig_sta_e {
> 
> Don't end an enum with "_e", as that's not needed at all.
> 
> thanks,
> 
> greg k-h

Oh! Thanks for that, it never occured to me that the '_e' was notation.
Again I'll fix up all those affected and resend.

jwhitmore

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-07-29  9:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27 23:28 [PATCH 00/10] staging:rtl8192u: Refactor enums r8192U_dm.h -Style John Whitmore
2018-07-27 23:28 ` [PATCH 01/10] staging:rtl8192u: Remove unused DM_check_fsync_time_interval - Style John Whitmore
2018-07-27 23:28 ` [PATCH 02/10] staging:rtl8192u: Refactor use of enum dm_dig_sta_e " John Whitmore
2018-07-29  8:17   ` Greg KH
2018-07-29  9:50     ` John Whitmore
2018-07-27 23:28 ` [PATCH 03/10] staging:rtl8192u: Refactor enum dm_ratr_sta_e usage " John Whitmore
2018-07-27 23:28 ` [PATCH 04/10] staging:rtl8192u: Remove enum dm_dig_op_e John Whitmore
2018-07-27 23:28 ` [PATCH 05/10] staging:rtl8192u: Refactor enum dm_dig_alg_e - Style John Whitmore
2018-07-27 23:28 ` [PATCH 06/10] staging:rtl8192u: Remove unused enum dm_dig_dbg_e " John Whitmore
2018-07-27 23:28 ` [PATCH 07/10] staging:rtl8192u: Refactor dm_dig_connect_e " John Whitmore
2018-07-27 23:28 ` [PATCH 08/10] staging:rtl8192u: Refactor enum dm_dig_pd_th_e " John Whitmore
2018-07-27 23:28 ` [PATCH 09/10] staging:rtl8192u: Refactor enum dm_dig_cs_ratio_e " John Whitmore
2018-07-27 23:28 ` [PATCH 10/10] staging:rtl8192u: Refactor enum DM_CCK_Rx_Path_Method " John Whitmore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).