Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754813AbcJUI2n (ORCPT ); Fri, 21 Oct 2016 04:28:43 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:36236 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753446AbcJUI2d (ORCPT ); Fri, 21 Oct 2016 04:28:33 -0400 Subject: Re: [RFC PATCH] net: stmmac: Add OXNAS Glue Driver To: Joachim Eastwood References: <20161020155406.27172-1-narmstrong@baylibre.com> Cc: "peppe.cavallaro" , alexandre.torgue@st.com, devicetree , netdev , "linux-kernel@vger.kernel.org" , linux-oxnas@lists.tuxfamily.org, "linux-arm-kernel@lists.infradead.org" From: Neil Armstrong Organization: Baylibre Message-ID: <872a84c9-6ec3-695b-0c37-c58719e0a034@baylibre.com> Date: Fri, 21 Oct 2016 10:28:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2750 Lines: 79 On 10/20/2016 06:26 PM, Joachim Eastwood wrote: > Hi Neil, > > On 20 October 2016 at 17:54, Neil Armstrong wrote: >> Add Synopsys Designware MAC Glue layer for the Oxford Semiconductor OX820. >> >> Signed-off-by: Neil Armstrong >> --- >> .../devicetree/bindings/net/oxnas-dwmac.txt | 44 ++++++ >> drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ >> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + >> drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c | 173 +++++++++++++++++++++ >> 4 files changed, 229 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/net/oxnas-dwmac.txt >> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c > >> + >> +static int oxnas_dwmac_probe(struct platform_device *pdev) >> +{ >> + struct plat_stmmacenet_data *plat_dat; >> + struct stmmac_resources stmmac_res; >> + struct device_node *sysctrl; >> + struct oxnas_dwmac *dwmac; >> + int ret; >> + >> + sysctrl = of_parse_phandle(pdev->dev.of_node, "oxsemi,sys-ctrl", 0); >> + if (!sysctrl) { >> + dev_err(&pdev->dev, "failed to get sys-ctrl node\n"); >> + return -EINVAL; >> + } >> + >> + ret = stmmac_get_platform_resources(pdev, &stmmac_res); >> + if (ret) >> + return ret; >> + >> + plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac); >> + if (IS_ERR(plat_dat)) >> + return PTR_ERR(plat_dat); >> + >> + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); >> + if (!dwmac) >> + return -ENOMEM; >> + >> + dwmac->regmap = syscon_node_to_regmap(sysctrl); >> + if (IS_ERR(dwmac->regmap)) { >> + dev_err(&pdev->dev, "failed to have sysctrl regmap\n"); >> + return PTR_ERR(dwmac->regmap); >> + } >> + >> + dwmac->clk = devm_clk_get(&pdev->dev, "gmac"); >> + if (IS_ERR(dwmac->clk)) >> + return PTR_ERR(dwmac->clk); >> + >> + plat_dat->bsp_priv = dwmac; >> + plat_dat->init = oxnas_dwmac_init; >> + plat_dat->exit = oxnas_dwmac_exit; > > Please do not use the init/exit callbacks. Implement proper driver > callbacks instead. I.e: PM resume/suspend and driver remove. > > Shouldn't you call oxnas_dwmac_init() from probe as well? > As it is now it will only be called during PM resume and that can't be right. > > >> + >> + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); > > If stmmac_dvr_probe() fails you should disable your clocks. > > > regards, > Joachim Eastwood > Hi Joachim, Thanks for the hints, stm32 glue does that and I will sync on it. Neil