Skip to contentSkip to conversation

staging:rtl8192u: One significant change...

PATCH In review John Whitmore 3 participants 13 messages Jul 11, 2018 – Jul 13, 2018 Staging

lore
Share & tools
lore
#0 lore raw

cover staging:rtl8192u: One significant change...

The first 9 patches in this series are coding style changes, including a number of patches to remove the "typedef" directive from a number of data structure definitions. This clears the checkpatch warning about defining new data types in the code.

The last patch in the series, however, changes the data type of a member variable from a u8 to an enumerated type. Generally in C an enumerated type is implemented by the compiler as an int, but can be changed by compiler directives. Either way the member variable will most probably have its size changed by this patch. I don't think that the structure is mapped to hardware or physical memory location, but is allocated and populated in the rtl8192_usb_probe() function in the file r8192U_core.c. Given that allocation/population I don't think that the size of the member variable is of run time significance, bar the slight increase in size of the overall structure.

The reason for doing this is to enable the compiler's checking of assignments to the variable defined as an enumerated type. The alternative is to leave the variable as a u8 and remove the enumerated type, replacing it with #define definitions of the possible values.

I raised this issue on the kernel newbies mailing list and of the two alternatives enumerated type won out.

#1 lore raw

PATCH 1/10 staging:rtl8192u: typedef struct tx_desc_819x_usb > struct tx_desc_819x_usb

Change structure tx_desc_819x_usb from being typedef to being a simple structure, without the typedef.

checkpatch warns about defining new types in code.

---
 drivers/staging/rtl8192u/r8192U.h      | 6 +++---
 drivers/staging/rtl8192u/r8192U_core.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8192u/r8192U.h +3 -3
index 37aa36126d19..fa451c6081ef 100644
@@ -177,7 +177,7 @@ extern u32 rt_global_debug_component;
 #define	CCK_Table_length	12
 
 /* For rtl819x */
