From patchwork Mon Nov 21 15:08:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 627385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7760DC4332F for ; Mon, 21 Nov 2022 15:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232016AbiKUPOr (ORCPT ); Mon, 21 Nov 2022 10:14:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiKUPOI (ORCPT ); Mon, 21 Nov 2022 10:14:08 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40B3DCFA73; Mon, 21 Nov 2022 07:08:56 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 25C74230D; Mon, 21 Nov 2022 16:08:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669043334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ShPOxC+vc6kAIrStj2HW/8mEr6+lT3FK4X9HcTeMoPg=; b=IlQZyAYQe3hDv2l9ZeBmKXQKfgyanqyB4reG447B/lnDD+KEp2prY3rs7NN6MBwQIZTujf 4+k0EtLtEjuLyHIlA84BP6Ljkw16yvuRd9bND2jqLLJyRiBWvUQGZHOxysCJy/6a0ZtZHn h4c2PbqpQthoCw+pX/ds8ufPoZNFnDDk8IGlURzWFyaogGzIhbYHbC3jFwEDWC4YLeM8oo JMSWuUjWARbv2CwwG5kuGfSbHMzROgcEP4UtO5bB4BoeCIHPtDyfiNOe5V9qIueDN9uUnO R3o3R0RWAh1nGrifXKUVI+aGoHu5c+vJ7YXmMdI254Lu8qqqNMm0xRpdGDqv7g== From: Michael Walle To: Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" , Linus Walleij , Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, William Breathitt Gray , Michael Walle Subject: [PATCH 1/2] regmap: add regmap_might_sleep() Date: Mon, 21 Nov 2022 16:08:42 +0100 Message-Id: <20221121150843.1562603-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org With the dawn of MMIO gpio-regmap users, it is desirable to let gpio-regmap ask the regmap if it might sleep during an access so it can pass that information to gpiochip. Add a new regmap_might_sleep() to query the regmap. Signed-off-by: Michael Walle --- drivers/base/regmap/regmap.c | 13 +++++++++++++ include/linux/regmap.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index c6d6d53e8cd3..d12d669157f2 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -3486,6 +3486,19 @@ int regmap_get_reg_stride(struct regmap *map) } EXPORT_SYMBOL_GPL(regmap_get_reg_stride); +/** + * regmap_might_sleep() - Returns whether a regmap access might sleep. + * + * @map: Register map to operate on. + * + * Returns true if an access to the register might sleep, else false. + */ +bool regmap_might_sleep(struct regmap *map) +{ + return map->can_sleep; +} +EXPORT_SYMBOL_GPL(regmap_might_sleep); + int regmap_parse_val(struct regmap *map, const void *buf, unsigned int *val) { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index ca3434dca3a0..3faf5d5dbb26 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1219,6 +1219,7 @@ static inline int regmap_write_bits(struct regmap *map, unsigned int reg, int regmap_get_val_bytes(struct regmap *map); int regmap_get_max_register(struct regmap *map); int regmap_get_reg_stride(struct regmap *map); +bool regmap_might_sleep(struct regmap *map); int regmap_async_complete(struct regmap *map); bool regmap_can_raw_write(struct regmap *map); size_t regmap_get_raw_read_max(struct regmap *map); @@ -1905,6 +1906,12 @@ static inline int regmap_get_reg_stride(struct regmap *map) return -EINVAL; } +static inline bool regmap_might_sleep(struct regmap *map) +{ + WARN_ONCE(1, "regmap API is disabled"); + return true; +} + static inline int regcache_sync(struct regmap *map) { WARN_ONCE(1, "regmap API is disabled");