From patchwork Mon Mar 18 08:26:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 2286051 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id CD89CDF215 for ; Mon, 18 Mar 2013 08:29:38 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UHVOv-0007wP-D2; Mon, 18 Mar 2013 08:26:37 +0000 Received: from co9ehsobe004.messaging.microsoft.com ([207.46.163.27] helo=co9outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UHVOs-0007vo-TK for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2013 08:26:35 +0000 Received: from mail148-co9-R.bigfish.com (10.236.132.231) by CO9EHSOBE023.bigfish.com (10.236.130.86) with Microsoft SMTP Server id 14.1.225.23; Mon, 18 Mar 2013 08:26:32 +0000 Received: from mail148-co9 (localhost [127.0.0.1]) by mail148-co9-R.bigfish.com (Postfix) with ESMTP id 862EC8800DF; Mon, 18 Mar 2013 08:26:32 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h1ee6h1de0h1202h1e76h1d1ah1d2ahzz8275dhz2dh87h2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail148-co9 (localhost.localdomain [127.0.0.1]) by mail148-co9 (MessageSwitch) id 1363595189851055_8677; Mon, 18 Mar 2013 08:26:29 +0000 (UTC) Received: from CO9EHSMHS003.bigfish.com (unknown [10.236.132.234]) by mail148-co9.bigfish.com (Postfix) with ESMTP id CCD00580076; Mon, 18 Mar 2013 08:26:29 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS003.bigfish.com (10.236.130.13) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 18 Mar 2013 08:26:29 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.2.328.11; Mon, 18 Mar 2013 08:26:28 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.135]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r2I8QJBA028538; Mon, 18 Mar 2013 01:26:26 -0700 From: Shawn Guo To: Subject: [PATCH v2 1/4] net: fec: handle optional clk_ptp more gracefully Date: Mon, 18 Mar 2013 16:26:22 +0800 Message-ID: <1363595185-12302-2-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1363595185-12302-1-git-send-email-shawn.guo@linaro.org> References: <1363595185-12302-1-git-send-email-shawn.guo@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130318_042635_089830_44CD80A1 X-CRM114-Status: GOOD ( 10.84 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [207.46.163.27 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: netdev@vger.kernel.org, Shawn Guo , "David S. Miller" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When the optional clk_ptp is absent, we can just set it to NULL, and clk API will just handle it gracefully. It saves us from checking clk_ptp whenever calling into clk API. Also since clk_ptp is optional, the "ret" variable shouldn't be set in case that the clock is absent. Signed-off-by: Shawn Guo --- drivers/net/ethernet/freescale/fec.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c index fccc3bf..d2a9851 100644 --- a/drivers/net/ethernet/freescale/fec.c +++ b/drivers/net/ethernet/freescale/fec.c @@ -1804,14 +1804,13 @@ fec_probe(struct platform_device *pdev) fep->bufdesc_ex = pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX; if (IS_ERR(fep->clk_ptp)) { - ret = PTR_ERR(fep->clk_ptp); + fep->clk_ptp = NULL; fep->bufdesc_ex = 0; } clk_prepare_enable(fep->clk_ahb); clk_prepare_enable(fep->clk_ipg); - if (!IS_ERR(fep->clk_ptp)) - clk_prepare_enable(fep->clk_ptp); + clk_prepare_enable(fep->clk_ptp); reg_phy = devm_regulator_get(&pdev->dev, "phy"); if (!IS_ERR(reg_phy)) { @@ -1876,8 +1875,7 @@ failed_irq: failed_regulator: clk_disable_unprepare(fep->clk_ahb); clk_disable_unprepare(fep->clk_ipg); - if (!IS_ERR(fep->clk_ptp)) - clk_disable_unprepare(fep->clk_ptp); + clk_disable_unprepare(fep->clk_ptp); failed_pin: failed_clk: iounmap(fep->hwp);