diff mbox series

[-next] ath9k: use clamp() in ar9003_aic_cal_post_process()

Message ID 20240830011858.603514-1-lizetao1@huawei.com
State New
Headers show
Series [-next] ath9k: use clamp() in ar9003_aic_cal_post_process() | expand

Commit Message

Li Zetao Aug. 30, 2024, 1:18 a.m. UTC
When it needs to get a value within a certain interval, using clamp()
makes the code easier to understand than min(max()).

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/wireless/ath/ath9k/ar9003_aic.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Toke Høiland-Jørgensen Sept. 5, 2024, 4:21 p.m. UTC | #1
Li Zetao <lizetao1@huawei.com> writes:

> When it needs to get a value within a certain interval, using clamp()
> makes the code easier to understand than min(max()).
>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Kalle Valo Sept. 14, 2024, 11:46 a.m. UTC | #2
Li Zetao <lizetao1@huawei.com> wrote:

> When it needs to get a value within a certain interval, using clamp()
> makes the code easier to understand than min(max()).
> 
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

1d66430cc9af wifi: ath9k: use clamp() in ar9003_aic_cal_post_process()
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_aic.c b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
index d0f1e8bcc846..45a7ca660f47 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_aic.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_aic.c
@@ -409,13 +409,11 @@  static bool ar9003_aic_cal_post_process(struct ath_hw *ah)
 		sram.valid = true;
 
 		sram.rot_dir_att_db =
-			min(max(rot_dir_path_att_db,
-				(int16_t)ATH_AIC_MIN_ROT_DIR_ATT_DB),
-			    ATH_AIC_MAX_ROT_DIR_ATT_DB);
+			clamp(rot_dir_path_att_db, (int16_t)ATH_AIC_MIN_ROT_DIR_ATT_DB,
+			      ATH_AIC_MAX_ROT_DIR_ATT_DB);
 		sram.rot_quad_att_db =
-			min(max(rot_quad_path_att_db,
-				(int16_t)ATH_AIC_MIN_ROT_QUAD_ATT_DB),
-			    ATH_AIC_MAX_ROT_QUAD_ATT_DB);
+			clamp(rot_quad_path_att_db, (int16_t)ATH_AIC_MIN_ROT_QUAD_ATT_DB,
+			      ATH_AIC_MAX_ROT_QUAD_ATT_DB);
 
 		aic->aic_sram[i] = (SM(sram.vga_dir_sign,
 				       AR_PHY_AIC_SRAM_VGA_DIR_SIGN) |