]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hinic3: Use array_size instead of multiplying
authorFan Gong <gongfan1@huawei.com>
Thu, 29 Jan 2026 04:01:10 +0000 (12:01 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 30 Jan 2026 02:50:07 +0000 (18:50 -0800)
Since commit 17fcb3dc12bb ("hinic3: module initialization and tx/rx logic")
use "size * sizeof(u64)" in hinic3_feature_nego.
Use array_size instead of multiplying can make it clearer.

Link: https://lore.kernel.org/netdev/20250911123120.GG30363@horms.kernel.org/
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
Reviewed-by: Joe Damato <joe@dama.to>
Link: https://patch.msgid.link/b7d6d384ccc0bd4c0d3e7af1f90901d589cbd0b1.1769656467.git.zhuyikai1@h-partners.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c

index b6cc7bb7bb0cc6cd2b42f0fc4cba69dcefc82910..44abccf9cb29f3e9b6c87527991dedbd6a0298c1 100644 (file)
@@ -23,7 +23,8 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
        feature_nego.func_id = hinic3_global_func_id(hwdev);
        feature_nego.opcode = opcode;
        if (opcode == MGMT_MSG_CMD_OP_SET)
-               memcpy(feature_nego.s_feature, s_feature, size * sizeof(u64));
+               memcpy(feature_nego.s_feature, s_feature,
+                      array_size(size, sizeof(u64)));
 
        mgmt_msg_params_init_default(&msg_params, &feature_nego,
                                     sizeof(feature_nego));
@@ -37,7 +38,8 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
        }
 
        if (opcode == MGMT_MSG_CMD_OP_GET)
-               memcpy(s_feature, feature_nego.s_feature, size * sizeof(u64));
+               memcpy(s_feature, feature_nego.s_feature,
+                      array_size(size, sizeof(u64)));
 
        return 0;
 }