* [PATCH 1/2] mdio_bus: handle only single PHY reset GPIO
@ 2017-06-12 20:55 Sergei Shtylyov
[not found] ` <20170612210547.823996341-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2017-06-12 20:55 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Rob Herring, Frank Rowand,
netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA
Cc: Sergei Shtylyov
[-- Attachment #1: mdio_bus-handle-only-single-PHY-reset-GPIO.patch --]
[-- Type: text/plain, Size: 4056 bytes --]
Commit 4c5e7a2c0501 ("dt-bindings: mdio: Clarify binding document")
declared that a MDIO reset GPIO property should have only a single GPIO
reference/specifier, however the supporting code was left intact, still
burdening the kernel with now apparently useless loops -- get rid of them.
Signed-off-by: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
---
drivers/net/phy/mdio_bus.c | 53 ++++++++++++++++-----------------------------
drivers/of/of_mdio.c | 1
include/linux/phy.h | 6 +----
3 files changed, 21 insertions(+), 39 deletions(-)
Index: net-next/drivers/net/phy/mdio_bus.c
===================================================================
--- net-next.orig/drivers/net/phy/mdio_bus.c
+++ net-next/drivers/net/phy/mdio_bus.c
@@ -353,33 +353,22 @@ int __mdiobus_register(struct mii_bus *b
mutex_init(&bus->mdio_lock);
- /* de-assert bus level PHY GPIO resets */
- if (bus->num_reset_gpios > 0) {
- bus->reset_gpiod = devm_kcalloc(&bus->dev,
- bus->num_reset_gpios,
- sizeof(struct gpio_desc *),
- GFP_KERNEL);
- if (!bus->reset_gpiod)
- return -ENOMEM;
- }
-
- for (i = 0; i < bus->num_reset_gpios; i++) {
- gpiod = devm_gpiod_get_index(&bus->dev, "reset", i,
- GPIOD_OUT_LOW);
- if (IS_ERR(gpiod)) {
- err = PTR_ERR(gpiod);
- if (err != -ENOENT) {
- dev_err(&bus->dev,
- "mii_bus %s couldn't get reset GPIO\n",
- bus->id);
- return err;
- }
- } else {
- bus->reset_gpiod[i] = gpiod;
- gpiod_set_value_cansleep(gpiod, 1);
- udelay(bus->reset_delay_us);
- gpiod_set_value_cansleep(gpiod, 0);
+ /* de-assert bus level PHY GPIO reset */
+ gpiod = devm_gpiod_get(&bus->dev, "reset", GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod)) {
+ err = PTR_ERR(gpiod);
+ if (err != -ENOENT) {
+ dev_err(&bus->dev,
+ "mii_bus %s couldn't get reset GPIO\n",
+ bus->id);
+ return err;
}
+ } else {
+ bus->reset_gpiod = gpiod;
+
+ gpiod_set_value_cansleep(gpiod, 1);
+ udelay(bus->reset_delay_us);
+ gpiod_set_value_cansleep(gpiod, 0);
}
if (bus->reset)
@@ -414,10 +403,8 @@ error:
}
/* Put PHYs in RESET to save power */
- for (i = 0; i < bus->num_reset_gpios; i++) {
- if (bus->reset_gpiod[i])
- gpiod_set_value_cansleep(bus->reset_gpiod[i], 1);
- }
+ if (bus->reset_gpiod)
+ gpiod_set_value_cansleep(bus->reset_gpiod, 1);
device_del(&bus->dev);
return err;
@@ -442,10 +429,8 @@ void mdiobus_unregister(struct mii_bus *
}
/* Put PHYs in RESET to save power */
- for (i = 0; i < bus->num_reset_gpios; i++) {
- if (bus->reset_gpiod[i])
- gpiod_set_value_cansleep(bus->reset_gpiod[i], 1);
- }
+ if (bus->reset_gpiod)
+ gpiod_set_value_cansleep(bus->reset_gpiod, 1);
device_del(&bus->dev);
}
Index: net-next/drivers/of/of_mdio.c
===================================================================
--- net-next.orig/drivers/of/of_mdio.c
+++ net-next/drivers/of/of_mdio.c
@@ -226,7 +226,6 @@ int of_mdiobus_register(struct mii_bus *
/* Get bus level PHY reset GPIO details */
mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY;
of_property_read_u32(np, "reset-delay-us", &mdio->reset_delay_us);
- mdio->num_reset_gpios = of_gpio_named_count(np, "reset-gpios");
/* Register the MDIO bus */
rc = mdiobus_register(mdio);
Index: net-next/include/linux/phy.h
===================================================================
--- net-next.orig/include/linux/phy.h
+++ net-next/include/linux/phy.h
@@ -226,10 +226,8 @@ struct mii_bus {
/* GPIO reset pulse width in microseconds */
int reset_delay_us;
- /* Number of reset GPIOs */
- int num_reset_gpios;
- /* Array of RESET GPIO descriptors */
- struct gpio_desc **reset_gpiod;
+ /* RESET GPIO descriptor pointer */
+ struct gpio_desc *reset_gpiod;
};
#define to_mii_bus(d) container_of(d, struct mii_bus, dev)
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] mdio_bus: handle only single PHY reset GPIO
[not found] ` <20170612210547.823996341-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
@ 2017-06-12 23:43 ` Florian Fainelli
[not found] ` <12bb1f10-79cc-25a5-1115-69d13c36a68b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2017-06-12 23:43 UTC (permalink / raw)
To: Sergei Shtylyov, Andrew Lunn, Rob Herring, Frank Rowand,
netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA
On 06/12/2017 01:55 PM, Sergei Shtylyov wrote:
Subject should be: net: phy: Handle only single PHY reset GPIO to be
consistent with prior submissions, and can you also send your patches
inline using git format-patch + git send-email so it's possible to quote
the contents?
Thanks
--
Florian
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] mdio_bus: handle only single PHY reset GPIO
[not found] ` <12bb1f10-79cc-25a5-1115-69d13c36a68b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-06-13 9:20 ` Sergei Shtylyov
0 siblings, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2017-06-13 9:20 UTC (permalink / raw)
To: Florian Fainelli, Andrew Lunn, Rob Herring, Frank Rowand,
netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA
Hello!
On 6/13/2017 2:43 AM, Florian Fainelli wrote:
> Subject should be: net: phy: Handle only single PHY reset GPIO to be
> consistent with prior submissions,
With what exactly previous submissions? I'm seeing all kinds of prefixes
for drivers/net/phy/mdio_bus.c, mine matched Roger's one (as well as my own
and others').
> and can you also send your patches
> inline using git format-patch + git send-email so it's possible to quote
> the contents?
Hm, you're the first complaining about my patches posted with quilt...
Using git adds more efforts on my side (I don't use git for the patch
development). :-/
> Thanks
MNR, Sergei
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-13 9:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-12 20:55 [PATCH 1/2] mdio_bus: handle only single PHY reset GPIO Sergei Shtylyov
[not found] ` <20170612210547.823996341-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-06-12 23:43 ` Florian Fainelli
[not found] ` <12bb1f10-79cc-25a5-1115-69d13c36a68b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-13 9:20 ` Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).