[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BLUPR03MB373972BFA572EE213A62B83F5830@BLUPR03MB373.namprd03.prod.outlook.com>
Date: Wed, 22 Jul 2015 01:58:43 +0000
From: Duan Andy <fugang.duan@...escale.com>
To: Lucas Stach <l.stach@...gutronix.de>,
"David S. Miller" <davem@...emloft.net>
CC: Li Frank <Frank.Li@...escale.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"kernel@...gutronix.de" <kernel@...gutronix.de>,
"patchwork-lst@...gutronix.de" <patchwork-lst@...gutronix.de>
Subject: RE: [PATCH v2 2/2] net: fec: introduce fec_ptp_stop and use in probe
fail path
From: Lucas Stach <l.stach@...gutronix.de> Sent: Tuesday, July 21, 2015 11:11 PM
> To: David S. Miller
> Cc: Duan Fugang-B38611; Li Frank-B20596; netdev@...r.kernel.org;
> kernel@...gutronix.de; patchwork-lst@...gutronix.de
> Subject: [PATCH v2 2/2] 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 <l.stach@...gutronix.de>
> ---
> drivers/net/ethernet/freescale/fec.h | 1 +
> drivers/net/ethernet/freescale/fec_main.c | 5 ++---
> drivers/net/ethernet/freescale/fec_ptp.c | 10 ++++++++++
> 3 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec.h
> b/drivers/net/ethernet/freescale/fec.h
> index 1eee73cccdf5..99d33e2d35e6 100644
> --- a/drivers/net/ethernet/freescale/fec.h
> +++ b/drivers/net/ethernet/freescale/fec.h
> @@ -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); diff --git
> a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index a7f1bdf718f8..32e3807c650e 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -3494,6 +3494,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:
> @@ -3515,14 +3516,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);
>
> diff --git a/drivers/net/ethernet/freescale/fec_ptp.c
> b/drivers/net/ethernet/freescale/fec_ptp.c
> index a15663ad7f5e..f457a23d0bfb 100644
> --- a/drivers/net/ethernet/freescale/fec_ptp.c
> +++ b/drivers/net/ethernet/freescale/fec_ptp.c
> @@ -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
> --
> 2.1.4
Acked-by: Fugang Duan <B38611@...escale.com>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists