Received: by 10.213.65.68 with SMTP id h4csp1754981imn; Mon, 19 Mar 2018 12:21:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELtcUlbhWotXlX3HrwO1nsPeqeT7RFtRpnbHZ94WtKVrihaidU0gHLelcBEpP1WZBjLD+/Sc X-Received: by 10.98.3.66 with SMTP id 63mr11222947pfd.177.1521487288984; Mon, 19 Mar 2018 12:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521487288; cv=none; d=google.com; s=arc-20160816; b=t0iV8xydarjtvHHW6QmLy1YCaEFi8jCFTU3PDhA6QNlO8/tEYlxZm4q7r/ePX0vwSb 200OguSPDldhkkl+JOXEV5QsL9JBcPMj4yN8QtQissgO8KMa7delgAxV7vKsteBZbvuj O5Re0UCBmIC+KL7daL8ib7kxgvghpwLjQ/v4yb6/fmYeUMQB4fEYGEhDb5p3pzvgELig ySc8BWl9lbS3iWqM7n2IwhwV8WOn0/DZXMAvCjXELtu6fD5JW5LcNOeQeHTycIP3VNUU 45KKIGjHv69b3rwjQjHd+JDvGu8QlbubhW9SnKi60qZ40odUTL25PjSkHqUL2v6VkhET tC5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=uswYoHDQZvVyNb6VvLutqc6PyFyXzp2Ro01730/QVf0=; b=aN6SqqbJHXZGc/aaO1zUyBRdatSSjcEr5mlUUJjQ/J2OjrW41siL6RnuxvTa0volj0 puSSgPgy8fwGkLRU2Lcu4c/mJnAQ3ABJ/iabuDkZdQD93RJwR5+pRtyS9LuPWgSEWvc2 XNwFTgIRfCjdEYD2AQ/mZ4P/67Jn/BgdAiQsOYOF9MkB1K8t1m9SkXqS1RORA2Id74/r ExXB04jmOB8mBPZsopAHmi09tHKSm7f+SS4j7J3ubS6uqkNs5vUN5pJliB7IHdoPXxxW +ArfFfl1pRxdsRWx0mL4GnqrIaQKo0Sk1MMjxiQ9g39O8cqeAybjislIUzrX6pxd/7HX iovA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o81si431275pfk.67.2018.03.19.12.21.14; Mon, 19 Mar 2018 12:21:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935862AbeCSTSd (ORCPT + 99 others); Mon, 19 Mar 2018 15:18:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50654 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969770AbeCSS0A (ORCPT ); Mon, 19 Mar 2018 14:26:00 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DFEC1100B; Mon, 19 Mar 2018 18:25:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fugang Duan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 145/241] net: fec: add phy-reset-gpios PROBE_DEFER check Date: Mon, 19 Mar 2018 19:06:50 +0100 Message-Id: <20180319180757.191602215@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fugang Duan [ Upstream commit 9269e5560b261eb9ee157497890dc0948db76cf8 ] Many boards use i2c/spi expander gpio as phy-reset-gpios and these gpios maybe registered after fec port, driver should check the return value of .of_get_named_gpio(). Signed-off-by: Fugang Duan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/freescale/fec_main.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3209,7 +3209,7 @@ static int fec_enet_init(struct net_devi } #ifdef CONFIG_OF -static void fec_reset_phy(struct platform_device *pdev) +static int fec_reset_phy(struct platform_device *pdev) { int err, phy_reset; bool active_high = false; @@ -3217,7 +3217,7 @@ static void fec_reset_phy(struct platfor struct device_node *np = pdev->dev.of_node; if (!np) - return; + return 0; of_property_read_u32(np, "phy-reset-duration", &msec); /* A sane reset duration should not be longer than 1s */ @@ -3225,8 +3225,10 @@ static void fec_reset_phy(struct platfor msec = 1; phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0); - if (!gpio_is_valid(phy_reset)) - return; + if (phy_reset == -EPROBE_DEFER) + return phy_reset; + else if (!gpio_is_valid(phy_reset)) + return 0; active_high = of_property_read_bool(np, "phy-reset-active-high"); @@ -3235,7 +3237,7 @@ static void fec_reset_phy(struct platfor "phy-reset"); if (err) { dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err); - return; + return err; } if (msec > 20) @@ -3244,14 +3246,17 @@ static void fec_reset_phy(struct platfor usleep_range(msec * 1000, msec * 1000 + 1000); gpio_set_value_cansleep(phy_reset, !active_high); + + return 0; } #else /* CONFIG_OF */ -static void fec_reset_phy(struct platform_device *pdev) +static int fec_reset_phy(struct platform_device *pdev) { /* * In case of platform probe, the reset has been done * by machine code. */ + return 0; } #endif /* CONFIG_OF */ @@ -3422,6 +3427,7 @@ fec_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "Failed to enable phy regulator: %d\n", ret); + clk_disable_unprepare(fep->clk_ipg); goto failed_regulator; } } else { @@ -3434,7 +3440,9 @@ fec_probe(struct platform_device *pdev) pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); - fec_reset_phy(pdev); + ret = fec_reset_phy(pdev); + if (ret) + goto failed_reset; if (fep->bufdesc_ex) fec_ptp_init(pdev); @@ -3495,8 +3503,10 @@ failed_init: fec_ptp_stop(pdev); if (fep->reg_phy) regulator_disable(fep->reg_phy); +failed_reset: + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); failed_regulator: - clk_disable_unprepare(fep->clk_ipg); failed_clk_ipg: fec_enet_clk_enable(ndev, false); failed_clk: