diff options
author | Oleksij Rempel <linux@rempel-privat.de> | 2014-02-26 04:04:44 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-02-28 14:33:25 -0500 |
commit | 2259ba38a5c545bb54ee0fd9b07cb1828a2849d6 (patch) | |
tree | 1ee38d3a6c613f7e27ef28a2321bf3e4c52214d5 /drivers/net/wireless/ath/ath9k | |
parent | 527492eefcee253e33bbe79bcfef6bedf9935492 (diff) |
ath9k_htc: add function ath9k_regwrite_multi
... to remove duplicate code
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/htc_drv_init.c | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index a8f30dc448bb..b22fb64403d9 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c | |||
@@ -256,6 +256,25 @@ static void ath9k_multi_regread(void *hw_priv, u32 *addr, | |||
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | static void ath9k_regwrite_multi(struct ath_common *common) | ||
260 | { | ||
261 | struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; | ||
262 | u32 rsp_status; | ||
263 | int r; | ||
264 | |||
265 | r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID, | ||
266 | (u8 *) &priv->wmi->multi_write, | ||
267 | sizeof(struct register_write) * priv->wmi->multi_write_idx, | ||
268 | (u8 *) &rsp_status, sizeof(rsp_status), | ||
269 | 100); | ||
270 | if (unlikely(r)) { | ||
271 | ath_dbg(common, WMI, | ||
272 | "REGISTER WRITE FAILED, multi len: %d\n", | ||
273 | priv->wmi->multi_write_idx); | ||
274 | } | ||
275 | priv->wmi->multi_write_idx = 0; | ||
276 | } | ||
277 | |||
259 | static void ath9k_regwrite_single(void *hw_priv, u32 val, u32 reg_offset) | 278 | static void ath9k_regwrite_single(void *hw_priv, u32 val, u32 reg_offset) |
260 | { | 279 | { |
261 | struct ath_hw *ah = (struct ath_hw *) hw_priv; | 280 | struct ath_hw *ah = (struct ath_hw *) hw_priv; |
@@ -282,8 +301,6 @@ static void ath9k_regwrite_buffer(void *hw_priv, u32 val, u32 reg_offset) | |||
282 | struct ath_hw *ah = (struct ath_hw *) hw_priv; | 301 | struct ath_hw *ah = (struct ath_hw *) hw_priv; |
283 | struct ath_common *common = ath9k_hw_common(ah); | 302 | struct ath_common *common = ath9k_hw_common(ah); |
284 | struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; | 303 | struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; |
285 | u32 rsp_status; | ||
286 | int r; | ||
287 | 304 | ||
288 | mutex_lock(&priv->wmi->multi_write_mutex); | 305 | mutex_lock(&priv->wmi->multi_write_mutex); |
289 | 306 | ||
@@ -296,19 +313,8 @@ static void ath9k_regwrite_buffer(void *hw_priv, u32 val, u32 reg_offset) | |||
296 | priv->wmi->multi_write_idx++; | 313 | priv->wmi->multi_write_idx++; |
297 | 314 | ||
298 | /* If the buffer is full, send it out. */ | 315 | /* If the buffer is full, send it out. */ |
299 | if (priv->wmi->multi_write_idx == MAX_CMD_NUMBER) { | 316 | if (priv->wmi->multi_write_idx == MAX_CMD_NUMBER) |
300 | r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID, | 317 | ath9k_regwrite_multi(common); |
301 | (u8 *) &priv->wmi->multi_write, | ||
302 | sizeof(struct register_write) * priv->wmi->multi_write_idx, | ||
303 | (u8 *) &rsp_status, sizeof(rsp_status), | ||
304 | 100); | ||
305 | if (unlikely(r)) { | ||
306 | ath_dbg(common, WMI, | ||
307 | "REGISTER WRITE FAILED, multi len: %d\n", | ||
308 | priv->wmi->multi_write_idx); | ||
309 | } | ||
310 | priv->wmi->multi_write_idx = 0; | ||
311 | } | ||
312 | 318 | ||
313 | mutex_unlock(&priv->wmi->multi_write_mutex); | 319 | mutex_unlock(&priv->wmi->multi_write_mutex); |
314 | } | 320 | } |
@@ -339,26 +345,13 @@ static void ath9k_regwrite_flush(void *hw_priv) | |||
339 | struct ath_hw *ah = (struct ath_hw *) hw_priv; | 345 | struct ath_hw *ah = (struct ath_hw *) hw_priv; |
340 | struct ath_common *common = ath9k_hw_common(ah); | 346 | struct ath_common *common = ath9k_hw_common(ah); |
341 | struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; | 347 | struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; |
342 | u32 rsp_status; | ||
343 | int r; | ||
344 | 348 | ||
345 | atomic_dec(&priv->wmi->mwrite_cnt); | 349 | atomic_dec(&priv->wmi->mwrite_cnt); |
346 | 350 | ||
347 | mutex_lock(&priv->wmi->multi_write_mutex); | 351 | mutex_lock(&priv->wmi->multi_write_mutex); |
348 | 352 | ||
349 | if (priv->wmi->multi_write_idx) { | 353 | if (priv->wmi->multi_write_idx) |
350 | r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID, | 354 | ath9k_regwrite_multi(common); |
351 | (u8 *) &priv->wmi->multi_write, | ||
352 | sizeof(struct register_write) * priv->wmi->multi_write_idx, | ||
353 | (u8 *) &rsp_status, sizeof(rsp_status), | ||
354 | 100); | ||
355 | if (unlikely(r)) { | ||
356 | ath_dbg(common, WMI, | ||
357 | "REGISTER WRITE FAILED, multi len: %d\n", | ||
358 | priv->wmi->multi_write_idx); | ||
359 | } | ||
360 | priv->wmi->multi_write_idx = 0; | ||
361 | } | ||
362 | 355 | ||
363 | mutex_unlock(&priv->wmi->multi_write_mutex); | 356 | mutex_unlock(&priv->wmi->multi_write_mutex); |
364 | } | 357 | } |