staging: vt6656: Check the return value of vnt_control_out_* calls
cover staging: vt6656: Check the return value of vnt_control_out_* calls
This patch series checks the return value of vnt_control_out_* function calls.
The first patch checks the return value and when necessary modify the function prototype to be able to return the new checked error code.
The second patch replaces the documentation of functions that their prototype has changed by the kernel-doc style, fixing the parameters and return value.
Oscar Carter (2):
staging: vt6656: Check the return value of vnt_control_out_* calls
staging: vt6656: Fix functions' documentation
drivers/staging/vt6656/baseband.c | 35 +++--- drivers/staging/vt6656/baseband.h | 4 +- drivers/staging/vt6656/card.c | 198 +++++++++++++++--------------- drivers/staging/vt6656/card.h | 18 +-- drivers/staging/vt6656/mac.c | 143 ++++++++++----------- drivers/staging/vt6656/mac.h | 26 ++-- drivers/staging/vt6656/power.c | 24 ++-- drivers/staging/vt6656/power.h | 2 +- 8 files changed, 217 insertions(+), 233 deletions(-)
--
2.20.1
PATCH 1/2 staging: vt6656: Check the return value of vnt_control_out_* calls
Check the return value of vnt_control_out_* function calls. When necessary modify the function prototype to be able to return the new checked error code.
It's safe to modify all the function prototypes without fix the call because the only change is the return value from void to int. If before the call didn't check the return value, now neither.
--- drivers/staging/vt6656/baseband.c | 35 ++++++----- drivers/staging/vt6656/baseband.h | 4 +- drivers/staging/vt6656/card.c | 97 ++++++++++++++++++++----------- drivers/staging/vt6656/card.h | 18 +++--- drivers/staging/vt6656/mac.c | 76 ++++++++++++------------ drivers/staging/vt6656/mac.h | 26 ++++----- drivers/staging/vt6656/power.c | 12 +++- drivers/staging/vt6656/power.h | 2 +- 8 files changed, 156 insertions(+), 114 deletions(-)
drivers/staging/vt6656/baseband.c +21 -14
@@ -23,6 +23,7 @@*/ #include <linux/bits.h> +#include <linux/errno.h> #include <linux/kernel.h> #include "mac.h" #include "baseband.h"
@@ -559,21 +560,22 @@ int vnt_set_short_slot_time(struct vnt_private *priv) ret =vnt_control_in_u8 (priv,MESSAGE_REQUEST_BBREG ,0xe7 , &bb_vga);if (ret) - goto end; +return ret;if (bb_vga == priv->bb_vga[0 ]) priv->bb_rx_conf |=0x20 ; - ret =vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0x0a , - priv->bb_rx_conf); - -end: -return ret; +return vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0x0a , + priv->bb_rx_conf); } -void vnt_set_vga_gain_offset (struct vnt_private *priv,u8 data) +int vnt_set_vga_gain_offset (struct vnt_private *priv,u8 data) { -vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0xE7 , data); +int ret; + + ret =vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0xE7 , data); +if (ret) +return ret;/* patch for 3253B0 Baseband with Cardbus module */ if (priv->short_slot_time)
@@ -581,7 +583,8 @@ void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)else priv->bb_rx_conf |=0x20 ;/* 0010 0000 */ -vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0x0a , priv->bb_rx_conf); +return vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0x0a , + priv->bb_rx_conf); }/*
@@ -622,12 +625,13 @@ int vnt_exit_deep_sleep(struct vnt_private *priv)return vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0x0d ,0x01 ); } -void vnt_update_pre_ed_threshold (struct vnt_private *priv,int scanning) +int vnt_update_pre_ed_threshold (struct vnt_private *priv,int scanning) {const struct vnt_threshold *threshold =NULL ;u8 length;u8 cr_201, cr_206;u8 ed_inx = priv->bb_pre_ed_index; +int ret;switch (priv->rf_type) {case RF_AL2230 :
@@ -650,7 +654,7 @@ void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning) }if (!threshold) -return ; +return -EINVAL ;for (ed_inx = scanning ?0 : length -1 ; ed_inx >0 ; ed_inx--) {if (priv->bb_pre_ed_rssi <= threshold[ed_inx].bb_pre_ed_rssi)
@@ -661,14 +665,17 @@ void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning) cr_206 = threshold[ed_inx].cr_206;if (ed_inx == priv->bb_pre_ed_index && !scanning) -return ; +return 0 ; priv->bb_pre_ed_index = ed_inx;dev_dbg (&priv->usb->dev,"%s bb_pre_ed_rssi %d\n" , __func__, priv->bb_pre_ed_rssi); -vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0xc9 , cr_201); -vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0xce , cr_206); + ret =vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0xc9 , cr_201); +if (ret) +return ret; + +return vnt_control_out_u8 (priv,MESSAGE_REQUEST_BBREG ,0xce , cr_206); }
drivers/staging/vt6656/baseband.h +2 -2
@@ -80,11 +80,11 @@ void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length, u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy);int vnt_set_short_slot_time (struct vnt_private *priv); -void vnt_set_vga_gain_offset (struct vnt_private *priv,u8 data); +int vnt_set_vga_gain_offset (struct vnt_private *priv,u8 data);int vnt_set_antenna_mode (struct vnt_private *priv,u8 antenna_mode);int vnt_vt3184_init (struct vnt_private *priv);int vnt_set_deep_sleep (struct vnt_private *priv);int vnt_exit_deep_sleep (struct vnt_private *priv); -void vnt_update_pre_ed_threshold (struct vnt_private *priv,int scanning); +int vnt_update_pre_ed_threshold (struct vnt_private *priv,int scanning);#endif /* __BASEBAND_H__ */
drivers/staging/vt6656/card.c +62 -35
228 lines not on this page · raw message
drivers/staging/vt6656/card.h +9 -9
@@ -25,23 +25,23 @@struct vnt_private ; -void vnt_set_channel (struct vnt_private *priv,u32 connection_channel); -void vnt_set_rspinf (struct vnt_private *priv,u8 bb_type); -void vnt_update_ifs (struct vnt_private *priv); +int vnt_set_channel (struct vnt_private *priv,u32 connection_channel); +int vnt_set_rspinf (struct vnt_private *priv,u8 bb_type); +int vnt_update_ifs (struct vnt_private *priv);void vnt_update_top_rates (struct vnt_private *priv);int vnt_ofdm_min_rate (struct vnt_private *priv); -void vnt_adjust_tsf (struct vnt_private *priv,u8 rx_rate, -u64 time_stamp,u64 local_tsf); +int vnt_adjust_tsf (struct vnt_private *priv,u8 rx_rate, +u64 time_stamp,u64 local_tsf);bool vnt_get_current_tsf (struct vnt_private *priv,u64 *current_tsf);bool vnt_clear_current_tsf (struct vnt_private *priv); -void vnt_reset_next_tbtt (struct vnt_private *priv,u16 beacon_interval); -void vnt_update_next_tbtt (struct vnt_private *priv,u64 tsf, -u16 beacon_interval); +int vnt_reset_next_tbtt (struct vnt_private *priv,u16 beacon_interval); +int vnt_update_next_tbtt (struct vnt_private *priv,u64 tsf, +u16 beacon_interval);u64 vnt_get_next_tbtt (u64 tsf,u16 beacon_interval);u64 vnt_get_tsf_offset (u8 rx_rate,u64 tsf1,u64 tsf2);int vnt_radio_power_off (struct vnt_private *priv);int vnt_radio_power_on (struct vnt_private *priv);u8 vnt_get_pkt_type (struct vnt_private *priv); -void vnt_set_bss_mode (struct vnt_private *priv); +int vnt_set_bss_mode (struct vnt_private *priv);#endif /* __CARD_H__ */
drivers/staging/vt6656/mac.c +39 -37
174 lines not on this page · raw message
drivers/staging/vt6656/mac.h +13 -13
@@ -355,21 +355,21 @@ struct vnt_mac_set_key {u8 key[WLAN_KEY_LEN_CCMP ]; } __packed; -void vnt_mac_set_filter (struct vnt_private *priv,u64 mc_filter); -void vnt_mac_shutdown (struct vnt_private *priv); -void vnt_mac_set_bb_type (struct vnt_private *priv,u8 type); -void vnt_mac_disable_keyentry (struct vnt_private *priv,u8 entry_idx); -void vnt_mac_set_keyentry (struct vnt_private *priv,u16 key_ctl,u32 entry_idx, -u32 key_idx,u8 *addr,u8 *key); +int vnt_mac_set_filter (struct vnt_private *priv,u64 mc_filter); +int vnt_mac_shutdown (struct vnt_private *priv); +int vnt_mac_set_bb_type (struct vnt_private *priv,u8 type); +int vnt_mac_disable_keyentry (struct vnt_private *priv,u8 entry_idx); +int vnt_mac_set_keyentry (struct vnt_private *priv,u16 key_ctl,u32 entry_idx, +u32 key_idx,u8 *addr,u8 *key);int vnt_mac_reg_bits_off (struct vnt_private *priv,u8 reg_ofs,u8 bits);int vnt_mac_reg_bits_on (struct vnt_private *priv,u8 reg_ofs,u8 bits); -void vnt_mac_write_word (struct vnt_private *priv,u8 reg_ofs,u16 word); -void vnt_mac_set_bssid_addr (struct vnt_private *priv,u8 *addr); -void vnt_mac_enable_protect_mode (struct vnt_private *priv); -void vnt_mac_disable_protect_mode (struct vnt_private *priv); -void vnt_mac_enable_barker_preamble_mode (struct vnt_private *priv); -void vnt_mac_disable_barker_preamble_mode (struct vnt_private *priv); -void vnt_mac_set_beacon_interval (struct vnt_private *priv,u16 interval); +int vnt_mac_write_word (struct vnt_private *priv,u8 reg_ofs,u16 word); +int vnt_mac_set_bssid_addr (struct vnt_private *priv,u8 *addr); +int vnt_mac_enable_protect_mode (struct vnt_private *priv); +int vnt_mac_disable_protect_mode (struct vnt_private *priv); +int vnt_mac_enable_barker_preamble_mode (struct vnt_private *priv); +int vnt_mac_disable_barker_preamble_mode (struct vnt_private *priv); +int vnt_mac_set_beacon_interval (struct vnt_private *priv,u16 interval);int vnt_mac_set_led (struct vnt_private *privpriv,u8 state,u8 led);#endif /* __MAC_H__ */
drivers/staging/vt6656/power.c +9 -3
@@ -87,17 +87,23 @@ void vnt_enable_power_saving(struct vnt_private *priv, u16 listen_interval)* */ -void vnt_disable_power_saving (struct vnt_private *priv) +int vnt_disable_power_saving (struct vnt_private *priv) { +int ret; +/* disable power saving hw function */ -vnt_control_out (priv,MESSAGE_TYPE_DISABLE_PS ,0 , -0 ,0 ,NULL ); + ret =vnt_control_out (priv,MESSAGE_TYPE_DISABLE_PS ,0 , +0 ,0 ,NULL ); +if (ret) +return ret;/* clear AutoSleep */ vnt_mac_reg_bits_off (priv,MAC_REG_PSCFG ,PSCFG_AUTOSLEEP );/* set always listen beacon */ vnt_mac_reg_bits_on (priv,MAC_REG_PSCTL ,PSCTL_ALBCN ); + +return 0 ; }/*
drivers/staging/vt6656/power.h +1 -1
@@ -18,7 +18,7 @@#define C_PWBT 1000/* micro sec. power up before TBTT */ -void vnt_disable_power_saving (struct vnt_private *priv); +int vnt_disable_power_saving (struct vnt_private *priv);void vnt_enable_power_saving (struct vnt_private *priv,u16 listen_interval);int vnt_next_tbtt_wakeup (struct vnt_private *priv);
--
2.20.1
PATCH 2/2 staging: vt6656: Fix functions' documentation
In reply to Oscar CarterReplace the functions' documentation by the kernel-doc style fixing the parameters and return value.
--- drivers/staging/vt6656/card.c | 101 +++++++++++---------------------- drivers/staging/vt6656/mac.c | 67 ++++++++-------------- drivers/staging/vt6656/power.c | 12 ++-- 3 files changed, 61 insertions(+), 119 deletions(-)
drivers/staging/vt6656/card.c +34 -67
@@ -46,15 +46,12 @@ static const u16 cw_rxbcntsf_off[MAX_RATE] = {192 ,96 ,34 ,17 ,34 ,23 ,17 ,11 ,8 ,5 ,4 ,3 }; -/* -* Description: Set NIC media channel +/** +* vnt_set_channel - Set NIC media channel. +* @priv: The adapter to be set. +* @connection_channel: The channel to be set. * -* Parameters: -* In: -* pDevice - The adapter to be set -* connection_channel - Channel to be set -* Out: -* none +* Return: 0 if successful, or a negative error code on failure. */ int vnt_set_channel (struct vnt_private *priv,u32 connection_channel) {
@@ -99,19 +96,13 @@ static const u8 vnt_rspinf_gb_table[] = {0x0e ,0x8d ,0x0a ,0x88 ,0x0a ,0x8c ,0x0a ,0x8c ,0x0a }; -/* -* Description: Set RSPINF -* -* Parameters: -* In: -* pDevice - The adapter to be set -* Out: -* none -* -* Return Value: None. +/** +* vnt_set_rspinf - Set RSPINF. +* @priv: The adapter to be set. +* @bb_type: The base band type. * +* Return: 0 if successful, or a negative error code on failure. */ -int vnt_set_rspinf (struct vnt_private *priv,u8 bb_type) {const u8 *data;
@@ -145,17 +136,11 @@ int vnt_set_rspinf(struct vnt_private *priv, u8 bb_type) MESSAGE_REQUEST_MACREG, len, data); } -/* -* Description: Update IFS -* -* Parameters: -* In: -* priv - The adapter to be set -* Out: -* none -* -* Return Value: None. +/** +* vnt_update_ifs - Update IFS. +* @priv: The adapter to be set. * +* Return: 0 if successful, or a negative error code on failure. */ int vnt_update_ifs (struct vnt_private *priv) {
@@ -300,20 +285,14 @@ u64 vnt_get_tsf_offset(u8 rx_rate, u64 tsf1, u64 tsf2)return tsf1 - tsf2 - (u64 )cw_rxbcntsf_off[rx_rate %MAX_RATE ]; } -/* -* Description: Sync. TSF counter to BSS -* Get TSF offset and write to HW -* -* Parameters: -* In: -* priv - The adapter to be sync. -* time_stamp - Rx BCN's TSF -* local_tsf - Local TSF -* Out: -* none -* -* Return Value: none +/** +* vnt_adjust_tsf - Sync TSF counter to BSS. Get TSF offset and write to HW. +* @priv: The adapter to be set. +* @rx_rate: The Rx rate. +* @time_stamp: The Rx BCN's TSF. +* @local_tsf: The local TSF. * +* Return: 0 if successful, or a negative error code on failure. */ int vnt_adjust_tsf (struct vnt_private *priv,u8 rx_rate,u64 time_stamp,u64 local_tsf)
@@ -408,19 +387,13 @@ u64 vnt_get_next_tbtt(u64 tsf, u16 beacon_interval)return tsf; } -/* -* Description: Set NIC TSF counter for first Beacon time -* Get NEXTTBTT from adjusted TSF and Beacon Interval -* -* Parameters: -* In: -* dwIoBase - IO Base -* beacon_interval - Beacon Interval -* Out: -* none -* -* Return Value: none +/** +* vnt_reset_next_tbtt - Set NIC TSF counter for first beacon time. Get +* NEXTTBTT from adjusted TSF and beacon interval. +* @priv: The adapter to be set. +* @beacon_interval: The beacon interval. * +* Return: 0 if successful, or a negative error code on failure. */ int vnt_reset_next_tbtt (struct vnt_private *priv,u16 beacon_interval) {
@@ -444,20 +417,14 @@ int vnt_reset_next_tbtt(struct vnt_private *priv, u16 beacon_interval) MESSAGE_REQUEST_TBTT, 0, 8, data); } -/* -* Description: Sync NIC TSF counter for Beacon time -* Get NEXTTBTT and write to HW -* -* Parameters: -* In: -* priv - The adapter to be set -* tsf - Current TSF counter -* beacon_interval - Beacon Interval -* Out: -* none -* -* Return Value: none +/** +* vnt_update_next_tbtt - Sync NIC TSF counter for beacon time. Get NEXTTBTT +* and write to HW. +* @priv: The adapter to be set. +* @tsf: The current TSF counter. +* @beacon_interval: The beacon interval. * +* Return: 0 if successful, or a negative error code on failure. */ int vnt_update_next_tbtt (struct vnt_private *priv,u64 tsf,u16 beacon_interval)
drivers/staging/vt6656/mac.c +23 -44
95 lines not on this page · raw message
drivers/staging/vt6656/power.c +4 -8
@@ -77,16 +77,12 @@ void vnt_enable_power_saving(struct vnt_private *priv, u16 listen_interval)dev_dbg (&priv->usb->dev,"PS:Power Saving Mode Enable...\n" ); } -/* -* -* Routine Description: -* Disable hw power saving functions -* -* Return Value: -* None. +/** +* vnt_disable_power_saving - Disable hw power saving functions. +* @priv: The adapter to be set. * +* Return: 0 if successful, or a negative error code on failure. */ -int vnt_disable_power_saving (struct vnt_private *priv) {int ret;
--
2.20.1
Re: [PATCH 2/2] staging: vt6656: Fix functions' documentation
Actually I don't really think the function descriptions are needed at all the names of the functions are enough.
card.c needs to be removed the bss callers to baseband.c, the tbtt's to power.c and the rest to mac.c
Regards
Malcolm
Re: [PATCH 2/2] staging: vt6656: Fix functions' documentation
Quoted 3 lines · Malcolm Priestley
Actually I don't really think the function descriptions are needed at all the names of the functions are enough.
Then, it would be better leave the documentation as it was before or remove it?
Quoted 6 lines
card.cneeds to be removed the bss callers tobaseband.c, the tbtt's topower.cand the rest tomac.cRegards
Malcolm
Thanks,
Oscar Carter
Re: [PATCH 2/2] staging: vt6656: Fix functions' documentation
Quoted 6 lines · Oscar Carter
Quoted 3 lines · Malcolm Priestley
Actually I don't really think the function descriptions are needed at all the names of the functions are enough.
Then, it would be better leave the documentation as it was before or remove it?
I would remove them all except for comments inside functions.
Regards
Malcolm
Re: [PATCH 2/2] staging: vt6656: Fix functions' documentation
Quoted 12 lines · Malcolm Priestley
Quoted 6 lines · Oscar Carter
Quoted 3 lines · Malcolm Priestley
Actually I don't really think the function descriptions are needed at all the names of the functions are enough.
Then, it would be better leave the documentation as it was before or remove it?
I would remove them all except for comments inside functions.
Ok, then I make the suggested changes and send a new version serie.
Quoted 3 lines
Regards
Malcolm
Thanks,
Oscar Carter