tulip: cleanup by using ARRAY_SIZE()
Subsystems (4)
PATCH 1/1 tulip: cleanup by using ARRAY_SIZE()
In this situation then ARRAY_SIZE() and sizeof() are the same, but we're really dealing with array indexes and not byte offsets so ARRAY_SIZE() is cleaner.
Signed-off-by Dan Carpenter <[email protected]>
drivers/net/ethernet/dec/tulip/media.c +1 -1
@@ -457,7 +457,7 @@ void tulip_find_mii(struct net_device *dev, int board_idx)/* Find the connected MII xcvrs. Doing this in open() would allow detecting external xcvrs later, but takes much time. */ - for (phyn = 1; phyn <= 32 && phy_idx < sizeof (tp->phys); phyn++) { + for (phyn = 1; phyn <= 32 && phy_idx < ARRAY_SIZE(tp->phys); phyn++) { int phy = phyn & 0x1f; int mii_status = tulip_mdio_read (dev, phy, MII_BMSR); if ((mii_status & 0x8301) = 0x8001 ||
Quoted 3 lines · Dan Carpenter
In this situation then
ARRAY_SIZE()andsizeof()are the same, but we're really dealing with array indexes and not byte offsets soARRAY_SIZE()is cleaner.
Yup.
Quoted 1 line
Signed-off-by Dan Carpenter <[email protected]>
Acked-by Grant Grundler <[email protected]>
cheers
grant
Quoted 14 lines
drivers/net/ethernet/dec/tulip/media.c +1
-1@@ -457,7 +457,7 @@ void tulip_find_mii(struct net_device *dev, int board_idx)/* Find the connected MII xcvrs. Doing this in open() would allow detecting external xcvrs later, but takes much time. */ - for (phyn = 1; phyn <= 32 && phy_idx < sizeof (tp->phys); phyn++) { + for (phyn = 1; phyn <= 32 && phy_idx < ARRAY_SIZE(tp->phys); phyn++) { int phy = phyn & 0x1f; int mii_status = tulip_mdio_read (dev, phy, MII_BMSR); if ((mii_status & 0x8301) = 0x8001 ||
From: Dan Carpenter <[email protected]>
Date: Thu, 23 Jan 2014 11:26:37 +0300
Quoted 5 lines
In this situation then
ARRAY_SIZE()andsizeof()are the same, but we're really dealing with array indexes and not byte offsets soARRAY_SIZE()is cleaner.Signed-off-by Dan Carpenter <[email protected]>
Applied, thanks Dan.