Skip to content

Commit 32cba57

Browse files
lynxeye-devdavem330
authored andcommitted
net: fec: introduce fec_ptp_stop and use in probe fail path
This function frees resources and cancels delayed work item that have been initialized in fec_ptp_init(). Use this to do proper error handling if something goes wrong in probe function after fec_ptp_init has been called. Signed-off-by: Lucas Stach <[email protected]> Acked-by: Fugang Duan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c0a1a0a commit 32cba57

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

drivers/net/ethernet/freescale/fec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ struct fec_enet_private {
562562
};
563563

564564
void fec_ptp_init(struct platform_device *pdev);
565+
void fec_ptp_stop(struct platform_device *pdev);
565566
void fec_ptp_start_cyclecounter(struct net_device *ndev);
566567
int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr);
567568
int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr);

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,6 +3454,7 @@ fec_probe(struct platform_device *pdev)
34543454
failed_mii_init:
34553455
failed_irq:
34563456
failed_init:
3457+
fec_ptp_stop(pdev);
34573458
if (fep->reg_phy)
34583459
regulator_disable(fep->reg_phy);
34593460
failed_regulator:
@@ -3473,14 +3474,12 @@ fec_drv_remove(struct platform_device *pdev)
34733474
struct net_device *ndev = platform_get_drvdata(pdev);
34743475
struct fec_enet_private *fep = netdev_priv(ndev);
34753476

3476-
cancel_delayed_work_sync(&fep->time_keep);
34773477
cancel_work_sync(&fep->tx_timeout_work);
3478+
fec_ptp_stop(pdev);
34783479
unregister_netdev(ndev);
34793480
fec_enet_mii_remove(fep);
34803481
if (fep->reg_phy)
34813482
regulator_disable(fep->reg_phy);
3482-
if (fep->ptp_clock)
3483-
ptp_clock_unregister(fep->ptp_clock);
34843483
of_node_put(fep->phy_node);
34853484
free_netdev(ndev);
34863485

drivers/net/ethernet/freescale/fec_ptp.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,16 @@ void fec_ptp_init(struct platform_device *pdev)
604604
schedule_delayed_work(&fep->time_keep, HZ);
605605
}
606606

607+
void fec_ptp_stop(struct platform_device *pdev)
608+
{
609+
struct net_device *ndev = platform_get_drvdata(pdev);
610+
struct fec_enet_private *fep = netdev_priv(ndev);
611+
612+
cancel_delayed_work_sync(&fep->time_keep);
613+
if (fep->ptp_clock)
614+
ptp_clock_unregister(fep->ptp_clock);
615+
}
616+
607617
/**
608618
* fec_ptp_check_pps_event
609619
* @fep: the fec_enet_private structure handle

0 commit comments

Comments
 (0)