Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1230097 > unrolled thread

[PATCH] net: ll_temac: Use of_property_read_u32 instead of open-coding it

Started byTobias Klauser <tklauser@distanz.ch>
First post2015-09-22 13:50 +0200
Last post2015-09-24 23:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: ll_temac: Use of_property_read_u32 instead of open-coding it Tobias Klauser <tklauser@distanz.ch> - 2015-09-22 13:50 +0200
    [PATCH v2] net: ll_temac: Use of_property_read_u32 instead of open-coding it Tobias Klauser <tklauser@distanz.ch> - 2015-09-23 09:30 +0200
    Re: [PATCH] net: ll_temac: Use of_property_read_u32 instead of  open-coding it David Miller <davem@davemloft.net> - 2015-09-24 23:40 +0200

#1230097 — [PATCH] net: ll_temac: Use of_property_read_u32 instead of open-coding it

FromTobias Klauser <tklauser@distanz.ch>
Date2015-09-22 13:50 +0200
Subject[PATCH] net: ll_temac: Use of_property_read_u32 instead of open-coding it
Message-ID<qbuf8-4hk-9@gated-at.bofh.it>
Use of_property_read_u32 to read the "clock-frequency" property instead
of using of_get_property with return value checks.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
 drivers/net/ethernet/xilinx/ll_temac_mdio.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_mdio.c b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
index 8cf9d4f..415de1e 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_mdio.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
@@ -59,16 +59,15 @@ static int temac_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 val)
 int temac_mdio_setup(struct temac_local *lp, struct device_node *np)
 {
 	struct mii_bus *bus;
-	const u32 *bus_hz;
+	u32 bus_hz;
 	int clk_div;
-	int rc, size;
+	int rc;
 	struct resource res;
 
 	/* Calculate a reasonable divisor for the clock rate */
 	clk_div = 0x3f; /* worst-case default setting */
-	bus_hz = of_get_property(np, "clock-frequency", &size);
-	if (bus_hz && size >= sizeof(*bus_hz)) {
-		clk_div = (*bus_hz) / (2500 * 1000 * 2) - 1;
+	if (of_property_read_u32(np, "clock-frequency", &bus_hz) == 0) {
+		clk_div = bus_hz / (2500 * 1000 * 2) - 1;
 		if (clk_div < 1)
 			clk_div = 1;
 		if (clk_div > 0x3f)
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1231194 — [PATCH v2] net: ll_temac: Use of_property_read_u32 instead of open-coding it

FromTobias Klauser <tklauser@distanz.ch>
Date2015-09-23 09:30 +0200
Subject[PATCH v2] net: ll_temac: Use of_property_read_u32 instead of open-coding it
Message-ID<qbMF4-5Lu-15@gated-at.bofh.it>
In reply to#1230097
Use of_property_read_u32 to read the "clock-frequency" property instead
of using of_get_property with return value checks.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Reviewed-by: Sören Brinkmann <soren.brinkmann@xilinx.com>
---
v2: Resending with Cc to netdev

 drivers/net/ethernet/xilinx/ll_temac_mdio.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_mdio.c b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
index 8cf9d4f..415de1e 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_mdio.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
@@ -59,16 +59,15 @@ static int temac_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 val)
 int temac_mdio_setup(struct temac_local *lp, struct device_node *np)
 {
 	struct mii_bus *bus;
-	const u32 *bus_hz;
+	u32 bus_hz;
 	int clk_div;
-	int rc, size;
+	int rc;
 	struct resource res;
 
 	/* Calculate a reasonable divisor for the clock rate */
 	clk_div = 0x3f; /* worst-case default setting */
-	bus_hz = of_get_property(np, "clock-frequency", &size);
-	if (bus_hz && size >= sizeof(*bus_hz)) {
-		clk_div = (*bus_hz) / (2500 * 1000 * 2) - 1;
+	if (of_property_read_u32(np, "clock-frequency", &bus_hz) == 0) {
+		clk_div = bus_hz / (2500 * 1000 * 2) - 1;
 		if (clk_div < 1)
 			clk_div = 1;
 		if (clk_div > 0x3f)
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1232447 — Re: [PATCH] net: ll_temac: Use of_property_read_u32 instead of open-coding it

FromDavid Miller <davem@davemloft.net>
Date2015-09-24 23:40 +0200
SubjectRe: [PATCH] net: ll_temac: Use of_property_read_u32 instead of open-coding it
Message-ID<qcmpc-6Pk-7@gated-at.bofh.it>
In reply to#1230097
From: Tobias Klauser <tklauser@distanz.ch>
Date: Tue, 22 Sep 2015 13:41:57 +0200

> Use of_property_read_u32 to read the "clock-frequency" property instead
> of using of_get_property with return value checks.
> 
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>

Applied to net-next.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web