diff mbox series

[net-next,2/3] net: phy: add new version of phy_do_ioctl

Message ID 9ed8f7eb-c2b7-ae14-c3b3-83b0aee655c4@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series net: phy: add new version of phy_do_ioctl and convert suitable drivers | expand

Commit Message

Heiner Kallweit Jan. 20, 2020, 9:17 p.m. UTC
Add a new version of phy_do_ioctl that doesn't check whether net_device
is running. It will typically be used if suitable drivers attach the
PHY in probe already.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy.c | 16 +++++++++++++---
 include/linux/phy.h   |  1 +
 2 files changed, 14 insertions(+), 3 deletions(-)

Comments

Florian Fainelli Jan. 20, 2020, 10:04 p.m. UTC | #1
On 1/20/20 1:17 PM, Heiner Kallweit wrote:
> Add a new version of phy_do_ioctl that doesn't check whether net_device
> is running. It will typically be used if suitable drivers attach the
> PHY in probe already.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Andrew Lunn Jan. 20, 2020, 10:17 p.m. UTC | #2
On Mon, Jan 20, 2020 at 10:17:11PM +0100, Heiner Kallweit wrote:
> Add a new version of phy_do_ioctl that doesn't check whether net_device
> is running. It will typically be used if suitable drivers attach the
> PHY in probe already.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

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

    Andrew
diff mbox series

Patch

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index cf25fa3be..d76e038cf 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -433,18 +433,28 @@  int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
 EXPORT_SYMBOL(phy_mii_ioctl);
 
 /**
- * phy_do_ioctl_running - generic ndo_do_ioctl implementation
+ * phy_do_ioctl - generic ndo_do_ioctl implementation
  * @dev: the net_device struct
  * @ifr: &struct ifreq for socket ioctl's
  * @cmd: ioctl cmd to execute
  */
-int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
+int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-	if (!netif_running(dev) || !dev->phydev)
+	if (!dev->phydev)
 		return -ENODEV;
 
 	return phy_mii_ioctl(dev->phydev, ifr, cmd);
 }
+EXPORT_SYMBOL(phy_do_ioctl);
+
+/* same as phy_do_ioctl, but ensures that net_device is running */
+int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+	if (!netif_running(dev))
+		return -ENODEV;
+
+	return phy_do_ioctl(dev, ifr, cmd);
+}
 EXPORT_SYMBOL(phy_do_ioctl_running);
 
 void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 28e8d8102..3629f1369 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1231,6 +1231,7 @@  void phy_ethtool_ksettings_get(struct phy_device *phydev,
 int phy_ethtool_ksettings_set(struct phy_device *phydev,
 			      const struct ethtool_link_ksettings *cmd);
 int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd);
+int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
 int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd);
 void phy_request_interrupt(struct phy_device *phydev);
 void phy_free_interrupt(struct phy_device *phydev);