Received: by 10.223.185.116 with SMTP id b49csp1102446wrg; Sat, 3 Mar 2018 15:37:35 -0800 (PST) X-Google-Smtp-Source: AG47ELuIaFRG2WbaXCGfK70UYZyu2TNJYppJLXcsO4RNnEevBjfFSTbuKrafBy1GlDeUONQybXLm X-Received: by 2002:a17:902:2c43:: with SMTP id m61-v6mr8980003plb.387.1520120255403; Sat, 03 Mar 2018 15:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520120255; cv=none; d=google.com; s=arc-20160816; b=YAMc8tCK0cqE4vQhjE1EoIolexrFVzltI3bQg28/AclrpMAc7jpSaMzXuRhhYrFuLf fyKXoWCfaJp9YiQA6DpIh73vYBYqIzjj51+54+bFHzDWusm6QpF4wc1irKLN0diZhrz7 AA3w0rTe7tUVDREhYiWYWmIYsQZT9lOA6It3nU/WiAVKgrxRZwl/JifAXR+Dd/8cpXjL u5o13cAZSdDdpn+11pfXeHOnbiWQ19Zy8Gix02WBwyYnyhoI8ypN9/iffxeS9LUfnjN4 Fz3gaTVxrJ8vzDf13+sH7emO+yngS2Xd0X3ODvylbaKCAyZeSTkfs6poCEVnAfMOF0Gx GNDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=+LTGz0tSATnq99T9TqIrl3RTZbL5VGnGpjVU2OOtD6g=; b=VliQ4T+o0x0s38vuBvGdvWSKmE0JgL75x/as7Erplyy2hVRr2s+LA0HlJDb5mwkNtx 3v5GFQkhEvVqi4LG8l8vHbwMoLoH1WxjpHKUwKa9eO90SDGZJ/o6dvDzbHKDWRyWVA3G oD/pUnuQjAXyhfysmum3WL1xLjdhIbj2MxRXV8voSRiQ1U7ITH4tU4uN8Y/DC682Rtcm nmx6v4RN9ruw7pOsuIRrR6WXxJgMhgHA65dBQKWaYGFcood0e6R3rNDefdjFYaYFE6c9 BkslUUpluPP4/fEn63hontOFtGednwBf7KQiXjKLKrvzH9Kk+hFTijQyZ3r0dX7Ok3Hi 9WWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=OziWm73B; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2-v6si5189001pls.436.2018.03.03.15.37.21; Sat, 03 Mar 2018 15:37:35 -0800 (PST) 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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=OziWm73B; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934427AbeCCWfr (ORCPT + 99 others); Sat, 3 Mar 2018 17:35:47 -0500 Received: from mail-bn3nam01on0090.outbound.protection.outlook.com ([104.47.33.90]:43384 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933860AbeCCWfn (ORCPT ); Sat, 3 Mar 2018 17:35:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+LTGz0tSATnq99T9TqIrl3RTZbL5VGnGpjVU2OOtD6g=; b=OziWm73BujfcWAYITjOlImZP+ws2SKerFXSx/vfkwmbwcIGiuE3Tirg4V7csTPBBxAkZPGXmS5LzbkxfLjr2rCJZgdrB46FaqfQwdgztZ8fqIqDVW0RnQutCuZYfqnfAb051GsHI8BBfMM+RqZVKck+lcdp4E9AkWD7T9kSTuf8= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Sat, 3 Mar 2018 22:35:40 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:35:40 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Fugang Duan , Fugang Duan , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 152/219] net: fec: add phy-reset-gpios PROBE_DEFER check Thread-Topic: [PATCH AUTOSEL for 4.9 152/219] net: fec: add phy-reset-gpios PROBE_DEFER check Thread-Index: AQHTsz8VZF8ia/Xn0kGKAXalr9jGBQ== Date: Sat, 3 Mar 2018 22:29:24 +0000 Message-ID: <20180303222716.26640-152-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB1034;7:LHTapJz6rCsFSpTc7tKZzvmeJEfKOhA1OXk6TFEvEujX2Pjj0bisMFzDaHUse2E6uroKjTC5RexTbcHcrfPiop6gZuw3dRn4yb3AM3nIGLF7dxXlfbubQlEvhDbXOcmgYPGHxQapAr7oIdmL2FPtGaCsXE88PtGp7qlol6S8g8zUy/0Klxrf8Orjm6uALfLG2pjgLZRar4JSPd9m+YeyKmcH+/U8eYOW3zvJ/BaCMwyPVOPDnsS0m1njhaJc4cG3 x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: a12317c8-64a9-49a5-1276-08d5815717a9 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1034; x-ms-traffictypediagnostic: MW2PR2101MB1034: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(185117386973197)(101931422205132); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(3231220)(944501244)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:MW2PR2101MB1034;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1034; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(39860400002)(39380400002)(366004)(396003)(199004)(189003)(99286004)(22452003)(72206003)(316002)(3846002)(6116002)(186003)(26005)(478600001)(76176011)(54906003)(110136005)(102836004)(97736004)(1076002)(2501003)(3660700001)(66066001)(5250100002)(5660300001)(86362001)(10090500001)(10290500003)(86612001)(6506007)(8656006)(68736007)(106356001)(25786009)(8666007)(8676002)(4326008)(6512007)(305945005)(2906002)(14454004)(107886003)(8936002)(7736002)(81166006)(3280700002)(53936002)(105586002)(81156014)(6666003)(6486002)(36756003)(2900100001)(6436002)(2950100002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1034;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: d+L2QtGwWoShei99FTt2Zr0+Tvi3bWOQFZTe+q9OpWWhAcAYh9vXBCtRNqRPJsjCDV862fxhOFlgsf9KBcDm5k8ACXXF87H0yqdIYWMK6TtRI7Ebt4BuD3ry6t/1wg4xYEOAmz8cD5CSoudn+/F9yLN9asbEPwIcPHDhUlSFemA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: a12317c8-64a9-49a5-1276-08d5815717a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:29:25.0101 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1034 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/ethernet/freescale/fec_main.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethern= et/freescale/fec_main.c index 917091871259..dd6e07c748f5 100644 --- 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_device *ndev) } =20 #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 =3D false; @@ -3217,7 +3217,7 @@ static void fec_reset_phy(struct platform_device *pde= v) struct device_node *np =3D pdev->dev.of_node; =20 if (!np) - return; + return 0; =20 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 platform_device *pd= ev) msec =3D 1; =20 phy_reset =3D of_get_named_gpio(np, "phy-reset-gpios", 0); - if (!gpio_is_valid(phy_reset)) - return; + if (phy_reset =3D=3D -EPROBE_DEFER) + return phy_reset; + else if (!gpio_is_valid(phy_reset)) + return 0; =20 active_high =3D of_property_read_bool(np, "phy-reset-active-high"); =20 @@ -3235,7 +3237,7 @@ static void fec_reset_phy(struct platform_device *pde= v) "phy-reset"); if (err) { dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err); - return; + return err; } =20 if (msec > 20) @@ -3244,14 +3246,17 @@ static void fec_reset_phy(struct platform_device *p= dev) usleep_range(msec * 1000, msec * 1000 + 1000); =20 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 */ =20 @@ -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); =20 - fec_reset_phy(pdev); + ret =3D fec_reset_phy(pdev); + if (ret) + goto failed_reset; =20 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: --=20 2.14.1