* [PATCH 0/2] Use ARRAY_SIZE to replace computing the size
@ 2018-08-03 6:53 zhong jiang
2018-08-03 6:53 ` [PATCH 1/2] net:usb: Use ARRAY_SIZE instead of calculating the array size zhong jiang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: zhong jiang @ 2018-08-03 6:53 UTC (permalink / raw)
To: woojung.huh, davem, UNGLinuxDriver; +Cc: netdev, linux-kernel
zhong jiang (2):
net:usb: Use ARRAY_SIZE instead of calculating the array size
include/net/bond_3ad: Simplify the code by using the ARRAY_SIZE
drivers/net/usb/lan78xx.c | 2 +-
include/net/bond_3ad.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] net:usb: Use ARRAY_SIZE instead of calculating the array size
2018-08-03 6:53 [PATCH 0/2] Use ARRAY_SIZE to replace computing the size zhong jiang
@ 2018-08-03 6:53 ` zhong jiang
2018-08-03 6:53 ` [PATCH 2/2] include/net/bond_3ad: Simplify the code by using the ARRAY_SIZE zhong jiang
2018-08-04 20:23 ` [PATCH 0/2] Use ARRAY_SIZE to replace computing the size David Miller
2 siblings, 0 replies; 4+ messages in thread
From: zhong jiang @ 2018-08-03 6:53 UTC (permalink / raw)
To: woojung.huh, davem, UNGLinuxDriver; +Cc: netdev, linux-kernel
We use ARRAY_SIZE to replace open code sizeof(lan78xx_regs) / sizeof(u32).
It make the code concise.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
drivers/net/usb/lan78xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 4662fa0..a9991c5 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1649,7 +1649,7 @@ static int lan78xx_get_regs_len(struct net_device *netdev)
struct lan78xx_net *dev = netdev_priv(netdev);
/* Read Device/MAC registers */
- for (i = 0; i < (sizeof(lan78xx_regs) / sizeof(u32)); i++)
+ for (i = 0; i < ARRAY_SIZE(lan78xx_regs); i++)
lan78xx_read_reg(dev, lan78xx_regs[i], &data[i]);
if (!netdev->phydev)
--
1.7.12.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] include/net/bond_3ad: Simplify the code by using the ARRAY_SIZE
2018-08-03 6:53 [PATCH 0/2] Use ARRAY_SIZE to replace computing the size zhong jiang
2018-08-03 6:53 ` [PATCH 1/2] net:usb: Use ARRAY_SIZE instead of calculating the array size zhong jiang
@ 2018-08-03 6:53 ` zhong jiang
2018-08-04 20:23 ` [PATCH 0/2] Use ARRAY_SIZE to replace computing the size David Miller
2 siblings, 0 replies; 4+ messages in thread
From: zhong jiang @ 2018-08-03 6:53 UTC (permalink / raw)
To: woojung.huh, davem, UNGLinuxDriver; +Cc: netdev, linux-kernel
We prefer to ARRAY_SIZE rather than the open code to calculate size.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
include/net/bond_3ad.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/bond_3ad.h b/include/net/bond_3ad.h
index f358ad5..fc31115 100644
--- a/include/net/bond_3ad.h
+++ b/include/net/bond_3ad.h
@@ -283,7 +283,7 @@ static inline const char *bond_3ad_churn_desc(churn_state_t state)
"none",
"unknown"
};
- int max_size = sizeof(churn_description) / sizeof(churn_description[0]);
+ int max_size = ARRAY_SIZE(churn_description);
if (state >= max_size)
state = max_size - 1;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Use ARRAY_SIZE to replace computing the size
2018-08-03 6:53 [PATCH 0/2] Use ARRAY_SIZE to replace computing the size zhong jiang
2018-08-03 6:53 ` [PATCH 1/2] net:usb: Use ARRAY_SIZE instead of calculating the array size zhong jiang
2018-08-03 6:53 ` [PATCH 2/2] include/net/bond_3ad: Simplify the code by using the ARRAY_SIZE zhong jiang
@ 2018-08-04 20:23 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-08-04 20:23 UTC (permalink / raw)
To: zhongjiang; +Cc: woojung.huh, UNGLinuxDriver, netdev, linux-kernel
From: zhong jiang <zhongjiang@huawei.com>
Date: Fri, 3 Aug 2018 14:53:13 +0800
> zhong jiang (2):
> net:usb: Use ARRAY_SIZE instead of calculating the array size
> include/net/bond_3ad: Simplify the code by using the ARRAY_SIZE
Series applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-08-04 20:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-03 6:53 [PATCH 0/2] Use ARRAY_SIZE to replace computing the size zhong jiang
2018-08-03 6:53 ` [PATCH 1/2] net:usb: Use ARRAY_SIZE instead of calculating the array size zhong jiang
2018-08-03 6:53 ` [PATCH 2/2] include/net/bond_3ad: Simplify the code by using the ARRAY_SIZE zhong jiang
2018-08-04 20:23 ` [PATCH 0/2] Use ARRAY_SIZE to replace computing the size David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).