Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755562AbbLACEn (ORCPT ); Mon, 30 Nov 2015 21:04:43 -0500 Received: from mail-by2on0105.outbound.protection.outlook.com ([207.46.100.105]:25583 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755517AbbLACEl (ORCPT ); Mon, 30 Nov 2015 21:04:41 -0500 From: Duan Andy To: =?utf-8?B?TG90aGFyIFdhw59tYW5u?= , Andrew Lunn , "David S. Miller" , Fabio Estevam , Greg Ungerer , Kevin Hao , Lucas Stach , Philippe Reynes , Richard Cochran , Russell King , Sascha Hauer , "Stefan Agner" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , Jeff Kirsher , "Uwe Kleine-K?nig" Subject: RE: [PATCH 1/3] net: fec: Remove redundant checks for NULL clk pointer Thread-Topic: [PATCH 1/3] net: fec: Remove redundant checks for NULL clk pointer Thread-Index: AQHRK2LolxcKij+aUEaoy3quCpVc4Z61YfzA Date: Tue, 1 Dec 2015 02:04:39 +0000 Message-ID: References: <1448883168-30742-1-git-send-email-LW@KARO-electronics.de> <1448883168-30742-2-git-send-email-LW@KARO-electronics.de> In-Reply-To: <1448883168-30742-2-git-send-email-LW@KARO-electronics.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=fugang.duan@freescale.com; x-originating-ip: [123.151.195.51] x-microsoft-exchange-diagnostics: 1;BY1PR03MB1433;5:5ABRiAy7RAF/wi/WIUbt3NIvLy2kqNNn8pCyuRXlT3JpSqDVObo7aHp127P2eWRqep9cP9HZX0fGayGQO8EAq7RDNKCcBvDKNb+o9I6YgnSPzEy7xKXOSyubrS3AO2ma1Nkc+DkmfhyN16hC5t2Uqg==;24:+kJh2hiroRHg7sH25g17eM99rWBW0gdUEMlXSztQ/j36Un+wY6WiPCaK1AQoTk8/fIR97W2hzZTCE7Ou/8xkcfla43cJSezpOu27V7XJ0PI= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1433; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(3002001)(10201501046);SRVR:BY1PR03MB1433;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1433; x-forefront-prvs: 07778E4001 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(377454003)(189002)(2950100001)(105586002)(11100500001)(40100003)(76576001)(102836003)(189998001)(3846002)(5003600100002)(5008740100001)(10400500002)(54356999)(6116002)(92566002)(33656002)(76176999)(5004730100002)(107886002)(97736004)(2501003)(586003)(5001960100002)(1220700001)(81156007)(106116001)(101416001)(19580395003)(2900100001)(1096002)(74316001)(5002640100001)(87936001)(106356001)(99286002)(50986999)(122556002)(5001770100001)(86362001)(77096005)(19580405001)(2201001)(66066001)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR03MB1433;H:BN3PR0301MB1219.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Dec 2015 02:04:39.1796 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1433 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id tB124mWi024281 Content-Length: 2545 Lines: 75 From: Lothar Waßmann 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@vger.kernel.org; netdev@vger.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 > --- > 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 ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?