Skip to contentSkip to conversation

of_mdio: use of_property_read_u32_array()

PATCH In review Sergei Shtylyov 6 participants 7 messages Aug 4, 2017 – Aug 7, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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)...

---
The patch is against the 'dt/next' branch of Rob Herring's 'linux-git' repo plus the previously posted patch killing the useless local variable in of_phy_register_fixed_link().

 drivers/of/of_mdio.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/of/of_mdio.c +8 -8
Index: linux/drivers/of/of_mdio.c
===================================================================
@@ -421,10 +421,10 @@ int of_phy_register_fixed_link(struct de
 {
 	struct fixed_phy_status status = {};
 	struct device_node *fixed_link_node;
-	const __be32 *fixed_link_prop;
+	u32 fixed_link_prop[5];
 	struct phy_device *phy;
 	const char *managed;
-	int link_gpio, len;
+	int link_gpio;
 
 	if (of_property_read_string(np, "managed", &managed) == 0) {
 		if (strcmp(managed, "in-band-status") == 0) {
@@ -459,13 +459,13 @@ int of_phy_register_fixed_link(struct de
 	}
 
 	/* Old binding */
-	fixed_link_prop = of_get_property(np, "fixed-link", &len);
-	if (fixed_link_prop && len == (5 * sizeof(__be32))) {
+	if (of_property_read_u32_array(np, "fixed-link", fixed_link_prop,
+				       ARRAY_SIZE(fixed_link_prop)) == 0) {
 		status.link = 1;
-		status.duplex = be32_to_cpu(fixed_link_prop[1]);
-		status.speed = be32_to_cpu(fixed_link_prop[2]);
-		status.pause = be32_to_cpu(fixed_link_prop[3]);
-		status.asym_pause = be32_to_cpu(fixed_link_prop[4]);
+		status.duplex = fixed_link_prop[1];
+		status.speed  = fixed_link_prop[2];
+		status.pause  = fixed_link_prop[3];
+		status.asym_pause = fixed_link_prop[4];
 		phy = fixed_phy_register(PHY_POLL, &status, -1, np);
 		return PTR_ERR_OR_ZERO(phy);
 	}
Reviewed-by
#2 lore raw
In reply to a message not in the archive
Quoted 7 lines · Sergei Shtylyov

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)...

Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 6 lines · Sergei Shtylyov

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)...

Quoted 6 lines

---
The patch is against the 'dt/next' branch of Rob Herring's 'linux-git' repo plus the previously posted patch killing the useless local variable in of_phy_register_fixed_link().

It shouldn't depend on anything in my tree and David normally takes of_mdio.c changes.

Quoted 3 lines
 drivers/of/of_mdio.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Hello!

Quoted 8 lines · Rob Herring
Quoted 8 lines

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)...

Quoted 7 lines
Quoted 4 lines

---
The patch is against the 'dt/next' branch of Rob Herring's 'linux-git' repo plus the previously posted patch killing the useless local variable in of_phy_register_fixed_link().

It shouldn't depend on anything in my tree and David normally takes of_mdio.c changes.

MAINTAINERS still only point at the DT repo, perhaps it should be updated?

Quoted 1 line

Thank you.

Quoted 2 lines
Quoted 2 lines
  drivers/of/of_mdio.c |   16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)

MBR, Sergei

#5 lore raw
Quoted 19 lines · Sergei Shtylyov

Hello!

Quoted 15 lines · Rob Herring
Quoted 14 lines

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)...

---
The patch is against the 'dt/next' branch of Rob Herring's 'linux-git' repo
plus the previously posted patch killing the useless local variable in of_phy_register_fixed_link().

Quoted 5 lines
Quoted 2 lines

It shouldn't depend on anything in my tree and David normally takes of_mdio.c changes.

MAINTAINERS still only point at the DT repo, perhaps it should be
updated?

More or less done with this (minus the repo part):

http://patchwork.ozlabs.org/patch/795887/

Signature · 1 line
Florian
#6 lore raw
Quoted 23 lines · Florian Fainelli
Quoted 22 lines · Sergei Shtylyov

Hello!

Quoted 17 lines · Rob Herring
Quoted 7 lines

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)...

Quoted 7 lines

---
The patch is against the 'dt/next' branch of Rob Herring's 'linux-git' repo
plus the previously posted patch killing the useless local variable in of_phy_register_fixed_link().

It shouldn't depend on anything in my tree and David normally takes of_mdio.c changes.

Quoted 6 lines
Quoted 2 lines

MAINTAINERS still only point at the DT repo, perhaps it should be
updated?

More or less done with this (minus the repo part):

http://patchwork.ozlabs.org/patch/795887/

Really I'd like to see this fixed by moving of_mdio.c and of_net.c to drivers/net/ as we've done for all other subsystems.

Rob

#7 lore raw
In reply to a message not in the archive

From: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/[email protected]>
Date: Sat, 05 Aug 2017 00:43:43 +0300

Quoted 7 lines

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)...

Applied to net-next.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html