From patchwork Tue Dec 27 15:36:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 89106 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp5039707qgi; Tue, 27 Dec 2016 07:36:41 -0800 (PST) X-Received: by 10.194.205.73 with SMTP id le9mr29264861wjc.31.1482853001498; Tue, 27 Dec 2016 07:36:41 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id ui11si50170258wjb.278.2016.12.27.07.36.41; Tue, 27 Dec 2016 07:36:41 -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 CD30AB38EB; Tue, 27 Dec 2016 16:36:34 +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 9JMf7nwRWt9s; Tue, 27 Dec 2016 16:36:34 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E8A93A7683; Tue, 27 Dec 2016 16:36:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 98FA6A766D for ; Tue, 27 Dec 2016 16:36:23 +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 mOMwUvYHIFB4 for ; Tue, 27 Dec 2016 16:36:23 +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 3F7F3A765B for ; Tue, 27 Dec 2016 16:36:18 +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 uBRFa5RL030807; Wed, 28 Dec 2016 00:36:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com uBRFa5RL030807 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1482852973; bh=7HGNpFKzzKPViIYt2jDw/t0bW6Wp1kZmPdY4wcreoZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kzeghz+CTQJonzWxIwF0Tum6/VC+KIrkPpHAg1HGg1D5vjoHi5R0LMdZh76BndXGV A5H4x7YDKGOPb9KYGQ/EcEwp3t2M9KmscCzAC9eJ9T/CtLMVJjc87cKP++1gsnK91v TcstuJ7Cg4IaplzHA9ZCpEVr97GnA1HD6vAlYpFXsJM1zlzLNKT45m2Z3qy0OuWuim 7RgbiKR2e6s8bwEm7jl8PO1G84y2GszpGBGtB+hbg5wCnJTHf0gfuLQri2roOKiwVz k6qezoCc9G4sfZ0sgpwsBfKj9s8MYgMMaNbdU4/Nj4zzvGD9a96717spTa7HVD/gpI bACa2yni4OZ/g== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 28 Dec 2016 00:36:03 +0900 Message-Id: <1482852963-6887-6-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> Subject: [U-Boot] [PATCH v2 5/5] iopoll: import include/linux/iopoll.h from Linux 4.9 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" This was imported from Linux 4.9 and adjusted for U-Boot. - Replace the license block with SPDX - Drop all *_atomic variants, which make no sense for U-Boot - Remove the sleep_us argument, which makes no sense for U-Boot Signed-off-by: Masahiro Yamada --- Changes in v2: None include/linux/iopoll.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 include/linux/iopoll.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/linux/iopoll.h b/include/linux/iopoll.h new file mode 100644 index 0000000..31c55ae --- /dev/null +++ b/include/linux/iopoll.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef _LINUX_IOPOLL_H +#define _LINUX_IOPOLL_H + +#include +#include +#include + +/** + * readx_poll_timeout - Periodically poll an address until a condition is met or a timeout occurs + * @op: accessor function (takes @addr as its only argument) + * @addr: Address to poll + * @val: Variable to read the value into + * @cond: Break condition (usually involving @val) + * @timeout_us: Timeout in us, 0 means never timeout + * + * Returns 0 on success and -ETIMEDOUT upon a timeout. In either + * case, the last read value at @addr is stored in @val. + * + * When available, you'll probably want to use one of the specialized + * macros defined below rather than this macro directly. + */ +#define readx_poll_timeout(op, addr, val, cond, timeout_us) \ +({ \ + unsigned long timeout = timer_get_us() + timeout_us; \ + for (;;) { \ + (val) = op(addr); \ + if (cond) \ + break; \ + if (timeout_us && time_after(timer_get_us(), timeout)) { \ + (val) = op(addr); \ + break; \ + } \ + } \ + (cond) ? 0 : -ETIMEDOUT; \ +}) + + +#define readb_poll_timeout(addr, val, cond, timeout_us) \ + readx_poll_timeout(readb, addr, val, cond, timeout_us) + +#define readw_poll_timeout(addr, val, cond, timeout_us) \ + readx_poll_timeout(readw, addr, val, cond, timeout_us) + +#define readl_poll_timeout(addr, val, cond, timeout_us) \ + readx_poll_timeout(readl, addr, val, cond, timeout_us) + +#define readq_poll_timeout(addr, val, cond, timeout_us) \ + readx_poll_timeout(readq, addr, val, cond, timeout_us) + +#define readb_relaxed_poll_timeout(addr, val, cond, timeout_us) \ + readx_poll_timeout(readb_relaxed, addr, val, cond, timeout_us) + +#define readw_relaxed_poll_timeout(addr, val, cond, timeout_us) \ + readx_poll_timeout(readw_relaxed, addr, val, cond, timeout_us) + +#define readl_relaxed_poll_timeout(addr, val, cond, timeout_us) \ + readx_poll_timeout(readl_relaxed, addr, val, cond, timeout_us) + +#define readq_relaxed_poll_timeout(addr, val, cond, timeout_us) \ + readx_poll_timeout(readq_relaxed, addr, val, cond, timeout_us) + +#endif /* _LINUX_IOPOLL_H */