staging: rtl8723bs: Fix coding style in ieee80211.h
v2 cover staging: rtl8723bs: Fix coding style in ieee80211.h
This series fixes four separate checkpatch.pl issues in ieee80211.h, split into one patch per logical change:
1. Replace __attribute__((packed)) with __packed in struct definitions.
2. Fix comparison direction and wrap macro arguments in parentheses in IS_CCK_RATE and IS_OFDM_RATE.
3. Fix block comment style: move trailing '*/' to its own line and add ' * ' prefix to continuation lines.
4. Enclose the CHAN_ARG macro body in outer parentheses.
v2: Split into one patch per logical change as requested by Nikolay
Kulikov. Previous combined patch was sent as "[PATCH] staging: rtl8723bs: Fix coding style in ieee80211.h".
Pramod Maurya (4):
staging: rtl8723bs: Replace __attribute__((packed)) with __packed in
ieee80211.h
staging: rtl8723bs: Fix comparison style in IS_CCK_RATE and
IS_OFDM_RATE macros
staging: rtl8723bs: Fix block comment style in ieee80211.h
staging: rtl8723bs: Enclose CHAN_ARG macro body in parentheses
drivers/staging/rtl8723bs/include/ieee80211.h | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-)
Signature · 1 line
2.52.0
PATCH v2 1/4 staging: rtl8723bs: Replace __attribute__((packed)) with __packed in ieee80211.h
Replace the verbose __attribute__ ((packed)) with the preferred kernel shorthand __packed in struct eapol and struct ieee80211_snap_hdr.
--- drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/include/ieee80211.h +2 -2
@@ -231,7 +231,7 @@ struct eapol {u8 version;u8 type;u16 length; -} __attribute__ ((packed)); +} __packed;#define IEEE80211_FCS_LEN 4
@@ -274,7 +274,7 @@ struct ieee80211_snap_hdr {u8 ssap;/* always 0xAA */ u8 ctrl;/* always 0x03 */ u8 oui[P80211_OUI_LEN ];/* organizational universal id */ -} __attribute__ ((packed)); +} __packed;#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
Signature · 1 line
2.52.0
PATCH v2 2/4 staging: rtl8723bs: Fix comparison style in IS_CCK_RATE and IS_OFDM_RATE macros
In reply to Pramod MauryaPlace the variable on the left side of comparisons, wrap macro arguments in parentheses to avoid precedence issues, and wrap the long macro definitions with a line continuation.
--- drivers/staging/rtl8723bs/include/ieee80211.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/include/ieee80211.h +4 -2
@@ -394,8 +394,10 @@ enum { };#define IS_HT_RATE (_rate) (_rate >= MGN_MCS0 && _rate <= MGN_MCS31) -#define IS_CCK_RATE (_rate) (MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M) -#define IS_OFDM_RATE (_rate) (MGN_6M <= _rate && _rate <= MGN_54M && _rate != MGN_11M) +#define IS_CCK_RATE (_rate) \ + ((_rate) == MGN_1M || (_rate) == MGN_2M || (_rate) == MGN_5_5M || (_rate) == MGN_11M) +#define IS_OFDM_RATE (_rate) \ + ((_rate) >= MGN_6M && (_rate) <= MGN_54M && (_rate) != MGN_11M)/* NOTE: This data is for statistical purposes; not all hardware provides this
Signature · 1 line
2.52.0
Re: [PATCH v2 2/4] staging: rtl8723bs: Fix comparison style in IS_CCK_RATE and IS_OFDM_RATE macros
Quoted 14 lines · Pramod Maurya
Place the variable on the left side of comparisons, wrap macro arguments in parentheses to avoid precedence issues, and wrap the long macro definitions with a line continuation.
Signed-off-by Pramod Maurya <[email protected]>--- drivers/staging/rtl8723bs/include/ieee80211.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/ieee80211.h +0
-0
drivers/staging/rtl8723bs/include/ieee80211.h enum { · line 400
Quoted 9 lines
drivers/staging/rtl8723bs/include/ieee80211.h +4
-2@@ -394,8 +394,10 @@ enum { };#define IS_HT_RATE (_rate) (_rate >= MGN_MCS0 && _rate <= MGN_MCS31) -#define IS_CCK_RATE (_rate) (MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M) -#define IS_OFDM_RATE (_rate) (MGN_6M <= _rate && _rate <= MGN_54M && _rate != MGN_11M) +#define IS_CCK_RATE (_rate) \ + ((_rate) == MGN_1M || (_rate) == MGN_2M || (_rate) == MGN_5_5M || (_rate) == MGN_11M) +#define IS_OFDM_RATE (_rate) \ + ((_rate) >= MGN_6M && (_rate) <= MGN_54M && (_rate) != MGN_11M)
The IS_OFDM_RATE() macro is also not used, peprhaps it would be better to remove it instead of formatting dead code? Of cource, in a separate patch to avoid mixing up different changes.
Thanks,
Nikolay
Greg KH
maintainerRe: [PATCH v2 2/4] staging: rtl8723bs: Fix comparison style in IS_CCK_RATE and IS_OFDM_RATE macros
In reply to Pramod MauryaQuoted 14 lines · Pramod Maurya
Place the variable on the left side of comparisons, wrap macro arguments in parentheses to avoid precedence issues, and wrap the long macro definitions with a line continuation.
Signed-off-by Pramod Maurya <[email protected]>--- drivers/staging/rtl8723bs/include/ieee80211.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/ieee80211.h +0
-0
drivers/staging/rtl8723bs/include/ieee80211.h enum { · line 400
Quoted 9 lines
drivers/staging/rtl8723bs/include/ieee80211.h +4
-2@@ -394,8 +394,10 @@ enum { };#define IS_HT_RATE (_rate) (_rate >= MGN_MCS0 && _rate <= MGN_MCS31) -#define IS_CCK_RATE (_rate) (MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M) -#define IS_OFDM_RATE (_rate) (MGN_6M <= _rate && _rate <= MGN_54M && _rate != MGN_11M) +#define IS_CCK_RATE (_rate) \ + ((_rate) == MGN_1M || (_rate) == MGN_2M || (_rate) == MGN_5_5M || (_rate) == MGN_11M) +#define IS_OFDM_RATE (_rate) \ + ((_rate) >= MGN_6M && (_rate) <= MGN_54M && (_rate) != MGN_11M)
This is now harder to read, why not just reduce the number of tabs for all of these #defines? ANd are you sure the () change is needed?
thanks,
greg k-h
PATCH v2 3/4 staging: rtl8723bs: Fix block comment style in ieee80211.h
In reply to Pramod MauryaMove trailing '*/' to a new line in multi-line block comments, add proper ' * ' prefix to comment continuation lines, and consolidate the OUI_MICROSOFT multi-line comment into a single line.
--- drivers/staging/rtl8723bs/include/ieee80211.h | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/staging/rtl8723bs/include/ieee80211.h +23 -23
@@ -402,12 +402,14 @@ enum {/* NOTE: This data is for statistical purposes; not all hardware provides this * information for frames received. Not setting these will not cause -* any adverse affects. */ +* any adverse affects. +*/ /* IEEE 802.11 requires that STA supports concurrent reception of at least * three fragmented frames. This define can be increased to support more * concurrent frames, but it should be noted that each entry can consume about -* 2 kB of RAM and increasing cache size will slow down frame reassembly. */ +* 2 kB of RAM and increasing cache size will slow down frame reassembly. +*/ #define IEEE80211_FRAG_CACHE_LEN 4#define SEC_KEY_1 (1<<0)
@@ -433,19 +435,17 @@ enum {#define BIP_AAD_SIZE 20/* - -802.11 data frame from AP - -,-------------------------------------------------------------------. -Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | -|------|------|---------|---------|---------|------|---------|------| -Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | -| | tion | (BSSID) | | | ence | data | | -`-------------------------------------------------------------------' - -Total: 28-2340 bytes - -*/ +* 802.11 data frame from AP +* +* ,-------------------------------------------------------------------. +* Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | +* |------|------|---------|---------|---------|------|---------|------| +* Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | +* | | tion | (BSSID) | | | ence | data | | +* `-------------------------------------------------------------------' +* +* Total: 28-2340 bytes +*/ #define BEACON_PROBE_SSID_ID_POSITION 12
@@ -469,7 +469,8 @@ Total: 28-2340 bytes/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the -* main rates information element... */ +* main rates information element... +*/ #define MAX_RATES_LENGTH ((u8)12)#define MAX_RATES_EX_LENGTH ((u8)16)#define MAX_NETWORK_COUNT 128
@@ -499,11 +500,11 @@ Total: 28-2340 bytes#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST#define IW_ESSID_MAX_SIZE 32/* -join_res: --1: authentication fail --2: association fail -> 0: TID -*/ +* join_res: +* -1: authentication fail +* -2: association fail +* > 0: TID +*/ #define DEFAULT_MAX_SCAN_AGE (15 * HZ)#define DEFAULT_FTS 2346
@@ -557,8 +558,7 @@ enum { ACT_PUBLIC_MAX }; -#define OUI_MICROSOFT 0x0050f2/* Microsoft (also used in Wi-Fi specs) -* 00:50:F2 */ +#define OUI_MICROSOFT 0x0050f2/* Microsoft OUI (also used in Wi-Fi specs) */ #define WME_OUI_TYPE 2#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
Signature · 1 line
2.52.0
PATCH v2 4/4 staging: rtl8723bs: Enclose CHAN_ARG macro body in parentheses
In reply to Pramod MauryaWrap the macro expansion in outer parentheses to prevent operator precedence issues when the macro is used in expressions.
--- drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/include/ieee80211.h +2 -2
@@ -639,7 +639,7 @@ struct rtw_ieee80211_channel {/*"orig_mpwr:%d\n"*/ #define CHAN_ARG (channel) \ -/*(channel)->band*/ \ + (/*(channel)->band*/ \/*, (channel)->center_freq*/ \ (channel)->hw_value \ , (channel)->flags \
@@ -649,7 +649,7 @@ struct rtw_ieee80211_channel {/*, (channel)->beacon_found*/ \/*, (channel)->orig_flags*/ \/*, (channel)->orig_mag*/ \ -/*, (channel)->orig_mpwr*/ \ + /*, (channel)->orig_mpwr*/)/* Parsed Information Elements */ struct rtw_ieee802_11_elems {
Signature · 1 line
2.52.0
Re: [PATCH v2 4/4] staging: rtl8723bs: Enclose CHAN_ARG macro body in parentheses
Quoted 33 lines · Pramod Maurya
Wrap the macro expansion in outer parentheses to prevent operator precedence issues when the macro is used in expressions.
Signed-off-by Pramod Maurya <[email protected]>--- drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/ieee80211.h +2
-2@@ -639,7 +639,7 @@ struct rtw_ieee80211_channel {/*"orig_mpwr:%d\n"*/ #define CHAN_ARG (channel) \ -/*(channel)->band*/ \ + (/*(channel)->band*/ \/*, (channel)->center_freq*/ \ (channel)->hw_value \ , (channel)->flags \@@ -649,7 +649,7 @@ struct rtw_ieee80211_channel {/*, (channel)->beacon_found*/ \/*, (channel)->orig_flags*/ \/*, (channel)->orig_mag*/ \ -/*, (channel)->orig_mpwr*/ \ + /*, (channel)->orig_mpwr*/)/* Parsed Information Elements */ struct rtw_ieee802_11_elems {Signature · 1 line
2.52.0
This macro is never used in the driver, why not just remove it?
Thanks,
Nikolay
Greg KH
maintainerRe: [PATCH v2 4/4] staging: rtl8723bs: Enclose CHAN_ARG macro body in parentheses
In reply to Pramod MauryaQuoted 22 lines · Pramod Maurya
Wrap the macro expansion in outer parentheses to prevent operator precedence issues when the macro is used in expressions.
Signed-off-by Pramod Maurya <[email protected]>--- drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/ieee80211.h +1
-1@@ -639,7 +639,7 @@ struct rtw_ieee80211_channel {/*"orig_mpwr:%d\n"*/ #define CHAN_ARG (channel) \ -/*(channel)->band*/ \ + (/*(channel)->band*/ \/*, (channel)->center_freq*/ \ (channel)->hw_value \ , (channel)->flags \
drivers/staging/rtl8723bs/include/ieee80211.h struct rtw_ieee80211_channel { · line 652
Quoted 5 lines
drivers/staging/rtl8723bs/include/ieee80211.h +1
-1@@ -649,7 +649,7 @@ struct rtw_ieee80211_channel {/*, (channel)->beacon_found*/ \/*, (channel)->orig_flags*/ \/*, (channel)->orig_mag*/ \ -/*, (channel)->orig_mpwr*/ \ + /*, (channel)->orig_mpwr*/)
These are comments? That macro is crazy, why not fix it up properly?
And what precedence issue is being fixed here?
thanks,
greg k-h