-typedef struct _tx_desc_819x_usb {
+struct tx_desc_819x_usb {
 	/* DWORD 0 */
 	u16	PktSize;
 	u8	Offset;
@@ -213,7 +213,7 @@ typedef struct _tx_desc_819x_usb {
 	u32	Reserved5;
 	u32	Reserved6;
 	u32	Reserved7;
-} tx_desc_819x_usb, *ptx_desc_819x_usb;
+};
 
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
 typedef struct _tx_desc_819x_usb_aggr_subframe {
@@ -371,7 +371,7 @@ typedef struct rx_drvinfo_819x_usb {
 #define MAX_FIRMWARE_INFORMATION_SIZE   32
 #define MAX_802_11_HEADER_LENGTH        (40 + MAX_FIRMWARE_INFORMATION_SIZE)
 #define ENCRYPTION_MAX_OVERHEAD		128
-#define	USB_HWDESC_HEADER_LEN		sizeof(tx_desc_819x_usb)
+#define	USB_HWDESC_HEADER_LEN		sizeof(struct tx_desc_819x_usb)
 #define TX_PACKET_SHIFT_BYTES		(USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb))
 #define MAX_FRAGMENT_COUNT		8
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
drivers/staging/rtl8192u/r8192U_core.c +2 -2
index 848239e24859..a2a107521450 100644
@@ -1462,7 +1462,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 {
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
-	tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data;
+	struct tx_desc_819x_usb *tx_desc = (struct tx_desc_819x_usb *)skb->data;
 	tx_fwinfo_819x_usb *tx_fwinfo =
 		(tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
 	struct usb_device *udev = priv->udev;
@@ -1535,7 +1535,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	}
 
 	/* Fill Tx descriptor */
-	memset(tx_desc, 0, sizeof(tx_desc_819x_usb));
+	memset(tx_desc, 0, sizeof(struct tx_desc_819x_usb));
 	/* DWORD 0 */
 	tx_desc->LINIP = 0;
 	tx_desc->CmdInit = 1;
Signature · 1 line
2.18.0
#2 lore raw

PATCH 2/10 staging:rtl8192u: trim multiple blank lines - Coding Style

In reply to John Whitmore

Trim the extra blank lines from the code, to clear checkpatch messages.

---
 drivers/staging/rtl8192u/r8192U.h | 20 --------------------
 1 file changed, 20 deletions(-)
drivers/staging/rtl8192u/r8192U.h +0 -20
index fa451c6081ef..da23e7e9e3b9 100644
@@ -59,7 +59,6 @@ extern u32 rt_global_debug_component;
 #define COMP_DBG                BIT(1)
 #define COMP_INIT               BIT(2)  /* Driver initialization/halt/reset. */
 
-
 #define COMP_RECV               BIT(3)  /* Receive data path. */
 #define COMP_SEND               BIT(4)  /* Send data path. */
 #define COMP_IO                 BIT(5)
@@ -127,7 +126,6 @@ extern u32 rt_global_debug_component;
 #define RT_DEBUG_DATA(level, data, datalen) do {} while (0)
 #endif /* RTL8169_DEBUG */
 
-
 /* Queue Select Value in TxDesc */
 #define QSLT_BK                                 0x1
 #define QSLT_BE                                 0x0
@@ -240,8 +238,6 @@ typedef struct _tx_desc_819x_usb_aggr_subframe {
 } tx_desc_819x_usb_aggr_subframe, *ptx_desc_819x_usb_aggr_subframe;
 #endif
 
-
-
 typedef struct _tx_desc_cmd_819x_usb {
 	/* DWORD 0 */
 	u16	Reserved0;
@@ -269,7 +265,6 @@ typedef struct _tx_desc_cmd_819x_usb {
 	u32	Reserved8;
 } tx_desc_cmd_819x_usb, *ptx_desc_cmd_819x_usb;
 
-
 typedef struct _tx_fwinfo_819x_usb {
 	/* DOWRD 0 */
 	u8	TxRate:7;
@@ -492,7 +487,6 @@ typedef struct _rt_firmware_info_819xUsb {
 
 #define		PHY_RSSI_SLID_WIN_MAX				100
 
-
 typedef enum _WIRELESS_MODE {
 	WIRELESS_MODE_UNKNOWN = 0x00,
 	WIRELESS_MODE_A = 0x01,
@@ -503,7 +497,6 @@ typedef enum _WIRELESS_MODE {
 	WIRELESS_MODE_N_5G = 0x20
 } WIRELESS_MODE;
 
-
 #define RTL_IOCTL_WPA_SUPPLICANT		(SIOCIWFIRSTPRIV + 30)
 
 typedef struct buffer {
@@ -523,11 +516,6 @@ typedef struct rtl_reg_debug {
 	unsigned char buf[0xff];
 } rtl_reg_debug;
 
-
-
-
-
-
 typedef struct _rt_9x_tx_rate_history {
 	u32             cck[4];
 	u32             ofdm[8];
@@ -642,13 +630,11 @@ typedef struct Stats {
 	u32	CurrentShowTxate;
 } Stats;
 
-
 /* Bandwidth Offset */
 #define HAL_PRIME_CHNL_OFFSET_DONT_CARE		0
 #define HAL_PRIME_CHNL_OFFSET_LOWER			1
 #define HAL_PRIME_CHNL_OFFSET_UPPER			2
 
-
 typedef struct	ChnlAccessSetting {
 	u16 SIFS_Timer;
 	u16 DIFS_Timer;
@@ -757,7 +743,6 @@ typedef struct _ccktxbbgain_struct {
 	u8	ccktxbb_valuearray[8];
 } ccktxbbgain_struct, *pccktxbbgain_struct;
 
-
 typedef struct _init_gain {
 	u8				xaagccore1;
 	u8				xbagccore1;
@@ -793,7 +778,6 @@ typedef struct _phy_cck_rx_status_report_819xusb {
 	u8	cck_agc_rpt;
 } phy_sts_cck_819xusb_t;
 
-
 struct phy_ofdm_rx_status_rxsc_sgien_exintfflag {
 	u8			reserved:4;
 	u8			rxsc:2;
@@ -885,7 +869,6 @@ typedef struct r8192_priv {
 	short sens;
 	short max_sens;
 
-
 	short up;
 	/* If 1, allow bad crc frame, reception in monitor mode */
 	short crcmon;
@@ -924,7 +907,6 @@ typedef struct r8192_priv {
 	short  tx_urb_index;
 	atomic_t tx_pending[0x10]; /* UART_PRIORITY + 1 */
 
-
 	struct tasklet_struct irq_rx_tasklet;
 	struct urb *rxurb_task;
 
@@ -937,7 +919,6 @@ typedef struct r8192_priv {
 	u32     LastRxDescTSFHigh;
 	u32     LastRxDescTSFLow;
 
-
 	/* Rx Related variables */
 	u16	EarlyRxThreshold;
 	u32	ReceiveConfig;
@@ -1172,5 +1153,4 @@ void rtl819xusb_beacon_tx(struct net_device *dev, u16 tx_rate);
 void EnableHWSecurityConfig8192(struct net_device *dev);
 void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
 
-
 #endif
Signature · 1 line
2.18.0
#3 lore raw

PATCH 3/10 staging:rtl8192u: remove unused structure tx_desc_819x_usb_aggr_subframe

In reply to John Whitmore

Structure tx_desc_819x_usb_aggr_subframe is defined in a local header file but is not used outside of the header file. Removed from the code as a result.

---
 drivers/staging/rtl8192u/r8192U.h | 28 ----------------------------
 1 file changed, 28 deletions(-)
drivers/staging/rtl8192u/r8192U.h +0 -28
index da23e7e9e3b9..a653a51f7b90 100644
@@ -213,31 +213,6 @@ struct tx_desc_819x_usb {
 	u32	Reserved7;
 };
 
-#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
-typedef struct _tx_desc_819x_usb_aggr_subframe {
-	/* DWORD 0 */
-	u16	PktSize;
-	u8	Offset;
-	u8	TxFWInfoSize;
-
-	/* DWORD 1 */
-	u8	RATid:3;
-	u8	DISFB:1;
-	u8	USERATE:1;
-	u8	MOREFRAG:1;
-	u8	NoEnc:1;
-	u8	PIFS:1;
-	u8	QueueSelect:5;
-	u8	NoACM:1;
-	u8	Reserved1:2;
-	u8	SecCAMID:5;
-	u8	SecDescAssign:1;
-	u8	SecType:2;
-	u8	PacketID:7;
-	u8	OWN:1;
-} tx_desc_819x_usb_aggr_subframe, *ptx_desc_819x_usb_aggr_subframe;
-#endif
-
 typedef struct _tx_desc_cmd_819x_usb {
 	/* DWORD 0 */
 	u16	Reserved0;
@@ -374,9 +349,6 @@ typedef struct rx_drvinfo_819x_usb {
 #else
 #define MAX_TRANSMIT_BUFFER_SIZE			8000
 #endif
-#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
-#define TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES (sizeof(tx_desc_819x_usb_aggr_subframe) + sizeof(tx_fwinfo_819x_usb))
-#endif
 /* Octets for crc32 (FCS, ICV) */
 #define scrclng					4
 
Signature · 1 line
2.18.0
#4 lore raw

PATCH 4/10 staging:rtl8192u: Rename file macro to avoid camel case - Coding Style

In reply to John Whitmore

Simple rename of the preprosessor switch, protecting against multiple inclusion of the header file. Change to clear the checkpatch coding style issue.

---
 drivers/staging/rtl8192u/r8192U.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192u/r8192U.h +2 -2
index a653a51f7b90..86cf3ef3a970 100644
@@ -15,8 +15,8 @@
  * project Authors.
  */
 
-#ifndef R819xU_H
-#define R819xU_H
+#ifndef R819U_H
+#define R819U_H
 
 #include <linux/compiler.h>
 #include <linux/module.h>
Signature · 1 line
2.18.0
maintainer
#5 lore raw

Re: [PATCH 04/10] staging:rtl8192u: Rename file macro to avoid camel case - Coding Style

Quoted 14 lines · John Whitmore

Simple rename of the preprosessor switch, protecting against multiple inclusion of the header file. Change to clear the checkpatch coding style issue.

---
 drivers/staging/rtl8192u/r8192U.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192u/r8192U.h +0 -0
index a653a51f7b90..86cf3ef3a970 100644

drivers/staging/rtl8192u/r8192U.h line 19

Quoted 7 lines
drivers/staging/rtl8192u/r8192U.h +2 -2
@@ -15,8 +15,8 @@
  * project Authors.
  */
 
-#ifndef R819xU_H
-#define R819xU_H
+#ifndef R819U_H
+#define R819U_H

Shouldn't this be R8192U_H?

thanks,

greg k-h

#6 lore raw

Re: [PATCH 04/10] staging:rtl8192u: Rename file macro to avoid camel case - Coding Style

Quoted 25 lines · Greg KH
Quoted 14 lines · John Whitmore

Simple rename of the preprosessor switch, protecting against multiple inclusion of the header file. Change to clear the checkpatch coding style issue.

---
 drivers/staging/rtl8192u/r8192U.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192u/r8192U.h +0 -0
index a653a51f7b90..86cf3ef3a970 100644

drivers/staging/rtl8192u/r8192U.h line 19

Quoted 7 lines
drivers/staging/rtl8192u/r8192U.h +2 -2
@@ -15,8 +15,8 @@
  * project Authors.
  */
 
-#ifndef R819xU_H
-#define R819xU_H
+#ifndef R819U_H
+#define R819U_H

Shouldn't this be R8192U_H?

Quoted 3 lines

thanks,

greg k-h

Yes definately. I had another series of minor changes ready to go, so I just tacked this change onto the end again.

jwhitmore

#7 lore raw

PATCH 5/10 staging:rtl8192u: typedef struct tx_desc_cmd_819x_usb remove typedef

In reply to John Whitmore

Change structure tx_desc_cmd_819x_usb from being typedef to being a simple structure, without the typedef.

checkpatch warns about defining new types in the code.

---
 drivers/staging/rtl8192u/r8192U.h      | 4 ++--
 drivers/staging/rtl8192u/r8192U_core.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rtl8192u/r8192U.h +2 -2
index 86cf3ef3a970..7dd99612620a 100644
@@ -213,7 +213,7 @@ struct tx_desc_819x_usb {
 	u32	Reserved7;
 };
 
-typedef struct _tx_desc_cmd_819x_usb {
+struct tx_desc_cmd_819x_usb {
 	/* DWORD 0 */
 	u16	Reserved0;
 	u8	Reserved1;
@@ -238,7 +238,7 @@ typedef struct _tx_desc_cmd_819x_usb {
 	u32	Reserved6;
 	u32	Reserved7;
 	u32	Reserved8;
-} tx_desc_cmd_819x_usb, *ptx_desc_cmd_819x_usb;
+};
 
 typedef struct _tx_fwinfo_819x_usb {
 	/* DOWRD 0 */
drivers/staging/rtl8192u/r8192U_core.c +1 -1
index a2a107521450..d7fa7ece62fb 100644
@@ -1242,7 +1242,7 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
 	int			status;
 	struct urb		*tx_urb;
 	unsigned int		idx_pipe;
-	tx_desc_cmd_819x_usb *pdesc = (tx_desc_cmd_819x_usb *)skb->data;
+	struct tx_desc_cmd_819x_usb *pdesc = (struct tx_desc_cmd_819x_usb *)skb->data;
 	struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
 	u8 queue_index = tcb_desc->queue_index;
 
Signature · 1 line
2.18.0
#8 lore raw

PATCH 6/10 staging:rtl8192u: typedef struct tx_fwinfo_819x_usb remove typedef

In reply to John Whitmore

Change structure tx_fwinfo_819x_usb from being typedef to being a simple structure, without the typedef.

Clears the coding style issue flagged by checkpatch, (new type definitions)

---
 drivers/staging/rtl8192u/r8192U.h      |  6 +++---
 drivers/staging/rtl8192u/r8192U_core.c | 10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/rtl8192u/r8192U.h +3 -3
index 7dd99612620a..d9dbd3ca3dac 100644
@@ -240,7 +240,7 @@ struct tx_desc_cmd_819x_usb {
 	u32	Reserved8;
 };
 
-typedef struct _tx_fwinfo_819x_usb {
+struct tx_fwinfo_819x_usb {
 	/* DOWRD 0 */
 	u8	TxRate:7;
 	u8	CtsEnable:1;
@@ -271,7 +271,7 @@ typedef struct _tx_fwinfo_819x_usb {
 	u32	TxAGCSign:1;
 	u32	Tx_INFO_RSVD:6;
 	u32	PacketID:13;
-} tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb;
+};
 
 struct rtl8192_rx_info {
 	struct urb *urb;
@@ -342,7 +342,7 @@ typedef struct rx_drvinfo_819x_usb {
 #define MAX_802_11_HEADER_LENGTH        (40 + MAX_FIRMWARE_INFORMATION_SIZE)
 #define ENCRYPTION_MAX_OVERHEAD		128
 #define	USB_HWDESC_HEADER_LEN		sizeof(struct tx_desc_819x_usb)
-#define TX_PACKET_SHIFT_BYTES		(USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb))
+#define TX_PACKET_SHIFT_BYTES		(USB_HWDESC_HEADER_LEN + sizeof(struct tx_fwinfo_819x_usb))
 #define MAX_FRAGMENT_COUNT		8
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
 #define MAX_TRANSMIT_BUFFER_SIZE			32000
drivers/staging/rtl8192u/r8192U_core.c +5 -5
index d7fa7ece62fb..75bbcc115141 100644
@@ -1463,8 +1463,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
 	struct tx_desc_819x_usb *tx_desc = (struct tx_desc_819x_usb *)skb->data;
-	tx_fwinfo_819x_usb *tx_fwinfo =
-		(tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
+	struct tx_fwinfo_819x_usb *tx_fwinfo =
+		(struct tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);
 	struct usb_device *udev = priv->udev;
 	int pend;
 	int status;
@@ -1489,7 +1489,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	}
 
 	/* Fill Tx firmware info */
-	memset(tx_fwinfo, 0, sizeof(tx_fwinfo_819x_usb));
+	memset(tx_fwinfo, 0, sizeof(struct tx_fwinfo_819x_usb));
 	/* DWORD 0 */
 	tx_fwinfo->TxHT = (tcb_desc->data_rate & 0x80) ? 1 : 0;
 	tx_fwinfo->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate);
@@ -1539,7 +1539,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	/* DWORD 0 */
 	tx_desc->LINIP = 0;
 	tx_desc->CmdInit = 1;
-	tx_desc->Offset =  sizeof(tx_fwinfo_819x_usb) + 8;
+	tx_desc->Offset =  sizeof(struct tx_fwinfo_819x_usb) + 8;
 	tx_desc->PktSize = (skb->len - TX_PACKET_SHIFT_BYTES) & 0xffff;
 
 	/*DWORD 1*/
@@ -1570,7 +1570,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 	}
 
 	tx_desc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index);
-	tx_desc->TxFWInfoSize =  sizeof(tx_fwinfo_819x_usb);
+	tx_desc->TxFWInfoSize =  sizeof(struct tx_fwinfo_819x_usb);
 
 	tx_desc->DISFB = tcb_desc->bTxDisableRateFallBack;
 	tx_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate;
Signature · 1 line
2.18.0
#9 lore raw

PATCH 7/10 staging:rtl8192u: typedef struct rx_desc_819x_usb remove typedef

In reply to John Whitmore

Change structure rx_desc_819x_usb from being typedef to being a simple structure, without the typedef.

Clears a checkpatch issue, definging new types in the code.

---
 drivers/staging/rtl8192u/r8192U.h      |  4 ++--
 drivers/staging/rtl8192u/r8192U_core.c | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/rtl8192u/r8192U.h +2 -2
index d9dbd3ca3dac..d7f090c1bb44 100644
@@ -279,7 +279,7 @@ struct rtl8192_rx_info {
 	u8 out_pipe;
 };
 
-typedef struct rx_desc_819x_usb {
+struct rx_desc_819x_usb {
 	/* DOWRD 0 */
 	u16                 Length:14;
 	u16                 CRC32:1;
@@ -292,7 +292,7 @@ typedef struct rx_desc_819x_usb {
 
 	/* DWORD 1 */
 	u32                 Reserved2;
-} rx_desc_819x_usb, *prx_desc_819x_usb;
+};
 
 #ifdef USB_RX_AGGREGATION_SUPPORT
 typedef struct _rx_desc_819x_usb_aggr_subframe {
drivers/staging/rtl8192u/r8192U_core.c +7 -7
index 75bbcc115141..655aae06f8a4 100644
@@ -739,7 +739,7 @@ static void rtl8192_rx_isr(struct urb *urb);
 
 static u32 get_rxpacket_shiftbytes_819xusb(struct ieee80211_rx_stats *pstats)
 {
-	return (sizeof(rx_desc_819x_usb) + pstats->RxDrvInfoSize
+	return (sizeof(struct rx_desc_819x_usb) + pstats->RxDrvInfoSize
 		+ pstats->RxBufShift);
 }
 
@@ -4633,7 +4633,7 @@ static void query_rxdesc_status(struct sk_buff *skb,
 	rx_drvinfo_819x_usb  *driver_info = NULL;
 
 	/* Get Rx Descriptor Information */
-	rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
+	struct rx_desc_819x_usb *desc = (struct rx_desc_819x_usb *)skb->data;
 
 	stats->Length = desc->Length;
 	stats->RxDrvInfoSize = desc->RxDrvInfoSize;
@@ -4659,7 +4659,7 @@ static void query_rxdesc_status(struct sk_buff *skb,
 	if (stats->RxDrvInfoSize != 0) {
 		driver_info = (rx_drvinfo_819x_usb *)(
 				skb->data
-				+ sizeof(rx_desc_819x_usb)
+				+ sizeof(struct rx_desc_819x_usb)
 				+ stats->RxBufShift
 			      );
 		/* unit: 0.5M */
@@ -4704,7 +4704,7 @@ static void query_rxdesc_status(struct sk_buff *skb,
 				 driver_info->FirstAGGR, driver_info->PartAggr);
 	}
 
-	skb_pull(skb, sizeof(rx_desc_819x_usb));
+	skb_pull(skb, sizeof(struct rx_desc_819x_usb));
 	/* Get Total offset of MPDU Frame Body */
 	if ((stats->RxBufShift + stats->RxDrvInfoSize) > 0) {
 		stats->bShift = 1;
@@ -4733,7 +4733,7 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
 	bool unicast_packet = false;
 
 	/* 20 is for ps-poll */
-	if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+	if ((skb->len >= (20 + sizeof(struct rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
 		/* first packet should not contain Rx aggregation header */
 		query_rxdesc_status(skb, &stats, false);
 		/* TODO */
@@ -4809,7 +4809,7 @@ static void rtl819xusb_process_received_packet(
 static void query_rx_cmdpkt_desc_status(struct sk_buff *skb,
 					struct ieee80211_rx_stats *stats)
 {
-	rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
+	struct rx_desc_819x_usb *desc = (struct rx_desc_819x_usb *)skb->data;
 
 	/* Get Rx Descriptor Information */
 	stats->virtual_address = (u8 *)skb->data;
@@ -4835,7 +4835,7 @@ static void rtl8192_rx_cmd(struct sk_buff *skb)
 		.freq = IEEE80211_24GHZ_BAND,
 	};
 
-	if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
+	if ((skb->len >= (20 + sizeof(struct rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
 		query_rx_cmdpkt_desc_status(skb, &stats);
 		/* prfd->queue_id = 1; */
 
Signature · 1 line
2.18.0
#10 lore raw

PATCH 8/10 staging:rtl8192u: Remove struct rx_desc_819x_usb_aggr_subframe

In reply to John Whitmore

Removal of structure rx_desc_819x_usb_aggr_subframe from local header file, which is not used outside the header file.

---
 drivers/staging/rtl8192u/r8192U.h | 18 ------------------
 1 file changed, 18 deletions(-)
drivers/staging/rtl8192u/r8192U.h +0 -18
index d7f090c1bb44..c8a23a831d51 100644
@@ -294,24 +294,6 @@ struct rx_desc_819x_usb {
 	u32                 Reserved2;
 };
 
-#ifdef USB_RX_AGGREGATION_SUPPORT
-typedef struct _rx_desc_819x_usb_aggr_subframe {
-	/* DOWRD 0 */
-	u16			Length:14;
-	u16			CRC32:1;
-	u16			ICV:1;
-	u8			Offset;
-	u8			RxDrvInfoSize;
-	/* DOWRD 1 */
-	u8			Shift:2;
-	u8			PHYStatus:1;
-	u8			SWDec:1;
-	u8			Reserved1:4;
-	u8			Reserved2;
-	u16			Reserved3;
-} rx_desc_819x_usb_aggr_subframe, *prx_desc_819x_usb_aggr_subframe;
-#endif
-
 typedef struct rx_drvinfo_819x_usb {
 	/* DWORD 0 */
 	u16                 Reserved1:12;
Signature · 1 line
2.18.0
#11 lore raw

PATCH 9/10 staging:rtl8192u: remove typedef from struct rx_drvinfo_819x_usb

In reply to John Whitmore

Removed the typedef from the struct rx_drvinfo_819x_usb to leave it as a simple structure.

This clears the issue flagged by checkpatch, defining new types.

---
 drivers/staging/rtl8192u/r8192U.h      |  4 ++--
 drivers/staging/rtl8192u/r8192U_core.c | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8192u/r8192U.h +2 -2
index c8a23a831d51..83bc4cef5b17 100644
@@ -294,7 +294,7 @@ struct rx_desc_819x_usb {
 	u32                 Reserved2;
 };
 
-typedef struct rx_drvinfo_819x_usb {
+struct rx_drvinfo_819x_usb {
 	/* DWORD 0 */
 	u16                 Reserved1:12;
 	u16                 PartAggr:1;
@@ -315,7 +315,7 @@ typedef struct rx_drvinfo_819x_usb {
 	/* DWORD 1 */
 	u32                  TSFL;
 
-} rx_drvinfo_819x_usb, *prx_drvinfo_819x_usb;
+};
 
 /* Support till 64 bit bus width OS */
 #define MAX_DEV_ADDR_SIZE		8
drivers/staging/rtl8192u/r8192U_core.c +5 -5
index 655aae06f8a4..c01e8d76a265 100644
@@ -4194,7 +4194,7 @@ static inline bool rx_hal_is_cck_rate(struct rx_drvinfo_819x_usb *pdrvinfo)
 
 static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 				      struct ieee80211_rx_stats *pstats,
-				      rx_drvinfo_819x_usb  *pdrvinfo,
+				      struct rx_drvinfo_819x_usb  *pdrvinfo,
 				      struct ieee80211_rx_stats *precord_stats,
 				      bool bpacket_match_bssid,
 				      bool bpacket_toself,
@@ -4231,7 +4231,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 	prxpkt = (u8 *)pdrvinfo;
 
 	/* Move pointer to the 16th bytes. Phy status start address. */
-	prxpkt += sizeof(rx_drvinfo_819x_usb);
+	prxpkt += sizeof(struct rx_drvinfo_819x_usb);
 
 	/* Initial the cck and ofdm buffer pointer */
 	pcck_buf = (phy_sts_cck_819xusb_t *)prxpkt;
@@ -4431,7 +4431,7 @@ static void rtl8192_record_rxdesc_forlateruse(
 
 static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 					  struct ieee80211_rx_stats *pstats,
-					  rx_drvinfo_819x_usb  *pdrvinfo)
+					  struct rx_drvinfo_819x_usb  *pdrvinfo)
 {
 	/* TODO: We must only check packet for current MAC address.
 	 * Not finish
@@ -4630,7 +4630,7 @@ static void query_rxdesc_status(struct sk_buff *skb,
 	struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
 	struct net_device *dev = info->dev;
 	struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-	rx_drvinfo_819x_usb  *driver_info = NULL;
+	struct rx_drvinfo_819x_usb  *driver_info = NULL;
 
 	/* Get Rx Descriptor Information */
 	struct rx_desc_819x_usb *desc = (struct rx_desc_819x_usb *)skb->data;
@@ -4657,7 +4657,7 @@ static void query_rxdesc_status(struct sk_buff *skb,
 	 * Driver info are written to the RxBuffer following rx desc
 	 */
 	if (stats->RxDrvInfoSize != 0) {
-		driver_info = (rx_drvinfo_819x_usb *)(
+		driver_info = (struct rx_drvinfo_819x_usb *)(
 				skb->data
 				+ sizeof(struct rx_desc_819x_usb)
 				+ stats->RxBufShift
Signature · 1 line
2.18.0
#12 lore raw

PATCH 10/10 staging:rtl8192u: Change struct r8192_priv member Rf_Mode from u8 > enum

In reply to John Whitmore

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).

---
 drivers/staging/rtl8192u/r8192U.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/rtl8192u/r8192U.h +4 -3
index 83bc4cef5b17..3963855ad743 100644
@@ -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;
Signature · 1 line
2.18.0