Commit 0bd199fd authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by Paolo Abeni

net: phy: constify phydev->drv

Device driver structures are shared between all devices that they
match, and thus nothing should never write to the device driver
structure through the phydev->drv pointer. Let's make this pointer
const to catch code that attempts to do so.
Suggested-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/E1rVxXt-002YqY-9G@rmk-PC.armlinux.org.ukSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 03ba6dc0
...@@ -1290,7 +1290,6 @@ int phy_disable_interrupts(struct phy_device *phydev) ...@@ -1290,7 +1290,6 @@ int phy_disable_interrupts(struct phy_device *phydev)
static irqreturn_t phy_interrupt(int irq, void *phy_dat) static irqreturn_t phy_interrupt(int irq, void *phy_dat)
{ {
struct phy_device *phydev = phy_dat; struct phy_device *phydev = phy_dat;
struct phy_driver *drv = phydev->drv;
irqreturn_t ret; irqreturn_t ret;
/* Wakeup interrupts may occur during a system sleep transition. /* Wakeup interrupts may occur during a system sleep transition.
...@@ -1316,7 +1315,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) ...@@ -1316,7 +1315,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
} }
mutex_lock(&phydev->lock); mutex_lock(&phydev->lock);
ret = drv->handle_interrupt(phydev); ret = phydev->drv->handle_interrupt(phydev);
mutex_unlock(&phydev->lock); mutex_unlock(&phydev->lock);
return ret; return ret;
......
...@@ -1413,7 +1413,7 @@ int phy_sfp_probe(struct phy_device *phydev, ...@@ -1413,7 +1413,7 @@ int phy_sfp_probe(struct phy_device *phydev,
} }
EXPORT_SYMBOL(phy_sfp_probe); EXPORT_SYMBOL(phy_sfp_probe);
static bool phy_drv_supports_irq(struct phy_driver *phydrv) static bool phy_drv_supports_irq(const struct phy_driver *phydrv)
{ {
return phydrv->config_intr && phydrv->handle_interrupt; return phydrv->config_intr && phydrv->handle_interrupt;
} }
...@@ -1867,7 +1867,7 @@ int phy_suspend(struct phy_device *phydev) ...@@ -1867,7 +1867,7 @@ int phy_suspend(struct phy_device *phydev)
{ {
struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
struct net_device *netdev = phydev->attached_dev; struct net_device *netdev = phydev->attached_dev;
struct phy_driver *phydrv = phydev->drv; const struct phy_driver *phydrv = phydev->drv;
int ret; int ret;
if (phydev->suspended) if (phydev->suspended)
...@@ -1892,7 +1892,7 @@ EXPORT_SYMBOL(phy_suspend); ...@@ -1892,7 +1892,7 @@ EXPORT_SYMBOL(phy_suspend);
int __phy_resume(struct phy_device *phydev) int __phy_resume(struct phy_device *phydev)
{ {
struct phy_driver *phydrv = phydev->drv; const struct phy_driver *phydrv = phydev->drv;
int ret; int ret;
lockdep_assert_held(&phydev->lock); lockdep_assert_held(&phydev->lock);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
struct gmii2rgmii { struct gmii2rgmii {
struct phy_device *phy_dev; struct phy_device *phy_dev;
struct phy_driver *phy_drv; const struct phy_driver *phy_drv;
struct phy_driver conv_phy_drv; struct phy_driver conv_phy_drv;
struct mdio_device *mdio; struct mdio_device *mdio;
}; };
......
...@@ -638,7 +638,7 @@ struct phy_device { ...@@ -638,7 +638,7 @@ struct phy_device {
/* Information about the PHY type */ /* Information about the PHY type */
/* And management functions */ /* And management functions */
struct phy_driver *drv; const struct phy_driver *drv;
struct device_link *devlink; struct device_link *devlink;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment