Skip to content

Commit

Permalink
net: ll_temac: Use of_property_read_u32 instead of open-coding it
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tobias Klauser authored and David S. Miller committed Sep 24, 2015
1 parent 38cf595 commit e734a42
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/net/ethernet/xilinx/ll_temac_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e734a42

Please sign in to comment.