Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752883AbdGLOvE (ORCPT ); Wed, 12 Jul 2017 10:51:04 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:52083 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750899AbdGLOvC (ORCPT ); Wed, 12 Jul 2017 10:51:02 -0400 Date: Wed, 12 Jul 2017 16:50:50 +0200 From: Andrew Lunn To: sean.wang@mediatek.com Cc: john@phrozen.org, davem@davemloft.net, nbd@openwrt.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH net-next 2/4] net-next: mediatek: add platform data to adapt into various hardware Message-ID: <20170712145050.GD2557@lunn.ch> References: <401e9fa04ea4759c936fa5af11bb2b5c97ef14f0.1499829241.git.sean.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <401e9fa04ea4759c936fa5af11bb2b5c97ef14f0.1499829241.git.sean.wang@mediatek.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 994 Lines: 42 > +static int mtk_clk_enable(struct mtk_eth *eth) > +{ > + int clk, ret; > + > + for (clk = 0; clk < MTK_CLK_MAX ; clk++) { > + if (eth->clks[clk]) { > + ret = clk_prepare_enable(eth->clks[clk]); > + if (ret) > + goto err_disable_clks; > + } > + } > + > + return 0; > + > +err_disable_clks: > + while (--clk >= 0) { > + if (eth->clks[clk]) > + clk_disable_unprepare(eth->clks[clk]); > + } > + > + return ret; > +} > + > static int mtk_hw_init(struct mtk_eth *eth) > { > int i, val; > @@ -1847,10 +1881,8 @@ static int mtk_hw_init(struct mtk_eth *eth) > pm_runtime_enable(eth->dev); > pm_runtime_get_sync(eth->dev); > > - clk_prepare_enable(eth->clks[MTK_CLK_ETHIF]); > - clk_prepare_enable(eth->clks[MTK_CLK_ESW]); > - clk_prepare_enable(eth->clks[MTK_CLK_GP1]); > - clk_prepare_enable(eth->clks[MTK_CLK_GP2]); > + mtk_clk_enable(eth); > + mtk_clk_enable() returns an error code. It is probably a good idea to use it, especially if it could be EPRODE_DEFER. Andrew