From patchwork Wed Oct 4 11:28:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 9984381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 36A9960237 for ; Wed, 4 Oct 2017 11:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25DB428AD7 for ; Wed, 4 Oct 2017 11:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A7F928ADE; Wed, 4 Oct 2017 11:45:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B05F128AD7 for ; Wed, 4 Oct 2017 11:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: In-Reply-To:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: References:List-Owner; bh=16DDYN2rQ/eUNMfs2R5QLT8vMTAdZZJ83AAU49Kfhcw=; b=Esv Jq6vZmRY93VZxjtizTXTZta8P+xYeII8fAP9gn9xl4jQat1xrrAgAK4YYx7DaY09JMJFxCw2T8KJ/ BFxVxs+7BgTS5Xn+rv+669HMdYvlgp4wc7vJqZp/RxRudGmYhzmYx/WBB8SA6yxObTHA7vTpcsdbZ JXp+I75Xpl3P190HRpXPYag1kix9Jrc9XLgJ+doCKd7ZbND3ETaQrzSA2o1Tt2hTxHQlJVDoheIsD NvL+Zu1ZxPDihwuGBukUwmmM68UCcx9vGQ+5xr6bnB4EGOBK/UjHZ2d+Pwo+1ukpJHlIlf6D1xafv 4mU4wYtKdxVy/TxqJix68FZtrNYgFuA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dzi6v-00013Q-O7; Wed, 04 Oct 2017 11:45:09 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dzi6s-0000NJ-O6 for linux-arm-kernel@bombadil.infradead.org; Wed, 04 Oct 2017 11:45:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Date:Message-Id:In-Reply-To:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=SEU8mUYcvmx03p8CUpyiQIi9WnG9qmVtVvXrnuSCorg=; b=vq6k0suLzQf1gbFmvZoPRQgy0t fkB5Nw/K+7Ue8/LCjgd9gt1bcyshDQeVumDZIZYA9MHtj0ZLt7qIW0DwgK6UPvQxLMkB6YFhIz3UU v+nEmK8MLi8+w5JlS6tsPtbvhCcWVNDuEkdtsgEPYJdldOkH5gWy4XjSVCpPX3ADX8uARQTlxdpu7 7NLt8CKoFaSNscYCogC5QCNMYCEj/J5qY1BRCbIdkZ8VU3LGdbKtI5wNPkDXCzp/3LQ58WwMKSFdf ixeYxHDAQIkUWdH5H7HuPZUwgTvarrNJukrX5OJfjykXuhJcHwcWmLPKCjMtBhFClznMvLLEJUHzW MajtlxdA==; Received: from heliosphere.sirena.org.uk ([2a01:7e01::f03c:91ff:fed4:a3b6]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dzht2-0007DF-41 for linux-arm-kernel@lists.infradead.org; Wed, 04 Oct 2017 11:30:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=SEU8mUYcvmx03p8CUpyiQIi9WnG9qmVtVvXrnuSCorg=; b=D7AztcFugGpm fwF4ZS60oSomwKrjH4n5DF27aJz8S2L/HkDIQn63TfC7Q4JHa2+k5vYf5j3WVoC+4cReEV+ewsXiW Jr5+uGqpzuZ7rUNjJ/r/Itu2rbHnChBvycfkKgo2XEEmDlLFj0zWvoXiaWVQefDIa3ATTuSME8lM8 NdFHs=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1dzhrF-0006ZX-Ns; Wed, 04 Oct 2017 11:28:57 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1dzhrF-0004Tf-A0; Wed, 04 Oct 2017 12:28:57 +0100 From: Mark Brown To: Chen-Yu Tsai Subject: Applied "regmap: add iopoll-like polling macro for regmap_field" to the regmap tree In-Reply-To: <20170926065919.24446-9-wens@csie.org> Message-Id: Date: Wed, 04 Oct 2017 12:28:57 +0100 X-Bad-Reply: In-Reply-To but no 'Re:' in Subject. X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171004_123048_183338_F692F6F2 X-CRM114-Status: GOOD ( 21.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, David Airlie , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, Rob Herring , linux-sunxi@googlegroups.com, Mark Brown , dri-devel@lists.freedesktop.org, Maxime Ripard , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The patch regmap: add iopoll-like polling macro for regmap_field has been applied to the regmap tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 667063acb81931e2f8fd0cb91df9fcccad131d9a Mon Sep 17 00:00:00 2001 From: Chen-Yu Tsai Date: Fri, 29 Sep 2017 16:23:01 +0800 Subject: [PATCH] regmap: add iopoll-like polling macro for regmap_field This patch adds a macro regmap_field_read_poll_timeout that works similar to the readx_poll_timeout defined in linux/iopoll.h, except that this can also return the error value returned by a failed regmap_field_read. Signed-off-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- include/linux/regmap.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 978abfbac617..93a4663d7acb 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -139,6 +139,45 @@ struct reg_sequence { pollret ?: ((cond) ? 0 : -ETIMEDOUT); \ }) +/** + * regmap_field_read_poll_timeout - Poll until a condition is met or timeout + * + * @field: Regmap field to read from + * @val: Unsigned integer variable to read the value into + * @cond: Break condition (usually involving @val) + * @sleep_us: Maximum time to sleep between reads in us (0 + * tight-loops). Should be less than ~20ms since usleep_range + * is used (see Documentation/timers/timers-howto.txt). + * @timeout_us: Timeout in us, 0 means never timeout + * + * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_field_read + * error return value in case of a error read. In the two former cases, + * the last read value at @addr is stored in @val. Must not be called + * from atomic context if sleep_us or timeout_us are used. + * + * This is modelled after the readx_poll_timeout macros in linux/iopoll.h. + */ +#define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \ +({ \ + ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); \ + int pollret; \ + might_sleep_if(sleep_us); \ + for (;;) { \ + pollret = regmap_field_read((field), &(val)); \ + if (pollret) \ + break; \ + if (cond) \ + break; \ + if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \ + pollret = regmap_field_read((field), &(val)); \ + break; \ + } \ + if (sleep_us) \ + usleep_range((sleep_us >> 2) + 1, sleep_us); \ + } \ + pollret ?: ((cond) ? 0 : -ETIMEDOUT); \ +}) + #ifdef CONFIG_REGMAP enum regmap_endian {