From nobody Sat Feb 7 21:24:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F54F2236E1 for ; Fri, 31 Oct 2025 08:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897949; cv=none; b=bDhWAa0wpYl8Y8BVLh6RQR0pJ+ms3nebPrm+nk5J4gnJbde5XMc5SDhYybdYM5gCaYWn783ti7R7GWAD/l1+WR5cC8cq5+cMDeGmEIwRTxqq5zElbvphhHWR0PsPcOCKI6JBokJBm1kygEilpxt76LMEjZwPSgVZ+rUN87it6rA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897949; c=relaxed/simple; bh=5BDc6KcSVzzM4URCYJVmlaEuRLHbvFkYpGfq3+8BKJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oGZzKNS4kZWPMHwpGIyurRKe0EhYzocrT5UTTFm/A8/1bcWfDQyV81bgzFVZHZ5k/UaXO9EoMaIEh5aEiE4P2dfpEkHO9EA8rN+ZIkGdzWbkyo1JQCtWW0qW4TmCQIJlFscbmn+aHKA3H/NaRhRjqD/+iWOoCXzdH20AdNtzwd4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RfZ4NeJq; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RfZ4NeJq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761897949; x=1793433949; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5BDc6KcSVzzM4URCYJVmlaEuRLHbvFkYpGfq3+8BKJM=; b=RfZ4NeJqanZEs/bNX9ama/e0ukm8D8XciKQsfTgfIFBh3uOBsrOJNaH8 bcMnIt+Tne61oYGnPdoaTyeMjyyJDjEyN+6zmFdwB5SW1J/Vu9xVEiO1v we266gOwcX1F0Xkqn3riMFZsdiFt00jwtWyDH7vniTrB+0G05s8ivNCPa hsg+FBa1FUTCLcmdPYDwoz/GCmhnf5Qz2uJwcgp3gHLvoEBTqJPshYxke eg8xz+Q2Lo4H3AoYXvPU0cJeVbqQV2wBmdKP6SBGwcH+ppWSzci5Xdw4F 06HxBTjJlmpaGj0abQDUKrtXPBdnb8XlIy7XYJsJAJ4esAkSvyKz3X7cK w==; X-CSE-ConnectionGUID: FrnZ/rg5RPOkP3GqmGOA2A== X-CSE-MsgGUID: LEQw6cTiQ7iJKHYYYyA/CA== X-IronPort-AV: E=McAfee;i="6800,10657,11531"; a="67888891" X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="67888891" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2025 01:05:46 -0700 X-CSE-ConnectionGUID: o1JGxKJIQQamQoQ73fzQwA== X-CSE-MsgGUID: a7Ij78lpQMiV8ri8NRXAlw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="191320283" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa004.fm.intel.com with ESMTP; 31 Oct 2025 01:05:43 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 96CB696; Fri, 31 Oct 2025 09:05:41 +0100 (CET) From: Andy Shevchenko To: Mark Brown , Christophe JAILLET , Sander Vanheule , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Subject: [PATCH v3 1/5] regcache: Add ->populate() callback to separate from ->init() Date: Fri, 31 Oct 2025 09:03:16 +0100 Message-ID: <20251031080540.3970776-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> References: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the future changes we would like to change the flow of the cache handlin= g. Add ->populate() callback in order to prepare for that. Signed-off-by: Andy Shevchenko Reviewed-by: Charles Keepax --- drivers/base/regmap/internal.h | 1 + drivers/base/regmap/regcache.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 8d19a1414d5b..1477329410ec 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@ -186,6 +186,7 @@ struct regcache_ops { enum regcache_type type; int (*init)(struct regmap *map); int (*exit)(struct regmap *map); + int (*populate)(struct regmap *map); #ifdef CONFIG_DEBUG_FS void (*debugfs_init)(struct regmap *map); #endif diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 0392f5525cf3..319c342bf5a0 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -222,8 +222,24 @@ int regcache_init(struct regmap *map, const struct reg= map_config *config) if (ret) goto err_free; } + + if (map->num_reg_defaults && map->cache_ops->populate) { + dev_dbg(map->dev, "Populating %s cache\n", map->cache_ops->name); + map->lock(map->lock_arg); + ret =3D map->cache_ops->populate(map); + map->unlock(map->lock_arg); + if (ret) + goto err_exit; + } return 0; =20 +err_exit: + if (map->cache_ops->exit) { + dev_dbg(map->dev, "Destroying %s cache\n", map->cache_ops->name); + map->lock(map->lock_arg); + ret =3D map->cache_ops->exit(map); + map->unlock(map->lock_arg); + } err_free: kfree(map->reg_defaults); if (map->cache_free) --=20 2.50.1 From nobody Sat Feb 7 21:24:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD4D2285C8C for ; Fri, 31 Oct 2025 08:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897946; cv=none; b=LYQmKuu9QozRIjdowqiOeAuBcmy+HUxWwz68YsUlvMmcuGuxMQhcsvcOqDM7K4mCK/Q8KluDgH7DiDfiz42CRRE6SIQ2O9L59fEwPrr3Xk9RVj9dn7zmxAvMBvW3R8skBOaUJZThgHo9Tg2jKxeV7Qhtk4p4BVQvq3dCN2KdKUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897946; c=relaxed/simple; bh=Kbe9y64hXWiuWxkOATu9oioQHRlr3eUQs/jSR4V/4vI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BZoyIUJwPhAs8UlItdtEe9thdvONmhd2mT4jSH7LZEZsgrs4OA4SGgJhL9p/GR01Y8+0ifhhbvx6Pf9En9vk2TyqbAg1osRulBn1b2DrS185MHH6U46Pm9hWtVkSuWIIiCzCFNew5SKsnEw0ID+nqKHZrR6x4WV5MS5Z3sQ5L+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hVFe66uN; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hVFe66uN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761897945; x=1793433945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kbe9y64hXWiuWxkOATu9oioQHRlr3eUQs/jSR4V/4vI=; b=hVFe66uNVSe4ioe6BnUOTUIG9xys9SFd06YwOX2vVM3EYrbIg5i6I1T6 tQFz0FSnbqT5aarYfc01IUEX+LVOH7kr5J8/r7dB57ofvBwvTh05B2byQ z7XLeXVyToUR6ASbRbfLgc06Zbz8PSuKtm1iFo0/W7++61iIYLZih1bwP 5zvK1LMoTF2p5TLCsZd/EiRP1d6+Zzq1qHOrY2zmreOsipo85UH6d6n2a 7pH1T39R4FvgV02zumbDbz7QpWm8C/VbDMhgyOzIjNGaIBBd103N69J7p HuFBgh81gx0wJNLklYS5gq6vnNu63V6UcRvQRkdkRNb0zasyHJTNWBfMu A==; X-CSE-ConnectionGUID: FLi74X7SRG+J2cMlfTuH2Q== X-CSE-MsgGUID: xY/gQuxrRRWWYQiPzUE1wg== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="75503182" X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="75503182" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2025 01:05:44 -0700 X-CSE-ConnectionGUID: HMy6gP6mThOoTurDAk3reA== X-CSE-MsgGUID: ZAHVhraOQ1mTEqIhPkGP/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="217010409" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa001.fm.intel.com with ESMTP; 31 Oct 2025 01:05:42 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 9B2E597; Fri, 31 Oct 2025 09:05:41 +0100 (CET) From: Andy Shevchenko To: Mark Brown , Christophe JAILLET , Sander Vanheule , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Subject: [PATCH v3 2/5] regcache: rbtree: Split ->populate() from ->init() Date: Fri, 31 Oct 2025 09:03:17 +0100 Message-ID: <20251031080540.3970776-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> References: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Split ->populate() implementation from ->init() code. This decoupling will help for the further changes. Signed-off-by: Andy Shevchenko Reviewed-by: Charles Keepax --- drivers/base/regmap/regcache-rbtree.c | 31 +++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/re= gcache-rbtree.c index a9d17f316e55..3344b82c3799 100644 --- a/drivers/base/regmap/regcache-rbtree.c +++ b/drivers/base/regmap/regcache-rbtree.c @@ -184,8 +184,6 @@ static void rbtree_debugfs_init(struct regmap *map) static int regcache_rbtree_init(struct regmap *map) { struct regcache_rbtree_ctx *rbtree_ctx; - int i; - int ret; =20 map->cache =3D kmalloc(sizeof *rbtree_ctx, map->alloc_flags); if (!map->cache) @@ -195,19 +193,7 @@ static int regcache_rbtree_init(struct regmap *map) rbtree_ctx->root =3D RB_ROOT; rbtree_ctx->cached_rbnode =3D NULL; =20 - for (i =3D 0; i < map->num_reg_defaults; i++) { - ret =3D regcache_rbtree_write(map, - map->reg_defaults[i].reg, - map->reg_defaults[i].def); - if (ret) - goto err; - } - return 0; - -err: - regcache_rbtree_exit(map); - return ret; } =20 static int regcache_rbtree_exit(struct regmap *map) @@ -239,6 +225,22 @@ static int regcache_rbtree_exit(struct regmap *map) return 0; } =20 +static int regcache_rbtree_populate(struct regmap *map) +{ + unsigned int i; + int ret; + + for (i =3D 0; i < map->num_reg_defaults; i++) { + ret =3D regcache_rbtree_write(map, + map->reg_defaults[i].reg, + map->reg_defaults[i].def); + if (ret) + return ret; + } + + return 0; +} + static int regcache_rbtree_read(struct regmap *map, unsigned int reg, unsigned int *value) { @@ -546,6 +548,7 @@ struct regcache_ops regcache_rbtree_ops =3D { .name =3D "rbtree", .init =3D regcache_rbtree_init, .exit =3D regcache_rbtree_exit, + .populate =3D regcache_rbtree_populate, #ifdef CONFIG_DEBUG_FS .debugfs_init =3D rbtree_debugfs_init, #endif --=20 2.50.1 From nobody Sat Feb 7 21:24:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CBD632D0C8 for ; Fri, 31 Oct 2025 08:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897946; cv=none; b=GdcXHheK1416TJl3aezAGNfLc5ybXotr0EulBN9SAZC6xdSY0DaIGatPbM7VtcS8HfObxkZiHHqyAVBeNT9lM/NxV9BFSKZXOQlwn1Yd1YOLLKbrnZqxbr2W2UWB9TJnrJyjg+khpS0Nm+/xYIyZPG8Gy+lmnRpdUyS50XzTBuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897946; c=relaxed/simple; bh=zHK079r4HYzsWM60ko/wEtpRjo7ot642qsjYLA51hhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jjcKHOY9A1MhCQHXCyfuZLvpgf2BOmdsErEGhyGqb9O0uhahMT5dSOCuhnhjaP4DBUbdP85YW4Hd7MlJK7vMXGg2ZctK3DJ7Qcg0xOcro8fa+RcXwB+cYYmu638PrTSdN6JnhY8xpr62okZddvsiBOx76P4Og0lKeAu+15FEwo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QcKjUrcV; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QcKjUrcV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761897945; x=1793433945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zHK079r4HYzsWM60ko/wEtpRjo7ot642qsjYLA51hhE=; b=QcKjUrcVBQXwfC6MrcGcVOFOxmic8o53KzJd9iHv8BuVtsV5vIqfpDft kbRFCPF31uyOZr8iifSLWlkxnTAJjNZIoQozXqOs0unK7iys1WA/7ryER cpWTBEx2jtFZByGGQUUqQDkzvqCfj9zLzI38EWvzL5rMP3ZYn6OH0HUkg KE/cS1Wb9jRxo26J9VIBqY2+SOXOoEYmu9IYSW9syHy2zL781ULYbO5bh rUSJ9dqtarqZYspdHXlslzXPWiyLI2efPZQDQQ8UAzi0AtqZTIoZWimla AkDx78aJ3L/uEnqYUoDRo81ZzopHCzi3gAOGUj1QP9bHJ7NxOw6NnqTuj A==; X-CSE-ConnectionGUID: vxjvuWMJRhWS0nOcPT0Awg== X-CSE-MsgGUID: T1lAXg3hQqiondIxM6r4xQ== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="74345309" X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="74345309" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2025 01:05:44 -0700 X-CSE-ConnectionGUID: COtXOfhVTvWfWx+x49L5cA== X-CSE-MsgGUID: nKagEXMBR+yQDuGd1zvbIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="186288942" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa008.jf.intel.com with ESMTP; 31 Oct 2025 01:05:43 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 9FDB498; Fri, 31 Oct 2025 09:05:41 +0100 (CET) From: Andy Shevchenko To: Mark Brown , Christophe JAILLET , Sander Vanheule , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Subject: [PATCH v3 3/5] regcache: flat: Remove unneeded check and error message for -ENOMEM Date: Fri, 31 Oct 2025 09:03:18 +0100 Message-ID: <20251031080540.3970776-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> References: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a convention in the kernel to avoid error messages in the cases of -ENOMEM errors. Besides that, the idea behind using struct_size() and other macros from overflow.h is to saturate the size that the following allocation call will definitely fail, hence the check and the error messaging added in regcache_flat_init() are redundant. Remove them. Acked-by: Sander Vanheule Signed-off-by: Andy Shevchenko Reviewed-by: Charles Keepax --- drivers/base/regmap/regcache-flat.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regc= ache-flat.c index 3b9235bb8313..bacb7137092f 100644 --- a/drivers/base/regmap/regcache-flat.c +++ b/drivers/base/regmap/regcache-flat.c @@ -30,7 +30,6 @@ struct regcache_flat_data { static int regcache_flat_init(struct regmap *map) { int i; - size_t cache_data_size; unsigned int cache_size; struct regcache_flat_data *cache; =20 @@ -38,14 +37,7 @@ static int regcache_flat_init(struct regmap *map) return -EINVAL; =20 cache_size =3D regcache_flat_get_index(map, map->max_register) + 1; - cache_data_size =3D struct_size(cache, data, cache_size); - - if (cache_data_size =3D=3D SIZE_MAX) { - dev_err(map->dev, "cannot allocate regmap cache"); - return -ENOMEM; - } - - cache =3D kzalloc(cache_data_size, map->alloc_flags); + cache =3D kzalloc(struct_size(cache, data, cache_size), map->alloc_flags); if (!cache) return -ENOMEM; =20 --=20 2.50.1 From nobody Sat Feb 7 21:24:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CA7F17E4 for ; Fri, 31 Oct 2025 08:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897946; cv=none; b=WiIjkKWc/h00nj4JV23BUTI1mtdvsGpwizNiRexsT+2SyoTi4NMmOO8q9lNjeXvMnMZ2BLSppxSkG7GTgjfE5Yo/it8fWqmfCGDZN27ZiuIOrrvmbUr102aT/aocNIcYX2tZ+aVvAIbUB/UrbwcJpfrenPnv1BgwKguXBjiXxQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897946; c=relaxed/simple; bh=p0TML9FLbpbHRHWAs71KOwBosv3+hC/P9zEcIKgeCk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bpznductDq+AiTtfbrn96w+SI4D/l1zfn8fNCC8fqEUDzw8lP+mcifF7G8vFY9pb7ZVvWHCuhc7CrW5fe0Q4p2vgkHp4TKU5J0VsZJhGSUl7LkvrSbRECsntFL95FucP2u9eKpyYzWKvK8Q90xpVhWnb17lfRtUr4EDlUr84M1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lT21J+Cd; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lT21J+Cd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761897945; x=1793433945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p0TML9FLbpbHRHWAs71KOwBosv3+hC/P9zEcIKgeCk0=; b=lT21J+Cd1OVIHt14MGVkVBzHhqFj6QMQrLamPQCE8yDN9bhl/K2RwtQW brTOpfIN9ITOIgoBBTOKFaCAWk8jFmDxxWuqGtLsVGwaJOGDc7f/6Nv0D stgyVR73MobQEz6N8JEMVCusl58K9jlDsiynP9sLqv0es4UFfn1p1NAXP QgN/0bqH54e0z0w35riAAdLGnIuhNt+GQnE8Kl5NHByrS4dC108qJjN0q EL2yunUtn4Lh/mq78SEMVM7N49CA3hvHbp0Ze0IZVj2fGB/ba82ZDST2a EbIWcXc1oicmEuPTi67mSI6Ozd0zBBTUG+bT9D0D37YWSwM4o/AFO9VyB Q==; X-CSE-ConnectionGUID: yBS0RKw4Td2Kv3AG/7qDSQ== X-CSE-MsgGUID: N3QciobqTlaWKFe3qQqDkg== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="63939057" X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="63939057" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2025 01:05:44 -0700 X-CSE-ConnectionGUID: A0RqXhG1QeagOqmIaKZgmg== X-CSE-MsgGUID: Ny/A/36HTDO2/2uSCjgizw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="190254451" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa003.jf.intel.com with ESMTP; 31 Oct 2025 01:05:42 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id A400599; Fri, 31 Oct 2025 09:05:41 +0100 (CET) From: Andy Shevchenko To: Mark Brown , Christophe JAILLET , Sander Vanheule , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Subject: [PATCH v3 4/5] regcache: flat: Split ->populate() from ->init() Date: Fri, 31 Oct 2025 09:03:19 +0100 Message-ID: <20251031080540.3970776-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> References: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Split ->populate() implementation from ->init() code. This decoupling will help for the further changes. Signed-off-by: Andy Shevchenko Reviewed-by: Charles Keepax --- drivers/base/regmap/regcache-flat.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regc= ache-flat.c index bacb7137092f..53cc59c84e2f 100644 --- a/drivers/base/regmap/regcache-flat.c +++ b/drivers/base/regmap/regcache-flat.c @@ -29,7 +29,6 @@ struct regcache_flat_data { =20 static int regcache_flat_init(struct regmap *map) { - int i; unsigned int cache_size; struct regcache_flat_data *cache; =20 @@ -47,14 +46,6 @@ static int regcache_flat_init(struct regmap *map) =20 map->cache =3D cache; =20 - for (i =3D 0; i < map->num_reg_defaults; i++) { - unsigned int reg =3D map->reg_defaults[i].reg; - unsigned int index =3D regcache_flat_get_index(map, reg); - - cache->data[index] =3D map->reg_defaults[i].def; - __set_bit(index, cache->valid); - } - return 0; =20 err_free: @@ -75,6 +66,22 @@ static int regcache_flat_exit(struct regmap *map) return 0; } =20 +static int regcache_flat_populate(struct regmap *map) +{ + struct regcache_flat_data *cache =3D map->cache; + unsigned int i; + + for (i =3D 0; i < map->num_reg_defaults; i++) { + unsigned int reg =3D map->reg_defaults[i].reg; + unsigned int index =3D regcache_flat_get_index(map, reg); + + cache->data[index] =3D map->reg_defaults[i].def; + __set_bit(index, cache->valid); + } + + return 0; +} + static int regcache_flat_read(struct regmap *map, unsigned int reg, unsigned int *value) { @@ -134,6 +141,7 @@ struct regcache_ops regcache_flat_ops =3D { .name =3D "flat", .init =3D regcache_flat_init, .exit =3D regcache_flat_exit, + .populate =3D regcache_flat_populate, .read =3D regcache_flat_read, .write =3D regcache_flat_write, }; @@ -143,6 +151,7 @@ struct regcache_ops regcache_flat_sparse_ops =3D { .name =3D "flat-sparse", .init =3D regcache_flat_init, .exit =3D regcache_flat_exit, + .populate =3D regcache_flat_populate, .read =3D regcache_flat_sparse_read, .write =3D regcache_flat_write, .drop =3D regcache_flat_drop, --=20 2.50.1 From nobody Sat Feb 7 21:24:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C535132ED24 for ; Fri, 31 Oct 2025 08:05:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897948; cv=none; b=pCKQkK5+dFLLYdtCJlWnvL4Kcipq6iTX1Bi6dKmje3xcTIUZtZ3iwz50FNUsqr8Zo9MdoAsSFiAVaeJaq1DQBSVAL4gIjFNKFv0v2LKnSMtvNPdjx+ZjJdUCU3tmtGBVIxcU98rG2rzc6d0ebkZmBsFuzmmD30s4k78Tm0Aa4N4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897948; c=relaxed/simple; bh=spUqVFANeu6zA5mqKFPkIzzbgdNgivsG0RxjQcBExq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MwDZOqur1tLJfqfUM0AP44UN97Z9tkSUBJMj8BSMJPpbtlAPdXXFszsPdUbkOHllR9b5n5bt+/PdRHJt6ywBUjrV2mGsQyxAU6icWCrL8qTtd+2YgHmj1HqRIuvkvusvAhvggXVHf1jAV8OVOJJ1VgVz+/SVPtDuzY+ZWC7CtG4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EhwqZzL4; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EhwqZzL4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761897947; x=1793433947; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=spUqVFANeu6zA5mqKFPkIzzbgdNgivsG0RxjQcBExq4=; b=EhwqZzL4rPw6uA9RaVWYPz8w//7kHB4mpJMiyPM469oTDH+efXf/gXQs uC61qZW8rrdjqpPmI0HCHVJRnkxArycWh5YOVsqtYdq8XvMHNQS717lm1 GT7d3d+vPenYwBLLcWw+SHn+bqw+SLsjzNlmFqXskKMnd0V2WeTBVf63j Q2CfLv+Nrh1afUWYm5Jsdyxfrg321VU1etuLhXdj9ZZVk+Fc1JWOuyR7G lzE3ANCbgAK3t3e0ONkCvQNDcu7hcDb9fy25CgtTNwKxfmrP8Hx0y/WDe S+TlGDinpR3zQwQYcoPmTEo/fVwaLOXz/do6QU19AvfmYE8ZPR1wUOKyL g==; X-CSE-ConnectionGUID: 3s1tbHxLRQOjqDhf/Rzeng== X-CSE-MsgGUID: mUOInZvKQfWDXf1yV/YPxw== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="75503186" X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="75503186" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2025 01:05:47 -0700 X-CSE-ConnectionGUID: 9HtADjhIR/q20v4VSLKXUw== X-CSE-MsgGUID: ZFhhlHvuSUC6p+w0M31Byg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,268,1754982000"; d="scan'208";a="216828328" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa002.jf.intel.com with ESMTP; 31 Oct 2025 01:05:45 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id A82D19A; Fri, 31 Oct 2025 09:05:41 +0100 (CET) From: Andy Shevchenko To: Mark Brown , Christophe JAILLET , Sander Vanheule , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Subject: [PATCH v3 5/5] regcache: maple: Split ->populate() from ->init() Date: Fri, 31 Oct 2025 09:03:20 +0100 Message-ID: <20251031080540.3970776-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> References: <20251031080540.3970776-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Split ->populate() implementation from ->init() code. This decoupling will help for the further changes. Signed-off-by: Andy Shevchenko Reviewed-by: Charles Keepax --- drivers/base/regmap/regcache-maple.c | 47 +++++++++++++--------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/reg= cache-maple.c index 2319c30283a6..ca1c72b68f31 100644 --- a/drivers/base/regmap/regcache-maple.c +++ b/drivers/base/regmap/regcache-maple.c @@ -289,6 +289,23 @@ static int regcache_maple_sync(struct regmap *map, uns= igned int min, return ret; } =20 +static int regcache_maple_init(struct regmap *map) +{ + struct maple_tree *mt; + + mt =3D kmalloc(sizeof(*mt), map->alloc_flags); + if (!mt) + return -ENOMEM; + map->cache =3D mt; + + mt_init(mt); + + if (!mt_external_lock(mt) && map->lock_key) + lockdep_set_class_and_subclass(&mt->ma_lock, map->lock_key, 1); + + return 0; +} + static int regcache_maple_exit(struct regmap *map) { struct maple_tree *mt =3D map->cache; @@ -340,26 +357,12 @@ static int regcache_maple_insert_block(struct regmap = *map, int first, return ret; } =20 -static int regcache_maple_init(struct regmap *map) +static int regcache_maple_populate(struct regmap *map) { - struct maple_tree *mt; int i; int ret; int range_start; =20 - mt =3D kmalloc(sizeof(*mt), map->alloc_flags); - if (!mt) - return -ENOMEM; - map->cache =3D mt; - - mt_init(mt); - - if (!mt_external_lock(mt) && map->lock_key) - lockdep_set_class_and_subclass(&mt->ma_lock, map->lock_key, 1); - - if (!map->num_reg_defaults) - return 0; - range_start =3D 0; =20 /* Scan for ranges of contiguous registers */ @@ -369,23 +372,14 @@ static int regcache_maple_init(struct regmap *map) ret =3D regcache_maple_insert_block(map, range_start, i - 1); if (ret !=3D 0) - goto err; + return ret; =20 range_start =3D i; } } =20 /* Add the last block */ - ret =3D regcache_maple_insert_block(map, range_start, - map->num_reg_defaults - 1); - if (ret !=3D 0) - goto err; - - return 0; - -err: - regcache_maple_exit(map); - return ret; + return regcache_maple_insert_block(map, range_start, map->num_reg_default= s - 1); } =20 struct regcache_ops regcache_maple_ops =3D { @@ -393,6 +387,7 @@ struct regcache_ops regcache_maple_ops =3D { .name =3D "maple", .init =3D regcache_maple_init, .exit =3D regcache_maple_exit, + .populate =3D regcache_maple_populate, .read =3D regcache_maple_read, .write =3D regcache_maple_write, .drop =3D regcache_maple_drop, --=20 2.50.1