Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756009AbdGLETv (ORCPT ); Wed, 12 Jul 2017 00:19:51 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34517 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751482AbdGLETu (ORCPT ); Wed, 12 Jul 2017 00:19:50 -0400 Subject: Re: [PATCH net-next 2/4] net-next: mediatek: add platform data to adapt into various hardware To: sean.wang@mediatek.com, john@phrozen.org, davem@davemloft.net Cc: nbd@openwrt.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org References: <401e9fa04ea4759c936fa5af11bb2b5c97ef14f0.1499829241.git.sean.wang@mediatek.com> From: Florian Fainelli Message-ID: <2ab410a6-bf08-79bc-28ca-e05eb8b67cf5@gmail.com> Date: Tue, 11 Jul 2017 21:19:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <401e9fa04ea4759c936fa5af11bb2b5c97ef14f0.1499829241.git.sean.wang@mediatek.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1468 Lines: 54 On 07/11/2017 08:37 PM, sean.wang@mediatek.com wrote: > From: Sean Wang > > This patch is the preparation patch in order to adapt into various > hardware through adding platform data which holds specific characteristics > among MediaTek SoCs and introducing the unified clock handler for those > distinct clock requirements depending on different features such as > TRGMII and SGMII getting support on the target SoC. And finally, add > enhancement with given the generic description for Kconfig and remove the > unnecessary machine type dependency in Makefile. > > Signed-off-by: Sean Wang > --- > if (dev->phydev->link) > @@ -1837,6 +1838,39 @@ static void ethsys_reset(struct mtk_eth *eth, u32 reset_bits) > mdelay(10); > } > > +static void mtk_clk_disable(struct mtk_eth *eth) > +{ > + int clk; > + > + for (clk = MTK_CLK_MAX - 1; clk >= 0; clk--) { > + if (eth->clks[clk]) > + clk_disable_unprepare(eth->clks[clk]); > + } The clock framework works just fine with NULL clk references, no need to check that. > +} There are now (or will be soon in clk-next) bulk accessors that you may consider using for this. > + > +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; > + } > + } Same here. -- Florian