Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9edda69 authored by Alejandro Martinez Ruiz's avatar Alejandro Martinez Ruiz Committed by Jeff Garzik
Browse files

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: default avatarAlejandro Martinez Ruiz <alex@flawedcode.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 88a15f2e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4443,7 +4443,7 @@ static struct {
	{REG_MAC_COLL_EXCESS},
	{REG_MAC_COLL_LATE}
};
#define CAS_REG_LEN 	(sizeof(ethtool_register_table)/sizeof(int))
#define CAS_REG_LEN 	ARRAY_SIZE(ethtool_register_table)
#define CAS_MAX_REGS 	(sizeof (u32)*CAS_REG_LEN)

static void cas_read_regs(struct cas *cp, u8 *ptr, int len)
+1 −1
Original line number Diff line number Diff line
@@ -840,7 +840,7 @@ toshoboe_probe (struct toshoboe_cb *self)

  /* test 1: SIR filter and back to back */

  for (j = 0; j < (sizeof (bauds) / sizeof (int)); ++j)
  for (j = 0; j < ARRAY_SIZE(bauds); ++j)
    {
      int fir = (j > 1);
      toshoboe_stopchip (self);
+2 −2
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ static int __init init_reg_offset(struct net_device *dev,unsigned long base_addr
	bus_width = *(volatile unsigned char *)ABWCR;
	bus_width &= 1 << ((base_addr >> 21) & 7);

	for (i = 0; i < sizeof(reg_offset) / sizeof(u32); i++)
	for (i = 0; i < ARRAY_SIZE(reg_offset); i++)
		if (bus_width == 0)
			reg_offset[i] = i * 2 + 1;
		else
@@ -115,7 +115,7 @@ static int h8300_ne_irq[] = {EXT_IRQ5};

static inline int init_dev(struct net_device *dev)
{
	if (h8300_ne_count < (sizeof(h8300_ne_base) / sizeof(unsigned long))) {
	if (h8300_ne_count < ARRAY_SIZE(h8300_ne_base)) {
		dev->base_addr = h8300_ne_base[h8300_ne_count];
		dev->irq       = h8300_ne_irq[h8300_ne_count];
		h8300_ne_count++;
+1 −1
Original line number Diff line number Diff line
@@ -9034,7 +9034,7 @@ static int tg3_do_mem_test(struct tg3 *tp, u32 offset, u32 len)
	int i;
	u32 j;

	for (i = 0; i < sizeof(test_pattern)/sizeof(u32); i++) {
	for (i = 0; i < ARRAY_SIZE(test_pattern); i++) {
		for (j = 0; j < len; j += 4) {
			u32 val;

+2 −2
Original line number Diff line number Diff line
@@ -1041,7 +1041,7 @@ static struct InfoLeaf infoleaf_array[] = {
    {DC21142, dc21142_infoleaf},
    {DC21143, dc21143_infoleaf}
};
#define INFOLEAF_SIZE (sizeof(infoleaf_array)/(sizeof(int)+sizeof(int *)))
#define INFOLEAF_SIZE ARRAY_SIZE(infoleaf_array)

/*
** List the SROM info block functions
@@ -1056,7 +1056,7 @@ static int (*dc_infoblock[])(struct net_device *dev, u_char, u_char *) = {
    compact_infoblock
};

#define COMPACT (sizeof(dc_infoblock)/sizeof(int *) - 1)
#define COMPACT (ARRAY_SIZE(dc_infoblock) - 1)

/*
** Miscellaneous defines...
Loading