wifi: wcn36xx: Slightly optimize PREPARE_HAL_BUF()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Thu, 2 Feb 2023 20:58:10 +0000 (21:58 +0100)
committerKalle Valo <quic_kvalo@quicinc.com>
Fri, 24 Feb 2023 10:22:45 +0000 (12:22 +0200)
In most (likely all) cases, INIT_HAL_MSG() is called before
PREPARE_HAL_BUF().
In such cases calling memset() is useless because:
   msg_body.header.len = sizeof(msg_body)

So, instead of writing twice the memory, we just have a sanity check to
make sure that some potential trailing memory is zeroed.
It even gives the opportunity to see that by itself and optimize it away.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/7d8ab7fee45222cdbaf80c507525f2d3941587c1.1675371372.git.christophe.jaillet@wanadoo.fr
drivers/net/wireless/ath/wcn36xx/smd.c

index 566f0b9c15841efabc101bc29fd6c52b3a49a8a7..17e1919d1cd8287b9bf5f85e69b1c7d51c1fd989 100644 (file)
@@ -475,8 +475,8 @@ out:
 
 #define PREPARE_HAL_BUF(send_buf, msg_body) \
        do {                                                    \
-               memset(send_buf, 0, msg_body.header.len);       \
-               memcpy(send_buf, &msg_body, sizeof(msg_body));  \
+               memcpy_and_pad(send_buf, msg_body.header.len,   \
+                              &msg_body, sizeof(msg_body), 0); \
        } while (0)                                             \
 
 #define PREPARE_HAL_PTT_MSG_BUF(send_buf, p_msg_body) \