From patchwork Tue Dec 27 15:35:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 89110 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp5040057qgi; Tue, 27 Dec 2016 07:37:30 -0800 (PST) X-Received: by 10.28.92.21 with SMTP id q21mr30470934wmb.71.1482853050810; Tue, 27 Dec 2016 07:37:30 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id i202si46584167wmd.36.2016.12.27.07.37.29; Tue, 27 Dec 2016 07:37:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EACFCB392F; Tue, 27 Dec 2016 16:37:00 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ImNvuPNMEWXN; Tue, 27 Dec 2016 16:37:00 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 41708B3931; Tue, 27 Dec 2016 16:36:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9C3C6B391A for ; Tue, 27 Dec 2016 16:36:45 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D0ElohRTLZDI for ; Tue, 27 Dec 2016 16:36:45 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by theia.denx.de (Postfix) with ESMTPS id 707CBB38F5 for ; Tue, 27 Dec 2016 16:36:43 +0100 (CET) Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-12.nifty.com with ESMTP id uBRFa5RH030807; Wed, 28 Dec 2016 00:36:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com uBRFa5RH030807 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1482852972; bh=Xg+KoMYwLiX2vfHwxy5DV3tDk18SHQEYJNlSJ/vhlc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MkSw7wQNFKf19pBE1/TRo4OskPrqRgEmAhzsvZPsKn3pRuO3ZEBH5GFuTVaug/8yY 1wM7iLGM4lTJVKP2TrklFkOQzV4Dt+N3fZYCd9TD3FIjoYZnJpN2ZiZjCIWCFrbE20 wh1Mp5mxL2yO0++2WyCzs/Af2rQUCz+wpn6euHugA+jSrDPtSEwbGVSzHs+lQqdu8a vQ012jhV2yGbdl0Yp7M+F4DQd3lQ6Y7iqWx5iinAqUjFvs2BXRdCYHrbF5t4bleFQr mjH82W1K7Wn7mHrB7a7hNJEhK5cRQqSz3OGXX64PWSDS0NcpuEgIK8mZKF4DuqCmW5 beTLEICmGpvrQ== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 28 Dec 2016 00:35:59 +0900 Message-Id: <1482852963-6887-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482852963-6887-1-git-send-email-yamada.masahiro@socionext.com> References: <1482852963-6887-1-git-send-email-yamada.masahiro@socionext.com> Cc: Albert ARIBAUD , Joe Hershberger Subject: [U-Boot] [PATCH v2 1/5] delay: collect {m, n, u}delay declarations to include/linux/delay.h X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Currently, mdelay() and udelay() are declared in include/common.h, while ndelay() in include/linux/compat.h. It would be nice to collect them into include/linux/delay.h like Linux. While we are here, fix the ndelay() implementation; I used the DIV_ROUND_UP() instead of (x)/1000 because it must wait *longer* than the given period of time. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- Changes in v2: None include/common.h | 6 +----- include/linux/compat.h | 2 -- include/linux/delay.h | 24 ++++++++++++++++++++++++ lib/time.c | 6 ------ 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 include/linux/delay.h -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/include/common.h b/include/common.h index a8d833b..682205d 100644 --- a/include/common.h +++ b/include/common.h @@ -19,6 +19,7 @@ typedef volatile unsigned char vu_char; #include #include #include +#include #include #include #include @@ -776,7 +777,6 @@ uint64_t get_ticks(void); void wait_ticks (unsigned long); /* arch/$(ARCH)/lib/time.c */ -void __udelay (unsigned long); ulong usec2ticks (unsigned long usec); ulong ticks2usec (unsigned long ticks); int init_timebase (void); @@ -833,10 +833,6 @@ void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); int strcmp_compar(const void *, const void *); -/* lib/time.c */ -void udelay (unsigned long); -void mdelay(unsigned long); - /* lib/uuid.c */ #include diff --git a/include/linux/compat.h b/include/linux/compat.h index 533983f..a43e4d6 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -15,8 +15,6 @@ struct p_current{ extern struct p_current *current; -#define ndelay(x) udelay((x) < 1000 ? 1 : (x)/1000) - #define dev_dbg(dev, fmt, args...) \ debug(fmt, ##args) #define dev_vdbg(dev, fmt, args...) \ diff --git a/include/linux/delay.h b/include/linux/delay.h new file mode 100644 index 0000000..3dcd435 --- /dev/null +++ b/include/linux/delay.h @@ -0,0 +1,24 @@ +/* + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _LINUX_DELAY_H +#define _LINUX_DELAY_H + +#include + +void __udelay(unsigned long usec); +void udelay(unsigned long usec); + +static inline void mdelay(unsigned long msec) +{ + while (msec--) + udelay(1000); +} + +static inline void ndelay(unsigned long nsec) +{ + udelay(DIV_ROUND_UP(nsec, 1000)); +} + +#endif /* defined(_LINUX_DELAY_H) */ diff --git a/lib/time.c b/lib/time.c index f37150f..3c49243 100644 --- a/lib/time.c +++ b/lib/time.c @@ -154,9 +154,3 @@ void udelay(unsigned long usec) usec -= kv; } while(usec); } - -void mdelay(unsigned long msec) -{ - while (msec--) - udelay(1000); -}