Received: by 10.223.164.202 with SMTP id h10csp3590070wrb; Mon, 20 Nov 2017 01:36:49 -0800 (PST) X-Google-Smtp-Source: AGs4zMZeLqoHph01f1n/0pIg9d1fEycrkeatGvWUl4tfrPdpywhjVzxDUCbIqBpajKSC5wBFsuSt X-Received: by 10.101.90.71 with SMTP id z7mr5808591pgs.14.1511170609283; Mon, 20 Nov 2017 01:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511170609; cv=none; d=google.com; s=arc-20160816; b=xCSm3eVP1HXGEmpbh9lrqviEP6J+GLsJJQqfkObBsdhLO7LTy7/HutuBFG+N0ZBrAW JXPcNyc7NfZPhHsf1g3ooYVyxrWgvCOlVRhAFc2TJhQ8hfknR5EuqMUCeut5V/dtYxcx STSNddaB0sjcORV8VQG88sUASu75SrRPSGJ91BQJ7W3Oj4ntwvKHJvUPUqrXuISXyPXY XRuCxbGaDHqKqMEVkfbz4uIoynZdFxI7Wauu5um1xVJh4XkfkcaLTs+GRa7udPt5O7UW Qb8PYohj0sy/6rqniHGM05KUYwkD5D6BlGlpjyHw56UH8e2aDwH/iaiYT8lxPJmfi1UJ lpYg== 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=GzGKDP0W484qnpvQANRWuk18fi7C0qmNRwEAzb0SiAo=; b=uUn5iCTOQgo10inpvpPQe9dJ0sU6W832bWQ7r7iCZ5JASJQp3mj1TSmjCYKS696Kma 8QqN17UbeuRSCTTxRxMSfZI18HDaSHRZGzWVFjDYK3m0GfzEf29rBeEJEF+5YKIL0r+X G5GcuwF8ZNIY3AaRlR2VRJIZnPJ2KA/mj3wCGUJUmeaZPiv75yywzpFXS24tdEWews9m pbxZQNhSI1/MZGms9miHTJJ48DUCcIkBn0yMOS+B8ONJFeISJ/Ap2AzI5+LUjb3OrJtC B0uQJqYsDKoPHECfhZUUUXfy++UYzq1cXSuvPw85sCwcHQNPujwXBjWqNY/Jqe3I3oWq Reng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=ENcPKpFV; 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=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68si7942380pla.682.2017.11.20.01.36.39; Mon, 20 Nov 2017 01:36:49 -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=@nxp.com header.s=selector1 header.b=ENcPKpFV; 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=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751174AbdKTJf4 (ORCPT + 68 others); Mon, 20 Nov 2017 04:35:56 -0500 Received: from mail-eopbgr20051.outbound.protection.outlook.com ([40.107.2.51]:57904 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751113AbdKTJfy (ORCPT ); Mon, 20 Nov 2017 04:35:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GzGKDP0W484qnpvQANRWuk18fi7C0qmNRwEAzb0SiAo=; b=ENcPKpFV8wkJi+5qkKgTI89gK/5uP+fpcDx8xfVW3r0VCBD6t89uWAHmb+7X7Q402pe67OMxnGWwNEAxpoSOfRoqsMZ4kWRI8IcFerXIaUXW+2b9radYUELcalkPI1ivi390AeACy3Dry/KZH1PNEG9satZJ/UpPMpNNfybVOJ0= Received: from AM4PR0401MB2260.eurprd04.prod.outlook.com (10.165.45.7) by AM4PR0401MB2259.eurprd04.prod.outlook.com (10.165.45.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Mon, 20 Nov 2017 09:35:51 +0000 Received: from AM4PR0401MB2260.eurprd04.prod.outlook.com ([fe80::1940:8424:82c5:9732]) by AM4PR0401MB2260.eurprd04.prod.outlook.com ([fe80::1940:8424:82c5:9732%13]) with mapi id 15.20.0239.009; Mon, 20 Nov 2017 09:35:51 +0000 From: Andy Duan To: Richard Leitner , "f.fainelli@gmail.com" , "andrew@lunn.ch" CC: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "richard.leitner@skidata.com" Subject: RE: [PATCH v2 1/3] net: ethernet: freescale: simplify fec_reset_phy Thread-Topic: [PATCH v2 1/3] net: ethernet: freescale: simplify fec_reset_phy Thread-Index: AQHTYdqJuZTX/cW+7kiBFwhFWspG5aMdAVKg Date: Mon, 20 Nov 2017 09:35:51 +0000 Message-ID: References: <20171120083417.32558-1-dev@g0hl1n.net> <20171120083417.32558-2-dev@g0hl1n.net> In-Reply-To: <20171120083417.32558-2-dev@g0hl1n.net> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=fugang.duan@nxp.com; x-originating-ip: [199.59.231.64] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM4PR0401MB2259;6:hG1SFBwevg/CW5AX2YEU7cw1QTLDht8Tddwy3jOKcQauUu90681FERa9jzXFlKbOkPg3yfVvCaGz4aQT0EWvQcPWF3yhk7Kv4gAJFp9HClVygYUwQl/QD3zT213IbdQTP8dDY0uImjpa35jG7/5YyCbxn0HmYQXY15/dcjWRPjdgil3tfmUxYDWU16jtJtGmiV2vnGytR0+2CpXGChOShlX08g/1tLNypipMATZSnh9q6WAIetNele+AAC/TymJq4muRJ5zg67wnArbVCYxfYRfLr4ndvYyVFgprbIjTmqwbjt3z095C62OixXFRPsL6UKoxWgZXRa5ZM737fdqLTAxFqGTt274+gUOfqFaDMDo=;5:x4yKE4DvncrSHnMd0TWuHGr02JgsHZlkMwl/i50EjmcHEj29E6/dOdyX+uQeNUvzwdYyYXpUKbSeOBZgjrErDQn5bpOfneTJME7HSAbFXYhHvkArqzGqpfnrjyBBXvorMQ//AZpPj4WuY63bt3t4bC0C1Hd2NN0lpabFshVx4bQ=;24:DYpx35u7eV6IPtjeOOAEl0VB7RxWutZDZJOVSLixTpBi2rHE4lZLW7to9M3x4u6fSSK21pUYOY10fwDvpLc/U0VbXFNAYV8l6vrsMc5NRG4=;7:u80BALUX6MSklnPEv9T/aE34vwD2fNe3SqaY+vjfTbnGLx9oYopOScmaNzCh7oSG9/E0s+rC4b8JKVXYHPdiRxvgx4LvA6VUqTYDL8l+Cj1vBtY4eNs4gCxm9WZlwFVQ/UHj30Ktzi7BwuwYto+pj96qVUbekE2EKdfCSOspWKv+K7TCGlHoJvwylHwFK0GtimnAHE/6CWSC7pGBZrS8JlS00r7lq2sxqLv9V15V8s33mevfbT/TGUmfvvWTRTiA x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 1d5eb1d7-081a-44f5-de35-08d52ffa1717 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603199);SRVR:AM4PR0401MB2259; x-ms-traffictypediagnostic: AM4PR0401MB2259: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(244540007438412); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3231022)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM4PR0401MB2259;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM4PR0401MB2259; x-forefront-prvs: 04976078F0 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(346002)(376002)(39860400002)(189002)(199003)(81156014)(81166006)(97736004)(25786009)(478600001)(189998001)(8676002)(105586002)(101416001)(68736007)(305945005)(74316002)(9686003)(33656002)(106356001)(2501003)(7736002)(6246003)(2906002)(2900100001)(5250100002)(39060400002)(3280700002)(5660300001)(53936002)(7696004)(3660700001)(229853002)(3846002)(102836003)(6116002)(55016002)(2950100002)(6506006)(6436002)(4326008)(8936002)(99286004)(86362001)(575784001)(110136005)(316002)(2201001)(54906003)(14454004)(66066001)(76176999)(54356999)(50986999);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR0401MB2259;H:AM4PR0401MB2260.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d5eb1d7-081a-44f5-de35-08d52ffa1717 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Nov 2017 09:35:51.7781 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0401MB2259 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Richard Leitner Sent: Monday, November 20, 2017 4:34= PM >The fec_reset_phy function allowed only one execution during probeing. >To make it more usable move the dt parsing and gpio allocation to the prob= e >function. The parameters of the phy reset are added to the fec_enet_privat= e >struct. As a result the fec_reset_phy function may be called anytime after >probe. > >One checkpatch.pl warning (too long line) is ignored. This is due to the f= act a >string (dt property name) otherwise needs to be split over multiple lines, >which is counterproductive for the readability. > >Signed-off-by: Richard Leitner >--- It is better to convert to gpio descriptor, and use dts gpio flag as the gp= io polarity instead of extra phy_reset_active_high variable. Regards, Andy > drivers/net/ethernet/freescale/fec.h | 4 ++ > drivers/net/ethernet/freescale/fec_main.c | 88 ++++++++++++++++---------- >----- > 2 files changed, 50 insertions(+), 42 deletions(-) > >diff --git a/drivers/net/ethernet/freescale/fec.h >b/drivers/net/ethernet/freescale/fec.h >index 5385074b3b7d..401c4eabf08a 100644 >--- a/drivers/net/ethernet/freescale/fec.h >+++ b/drivers/net/ethernet/freescale/fec.h >@@ -539,6 +539,10 @@ struct fec_enet_private { > int pause_flag; > int wol_flag; > u32 quirks; >+ int phy_reset; >+ int phy_reset_duration; >+ int phy_reset_post_delay; >+ bool phy_reset_active_high; > > struct napi_struct napi; > int csum_flags; >diff --git a/drivers/net/ethernet/freescale/fec_main.c >b/drivers/net/ethernet/freescale/fec_main.c >index 610573855213..06a7caca0cee 100644 >--- a/drivers/net/ethernet/freescale/fec_main.c >+++ b/drivers/net/ethernet/freescale/fec_main.c >@@ -3212,62 +3212,36 @@ static int fec_enet_init(struct net_device *ndev) = } > > #ifdef CONFIG_OF >-static int fec_reset_phy(struct platform_device *pdev) >+static int fec_reset_phy(struct net_device *ndev) > { >- int err, phy_reset; >- bool active_high =3D false; >- int msec =3D 1, phy_post_delay =3D 0; >- struct device_node *np =3D pdev->dev.of_node; >- >- if (!np) >- return 0; >- >- err =3D of_property_read_u32(np, "phy-reset-duration", &msec); >- /* A sane reset duration should not be longer than 1s */ >- if (!err && msec > 1000) >- msec =3D 1; >+ struct fec_enet_private *fep =3D netdev_priv(ndev); > >- phy_reset =3D of_get_named_gpio(np, "phy-reset-gpios", 0); >- if (phy_reset =3D=3D -EPROBE_DEFER) >- return phy_reset; >- else if (!gpio_is_valid(phy_reset)) >+ if (!fep->phy_reset) > return 0; > >- err =3D of_property_read_u32(np, "phy-reset-post-delay", >&phy_post_delay); >- /* valid reset duration should be less than 1s */ >- if (!err && phy_post_delay > 1000) >- return -EINVAL; >- >- active_high =3D of_property_read_bool(np, "phy-reset-active-high"); >+ gpio_set_value_cansleep(fep->phy_reset, fep- >>phy_reset_active_high); > >- err =3D devm_gpio_request_one(&pdev->dev, phy_reset, >- active_high ? GPIOF_OUT_INIT_HIGH : >GPIOF_OUT_INIT_LOW, >- "phy-reset"); >- if (err) { >- dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", >err); >- return err; >- } >- >- if (msec > 20) >- msleep(msec); >+ if (fep->phy_reset_duration > 20) >+ msleep(fep->phy_reset_duration); > else >- usleep_range(msec * 1000, msec * 1000 + 1000); >+ usleep_range(fep->phy_reset_duration * 1000, >+ fep->phy_reset_duration * 1000 + 1000); > >- gpio_set_value_cansleep(phy_reset, !active_high); >+ gpio_set_value_cansleep(fep->phy_reset, !fep- >>phy_reset_active_high); > >- if (!phy_post_delay) >+ if (!fep->phy_reset_post_delay) > return 0; > >- if (phy_post_delay > 20) >- msleep(phy_post_delay); >+ if (fep->phy_reset_post_delay > 20) >+ msleep(fep->phy_reset_post_delay); > else >- usleep_range(phy_post_delay * 1000, >- phy_post_delay * 1000 + 1000); >+ usleep_range(fep->phy_reset_post_delay * 1000, >+ fep->phy_reset_post_delay * 1000 + 1000); > > return 0; > } > #else /* CONFIG_OF */ >-static int fec_reset_phy(struct platform_device *pdev) >+static int fec_reset_phy(struct net_device *ndev) > { > /* > * In case of platform probe, the reset has been done @@ -3400,6 >+3374,36 @@ fec_probe(struct platform_device *pdev) > } > fep->phy_node =3D phy_node; > >+ fep->phy_reset =3D of_get_named_gpio(np, "phy-reset-gpios", 0); >+ if (gpio_is_valid(fep->phy_reset)) { >+ ret =3D of_property_read_u32(np, "phy-reset-duration", >+ &fep->phy_reset_duration); >+ /* A sane reset duration should not be longer than 1s */ >+ if (!ret && fep->phy_reset_post_delay > 1000) >+ fep->phy_reset_post_delay =3D 1; >+ >+ ret =3D of_property_read_u32(np, "phy-reset-post-delay", >+ &fep->phy_reset_post_delay); >+ /* valid post reset delay should be less than 1s */ >+ if (!ret && fep->phy_reset_post_delay > 1000) >+ fep->phy_reset_post_delay =3D 1; >+ >+ fep->phy_reset_active_high =3D of_property_read_bool(np, >+"phy-reset-active-high"); >+ >+ ret =3D devm_gpio_request_one(&pdev->dev, fep->phy_reset, >+ fep->phy_reset_active_high ? >+ GPIOF_OUT_INIT_HIGH : >+ GPIOF_OUT_INIT_LOW, >+ "phy-reset"); >+ if (ret) { >+ dev_err(&pdev->dev, "failed to get reset- >gpios: %d\n", >+ ret); >+ goto failed_phy; >+ } >+ } else { >+ fep->phy_reset =3D 0; >+ } >+ > ret =3D of_get_phy_mode(pdev->dev.of_node); > if (ret < 0) { > pdata =3D dev_get_platdata(&pdev->dev); @@ -3472,7 +3476,7 >@@ fec_probe(struct platform_device *pdev) > pm_runtime_set_active(&pdev->dev); > pm_runtime_enable(&pdev->dev); > >- ret =3D fec_reset_phy(pdev); >+ ret =3D fec_reset_phy(ndev); > if (ret) > goto failed_reset; > >-- >2.11.0 From 1584573521511900384@xxx Mon Nov 20 08:37:49 +0000 2017 X-GM-THRID: 1584573521511900384 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread