diff mbox series

[net-next] net: hns3: Use ARRAY_SIZE() to improve readability

Message ID 20240818052518.45489-1-zhangzekun11@huawei.com (mailing list archive)
State Accepted
Commit 2cbece60a4af03803634abd1e840e513db48d42e
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: hns3: Use ARRAY_SIZE() to improve readability | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-20--09-00 (tests: 712)

Commit Message

zhangzekun (A) Aug. 18, 2024, 5:25 a.m. UTC
There is a helper function ARRAY_SIZE() to help calculating the
u32 array size, and we don't need to do it mannually. So, let's
use ARRAY_SIZE() to calculate the array size, and improve the code
readability.

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jijie Shao Aug. 19, 2024, 1:05 a.m. UTC | #1
on 2024/8/18 13:25, Zhang Zekun wrote:
> There is a helper function ARRAY_SIZE() to help calculating the
> u32 array size, and we don't need to do it mannually. So, let's
> use ARRAY_SIZE() to calculate the array size, and improve the code
> readability.
>
> Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>

Reviewed-by: Jijie Shao<shaojijie@huawei.com>

	Jijie Shao

> ---
>   drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
> index 65b9dcd38137..6db415d8b917 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
> @@ -134,17 +134,17 @@ void hclgevf_get_regs(struct hnae3_handle *handle, u32 *version,
>   	reg += hclgevf_reg_get_header(reg);
>   
>   	/* fetching per-VF registers values from VF PCIe register space */
> -	reg_um = sizeof(cmdq_reg_addr_list) / sizeof(u32);
> +	reg_um = ARRAY_SIZE(cmdq_reg_addr_list);
>   	reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_CMDQ, reg_um, reg);
>   	for (i = 0; i < reg_um; i++)
>   		*reg++ = hclgevf_read_dev(&hdev->hw, cmdq_reg_addr_list[i]);
>   
> -	reg_um = sizeof(common_reg_addr_list) / sizeof(u32);
> +	reg_um = ARRAY_SIZE(common_reg_addr_list);
>   	reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_COMMON, reg_um, reg);
>   	for (i = 0; i < reg_um; i++)
>   		*reg++ = hclgevf_read_dev(&hdev->hw, common_reg_addr_list[i]);
>   
> -	reg_um = sizeof(ring_reg_addr_list) / sizeof(u32);
> +	reg_um = ARRAY_SIZE(ring_reg_addr_list);
>   	for (j = 0; j < hdev->num_tqps; j++) {
>   		reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_RING, reg_um, reg);
>   		for (i = 0; i < reg_um; i++)
> @@ -153,7 +153,7 @@ void hclgevf_get_regs(struct hnae3_handle *handle, u32 *version,
>   						  HCLGEVF_RING_REG_OFFSET * j);
>   	}
>   
> -	reg_um = sizeof(tqp_intr_reg_addr_list) / sizeof(u32);
> +	reg_um = ARRAY_SIZE(tqp_intr_reg_addr_list);
>   	for (j = 0; j < hdev->num_msi_used - 1; j++) {
>   		reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_TQP_INTR, reg_um, reg);
>   		for (i = 0; i < reg_um; i++)
patchwork-bot+netdevbpf@kernel.org Aug. 20, 2024, 10:30 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sun, 18 Aug 2024 13:25:18 +0800 you wrote:
> There is a helper function ARRAY_SIZE() to help calculating the
> u32 array size, and we don't need to do it mannually. So, let's
> use ARRAY_SIZE() to calculate the array size, and improve the code
> readability.
> 
> Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
> 
> [...]

Here is the summary with links:
  - [net-next] net: hns3: Use ARRAY_SIZE() to improve readability
    https://git.kernel.org/netdev/net-next/c/2cbece60a4af

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
index 65b9dcd38137..6db415d8b917 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
@@ -134,17 +134,17 @@  void hclgevf_get_regs(struct hnae3_handle *handle, u32 *version,
 	reg += hclgevf_reg_get_header(reg);
 
 	/* fetching per-VF registers values from VF PCIe register space */
-	reg_um = sizeof(cmdq_reg_addr_list) / sizeof(u32);
+	reg_um = ARRAY_SIZE(cmdq_reg_addr_list);
 	reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_CMDQ, reg_um, reg);
 	for (i = 0; i < reg_um; i++)
 		*reg++ = hclgevf_read_dev(&hdev->hw, cmdq_reg_addr_list[i]);
 
-	reg_um = sizeof(common_reg_addr_list) / sizeof(u32);
+	reg_um = ARRAY_SIZE(common_reg_addr_list);
 	reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_COMMON, reg_um, reg);
 	for (i = 0; i < reg_um; i++)
 		*reg++ = hclgevf_read_dev(&hdev->hw, common_reg_addr_list[i]);
 
-	reg_um = sizeof(ring_reg_addr_list) / sizeof(u32);
+	reg_um = ARRAY_SIZE(ring_reg_addr_list);
 	for (j = 0; j < hdev->num_tqps; j++) {
 		reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_RING, reg_um, reg);
 		for (i = 0; i < reg_um; i++)
@@ -153,7 +153,7 @@  void hclgevf_get_regs(struct hnae3_handle *handle, u32 *version,
 						  HCLGEVF_RING_REG_OFFSET * j);
 	}
 
-	reg_um = sizeof(tqp_intr_reg_addr_list) / sizeof(u32);
+	reg_um = ARRAY_SIZE(tqp_intr_reg_addr_list);
 	for (j = 0; j < hdev->num_msi_used - 1; j++) {
 		reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_TQP_INTR, reg_um, reg);
 		for (i = 0; i < reg_um; i++)