Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32cba57b authored by Lucas Stach's avatar Lucas Stach Committed by David S. Miller
Browse files

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: default avatarLucas Stach <l.stach@pengutronix.de>
Acked-by: default avatarFugang Duan <B38611@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c0a1a0a6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -562,6 +562,7 @@ struct fec_enet_private {
};

void fec_ptp_init(struct platform_device *pdev);
void fec_ptp_stop(struct platform_device *pdev);
void fec_ptp_start_cyclecounter(struct net_device *ndev);
int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr);
int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr);
+2 −3
Original line number Diff line number Diff line
@@ -3454,6 +3454,7 @@ failed_register:
failed_mii_init:
failed_irq:
failed_init:
	fec_ptp_stop(pdev);
	if (fep->reg_phy)
		regulator_disable(fep->reg_phy);
failed_regulator:
@@ -3473,14 +3474,12 @@ fec_drv_remove(struct platform_device *pdev)
	struct net_device *ndev = platform_get_drvdata(pdev);
	struct fec_enet_private *fep = netdev_priv(ndev);

	cancel_delayed_work_sync(&fep->time_keep);
	cancel_work_sync(&fep->tx_timeout_work);
	fec_ptp_stop(pdev);
	unregister_netdev(ndev);
	fec_enet_mii_remove(fep);
	if (fep->reg_phy)
		regulator_disable(fep->reg_phy);
	if (fep->ptp_clock)
		ptp_clock_unregister(fep->ptp_clock);
	of_node_put(fep->phy_node);
	free_netdev(ndev);

+10 −0
Original line number Diff line number Diff line
@@ -604,6 +604,16 @@ void fec_ptp_init(struct platform_device *pdev)
	schedule_delayed_work(&fep->time_keep, HZ);
}

void fec_ptp_stop(struct platform_device *pdev)
{
	struct net_device *ndev = platform_get_drvdata(pdev);
	struct fec_enet_private *fep = netdev_priv(ndev);

	cancel_delayed_work_sync(&fep->time_keep);
	if (fep->ptp_clock)
		ptp_clock_unregister(fep->ptp_clock);
}

/**
 * fec_ptp_check_pps_event
 * @fep: the fec_enet_private structure handle