From patchwork Tue Dec 20 06:53:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 88547 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1575264qgi; Mon, 19 Dec 2016 22:54:22 -0800 (PST) X-Received: by 10.28.104.213 with SMTP id d204mr414102wmc.101.1482216861992; Mon, 19 Dec 2016 22:54:21 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id f21si17704376wmh.150.2016.12.19.22.54.21; Mon, 19 Dec 2016 22:54:21 -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 83E64B38EC; Tue, 20 Dec 2016 07:54:17 +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 B_1M9R_Qb1j3; Tue, 20 Dec 2016 07:54:17 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A445B38F0; Tue, 20 Dec 2016 07:54:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 00B36A7666 for ; Tue, 20 Dec 2016 07:54:04 +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 h1UDb0JWAYjt for ; Tue, 20 Dec 2016 07:54:03 +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 206D9A75C9 for ; Tue, 20 Dec 2016 07:53:59 +0100 (CET) Received: from pug.jp.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id uBK6ratN015897; Tue, 20 Dec 2016 15:53:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com uBK6ratN015897 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1482216820; bh=R0Hk/L7O/JE1bIjGSbmMZfL5etADDXnlMIfAsxRDPT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t33eRsbugvwXvQYqWY2+f8rJgbCQA8WAkKqU7OITW7PkzpsU+rjsEs+KE1L5RLyMd d9bLRzE0dW/hq9OOsa5bc/EiwtVpoK1ZcDai1BrwZwELfEsiUK/JyeHSZAV9kbKiqI NUFYqFGVNHt5JPHk6iA98Of26AGsZJRI3TOQS4dmaaLMxiIDkl0Nn0p470k0eZaD9b IuNVEqVxJI7d/5JoCo/GdfBCL57GstBc+dunmjXWFdJs+v691Dwg83Fv/Ag8tWdNQx jz3TRMIOxCqfG5iWlOejWLEIpS4JVsTUzei4ZG+djNnTVltZpyyuaJ4qIdLEoa59Sr b3ldCcMNUiKRg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 20 Dec 2016 15:53:32 +0900 Message-Id: <1482216812-18379-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482216812-18379-1-git-send-email-yamada.masahiro@socionext.com> References: <1482216812-18379-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 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 --- 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 */