netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] enetc: add ioctl() support for PHY-related ops
@ 2019-11-07  8:39 Michael Walle
  2019-11-07 15:25 ` Andrew Lunn
  2019-11-07 23:25 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Walle @ 2019-11-07  8:39 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: Claudiu Manoil, David S . Miller, Michael Walle

If there is an attached PHY try to handle the requested ioctl with its
handler, which allows the userspace to access PHY registers, for
example. This will make mii-diag and similar tools work.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/net/ethernet/freescale/enetc/enetc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index b6ff89307409..25af207f1962 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -1599,7 +1599,10 @@ int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
 	if (cmd == SIOCGHWTSTAMP)
 		return enetc_hwtstamp_get(ndev, rq);
 #endif
-	return -EINVAL;
+
+	if (!ndev->phydev)
+		return -EINVAL;
+	return phy_mii_ioctl(ndev->phydev, rq, cmd);
 }
 
 int enetc_alloc_msix(struct enetc_ndev_priv *priv)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] enetc: add ioctl() support for PHY-related ops
  2019-11-07  8:39 [PATCH] enetc: add ioctl() support for PHY-related ops Michael Walle
@ 2019-11-07 15:25 ` Andrew Lunn
  2019-11-07 23:25 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2019-11-07 15:25 UTC (permalink / raw)
  To: Michael Walle; +Cc: linux-kernel, netdev, Claudiu Manoil, David S . Miller

On Thu, Nov 07, 2019 at 09:39:37AM +0100, Michael Walle wrote:
> If there is an attached PHY try to handle the requested ioctl with its
> handler, which allows the userspace to access PHY registers, for
> example. This will make mii-diag and similar tools work.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
>  drivers/net/ethernet/freescale/enetc/enetc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index b6ff89307409..25af207f1962 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -1599,7 +1599,10 @@ int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
>  	if (cmd == SIOCGHWTSTAMP)
>  		return enetc_hwtstamp_get(ndev, rq);
>  #endif
> -	return -EINVAL;
> +
> +	if (!ndev->phydev)
> +		return -EINVAL;

Hi Michael

I think EOPNOTSUPP is normal. Yes, you are just moving around what was
there before, but you could make this improvement as well.

If you don't want to:

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] enetc: add ioctl() support for PHY-related ops
  2019-11-07  8:39 [PATCH] enetc: add ioctl() support for PHY-related ops Michael Walle
  2019-11-07 15:25 ` Andrew Lunn
@ 2019-11-07 23:25 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-11-07 23:25 UTC (permalink / raw)
  To: michael; +Cc: linux-kernel, netdev, claudiu.manoil

From: Michael Walle <michael@walle.cc>
Date: Thu,  7 Nov 2019 09:39:37 +0100

> If there is an attached PHY try to handle the requested ioctl with its
> handler, which allows the userspace to access PHY registers, for
> example. This will make mii-diag and similar tools work.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-07 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07  8:39 [PATCH] enetc: add ioctl() support for PHY-related ops Michael Walle
2019-11-07 15:25 ` Andrew Lunn
2019-11-07 23:25 ` David Miller

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).