* [PATCH] [v2] fec: convert to gpio descriptor
@ 2023-01-26 21:05 Arnd Bergmann
2023-01-26 22:10 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2023-01-26 21:05 UTC (permalink / raw)
To: Wei Fang, Jakub Kicinski
Cc: Arnd Bergmann, Shenwei Wang, Clark Wang, NXP Linux Team,
David S. Miller, Eric Dumazet, Paolo Abeni, Andrew Lunn, netdev,
linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
The driver can be trivially converted, as it only triggers the gpio
pin briefly to do a reset, and it already only supports DT.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2 changes, suggested by Andrew Lunn:
- reorder header inclusions,
- use dev_err_probe()
---
drivers/net/ethernet/freescale/fec_main.c | 25 ++++++++---------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 5ff45b1a74a5..2716898e0b9b 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -56,12 +56,12 @@
#include <linux/fec.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <linux/of_gpio.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/regulator/consumer.h>
#include <linux/if_vlan.h>
#include <linux/pinctrl/consumer.h>
+#include <linux/gpio/consumer.h>
#include <linux/prefetch.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
@@ -4035,10 +4035,11 @@ static int fec_enet_init(struct net_device *ndev)
#ifdef CONFIG_OF
static int fec_reset_phy(struct platform_device *pdev)
{
- int err, phy_reset;
+ struct gpio_desc *phy_reset;
bool active_high = false;
int msec = 1, phy_post_delay = 0;
struct device_node *np = pdev->dev.of_node;
+ int err;
if (!np)
return 0;
@@ -4048,12 +4049,6 @@ static int fec_reset_phy(struct platform_device *pdev)
if (!err && msec > 1000)
msec = 1;
- phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
- if (phy_reset == -EPROBE_DEFER)
- return phy_reset;
- else if (!gpio_is_valid(phy_reset))
- return 0;
-
err = of_property_read_u32(np, "phy-reset-post-delay", &phy_post_delay);
/* valid reset duration should be less than 1s */
if (!err && phy_post_delay > 1000)
@@ -4061,20 +4056,18 @@ static int fec_reset_phy(struct platform_device *pdev)
active_high = of_property_read_bool(np, "phy-reset-active-high");
- err = devm_gpio_request_one(&pdev->dev, phy_reset,
- active_high ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
- "phy-reset");
- if (err) {
- dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err);
- return err;
- }
+ phy_reset = devm_gpiod_get(&pdev->dev, "phy-reset",
+ active_high ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
+ if (IS_ERR(phy_reset))
+ return dev_err_probe(&pdev->dev, PTR_ERR(phy_reset),
+ "failed to get phy-reset-gpios\n");
if (msec > 20)
msleep(msec);
else
usleep_range(msec * 1000, msec * 1000 + 1000);
- gpio_set_value_cansleep(phy_reset, !active_high);
+ gpiod_set_value_cansleep(phy_reset, !active_high);
if (!phy_post_delay)
return 0;
--
2.39.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] [v2] fec: convert to gpio descriptor
2023-01-26 21:05 [PATCH] [v2] fec: convert to gpio descriptor Arnd Bergmann
@ 2023-01-26 22:10 ` Andrew Lunn
2023-01-30 7:30 ` patchwork-bot+netdevbpf
2023-01-31 15:38 ` Marc Kleine-Budde
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2023-01-26 22:10 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Wei Fang, Jakub Kicinski, Arnd Bergmann, Shenwei Wang,
Clark Wang, NXP Linux Team, David S. Miller, Eric Dumazet,
Paolo Abeni, netdev, linux-kernel
On Thu, Jan 26, 2023 at 10:05:59PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The driver can be trivially converted, as it only triggers the gpio
> pin briefly to do a reset, and it already only supports DT.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [v2] fec: convert to gpio descriptor
2023-01-26 21:05 [PATCH] [v2] fec: convert to gpio descriptor Arnd Bergmann
2023-01-26 22:10 ` Andrew Lunn
@ 2023-01-30 7:30 ` patchwork-bot+netdevbpf
2023-01-31 15:38 ` Marc Kleine-Budde
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-30 7:30 UTC (permalink / raw)
To: Arnd Bergmann
Cc: wei.fang, kuba, arnd, shenwei.wang, xiaoning.wang, linux-imx,
davem, edumazet, pabeni, andrew, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Thu, 26 Jan 2023 22:05:59 +0100 you wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The driver can be trivially converted, as it only triggers the gpio
> pin briefly to do a reset, and it already only supports DT.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> [...]
Here is the summary with links:
- [v2] fec: convert to gpio descriptor
https://git.kernel.org/netdev/net-next/c/468ba54bd616
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [v2] fec: convert to gpio descriptor
2023-01-26 21:05 [PATCH] [v2] fec: convert to gpio descriptor Arnd Bergmann
2023-01-26 22:10 ` Andrew Lunn
2023-01-30 7:30 ` patchwork-bot+netdevbpf
@ 2023-01-31 15:38 ` Marc Kleine-Budde
2023-01-31 17:25 ` Andrew Lunn
2 siblings, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2023-01-31 15:38 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Wei Fang, Jakub Kicinski, Arnd Bergmann, Shenwei Wang,
Clark Wang, NXP Linux Team, David S. Miller, Eric Dumazet,
Paolo Abeni, Andrew Lunn, netdev, linux-kernel, ore, kernel
[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]
On 26.01.2023 22:05:59, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The driver can be trivially converted, as it only triggers the gpio
> pin briefly to do a reset, and it already only supports DT.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
On current net-next/main 6a8ab436831d ("Merge branch
'add-support-for-the-the-vsc7512-internal-copper-phys'") this causes the
riot board (arch/arm/boot/dts/imx6dl-riotboard.dts) to not probe the
fec:
| Jan 31 16:32:12 riot kernel: fec 2188000.ethernet: error -ENOENT: failed to get phy-reset-gpios
| Jan 31 16:32:12 riot kernel: fec: probe of 2188000.ethernet failed with error -2
reverting 468ba54bd616 ("fec: convert to gpio descriptor") solves the
problem.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [v2] fec: convert to gpio descriptor
2023-01-31 15:38 ` Marc Kleine-Budde
@ 2023-01-31 17:25 ` Andrew Lunn
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2023-01-31 17:25 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Arnd Bergmann, Wei Fang, Jakub Kicinski, Arnd Bergmann,
Shenwei Wang, Clark Wang, NXP Linux Team, David S. Miller,
Eric Dumazet, Paolo Abeni, netdev, linux-kernel, ore, kernel
On Tue, Jan 31, 2023 at 04:38:51PM +0100, Marc Kleine-Budde wrote:
> On 26.01.2023 22:05:59, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > The driver can be trivially converted, as it only triggers the gpio
> > pin briefly to do a reset, and it already only supports DT.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> On current net-next/main 6a8ab436831d ("Merge branch
> 'add-support-for-the-the-vsc7512-internal-copper-phys'") this causes the
> riot board (arch/arm/boot/dts/imx6dl-riotboard.dts) to not probe the
> fec:
>
> | Jan 31 16:32:12 riot kernel: fec 2188000.ethernet: error -ENOENT: failed to get phy-reset-gpios
> | Jan 31 16:32:12 riot kernel: fec: probe of 2188000.ethernet failed with error -2
Hi Marc
Could you try swapping the devm_gpiod_get() for
devm_gpiod_get_optional().
It is kind of hidden, but:
- else if (!gpio_is_valid(phy_reset))
- return 0;
made the GPIO optional, since -2 is not a valid GPIO number and so it
would silently return.
The real fix will need to be a bit more complex, since we don't want
to do the sleeps etc if the GPIO is not present.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-31 17:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26 21:05 [PATCH] [v2] fec: convert to gpio descriptor Arnd Bergmann
2023-01-26 22:10 ` Andrew Lunn
2023-01-30 7:30 ` patchwork-bot+netdevbpf
2023-01-31 15:38 ` Marc Kleine-Budde
2023-01-31 17:25 ` Andrew Lunn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.