diff options
author | Alejandro Martinez Ruiz <alex@flawedcode.org> | 2007-10-14 21:37:43 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-15 15:57:38 -0400 |
commit | e9edda697ed7697f1288d0656570e49c47e204ae (patch) | |
tree | 6d43d602b7e0eb98940a516e0e0d2c8fd1a7006a | |
parent | 88a15f2e28bd6a908b2925f1b76e70ef3a88297d (diff) |
netdev: convert non-obvious instances to use ARRAY_SIZE()
This will convert remaining non-obvious or naive calculations of array
sizes to use ARRAY_SIZE() macro.
Signed-off-by: Alejandro Martinez Ruiz <alex@flawedcode.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | drivers/net/cassini.c | 2 | ||||
-rw-r--r-- | drivers/net/irda/donauboe.c | 2 | ||||
-rw-r--r-- | drivers/net/ne-h8300.c | 4 | ||||
-rw-r--r-- | drivers/net/tg3.c | 2 | ||||
-rw-r--r-- | drivers/net/tulip/de4x5.c | 4 | ||||
-rw-r--r-- | drivers/net/wan/sdla.c | 8 |
6 files changed, 11 insertions, 11 deletions
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c index 563bf5f6fa2a..7df31b5561cc 100644 --- a/drivers/net/cassini.c +++ b/drivers/net/cassini.c | |||
@@ -4443,7 +4443,7 @@ static struct { | |||
4443 | {REG_MAC_COLL_EXCESS}, | 4443 | {REG_MAC_COLL_EXCESS}, |
4444 | {REG_MAC_COLL_LATE} | 4444 | {REG_MAC_COLL_LATE} |
4445 | }; | 4445 | }; |
4446 | #define CAS_REG_LEN (sizeof(ethtool_register_table)/sizeof(int)) | 4446 | #define CAS_REG_LEN ARRAY_SIZE(ethtool_register_table) |
4447 | #define CAS_MAX_REGS (sizeof (u32)*CAS_REG_LEN) | 4447 | #define CAS_MAX_REGS (sizeof (u32)*CAS_REG_LEN) |
4448 | 4448 | ||
4449 | static void cas_read_regs(struct cas *cp, u8 *ptr, int len) | 4449 | static void cas_read_regs(struct cas *cp, u8 *ptr, int len) |
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c index 3e5eca1aa987..a82d8f98383d 100644 --- a/drivers/net/irda/donauboe.c +++ b/drivers/net/irda/donauboe.c | |||
@@ -840,7 +840,7 @@ toshoboe_probe (struct toshoboe_cb *self) | |||
840 | 840 | ||
841 | /* test 1: SIR filter and back to back */ | 841 | /* test 1: SIR filter and back to back */ |
842 | 842 | ||
843 | for (j = 0; j < (sizeof (bauds) / sizeof (int)); ++j) | 843 | for (j = 0; j < ARRAY_SIZE(bauds); ++j) |
844 | { | 844 | { |
845 | int fir = (j > 1); | 845 | int fir = (j > 1); |
846 | toshoboe_stopchip (self); | 846 | toshoboe_stopchip (self); |
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c index 368f2560856d..fbc7531d3c7d 100644 --- a/drivers/net/ne-h8300.c +++ b/drivers/net/ne-h8300.c | |||
@@ -93,7 +93,7 @@ static int __init init_reg_offset(struct net_device *dev,unsigned long base_addr | |||
93 | bus_width = *(volatile unsigned char *)ABWCR; | 93 | bus_width = *(volatile unsigned char *)ABWCR; |
94 | bus_width &= 1 << ((base_addr >> 21) & 7); | 94 | bus_width &= 1 << ((base_addr >> 21) & 7); |
95 | 95 | ||
96 | for (i = 0; i < sizeof(reg_offset) / sizeof(u32); i++) | 96 | for (i = 0; i < ARRAY_SIZE(reg_offset); i++) |
97 | if (bus_width == 0) | 97 | if (bus_width == 0) |
98 | reg_offset[i] = i * 2 + 1; | 98 | reg_offset[i] = i * 2 + 1; |
99 | else | 99 | else |
@@ -115,7 +115,7 @@ static int h8300_ne_irq[] = {EXT_IRQ5}; | |||
115 | 115 | ||
116 | static inline int init_dev(struct net_device *dev) | 116 | static inline int init_dev(struct net_device *dev) |
117 | { | 117 | { |
118 | if (h8300_ne_count < (sizeof(h8300_ne_base) / sizeof(unsigned long))) { | 118 | if (h8300_ne_count < ARRAY_SIZE(h8300_ne_base)) { |
119 | dev->base_addr = h8300_ne_base[h8300_ne_count]; | 119 | dev->base_addr = h8300_ne_base[h8300_ne_count]; |
120 | dev->irq = h8300_ne_irq[h8300_ne_count]; | 120 | dev->irq = h8300_ne_irq[h8300_ne_count]; |
121 | h8300_ne_count++; | 121 | h8300_ne_count++; |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 30b1cca8144c..76efb3feffbf 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -9034,7 +9034,7 @@ static int tg3_do_mem_test(struct tg3 *tp, u32 offset, u32 len) | |||
9034 | int i; | 9034 | int i; |
9035 | u32 j; | 9035 | u32 j; |
9036 | 9036 | ||
9037 | for (i = 0; i < sizeof(test_pattern)/sizeof(u32); i++) { | 9037 | for (i = 0; i < ARRAY_SIZE(test_pattern); i++) { |
9038 | for (j = 0; j < len; j += 4) { | 9038 | for (j = 0; j < len; j += 4) { |
9039 | u32 val; | 9039 | u32 val; |
9040 | 9040 | ||
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c index 9b9cd83fb8b6..41f34bb91cad 100644 --- a/drivers/net/tulip/de4x5.c +++ b/drivers/net/tulip/de4x5.c | |||
@@ -1041,7 +1041,7 @@ static struct InfoLeaf infoleaf_array[] = { | |||
1041 | {DC21142, dc21142_infoleaf}, | 1041 | {DC21142, dc21142_infoleaf}, |
1042 | {DC21143, dc21143_infoleaf} | 1042 | {DC21143, dc21143_infoleaf} |
1043 | }; | 1043 | }; |
1044 | #define INFOLEAF_SIZE (sizeof(infoleaf_array)/(sizeof(int)+sizeof(int *))) | 1044 | #define INFOLEAF_SIZE ARRAY_SIZE(infoleaf_array) |
1045 | 1045 | ||
1046 | /* | 1046 | /* |
1047 | ** List the SROM info block functions | 1047 | ** List the SROM info block functions |
@@ -1056,7 +1056,7 @@ static int (*dc_infoblock[])(struct net_device *dev, u_char, u_char *) = { | |||
1056 | compact_infoblock | 1056 | compact_infoblock |
1057 | }; | 1057 | }; |
1058 | 1058 | ||
1059 | #define COMPACT (sizeof(dc_infoblock)/sizeof(int *) - 1) | 1059 | #define COMPACT (ARRAY_SIZE(dc_infoblock) - 1) |
1060 | 1060 | ||
1061 | /* | 1061 | /* |
1062 | ** Miscellaneous defines... | 1062 | ** Miscellaneous defines... |
diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c index b39a541b2509..05df0a345b60 100644 --- a/drivers/net/wan/sdla.c +++ b/drivers/net/wan/sdla.c | |||
@@ -1342,11 +1342,11 @@ static int sdla_set_config(struct net_device *dev, struct ifmap *map) | |||
1342 | if (flp->initialized) | 1342 | if (flp->initialized) |
1343 | return(-EINVAL); | 1343 | return(-EINVAL); |
1344 | 1344 | ||
1345 | for(i=0;i < sizeof(valid_port) / sizeof (int) ; i++) | 1345 | for(i=0; i < ARRAY_SIZE(valid_port); i++) |
1346 | if (valid_port[i] == map->base_addr) | 1346 | if (valid_port[i] == map->base_addr) |
1347 | break; | 1347 | break; |
1348 | 1348 | ||
1349 | if (i == sizeof(valid_port) / sizeof(int)) | 1349 | if (i == ARRAY_SIZE(valid_port)) |
1350 | return(-EINVAL); | 1350 | return(-EINVAL); |
1351 | 1351 | ||
1352 | if (!request_region(map->base_addr, SDLA_IO_EXTENTS, dev->name)){ | 1352 | if (!request_region(map->base_addr, SDLA_IO_EXTENTS, dev->name)){ |
@@ -1487,12 +1487,12 @@ got_type: | |||
1487 | } | 1487 | } |
1488 | } | 1488 | } |
1489 | 1489 | ||
1490 | for(i=0;i < sizeof(valid_mem) / sizeof (int) ; i++) | 1490 | for(i=0; i < ARRAY_SIZE(valid_mem); i++) |
1491 | if (valid_mem[i] == map->mem_start) | 1491 | if (valid_mem[i] == map->mem_start) |
1492 | break; | 1492 | break; |
1493 | 1493 | ||
1494 | err = -EINVAL; | 1494 | err = -EINVAL; |
1495 | if (i == sizeof(valid_mem) / sizeof(int)) | 1495 | if (i == ARRAY_SIZE(valid_mem)) |
1496 | goto fail2; | 1496 | goto fail2; |
1497 | 1497 | ||
1498 | if (flp->type == SDLA_S502A && (map->mem_start & 0xF000) >> 12 == 0x0E) | 1498 | if (flp->type == SDLA_S502A && (map->mem_start & 0xF000) >> 12 == 0x0E) |