Thread (11 messages) 11 messages, 5 authors, 2017-10-21

Re: [PATCH v3 1/4] phylib: Add device reset GPIO support

flat view

From: Geert Uytterhoeven <hidden>
Date: 2017-10-21 10:08:45
Also in: linux-renesas-soc, lkml, netdev

On Sat, Oct 21, 2017 at 12:03 PM, Sergei Shtylyov
[off-list ref] wrote:
On 10/20/2017 9:11 PM, Florian Fainelli wrote:
quoted
quoted
From: Sergei Shtylyov <redacted>
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
[...]
quoted
quoted
@@ -55,10 +56,22 @@ static int of_mdiobus_register_phy(struct mii_bus
*mdio,
        is_c45 = of_device_is_compatible(child,
                                         "ethernet-phy-ieee802.3-c45");
  +     /* Deassert the optional reset signal */
+       gpiod = fwnode_get_named_gpiod(&child->fwnode, "reset-gpios", 0,
+                                      GPIOD_OUT_LOW, "PHY reset");
+       if (PTR_ERR(gpiod) == -ENOENT)
+               gpiod = NULL;
+       else if (IS_ERR(gpiod))
+               return PTR_ERR(gpiod);
+
        if (!is_c45 && !of_get_phy_id(child, &phy_id))
                phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
        else
                phy = get_phy_device(mdio, addr, is_c45);
+
+       /* Assert the reset signal again */
+       gpiod_set_value(gpiod, 1);
You have a phy_device reference now, so why not call phy_device_reset()
directly here?
   Symmetry, perhaps? (There was a gpiod_set_value(gpiod, 0) call above
it...
Not only because of symmetry: the validity of the phy object hasn't been
checked yet (that's done immediately below), and phy->mdio.reset hasn't been
filled in yet.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help