[PATCH] soundwire: Use min() to improve code

Qianfeng Rong posted 1 patch 1 month, 2 weeks ago
drivers/soundwire/qcom.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH] soundwire: Use min() to improve code
Posted by Qianfeng Rong 1 month, 2 weeks ago
Use min() to reduce the code in qcom_swrm_xfer_msg() and improve its
readability.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 drivers/soundwire/qcom.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index bd2b293b44f2..5b3078220189 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -924,10 +924,7 @@ static enum sdw_command_response qcom_swrm_xfer_msg(struct sdw_bus *bus,
 
 	if (msg->flags == SDW_MSG_FLAG_READ) {
 		for (i = 0; i < msg->len;) {
-			if ((msg->len - i) < QCOM_SWRM_MAX_RD_LEN)
-				len = msg->len - i;
-			else
-				len = QCOM_SWRM_MAX_RD_LEN;
+			len = min(msg->len - i, QCOM_SWRM_MAX_RD_LEN);
 
 			ret = qcom_swrm_cmd_fifo_rd_cmd(ctrl, msg->dev_num,
 							msg->addr + i, len,
-- 
2.34.1
Re: [PATCH] soundwire: Use min() to improve code
Posted by Vinod Koul 1 month ago
On Thu, 14 Aug 2025 22:24:28 +0800, Qianfeng Rong wrote:
> Use min() to reduce the code in qcom_swrm_xfer_msg() and improve its
> readability.
> 
> 

Applied, thanks!

[1/1] soundwire: Use min() to improve code
      commit: 88f5d2a477ec64b12e83b488407490bb4a9298f8

Best regards,
-- 
~Vinod