Skip to content

Commit de9c785

Browse files
zonquedavem330
authored andcommitted
net: axienet: allow setups without MDIO
In setups with fixed-link settings there is no mdio node in DTS. axienet_probe() already handles that gracefully but lp->mii_bus is then NULL. Fix code that tries to blindly grab the MDIO lock by introducing two helper functions that make the locking conditional. Signed-off-by: Daniel Mack <[email protected]> Reviewed-by: Radhey Shyam Pandey <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 479dc49 commit de9c785

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

drivers/net/ethernet/xilinx/xilinx_axienet.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,18 @@ static inline u32 axinet_ior_read_mcr(struct axienet_local *lp)
504504
return axienet_ior(lp, XAE_MDIO_MCR_OFFSET);
505505
}
506506

507+
static inline void axienet_lock_mii(struct axienet_local *lp)
508+
{
509+
if (lp->mii_bus)
510+
mutex_lock(&lp->mii_bus->mdio_lock);
511+
}
512+
513+
static inline void axienet_unlock_mii(struct axienet_local *lp)
514+
{
515+
if (lp->mii_bus)
516+
mutex_unlock(&lp->mii_bus->mdio_lock);
517+
}
518+
507519
/**
508520
* axienet_iow - Memory mapped Axi Ethernet register write
509521
* @lp: Pointer to axienet local structure

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,9 +1053,9 @@ static int axienet_open(struct net_device *ndev)
10531053
* including the MDIO. MDIO must be disabled before resetting.
10541054
* Hold MDIO bus lock to avoid MDIO accesses during the reset.
10551055
*/
1056-
mutex_lock(&lp->mii_bus->mdio_lock);
1056+
axienet_lock_mii(lp);
10571057
ret = axienet_device_reset(ndev);
1058-
mutex_unlock(&lp->mii_bus->mdio_lock);
1058+
axienet_unlock_mii(lp);
10591059

10601060
ret = phylink_of_phy_connect(lp->phylink, lp->dev->of_node, 0);
10611061
if (ret) {
@@ -1148,9 +1148,9 @@ static int axienet_stop(struct net_device *ndev)
11481148
}
11491149

11501150
/* Do a reset to ensure DMA is really stopped */
1151-
mutex_lock(&lp->mii_bus->mdio_lock);
1151+
axienet_lock_mii(lp);
11521152
__axienet_device_reset(lp);
1153-
mutex_unlock(&lp->mii_bus->mdio_lock);
1153+
axienet_unlock_mii(lp);
11541154

11551155
cancel_work_sync(&lp->dma_err_task);
11561156

@@ -1709,9 +1709,9 @@ static void axienet_dma_err_handler(struct work_struct *work)
17091709
* including the MDIO. MDIO must be disabled before resetting.
17101710
* Hold MDIO bus lock to avoid MDIO accesses during the reset.
17111711
*/
1712-
mutex_lock(&lp->mii_bus->mdio_lock);
1712+
axienet_lock_mii(lp);
17131713
__axienet_device_reset(lp);
1714-
mutex_unlock(&lp->mii_bus->mdio_lock);
1714+
axienet_unlock_mii(lp);
17151715

17161716
for (i = 0; i < lp->tx_bd_num; i++) {
17171717
cur_p = &lp->tx_bd_v[i];

0 commit comments

Comments
 (0)