[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN3PR0301MB1219B4C39D2D9202A5C96349F50F0@BN3PR0301MB1219.namprd03.prod.outlook.com>
Date: Tue, 1 Dec 2015 02:04:39 +0000
From: Duan Andy <fugang.duan@...escale.com>
To: Lothar Waßmann <LW@...O-electronics.de>,
Andrew Lunn <andrew@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Fabio Estevam <Fabio.Estevam@...escale.com>,
Greg Ungerer <gerg@...inux.org>,
Kevin Hao <haokexin@...il.com>,
Lucas Stach <l.stach@...gutronix.de>,
Philippe Reynes <tremyfr@...il.com>,
Richard Cochran <richardcochran@...il.com>,
Russell King <rmk+kernel@....linux.org.uk>,
Sascha Hauer <s.hauer@...gutronix.de>,
"Stefan Agner" <stefan@...er.ch>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Jeff Kirsher <jeffrey.t.kirsher@...el.com>,
"Uwe Kleine-K?nig" <u.kleine-koenig@...gutronix.de>
Subject: RE: [PATCH 1/3] net: fec: Remove redundant checks for NULL clk
pointer
From: Lothar Waßmann <LW@...O-electronics.de> Sent: Monday, November 30, 2015 7:33 PM
> To: Andrew Lunn; David S. Miller; Estevam Fabio-R49496; Greg Ungerer;
> Kevin Hao; Lothar Waßmann; Lucas Stach; Duan Fugang-B38611; Philippe
> Reynes; Richard Cochran; Russell King; Sascha Hauer; Stefan Agner; linux-
> kernel@...r.kernel.org; netdev@...r.kernel.org; Jeff Kirsher; Uwe Kleine-
> König
> Subject: [PATCH 1/3] net: fec: Remove redundant checks for NULL clk
> pointer
>
> NULL is a valid argument to clk_enable()/clk_disable(). Remove redundant
> checks before calling those functions.
>
> Signed-off-by: Lothar Waßmann <LW@...O-electronics.de>
> ---
> drivers/net/ethernet/freescale/fec_main.c | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index d2328fc..e17d74f 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1873,35 +1873,30 @@ static int fec_enet_clk_enable(struct net_device
> *ndev, bool enable)
> }
> mutex_unlock(&fep->ptp_clk_mutex);
> }
> - if (fep->clk_ref) {
> - ret = clk_prepare_enable(fep->clk_ref);
> - if (ret)
> - goto failed_clk_ref;
> - }
> +
> + ret = clk_prepare_enable(fep->clk_ref);
> + if (ret)
> + goto failed_clk_ref;
If you want to clean up the code, pls also remove "fep->clk_enet_out" check in this brace.
> } else {
> clk_disable_unprepare(fep->clk_ahb);
> - if (fep->clk_enet_out)
> - clk_disable_unprepare(fep->clk_enet_out);
> + clk_disable_unprepare(fep->clk_enet_out);
> if (fep->clk_ptp) {
> mutex_lock(&fep->ptp_clk_mutex);
> clk_disable_unprepare(fep->clk_ptp);
> fep->ptp_clk_on = false;
> mutex_unlock(&fep->ptp_clk_mutex);
> }
> - if (fep->clk_ref)
> - clk_disable_unprepare(fep->clk_ref);
> + clk_disable_unprepare(fep->clk_ref);
> }
>
> return 0;
>
> failed_clk_ref:
> - if (fep->clk_ref)
> - clk_disable_unprepare(fep->clk_ref);
> + clk_disable_unprepare(fep->clk_ref);
> failed_clk_ptp:
> - if (fep->clk_enet_out)
> - clk_disable_unprepare(fep->clk_enet_out);
> + clk_disable_unprepare(fep->clk_enet_out);
> failed_clk_enet_out:
> - clk_disable_unprepare(fep->clk_ahb);
> + clk_disable_unprepare(fep->clk_ahb);
>
> return ret;
> }
> --
> 2.1.4
Powered by blists - more mailing lists