* [PATCH v3 1/3] net: phylink: switch to using fwnode_gpiod_get_index()
2020-01-03 1:03 [PATCH v3 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
@ 2020-01-03 1:03 ` Dmitry Torokhov
2020-01-03 1:03 ` [PATCH v3 2/3] net: phy: fixed_phy: fix use-after-free when checking link GPIO Dmitry Torokhov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2020-01-03 1:03 UTC (permalink / raw)
To: David S . Miller
Cc: netdev, Linus Walleij, linux-kernel, Andy Shevchenko,
Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King
Instead of fwnode_get_named_gpiod() that I plan to hide away, let's use
the new fwnode_gpiod_get_index() that mimics gpiod_get_index(), but
works with arbitrary firmware node.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/net/phy/phylink.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index ba9468cc8e134..3f7fa634134a1 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -186,8 +186,8 @@ static int phylink_parse_fixedlink(struct phylink *pl,
pl->link_config.pause |= MLO_PAUSE_ASYM;
if (ret == 0) {
- desc = fwnode_get_named_gpiod(fixed_node, "link-gpios",
- 0, GPIOD_IN, "?");
+ desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
+ GPIOD_IN, "?");
if (!IS_ERR(desc))
pl->link_gpio = desc;
--
2.24.1.735.g03f4e72817-goog
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v3 2/3] net: phy: fixed_phy: fix use-after-free when checking link GPIO
2020-01-03 1:03 [PATCH v3 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
2020-01-03 1:03 ` [PATCH v3 1/3] net: phylink: switch to using fwnode_gpiod_get_index() Dmitry Torokhov
@ 2020-01-03 1:03 ` Dmitry Torokhov
2020-01-03 1:03 ` [PATCH v3 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
2020-01-05 22:27 ` [PATCH v3 0/3] net: phy: " David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2020-01-03 1:03 UTC (permalink / raw)
To: David S . Miller
Cc: netdev, Linus Walleij, linux-kernel, Andrew Lunn,
Florian Fainelli, Heiner Kallweit
If we fail to locate GPIO for any reason other than deferral or
not-found-GPIO, we try to print device tree node info, however if might
be freed already as we called of_node_put() on it.
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/net/phy/fixed_phy.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index 7c5265fd2b94d..4190f9ed5313d 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -212,16 +212,13 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
*/
gpiod = gpiod_get_from_of_node(fixed_link_node, "link-gpios", 0,
GPIOD_IN, "mdio");
- of_node_put(fixed_link_node);
- if (IS_ERR(gpiod)) {
- if (PTR_ERR(gpiod) == -EPROBE_DEFER)
- return gpiod;
-
+ if (IS_ERR(gpiod) && PTR_ERR(gpiod) != -EPROBE_DEFER) {
if (PTR_ERR(gpiod) != -ENOENT)
pr_err("error getting GPIO for fixed link %pOF, proceed without\n",
fixed_link_node);
gpiod = NULL;
}
+ of_node_put(fixed_link_node);
return gpiod;
}
--
2.24.1.735.g03f4e72817-goog
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v3 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index
2020-01-03 1:03 [PATCH v3 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
2020-01-03 1:03 ` [PATCH v3 1/3] net: phylink: switch to using fwnode_gpiod_get_index() Dmitry Torokhov
2020-01-03 1:03 ` [PATCH v3 2/3] net: phy: fixed_phy: fix use-after-free when checking link GPIO Dmitry Torokhov
@ 2020-01-03 1:03 ` Dmitry Torokhov
2020-01-05 22:27 ` [PATCH v3 0/3] net: phy: " David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2020-01-03 1:03 UTC (permalink / raw)
To: David S . Miller
Cc: netdev, Linus Walleij, linux-kernel, Andrew Lunn,
Florian Fainelli, Heiner Kallweit
gpiod_get_from_of_node() is being retired in favor of
[devm_]fwnode_gpiod_get_index(), that behaves similar to
[devm_]gpiod_get_index(), but can work with arbitrary firmware node. It
will also be able to support secondary software nodes.
Let's switch this driver over.
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/net/phy/fixed_phy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index 4190f9ed5313d..73a72ff0fb16b 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -210,8 +210,8 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
* Linux device associated with it, we simply have obtain
* the GPIO descriptor from the device tree like this.
*/
- gpiod = gpiod_get_from_of_node(fixed_link_node, "link-gpios", 0,
- GPIOD_IN, "mdio");
+ gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
+ "link", 0, GPIOD_IN, "mdio");
if (IS_ERR(gpiod) && PTR_ERR(gpiod) != -EPROBE_DEFER) {
if (PTR_ERR(gpiod) != -ENOENT)
pr_err("error getting GPIO for fixed link %pOF, proceed without\n",
--
2.24.1.735.g03f4e72817-goog
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3 0/3] net: phy: switch to using fwnode_gpiod_get_index
2020-01-03 1:03 [PATCH v3 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
` (2 preceding siblings ...)
2020-01-03 1:03 ` [PATCH v3 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
@ 2020-01-05 22:27 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-01-05 22:27 UTC (permalink / raw)
To: dmitry.torokhov
Cc: netdev, linus.walleij, linux-kernel, andrew, f.fainelli,
hkallweit1, linux
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Thu, 2 Jan 2020 17:03:17 -0800
> This series switches phy drivers form using fwnode_get_named_gpiod() and
> gpiod_get_from_of_node() that are scheduled to be removed in favor
> of fwnode_gpiod_get_index() that behaves more like standard
> gpiod_get_index() and will potentially handle secondary software
> nodes in cases we need to augment platform firmware.
>
> Now that the dependencies have been merged into networking tree the
> patches can be applied there as well.
>
> v3:
> - rebased on top of net-next
>
> v2:
> - rebased on top of Linus' W devel branch
> - added David's ACKs
Series applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread