linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Whitmore <johnfwhitmore@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	aastha.gupta4104@gmail.com, keescook@chromium.org,
	pombredanne@nexb.com, kstewart@linuxfoundation.org,
	tglx@linutronix.de, John Whitmore <johnfwhitmore@gmail.com>
Subject: [PATCH 10/10] staging:rtl8192u: Change struct r8192_priv member Rf_Mode from u8 > enum
Date: Wed, 11 Jul 2018 20:21:49 +0100	[thread overview]
Message-ID: <20180711192149.21621-11-johnfwhitmore@gmail.com> (raw)
In-Reply-To: <20180711192149.21621-1-johnfwhitmore@gmail.com>

The file r8192U.h defines the structure for holding private data for the
driver (typedef struct r8192_priv). This structure includes a member Rf_Mode
which is defined to be of type "u8".

Whilst the variable Rf_Mode is defined to be of type "u8" it is being assigned
enumerated values defined by the enumerated type "enum rf_op_type". Because of
the mismatch in types being used any advantage of using an enumerated type, to
have the compiler check assignments, is nullified.

This patch changes the type of the Rf_Mode member from a u8 to the enumerated
type "enum rf_op_type", so that the compiler can now check assignments.

This change of type would cause a problem if the structure was mapped from a
hardware device and the size and location of members was significant. I
believe that the structure to hold private data for the driver is allocated
from memory and populated with data in the function rtl8192_usb_probe() in the
file r8192U_core.c. As such the physical size of the member variable Rf_Mode
is not significant, so the change should have no impact on code execution, bar
the move from a u8 type to an int, (or whatever size compiler uses for enum).

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

diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
index 83bc4cef5b17..3963855ad743 100644
--- a/drivers/staging/rtl8192u/r8192U.h
+++ b/drivers/staging/rtl8192u/r8192U.h
@@ -334,11 +334,12 @@ struct rx_drvinfo_819x_usb {
 /* Octets for crc32 (FCS, ICV) */
 #define scrclng					4
 
-typedef enum rf_optype {
+enum rf_op_type {
 	RF_OP_By_SW_3wire = 0,
 	RF_OP_By_FW,
 	RF_OP_MAX
-} rf_op_type;
+};
+
 /* 8190 Loopback Mode definition */
 typedef enum _rtl819xUsb_loopback {
 	RTL819xU_NO_LOOPBACK = 0,
@@ -894,7 +895,7 @@ typedef struct r8192_priv {
 	u8      slot_time;
 	bool	bDcut;
 	bool bCurrentRxAggrEnable;
-	u8 Rf_Mode;	/* For Firmware RF -R/W switch */
+	enum rf_op_type Rf_Mode;	/* For Firmware RF -R/W switch */
 	prt_firmware		pFirmware;
 	rtl819xUsb_loopback_e	LoopbackMode;
 	u16 EEPROMTxPowerDiff;
-- 
2.18.0


      parent reply	other threads:[~2018-07-11 19:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11 19:21 [0/10] staging:rtl8192u: One significant change John Whitmore
2018-07-11 19:21 ` [PATCH 01/10] staging:rtl8192u: typedef struct tx_desc_819x_usb > struct tx_desc_819x_usb John Whitmore
2018-07-11 19:21 ` [PATCH 02/10] staging:rtl8192u: trim multiple blank lines - Coding Style John Whitmore
2018-07-11 19:21 ` [PATCH 03/10] staging:rtl8192u: remove unused structure tx_desc_819x_usb_aggr_subframe John Whitmore
2018-07-11 19:21 ` [PATCH 04/10] staging:rtl8192u: Rename file macro to avoid camel case - Coding Style John Whitmore
2018-07-13  9:39   ` Greg KH
2018-07-13 11:26     ` John Whitmore
2018-07-11 19:21 ` [PATCH 05/10] staging:rtl8192u: typedef struct tx_desc_cmd_819x_usb remove typedef John Whitmore
2018-07-11 19:21 ` [PATCH 06/10] staging:rtl8192u: typedef struct tx_fwinfo_819x_usb " John Whitmore
2018-07-11 19:21 ` [PATCH 07/10] staging:rtl8192u: typedef struct rx_desc_819x_usb " John Whitmore
2018-07-11 19:21 ` [PATCH 08/10] staging:rtl8192u: Remove struct rx_desc_819x_usb_aggr_subframe John Whitmore
2018-07-11 19:21 ` [PATCH 09/10] staging:rtl8192u: remove typedef from struct rx_drvinfo_819x_usb John Whitmore
2018-07-11 19:21 ` John Whitmore [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180711192149.21621-11-johnfwhitmore@gmail.com \
    --to=johnfwhitmore@gmail.com \
    --cc=aastha.gupta4104@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pombredanne@nexb.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).