diff options
author | Winkler, Tomas <tomas.winkler@intel.com> | 2009-01-19 18:30:21 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:00:53 -0500 |
commit | 5cd19c5f15f4bd3354cc7f8f8b1125018a84a25c (patch) | |
tree | fc744611183b364ef10c9a84b000121b2d5238d7 /drivers | |
parent | f797eb7e2903571e9c0e7e5d64113f51209f8dc4 (diff) |
iwlwifi: make iwl-power.c more readable
This patch rearrange code in iwl-power.c function to make it a little more
readable. No functional changes.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-power.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index a9f9ffe4b94e..0276d51d37ce 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c | |||
@@ -149,7 +149,7 @@ static u16 iwl_get_auto_power_mode(struct iwl_priv *priv) | |||
149 | } | 149 | } |
150 | 150 | ||
151 | /* initialize to default */ | 151 | /* initialize to default */ |
152 | static int iwl_power_init_handle(struct iwl_priv *priv) | 152 | static void iwl_power_init_handle(struct iwl_priv *priv) |
153 | { | 153 | { |
154 | struct iwl_power_mgr *pow_data; | 154 | struct iwl_power_mgr *pow_data; |
155 | int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX; | 155 | int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX; |
@@ -159,7 +159,7 @@ static int iwl_power_init_handle(struct iwl_priv *priv) | |||
159 | 159 | ||
160 | IWL_DEBUG_POWER("Initialize power \n"); | 160 | IWL_DEBUG_POWER("Initialize power \n"); |
161 | 161 | ||
162 | pow_data = &(priv->power_data); | 162 | pow_data = &priv->power_data; |
163 | 163 | ||
164 | memset(pow_data, 0, sizeof(*pow_data)); | 164 | memset(pow_data, 0, sizeof(*pow_data)); |
165 | 165 | ||
@@ -179,26 +179,25 @@ static int iwl_power_init_handle(struct iwl_priv *priv) | |||
179 | else | 179 | else |
180 | cmd->flags |= IWL_POWER_PCI_PM_MSK; | 180 | cmd->flags |= IWL_POWER_PCI_PM_MSK; |
181 | } | 181 | } |
182 | return 0; | ||
183 | } | 182 | } |
184 | 183 | ||
185 | /* adjust power command according to DTIM period and power level*/ | 184 | /* adjust power command according to DTIM period and power level*/ |
186 | static int iwl_update_power_command(struct iwl_priv *priv, | 185 | static int iwl_update_power_cmd(struct iwl_priv *priv, |
187 | struct iwl_powertable_cmd *cmd, | 186 | struct iwl_powertable_cmd *cmd, u16 mode) |
188 | u16 mode) | ||
189 | { | 187 | { |
190 | int ret = 0, i; | ||
191 | u8 skip; | ||
192 | u32 max_sleep = 0; | ||
193 | struct iwl_power_vec_entry *range; | 188 | struct iwl_power_vec_entry *range; |
194 | u8 period = 0; | ||
195 | struct iwl_power_mgr *pow_data; | 189 | struct iwl_power_mgr *pow_data; |
190 | int i; | ||
191 | u32 max_sleep = 0; | ||
192 | u8 period; | ||
193 | bool skip; | ||
196 | 194 | ||
197 | if (mode > IWL_POWER_INDEX_5) { | 195 | if (mode > IWL_POWER_INDEX_5) { |
198 | IWL_DEBUG_POWER("Error invalid power mode \n"); | 196 | IWL_DEBUG_POWER("Error invalid power mode \n"); |
199 | return -1; | 197 | return -EINVAL; |
200 | } | 198 | } |
201 | pow_data = &(priv->power_data); | 199 | |
200 | pow_data = &priv->power_data; | ||
202 | 201 | ||
203 | if (pow_data->dtim_period <= IWL_POWER_RANGE_0_MAX) | 202 | if (pow_data->dtim_period <= IWL_POWER_RANGE_0_MAX) |
204 | range = &pow_data->pwr_range_0[0]; | 203 | range = &pow_data->pwr_range_0[0]; |
@@ -212,14 +211,12 @@ static int iwl_update_power_command(struct iwl_priv *priv, | |||
212 | 211 | ||
213 | if (period == 0) { | 212 | if (period == 0) { |
214 | period = 1; | 213 | period = 1; |
215 | skip = 0; | 214 | skip = false; |
216 | } else | ||
217 | skip = range[mode].no_dtim; | ||
218 | |||
219 | if (skip == 0) { | ||
220 | max_sleep = period; | ||
221 | cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK; | ||
222 | } else { | 215 | } else { |
216 | skip = !!range[mode].no_dtim; | ||
217 | } | ||
218 | |||
219 | if (skip) { | ||
223 | __le32 slp_itrvl = cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]; | 220 | __le32 slp_itrvl = cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]; |
224 | max_sleep = le32_to_cpu(slp_itrvl); | 221 | max_sleep = le32_to_cpu(slp_itrvl); |
225 | if (max_sleep == 0xFF) | 222 | if (max_sleep == 0xFF) |
@@ -227,12 +224,14 @@ static int iwl_update_power_command(struct iwl_priv *priv, | |||
227 | else if (max_sleep > period) | 224 | else if (max_sleep > period) |
228 | max_sleep = (le32_to_cpu(slp_itrvl) / period) * period; | 225 | max_sleep = (le32_to_cpu(slp_itrvl) / period) * period; |
229 | cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK; | 226 | cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK; |
227 | } else { | ||
228 | max_sleep = period; | ||
229 | cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK; | ||
230 | } | 230 | } |
231 | 231 | ||
232 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) { | 232 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) |
233 | if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep) | 233 | if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep) |
234 | cmd->sleep_interval[i] = cpu_to_le32(max_sleep); | 234 | cmd->sleep_interval[i] = cpu_to_le32(max_sleep); |
235 | } | ||
236 | 235 | ||
237 | IWL_DEBUG_POWER("Flags value = 0x%08X\n", cmd->flags); | 236 | IWL_DEBUG_POWER("Flags value = 0x%08X\n", cmd->flags); |
238 | IWL_DEBUG_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); | 237 | IWL_DEBUG_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); |
@@ -244,7 +243,7 @@ static int iwl_update_power_command(struct iwl_priv *priv, | |||
244 | le32_to_cpu(cmd->sleep_interval[3]), | 243 | le32_to_cpu(cmd->sleep_interval[3]), |
245 | le32_to_cpu(cmd->sleep_interval[4])); | 244 | le32_to_cpu(cmd->sleep_interval[4])); |
246 | 245 | ||
247 | return ret; | 246 | return 0; |
248 | } | 247 | } |
249 | 248 | ||
250 | 249 | ||
@@ -295,7 +294,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force) | |||
295 | if (final_mode != IWL_POWER_MODE_CAM) | 294 | if (final_mode != IWL_POWER_MODE_CAM) |
296 | set_bit(STATUS_POWER_PMI, &priv->status); | 295 | set_bit(STATUS_POWER_PMI, &priv->status); |
297 | 296 | ||
298 | iwl_update_power_command(priv, &cmd, final_mode); | 297 | iwl_update_power_cmd(priv, &cmd, final_mode); |
299 | cmd.keep_alive_beacons = 0; | 298 | cmd.keep_alive_beacons = 0; |
300 | 299 | ||
301 | if (final_mode == IWL_POWER_INDEX_5) | 300 | if (final_mode == IWL_POWER_INDEX_5) |
@@ -392,13 +391,11 @@ EXPORT_SYMBOL(iwl_power_set_system_mode); | |||
392 | /* initialize to default */ | 391 | /* initialize to default */ |
393 | void iwl_power_initialize(struct iwl_priv *priv) | 392 | void iwl_power_initialize(struct iwl_priv *priv) |
394 | { | 393 | { |
395 | |||
396 | iwl_power_init_handle(priv); | 394 | iwl_power_init_handle(priv); |
397 | priv->power_data.user_power_setting = IWL_POWER_AUTO; | 395 | priv->power_data.user_power_setting = IWL_POWER_AUTO; |
398 | priv->power_data.power_disabled = 0; | ||
399 | priv->power_data.system_power_setting = IWL_POWER_SYS_AUTO; | 396 | priv->power_data.system_power_setting = IWL_POWER_SYS_AUTO; |
400 | priv->power_data.is_battery_active = 0; | ||
401 | priv->power_data.power_disabled = 0; | 397 | priv->power_data.power_disabled = 0; |
398 | priv->power_data.is_battery_active = 0; | ||
402 | priv->power_data.critical_power_setting = 0; | 399 | priv->power_data.critical_power_setting = 0; |
403 | } | 400 | } |
404 | EXPORT_SYMBOL(iwl_power_initialize); | 401 | EXPORT_SYMBOL(iwl_power_initialize); |
@@ -407,8 +404,8 @@ EXPORT_SYMBOL(iwl_power_initialize); | |||
407 | int iwl_power_temperature_change(struct iwl_priv *priv) | 404 | int iwl_power_temperature_change(struct iwl_priv *priv) |
408 | { | 405 | { |
409 | int ret = 0; | 406 | int ret = 0; |
410 | u16 new_critical = priv->power_data.critical_power_setting; | ||
411 | s32 temperature = KELVIN_TO_CELSIUS(priv->last_temperature); | 407 | s32 temperature = KELVIN_TO_CELSIUS(priv->last_temperature); |
408 | u16 new_critical = priv->power_data.critical_power_setting; | ||
412 | 409 | ||
413 | if (temperature > IWL_CT_KILL_TEMPERATURE) | 410 | if (temperature > IWL_CT_KILL_TEMPERATURE) |
414 | return 0; | 411 | return 0; |