Skip to content

Commit d226a2b

Browse files
Sergei Shtylyovdavem330
authored andcommitted
of_mdio: use of_property_read_u32_array()
The "fixed-link" prop support predated of_property_read_u32_array(), so basically had to open-code it. Using the modern API saves 24 bytes of the object code (ARM gcc 4.8.5); the only behavior change would be that the prop length check is now less strict (however the strict pre-check done in of_phy_is_fixed_link() is left intact anyway)... Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e1cea2e commit d226a2b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/of/of_mdio.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ int of_phy_register_fixed_link(struct device_node *np)
421421
{
422422
struct fixed_phy_status status = {};
423423
struct device_node *fixed_link_node;
424-
const __be32 *fixed_link_prop;
424+
u32 fixed_link_prop[5];
425425
struct phy_device *phy;
426426
const char *managed;
427-
int link_gpio, len;
427+
int link_gpio;
428428

429429
if (of_property_read_string(np, "managed", &managed) == 0) {
430430
if (strcmp(managed, "in-band-status") == 0) {
@@ -459,13 +459,13 @@ int of_phy_register_fixed_link(struct device_node *np)
459459
}
460460

461461
/* Old binding */
462-
fixed_link_prop = of_get_property(np, "fixed-link", &len);
463-
if (fixed_link_prop && len == (5 * sizeof(__be32))) {
462+
if (of_property_read_u32_array(np, "fixed-link", fixed_link_prop,
463+
ARRAY_SIZE(fixed_link_prop)) == 0) {
464464
status.link = 1;
465-
status.duplex = be32_to_cpu(fixed_link_prop[1]);
466-
status.speed = be32_to_cpu(fixed_link_prop[2]);
467-
status.pause = be32_to_cpu(fixed_link_prop[3]);
468-
status.asym_pause = be32_to_cpu(fixed_link_prop[4]);
465+
status.duplex = fixed_link_prop[1];
466+
status.speed = fixed_link_prop[2];
467+
status.pause = fixed_link_prop[3];
468+
status.asym_pause = fixed_link_prop[4];
469469
phy = fixed_phy_register(PHY_POLL, &status, -1, np);
470470
return PTR_ERR_OR_ZERO(phy);
471471
}

0 commit comments

Comments
 (0)