From: Zhu Yi <yi.zhu@intel.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org,
Tomas Winkler <tomas.winkler@intel.com>,
Zhu Yi <yi.zhu@intel.com>
Subject: [PATCH 04/30] iwlwifi: rs-4965 fix return values
Date: Thu, 25 Oct 2007 17:15:25 +0800 [thread overview]
Message-ID: <119330375796-git-send-email-yi.zhu@intel.com> (raw)
In-Reply-To: <11933037553170-git-send-email-yi.zhu@intel.com>
From: Tomas Winkler <tomas.winkler@intel.com>
This patch cleans up style of 'return' of rate scale 4965 functions.
It renames return name variables rc to ret, change functions to void if no
meaningful value was returned it add return of -EINVAL for checks of wrong
arguments.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
---
drivers/net/wireless/iwlwifi/iwl-4965-rs.c | 101 ++++++++++------------------
1 files changed, 37 insertions(+), 64 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
index e80f5e2..015e735 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
@@ -202,8 +202,6 @@ static int rs_send_lq_cmd(struct iwl_priv *priv,
#ifdef CONFIG_IWLWIFI_DEBUG
int i;
#endif
- int rc = -1;
-
struct iwl_host_cmd cmd = {
.id = REPLY_TX_LINK_QUALITY_CMD,
.len = sizeof(struct iwl_link_quality_cmd),
@@ -213,7 +211,7 @@ static int rs_send_lq_cmd(struct iwl_priv *priv,
if ((lq->sta_id == 0xFF) &&
(priv->iw_mode == IEEE80211_IF_TYPE_IBSS))
- return rc;
+ return -EINVAL;
if (lq->sta_id == 0xFF)
lq->sta_id = IWL_AP_ID;
@@ -233,12 +231,12 @@ static int rs_send_lq_cmd(struct iwl_priv *priv,
if (iwl_is_associated(priv) && priv->assoc_station_added &&
priv->lq_mngr.lq_ready)
- rc = iwl_send_cmd(priv, &cmd);
+ return iwl_send_cmd(priv, &cmd);
- return rc;
+ return 0;
}
-static int rs_rate_scale_clear_window(struct iwl_rate_scale_data *window)
+static void rs_rate_scale_clear_window(struct iwl_rate_scale_data *window)
{
window->data = 0;
window->success_counter = 0;
@@ -246,24 +244,18 @@ static int rs_rate_scale_clear_window(struct iwl_rate_scale_data *window)
window->counter = 0;
window->average_tpt = IWL_INVALID_VALUE;
window->stamp = 0;
-
- return 0;
}
static int rs_collect_tx_data(struct iwl_rate_scale_data *windows,
int scale_index, s32 tpt, u32 status)
{
- int rc = 0;
struct iwl_rate_scale_data *window = NULL;
u64 mask;
u8 win_size = IWL_RATE_MAX_WINDOW;
s32 fail_count;
- if (scale_index < 0)
- return -1;
-
- if (scale_index >= IWL_RATE_COUNT)
- return -1;
+ if (scale_index < 0 || scale_index >= IWL_RATE_COUNT)
+ return -EINVAL;
window = &(windows[scale_index]);
@@ -302,15 +294,13 @@ static int rs_collect_tx_data(struct iwl_rate_scale_data *windows,
window->stamp = jiffies;
- return rc;
+ return 0;
}
-int static rs_mcs_from_tbl(struct iwl_rate *mcs_rate,
+static void rs_mcs_from_tbl(struct iwl_rate *mcs_rate,
struct iwl_scale_tbl_info *tbl,
int index, u8 use_green)
{
- int rc = 0;
-
if (is_legacy(tbl->lq_type)) {
mcs_rate->rate_n_flags = iwl_rates[index].plcp;
if (index >= IWL_FIRST_CCK_RATE && index <= IWL_LAST_CCK_RATE)
@@ -343,7 +333,7 @@ int static rs_mcs_from_tbl(struct iwl_rate *mcs_rate,
}
if (is_legacy(tbl->lq_type))
- return rc;
+ return;
if (tbl->is_fat) {
if (tbl->is_dup)
@@ -359,7 +349,6 @@ int static rs_mcs_from_tbl(struct iwl_rate *mcs_rate,
if (is_siso(tbl->lq_type))
mcs_rate->rate_n_flags &= ~RATE_MCS_SGI_MSK;
}
- return rc;
}
static int rs_get_tbl_info_from_mcs(const struct iwl_rate *mcs_rate,
@@ -373,7 +362,7 @@ static int rs_get_tbl_info_from_mcs(const struct iwl_rate *mcs_rate,
if (index == IWL_RATE_INVALID) {
*rate_idx = -1;
- return -1;
+ return -EINVAL;
}
tbl->is_SGI = 0;
tbl->is_fat = 0;
@@ -453,18 +442,16 @@ static inline void rs_toggle_antenna(struct iwl_rate *new_rate,
}
}
-static inline s8 rs_use_green(struct iwl_priv *priv)
+static inline u8 rs_use_green(struct iwl_priv *priv)
{
- s8 rc = 0;
#ifdef CONFIG_IWLWIFI_HT
if (!priv->is_ht_enabled || !priv->current_assoc_ht.is_ht)
return 0;
- if ((priv->current_assoc_ht.is_green_field) &&
- !(priv->current_assoc_ht.operating_mode & 0x4))
- rc = 1;
+ return ((priv->current_assoc_ht.is_green_field) &&
+ !(priv->current_assoc_ht.operating_mode & 0x4));
#endif /*CONFIG_IWLWIFI_HT */
- return rc;
+ return 0;
}
/**
@@ -548,7 +535,7 @@ static u16 rs_get_adjacent_rate(u8 index, u16 rate_mask, int rate_type)
return (high << 8) | low;
}
-static int rs_get_lower_rate(struct iwl_rate_scale_priv *lq_data,
+static void rs_get_lower_rate(struct iwl_rate_scale_priv *lq_data,
struct iwl_scale_tbl_info *tbl, u8 scale_index,
u8 ht_possible, struct iwl_rate *mcs_rate)
{
@@ -589,10 +576,9 @@ static int rs_get_lower_rate(struct iwl_rate_scale_priv *lq_data,
}
/* if we did switched from HT to legacy check current rate */
- if ((switch_to_legacy) &&
- (rate_mask & (1 << scale_index))) {
+ if (switch_to_legacy && (rate_mask & (1 << scale_index))) {
rs_mcs_from_tbl(mcs_rate, tbl, scale_index, is_green);
- return 0;
+ return;
}
high_low = rs_get_adjacent_rate(scale_index, rate_mask, tbl->lq_type);
@@ -602,8 +588,6 @@ static int rs_get_lower_rate(struct iwl_rate_scale_priv *lq_data,
rs_mcs_from_tbl(mcs_rate, tbl, low, is_green);
else
rs_mcs_from_tbl(mcs_rate, tbl, scale_index, is_green);
-
- return 0;
}
static void rs_tx_status(void *priv_rate,
@@ -775,12 +759,8 @@ static u8 rs_is_ant_connected(u8 valid_antenna,
return ((valid_antenna & 0x2) ? 1:0);
else if (antenna_type == ANT_MAIN)
return ((valid_antenna & 0x1) ? 1:0);
- else if (antenna_type == ANT_BOTH) {
- if ((valid_antenna & 0x3) == 0x3)
- return 1;
- else
- return 0;
- }
+ else if (antenna_type == ANT_BOTH)
+ return ((valid_antenna & 0x3) == 0x3);
return 1;
}
@@ -789,9 +769,9 @@ static u8 rs_is_other_ant_connected(u8 valid_antenna,
enum iwl_antenna_type antenna_type)
{
if (antenna_type == ANT_AUX)
- return (rs_is_ant_connected(valid_antenna, ANT_MAIN));
+ return rs_is_ant_connected(valid_antenna, ANT_MAIN);
else
- return (rs_is_ant_connected(valid_antenna, ANT_AUX));
+ return rs_is_ant_connected(valid_antenna, ANT_AUX);
return 0;
}
@@ -912,7 +892,6 @@ static int rs_switch_to_mimo(struct iwl_priv *priv,
struct iwl_rate_scale_priv *lq_data,
struct iwl_scale_tbl_info *tbl, int index)
{
- int rc = -1;
#ifdef CONFIG_IWLWIFI_HT
u16 rate_mask;
s32 rate;
@@ -932,7 +911,6 @@ static int rs_switch_to_mimo(struct iwl_priv *priv,
if (!rs_is_both_ant_supp(lq_data->antenna))
return -1;
- rc = 0;
tbl->is_dup = lq_data->is_dup;
tbl->action = 0;
if (priv->current_channel_width == IWL_CHANNEL_WIDTH_40MHZ)
@@ -963,14 +941,13 @@ static int rs_switch_to_mimo(struct iwl_priv *priv,
tbl->current_rate.rate_n_flags, is_green);
#endif /*CONFIG_IWLWIFI_HT */
- return rc;
+ return 0;
}
static int rs_switch_to_siso(struct iwl_priv *priv,
struct iwl_rate_scale_priv *lq_data,
struct iwl_scale_tbl_info *tbl, int index)
{
- int rc = -1;
#ifdef CONFIG_IWLWIFI_HT
u16 rate_mask;
u8 is_green = lq_data->is_green;
@@ -980,7 +957,6 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
if (!priv->is_ht_enabled || !priv->current_assoc_ht.is_ht)
return -1;
- rc = 0;
tbl->is_dup = lq_data->is_dup;
tbl->lq_type = LQ_SISO;
tbl->action = 0;
@@ -1019,14 +995,14 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
tbl->current_rate.rate_n_flags, is_green);
#endif /*CONFIG_IWLWIFI_HT */
- return rc;
+ return 0;
}
static int rs_move_legacy_other(struct iwl_priv *priv,
struct iwl_rate_scale_priv *lq_data,
int index)
{
- int rc = 0;
+ int ret = 0;
struct iwl_scale_tbl_info *tbl =
&(lq_data->lq_info[lq_data->active_tbl]);
struct iwl_scale_tbl_info *search_tbl =
@@ -1063,14 +1039,13 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
search_tbl->lq_type = LQ_SISO;
search_tbl->is_SGI = 0;
search_tbl->is_fat = 0;
- rc = rs_switch_to_siso(priv, lq_data, search_tbl,
+ ret = rs_switch_to_siso(priv, lq_data, search_tbl,
index);
- if (!rc) {
+ if (!ret) {
lq_data->search_better_tbl = 1;
lq_data->action_counter = 0;
- }
- if (!rc)
goto out;
+ }
break;
case IWL_LEGACY_SWITCH_MIMO:
@@ -1080,14 +1055,13 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
search_tbl->is_SGI = 0;
search_tbl->is_fat = 0;
search_tbl->antenna_type = ANT_BOTH;
- rc = rs_switch_to_mimo(priv, lq_data, search_tbl,
+ ret = rs_switch_to_mimo(priv, lq_data, search_tbl,
index);
- if (!rc) {
+ if (!ret) {
lq_data->search_better_tbl = 1;
lq_data->action_counter = 0;
- }
- if (!rc)
goto out;
+ }
break;
}
tbl->action++;
@@ -1112,7 +1086,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
struct iwl_rate_scale_priv *lq_data,
int index)
{
- int rc = -1;
+ int ret;
u8 is_green = lq_data->is_green;
struct iwl_scale_tbl_info *tbl =
&(lq_data->lq_info[lq_data->active_tbl]);
@@ -1150,13 +1124,12 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
search_tbl->is_SGI = 0;
search_tbl->is_fat = 0;
search_tbl->antenna_type = ANT_BOTH;
- rc = rs_switch_to_mimo(priv, lq_data, search_tbl,
+ ret = rs_switch_to_mimo(priv, lq_data, search_tbl,
index);
- if (!rc)
+ if (!ret) {
lq_data->search_better_tbl = 1;
-
- if (!rc)
goto out;
+ }
break;
case IWL_SISO_SWITCH_GI:
IWL_DEBUG_HT("LQ: SISO SWITCH TO GI\n");
@@ -1203,7 +1176,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
struct iwl_rate_scale_priv *lq_data,
int index)
{
- int rc = -1;
+ int ret;
s8 is_green = lq_data->is_green;
struct iwl_scale_tbl_info *tbl =
&(lq_data->lq_info[lq_data->active_tbl]);
@@ -1228,9 +1201,9 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
else
search_tbl->antenna_type = ANT_AUX;
- rc = rs_switch_to_siso(priv, lq_data, search_tbl,
+ ret = rs_switch_to_siso(priv, lq_data, search_tbl,
index);
- if (!rc) {
+ if (!ret) {
lq_data->search_better_tbl = 1;
goto out;
}
--
1.5.2
next prev parent reply other threads:[~2007-10-25 9:22 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-25 9:15 [PATCH 01/30] iwlwifi: fix various spelling and typos Zhu Yi
2007-10-25 9:15 ` [PATCH 02/30] iwlwifi: rename iwl_eeprom_aqcuire_semaphore to _acquire_ Zhu Yi
2007-10-25 9:15 ` [PATCH 03/30] iwlwifi: renaming last_used and first_empty Zhu Yi
2007-10-25 9:15 ` Zhu Yi [this message]
2007-10-25 9:15 ` [PATCH 05/30] iwlwifi: add TGN flag to qos parameters Zhu Yi
2007-10-25 9:15 ` [PATCH 06/30] iwlwifi: remove cck_flag from iwl_driver_hw_info Zhu Yi
2007-10-25 9:15 ` [PATCH 07/30] iwlwifi: Two comments in iwl-3945.c were longer than 80 columns Zhu Yi
2007-10-25 9:15 ` [PATCH 08/30] iwlwifi: Beautify by removing superfluous newlines and code Zhu Yi
2007-10-25 9:15 ` [PATCH 09/30] iwlwifi: remove late null-check and duplicate bug_on Zhu Yi
2007-10-25 9:15 ` [PATCH 10/30] iwlwifi: remove cck_power_index_compensation Zhu Yi
2007-10-25 9:15 ` [PATCH 11/30] iwlwifi: using PCI_DEVICE macro Zhu Yi
2007-10-25 9:15 ` [PATCH 12/30] iwlwifi: fix sending probe request in iwl 4965 Zhu Yi
2007-10-25 9:15 ` [PATCH 13/30] iwlwifi: accept up to 4K frame size on Rx side to fit A-MSDU frame Zhu Yi
2007-10-25 9:15 ` [PATCH 14/30] iwlwifi: replace restricted_reg with prph Zhu Yi
2007-10-25 9:15 ` [PATCH 15/30] iwlwifi: rename restricted_mem to targ_mem Zhu Yi
2007-10-25 9:15 ` [PATCH 16/30] iwlwifi: replacing wording restricted to nic access in iwl-io Zhu Yi
2007-10-25 9:15 ` [PATCH 17/30] iwlwifi-ht: move 4965 SCD registers to iwl-prph.h Zhu Yi
2007-10-25 9:15 ` [PATCH 18/30] iwlwifi: move 3945 " Zhu Yi
2007-10-25 9:15 ` [PATCH 19/30] iwlwifi: add 5965 " Zhu Yi
2007-10-25 9:15 ` [PATCH 20/30] iwlwifi: Renames struct fw_image_desc to struct fw_desc Zhu Yi
2007-10-25 9:15 ` [PATCH 21/30] iwl4965: exclude 60M rate from probe request Zhu Yi
2007-10-25 9:15 ` [PATCH 22/30] iwl4965: fix driver hang related to hardware scan Zhu Yi
2007-10-25 9:15 ` [PATCH 23/30] iwlwifi: Update iwlwifi version stamp to 1.1.18 Zhu Yi
2007-10-25 9:15 ` [PATCH 24/30] iwl4965: fix scan problem Zhu Yi
2007-10-25 9:15 ` [PATCH 25/30] iwl3945: cancel scan on rxon command Zhu Yi
2007-10-25 9:15 ` [PATCH 26/30] iwl3945: fix direct scan problem Zhu Yi
2007-10-25 9:15 ` [PATCH 27/30] iwlwifi: Update iwlwifi version stamp to 1.1.19 Zhu Yi
2007-10-25 9:15 ` [PATCH 28/30] iwlwifi: mark more functions/variables static Zhu Yi
[not found] ` <11933037931724-git-send-email-yi.zhu@intel.com>
2007-10-25 9:15 ` [PATCH 30/30] iwlwifi: cleanup Kconfig and ifdefs to split 3945 and 4965 Zhu Yi
2007-10-25 9:32 ` [PATCH 11/30] iwlwifi: using PCI_DEVICE macro Jeff Garzik
2007-10-25 10:44 ` Holger Schurig
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=119330375796-git-send-email-yi.zhu@intel.com \
--to=yi.zhu@intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=tomas.winkler@intel.com \
/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).