Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1580376ybv; Thu, 6 Feb 2020 06:25:48 -0800 (PST) X-Google-Smtp-Source: APXvYqwljaHDs1qlVDLVazNUuQEQnUCtkmvUx352fSwj9WbVjJfUY212cVOu6EjA65FunW7qPmFR X-Received: by 2002:aca:1a06:: with SMTP id a6mr6764122oia.148.1580999148823; Thu, 06 Feb 2020 06:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580999148; cv=none; d=google.com; s=arc-20160816; b=D1LsnhZyNcYZviAxXtkSpksvBuoNVJCwVbME0Ax0aYS/Y6LNDW0LWKAnGRwUug9gqS D/kMZ/79li3UXkgEeKG03w08qvy2LGIbWKNgrmPecod1PitdHeMnehLWrADC+HDy1y5G 3lKvHKTPzoHvZC8Ctb85p5tDFvnRq84eu98r41e8adGIP//fl4s7YG42ah3wdtAhcdvr 5XQ7cpoi2pMPFHdQNbMF0eJ82Bk0MvhIUtF+lV2dHZTq83lsP2I0LQ8gyd+10jrp5lKk yLzATsPs7+E+Ugq2DxUOSALVCnexsl/rUk74NnNMW8Wtx73tkKmFJtoP3a7wK9u73q40 EHGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2k1+BmAg/PACALQSiYk+3lsPVNBiCnjdKk4ZEAWEMAo=; b=ps51SZdabJA3/fUwf/lmCkSCKhNVX77BHtYqX+FL/eOVAU+eFxGTrz/gSSJKrKiPuN mveBQGspPImAmQmVjTEVRcVUtneRm7WfOJ/HHimAwtI493jVsfcMdBZYI0S0yKetKyYa LRsEZ2jzhMAnPMIRSyq5HEsQ7tmWyk1SBZKDSriGNpeYWgJspULdDQhKzJrBAOFjwPVN uc4PLfi+hExvm8EAwAvfTfezGj02PEuDb/BbsME/06z3UK3mha0+blYe4oL/7bURGmSE 2kFSXMp8B9VeCj8bqyHCqLFfJlBTZnaObQ8RQemRWquvZDi4DRUnzhTj2BRI4EBvOXZ3 vm2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="D/EBBAtU"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o15si1923217otp.314.2020.02.06.06.25.35; Thu, 06 Feb 2020 06:25:48 -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=@gmail.com header.s=20161025 header.b="D/EBBAtU"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728174AbgBFOYd (ORCPT + 99 others); Thu, 6 Feb 2020 09:24:33 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46536 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727415AbgBFOYd (ORCPT ); Thu, 6 Feb 2020 09:24:33 -0500 Received: by mail-pf1-f196.google.com with SMTP id k29so3187706pfp.13; Thu, 06 Feb 2020 06:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2k1+BmAg/PACALQSiYk+3lsPVNBiCnjdKk4ZEAWEMAo=; b=D/EBBAtUCOsUg+i5bc2KUgV/GljhCwwCEpfUQIBNM6QpF/qcvleiiWUPzWuhRHg8vI mDk35foTgP7jqdshD7/iiIlVKlV2x7GldZeLGYzETC2/QlYsZUOna04O9EwJaZrng0M9 hC2lth/uBHlK0Kg47gN2csh+tnTUb3bYoIJm2kriip+fzAyCn2vigf4DFqe9hV1sRi9e Od17WHXkwoXftisbxh/kTJRQLidKXb/tewXkYnYDAdzzPLBJFMOKDFNkWbPuIE0LlILx dbnOF4b2+CIsfQhgW8mhX1W+t4KNDy9nv+BTOkn953zm+roBm1fpl17o2yF+riu8Yl1c oyJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2k1+BmAg/PACALQSiYk+3lsPVNBiCnjdKk4ZEAWEMAo=; b=p5O+fNg03PN0Nt2Lj7H0TWPTeQJYB7znoLt/qupMhuNnZOTVBq2n83Ykjy/tZ3MUtO cVHrLdTUZzbONcmjaQbaLU2nur5iX3egYfCZDNDrGVU5nWrZCGyPWnhepqVfwEyu9zi1 vwECq4igpMhvNgMlSWU1XtkxElk4AQLRF186zyj/X6g2bjfbHBeEb+EGHJXvSPqWTDw9 ctgvrYMl5bgnLxy2zouHh1EwMzCSgJaXDUbXzYouVVj/JJqUccEShRr0JKUsDdSwhboZ 7bvL4E/U+xS1S+jYMkb5/uZfYENujLeCc4eSXA6Jg25++PMxuND9QIIltRRAWuv/PTPu zRlw== X-Gm-Message-State: APjAAAXnbS7GUk4jA0/gCGSlp6C+/hOPWMZy0Kv+wV1QTCRmQun+UXDf wWEkZdnC3V+pqeHccd8I4A4= X-Received: by 2002:a63:ba19:: with SMTP id k25mr4089647pgf.333.1580999072575; Thu, 06 Feb 2020 06:24:32 -0800 (PST) Received: from localhost (104.128.80.227.16clouds.com. [104.128.80.227]) by smtp.gmail.com with ESMTPSA id q12sm3595749pfh.158.2020.02.06.06.24.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2020 06:24:31 -0800 (PST) From: Dejin Zheng To: peppe.cavallaro@st.com, alexandre.torgue@st.com, joabreu@synopsys.com, davem@davemloft.net, mcoquelin.stm32@gmail.com, netdev@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Date: Thu, 6 Feb 2020 22:24:03 +0800 Message-Id: <20200206142404.24980-2-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200206142404.24980-1-zhengdejin5@gmail.com> References: <20200206142404.24980-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The init_systime() function use an open coded of readl_poll_timeout(). Replace the open coded handling with the proper function. Signed-off-by: Dejin Zheng --- .../net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 020159622559..2a24e2a7db3b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -10,6 +10,7 @@ *******************************************************************************/ #include +#include #include #include "common.h" #include "stmmac_ptp.h" @@ -53,8 +54,8 @@ static void config_sub_second_increment(void __iomem *ioaddr, static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec) { - int limit; u32 value; + int err; writel(sec, ioaddr + PTP_STSUR); writel(nsec, ioaddr + PTP_STNSUR); @@ -64,13 +65,10 @@ static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec) writel(value, ioaddr + PTP_TCR); /* wait for present system time initialize to complete */ - limit = 10; - while (limit--) { - if (!(readl(ioaddr + PTP_TCR) & PTP_TCR_TSINIT)) - break; - mdelay(10); - } - if (limit < 0) + err = readl_poll_timeout(ioaddr + PTP_TCR, value, + !(value & PTP_TCR_TSINIT), + 10000, 100000); + if (err) return -EBUSY; return 0; -- 2.25.0