From mboxrd@z Thu Jan 1 00:00:00 1970 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 B00DBC77B61 for ; Mon, 1 May 2023 03:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233081AbjEADO1 (ORCPT ); Sun, 30 Apr 2023 23:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232956AbjEADMk (ORCPT ); Sun, 30 Apr 2023 23:12:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC6FF2D58; Sun, 30 Apr 2023 20:04:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2BF9461137; Mon, 1 May 2023 03:04:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F23F9C4339B; Mon, 1 May 2023 03:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682910283; bh=KjgtbDCxzQ4M6up/uMs1fEi+aKQ1FBB5mGRllVZiH8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sOfk7lYQRlOR7vsjU7e5XS1tcjNst1JWVwvFskG5a24QcUTtZ1EJprzM4cm0zZjfP QA6A3AyHON4ESS574j7N3Yl1W8/Wdc20VxyTQ5NPNWCEmtJg/bpMYJNAZ7i8i0FV1d wTz/S6SlMO8dsQ/Cz7kbEd+6AF56pGCGFyPhbgKuLIaPzSSYdStN2AZuSHUfe7lUZj JAxlFBoxmBeYEnH+r0l9U2JQruKpwUd9/eVevB0gUTd+u0R5n55mPf/Lbb83JQIFl7 d71O5rt2kpbn8Ratvwq80z8XBLxTak+jpL8Sm/Paw2fX/JluRyXMz5xDNr6MLfqFt5 /wv2Sz7Ffc2fQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexander Stein , Mark Brown , Sasha Levin , gregkh@linuxfoundation.org Subject: [PATCH AUTOSEL 5.15 03/17] regmap: cache: Return error in cache sync operations for REGCACHE_NONE Date: Sun, 30 Apr 2023 23:04:20 -0400 Message-Id: <20230501030435.3254695-3-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501030435.3254695-1-sashal@kernel.org> References: <20230501030435.3254695-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alexander Stein [ Upstream commit fd883d79e4dcd2417c2b80756f22a2ff03b0f6e0 ] There is no sense in doing a cache sync on REGCACHE_NONE regmaps. Instead of panicking the kernel due to missing cache_ops, return an error to client driver. Signed-off-by: Alexander Stein Link: https://lore.kernel.org/r/20230313071812.13577-1-alexander.stein@ew.tq-group.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/base/regmap/regcache.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index f2469d3435ca3..0b517a83c4493 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -343,6 +343,9 @@ int regcache_sync(struct regmap *map) const char *name; bool bypass; + if (WARN_ON(map->cache_type == REGCACHE_NONE)) + return -EINVAL; + BUG_ON(!map->cache_ops); map->lock(map->lock_arg); @@ -412,6 +415,9 @@ int regcache_sync_region(struct regmap *map, unsigned int min, const char *name; bool bypass; + if (WARN_ON(map->cache_type == REGCACHE_NONE)) + return -EINVAL; + BUG_ON(!map->cache_ops); map->lock(map->lock_arg); -- 2.39.2