Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp314989pxy; Fri, 30 Apr 2021 06:10:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy94oX5EKP0wj43JD0YFD8NmFonW9hPSw+uQVsinsBwMXK2NzQ6OQPb52kdqpvYfXOhmna4 X-Received: by 2002:a05:6402:26ce:: with SMTP id x14mr175878edd.216.1619788202152; Fri, 30 Apr 2021 06:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619788202; cv=none; d=google.com; s=arc-20160816; b=Se+GFchqsARDeuCTsU+HmHifa7u+bKh9F45eH8dEwMEfA5uSETEziboL8b4azzd+Uk EITUleVqcHqS5J370xj941jJC9QfGfg3nTcfRffPbb0CT/3A6MQsN1pvUeUxA3MiC1nw yXFDBn8vhXGKpDZUm8V4AUXEQlR7GYdxKogs+bpFoEgFfLqJ3QynsvCJt1hvse0KKG5L oJgklGwMw0/21QrohGd60yLpM0zahOXL7ONjwJTfoCIXn4aHWev19+GoQQWM7cjk7U5Y xTjld2aqiLDw1fqA++Zi/sdOLmjB7sCYi8wkO+YNoXEb85xZVGZbXeavNG+BI8xG13vg lDDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zC0r0cckX9eIpVeHFu6739oEE90Di2YevbPicKD2pSg=; b=FrzYFDbA0V82AM7koN7ZUf9l28weDc5+6GLOsxaaHwfe0aBRGVzH8uak7GA0Hf8Php V5CUEbX4I9rGZ3SMhAHNioKBcejPJypkU8pNF8OxuCQJObALLwyf++UK/XhbeJTDGLDk gIFm0nf0Akx/9RtcWkj5vEgvNGY7BiMjY/3Hmpv55CL4iegIWYRdXgQTUUyrD+NSRQ4S SiQzvLCsy8/btCqnO4vgrdDpJDFVZIUQr+s07zKLpF5d+pGwL/3V2wrr9SC0up9qZDV3 8XnKavDL/48UxoqUyCdWEt6wmfgSC8Ug3I5Rk1mzmdEae66zlkWfjO18pfpwcd36vZ+7 QGAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=TU6IwpCB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si3106218ejy.218.2021.04.30.06.09.38; Fri, 30 Apr 2021 06:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=TU6IwpCB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232295AbhD3NHp (ORCPT + 99 others); Fri, 30 Apr 2021 09:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbhD3NHm (ORCPT ); Fri, 30 Apr 2021 09:07:42 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F115FC06174A; Fri, 30 Apr 2021 06:06:53 -0700 (PDT) Received: from mwalle01.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:fa59:71ff:fe9b:b851]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id A99472224F; Fri, 30 Apr 2021 15:06:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1619788011; 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=zC0r0cckX9eIpVeHFu6739oEE90Di2YevbPicKD2pSg=; b=TU6IwpCBl3tGzLfBPAmgBNQIYA9N5c+K6JqFeqxjc0g3pFDq/0HGHUKmj86cvqLs6yTOk3 w3RYC2I6Mh4lHCRdaTgtDKx27OI+gGMTt+/oGXtvX1uj91YXbC6DJ/7RqE+OUE126gWuIu 76NSs52gBhJ/jYaemAknXEX8Ij5FhzM= From: Michael Walle To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Michael Walle Subject: [PATCH 1/2] regmap: add regmap_might_sleep() Date: Fri, 30 Apr 2021 15:06:44 +0200 Message-Id: <20210430130645.31562-1-michael@walle.cc> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sometimes a driver needs to know if the underlying regmap could sleep. For example, consider the gpio-regmap driver which needs to fill the gpiochip->can_sleep property. It might be possible to pass this information via the gpio_regmap_config, but this has the following drawbacks. First, that property is redundant and both places might contratict each other. And secondly, the driver might not even know the type of the regmap because it just gets an opaque pointer by querying the device tree. Signed-off-by: Michael Walle --- drivers/base/regmap/regmap.c | 11 +++++++++++ include/linux/regmap.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 297e95be25b3..f0661ff6bdcf 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1847,6 +1847,17 @@ size_t regmap_get_raw_write_max(struct regmap *map) } EXPORT_SYMBOL_GPL(regmap_get_raw_write_max); +/** + * regmap_might_sleep - Returns whether a regmap access might sleep. + * + * @map: Map to check. + */ +bool regmap_might_sleep(struct regmap *map) +{ + return map->can_sleep; +} +EXPORT_SYMBOL_GPL(regmap_might_sleep); + static int _regmap_bus_formatted_write(void *context, unsigned int reg, unsigned int val) { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index f87a11a5cc4a..955fbe61557a 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1079,6 +1079,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config); struct regmap *dev_get_regmap(struct device *dev, const char *name); struct device *regmap_get_device(struct regmap *map); +bool regmap_might_sleep(struct regmap *map); int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val); int regmap_raw_write(struct regmap *map, unsigned int reg, @@ -1816,6 +1817,12 @@ static inline struct device *regmap_get_device(struct regmap *map) return NULL; } +static inline bool regmap_might_sleep(struct regmap *map) +{ + WARN_ONCE(1, "regmap API is disabled"); + return true; +} + #endif #endif -- 2.20.1