From nobody Sun Feb 8 11:26:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 B3B9F36B972 for ; Thu, 30 Oct 2025 17:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845962; cv=none; b=Pv+eKmVqz7xU01F5Hy+NQtWX6gxe5leFn78De+cfIEIEk/sByFZvoWnQBMXnA/OzPhSDhJIgaetRTveY55UgdPOb3Cv29BZOlUQ7sm+6pL4EiXjypNkNLT67Iw7gQ4wo98AJFIRJMNea0NyeQjDGCX+7rkSgnmcx0nBgmjCmikM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845962; c=relaxed/simple; bh=5BDc6KcSVzzM4URCYJVmlaEuRLHbvFkYpGfq3+8BKJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aNPZ5LLoC0eEd51j7KR6VBTLXicStzY0yTDIv8ZE9wOdEgiFFjCmPevOg/0yFGAF/WBGPdCCzfhEOvrG0ygRlArlN3jhnjNOm2xtj5dInUxuExlzt1vuqyH8L0TGHb1ycjq8FkbmtM2cmzHng+A7yI/TKC/GUtuAHEZM4SYcSJY= 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=F7hwiSLr; arc=none smtp.client-ip=192.198.163.10 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="F7hwiSLr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761845959; x=1793381959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5BDc6KcSVzzM4URCYJVmlaEuRLHbvFkYpGfq3+8BKJM=; b=F7hwiSLryq2XqKj1ZJdLYTZh5gvXfJQ2j/pZvqcU+if5X4WdzLMvGd9u cfJEbRUc9H438ZvkWSkCamtwS5I3FAo+M0Itz4HOfZHyRALnkRqE82uk0 vcadLkXmQHOV8r1a9Pu/OfawB1vFHvfypYohCmldpDsAd8CXsyRP385Gm p3Tj0mCzY5kDQ0JIiBi3VwdOZIiqIRQWwSYWd5LknMQI516r3kQEyWUpZ tQzSapptGY2OFt4MUucExvl/K5MuCe9xbzGhtaO/qpZf1X6qXc/yQNjHe QjI0Xy7HaRicMlzlc8EgXL4E0GdaHh4yCwKHmdxwaHkmrn54lOGB2R4oJ Q==; X-CSE-ConnectionGUID: /R3YbbniTeiZ0CYQhWqGDA== X-CSE-MsgGUID: we+TuCXkTa2ZdGG+pdAdeA== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="75345921" X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="75345921" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 10:39:19 -0700 X-CSE-ConnectionGUID: KtDE4tdeQrys1RMOIkaF7A== X-CSE-MsgGUID: Aq9qppV4T46bD854lFsMBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="185224750" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa006.jf.intel.com with ESMTP; 30 Oct 2025 10:39:17 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 6437D96; Thu, 30 Oct 2025 18:39:16 +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 v2 1/5] regcache: Add ->populate() callback to separate from ->init() Date: Thu, 30 Oct 2025 18:37:01 +0100 Message-ID: <20251030173915.3886882-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251030173915.3886882-1-andriy.shevchenko@linux.intel.com> References: <20251030173915.3886882-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 --- 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 Sun Feb 8 11:26:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 532BF368F2A for ; Thu, 30 Oct 2025 17:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845961; cv=none; b=CqWEUY2eqxttdgTa3R+0GxXPVnHNhy/Zmz+ai8iX3xJ/yLiqZYiYztSF+Dyp9SqD6UPZg4Qz0qdX5TonWVfR7mCSAtQyBJ37CyNs8/qFxBQRUMJduRpvKCL8Ke2eWT8+4QV0r1yVwc90s1yEKYi7Mrnmb09O+oWLrygdekD43h8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845961; c=relaxed/simple; bh=64hz6eN9wMTQb/u5lIj1gRNc79dS5LgF6HqMkkNo/mw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=brLehFI+cBA8HazTJOzDnhChcL+yxTuLGP5ttbQEGCdmX1TrP4jMZJ3fBHGAv4WgZ9wKwEsnhBAdqTLpMNNMo7mRXbEK9hWDL2j4IlHrvg/PzJS0/vSOd4j/ZUzaeffp6mjmxDhf88nCbrMotrCtff/2AN5nUYYqQbzH/wiP5uI= 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=cqoysPAC; arc=none smtp.client-ip=192.198.163.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="cqoysPAC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761845959; x=1793381959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=64hz6eN9wMTQb/u5lIj1gRNc79dS5LgF6HqMkkNo/mw=; b=cqoysPACLw6IJQPAm+Yfa7iUM89JbbIuDPIbLCuYMGNpr7bW7kypt6gT o5eRREcmy0fVaq9ErE6G5tvVOiwcZDChaBGwo+Mvy+BJz3ZTxiz+eci2u 8gXaxzG+I6qu9MR463kS/PyP89UjBGET8IOf1weja1BzTKTycBpIy1TVZ yvPBOhVWteen8gHF3O61RDr4p8gSzXI3c7Wm8KomaP6+dv7tj3td+Aqpu 4iufDlySw4FvNGAYdQjuNuTygX0NFHtIsfUy6KxA4vQZ2lEqbpfDf1VDy MkCV6mx1+4BOoi8kWSvB6QhSHDg+lsAhJQULXv7dwxWdxf63BlBOB4v0N g==; X-CSE-ConnectionGUID: R2h37poQSrSt9yqVlESu2Q== X-CSE-MsgGUID: VTfKWjr1T2GpJxm7SFRw2g== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="67859007" X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="67859007" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 10:39:19 -0700 X-CSE-ConnectionGUID: EB90RWiOSDOWGMYainPjBA== X-CSE-MsgGUID: T7X94qlYR1yC2H60Zprgeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="186458300" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa009.fm.intel.com with ESMTP; 30 Oct 2025 10:39:17 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 688C397; Thu, 30 Oct 2025 18:39:16 +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 v2 2/5] regcache: rbtree: Split ->populate() from ->init() Date: Thu, 30 Oct 2025 18:37:02 +0100 Message-ID: <20251030173915.3886882-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251030173915.3886882-1-andriy.shevchenko@linux.intel.com> References: <20251030173915.3886882-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 --- 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..2751714d52ea 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 Sun Feb 8 11:26:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 8450836A61B for ; Thu, 30 Oct 2025 17:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845962; cv=none; b=X7s+xZQXXC4m7KWMrilZRenlCrgEGj4AXz1O8HilTcV7p97b4oEbAK1hkVxvKPf9+oy4YyIelpTNzk2lNmjiyXCJHNHCuYFU8+cSVXOdfRW1oLq5LwgkFw1XEO/k1aQ2WYl1F7YbqnzOo4Bs4v8+tnGzjuhU2t2txv1+CKvht7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845962; c=relaxed/simple; bh=HvnsiY17eHzORT91DrZmgc5kRgcglwx4EykmEctk1DM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eus7oL1vlffRHLjKkHrFx2B9Sg8oot5EfE/TXiFE4O/1fzQ68ew1XXo8dv/y+p0cRU9XH33fhHDSrxvLujvfyggBW5AvBZx4wGuySV13HtffWKpEy4KQKitqW0LoNJ2Pn3igv/hmtFkUp0lVZQ+FVYnXVWF1O15Oh7KOzF8CzGs= 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=fItbeAW6; arc=none smtp.client-ip=198.175.65.18 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="fItbeAW6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761845960; x=1793381960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HvnsiY17eHzORT91DrZmgc5kRgcglwx4EykmEctk1DM=; b=fItbeAW6Zp3iL6lUxJeA9Cqi3imQfnbmvqR7pVce9LyjX+DOrX+VsuVn YciF5XkArHGqgaDVL3zVx/va3bnGYiEzRVvJs2AKBtDVxkLOKDfClCDtN Oup2z0d9ZKAywt5O4NMa4cZzv/P0sn60u/Ncara+UCNU4AlKEnSwrV5qR 9CSh9fUZIYtg14MpaCdc47fPlnX5sLvu0Us8MPtQpF5u1aED0VBaiBy0C J47au+alCUiSt90s32UA486dnxU0xgW6Ej1yuo3edQqBgW2BBtu3lmGZo prsXXoGEAOpK+Y4Bk42emxZlMkiafkkJAkcs/J6Q102n+VgxV/tL7udxb w==; X-CSE-ConnectionGUID: xMKx9IPcRQWEgziFNjvnCA== X-CSE-MsgGUID: 1StB1nf+QTWZjSMn376j+Q== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="64038630" X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="64038630" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 10:39:19 -0700 X-CSE-ConnectionGUID: byRNiFhXSfK9Am+CpmtXYQ== X-CSE-MsgGUID: sFaxre9DT0a1wkz0x/tjdg== X-ExtLoop1: 1 Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa003.fm.intel.com with ESMTP; 30 Oct 2025 10:39:17 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 6CD5898; Thu, 30 Oct 2025 18:39:16 +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 v2 3/5] regcache: flat: Remove unneeded check and error message for -ENOMEM Date: Thu, 30 Oct 2025 18:37:03 +0100 Message-ID: <20251030173915.3886882-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251030173915.3886882-1-andriy.shevchenko@linux.intel.com> References: <20251030173915.3886882-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. Signed-off-by: Andy Shevchenko Acked-by: Sander Vanheule --- 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 Sun Feb 8 11:26:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 5334636A608 for ; Thu, 30 Oct 2025 17:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845961; cv=none; b=CZojzZH5ZyXQDIcRsHEYEChNW07lL3J2QsLSkzcysfWVgfWcuZU/dIAUsl7QC40iR9aObsDcyxs+n2KmhCuTOOevwLNEWsOdRCqvHzoSzqeb0L4HzMo76MxVns2/dqVWM6CtRTNrZ6XeZr5YX2ayjg9wy5Wqlc8Gm/yzCJBHgqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845961; c=relaxed/simple; bh=p0TML9FLbpbHRHWAs71KOwBosv3+hC/P9zEcIKgeCk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nmehs5lb2O+m3gkIPBb0ltPSVLZzFvO2Nthbngl+KHVcILLn7FyJVA7rAOGeGwaB3NaHZIbppwaVDxQtiP3Hz8rwOdiZ9l9h01NDgfDinY4dzgPUwI6SxmiLnR/EMSbvr4j85lB5U70qCXdCULSeRe6fOLWx2E8ouqJyiGACi08= 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=l80ABL/c; arc=none smtp.client-ip=192.198.163.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="l80ABL/c" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761845958; x=1793381958; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p0TML9FLbpbHRHWAs71KOwBosv3+hC/P9zEcIKgeCk0=; b=l80ABL/cUkkF3oX+6U3afIIgWgKH0hfpxdgMRfW9WzqV6d+XN9eGmpIA cIryxKc/SniOYhpvUaSRcqBbzrO8J+bIAcItYPZ5jjynjmP+mejjk7G/8 TfexSOBqM+lbEYQpn0Y4/fWZ9wgsBAee6BqvRHRpZYmYLtgMSJA1T2QtO Vs7cHnkVitnMLv09HtsdNtUXTelUxPFxcV4+TxpO6KhYfp/s8PC+RiGa6 gT7/RqM3m3WwPPbNlWXVkp0l39JhasKJG7gRqM/CW8uOV+O8ELjo9UH0U dDzbHp91k3ToSqm1+OFxwp22zCpdVIccNH8u34T1KJBoxMYPkQD2SJZ8z Q==; X-CSE-ConnectionGUID: xkBERv8ES4qVi9vx+5Qjxg== X-CSE-MsgGUID: LeKo0O7KTeCbZa0efNCFkw== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="74596797" X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="74596797" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 10:39:17 -0700 X-CSE-ConnectionGUID: w+0zih30TxCk7ED1Y9bf1g== X-CSE-MsgGUID: jvyRwa7LTUWMvYl+ugwuCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="185895474" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa006.fm.intel.com with ESMTP; 30 Oct 2025 10:39:17 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 70F1899; Thu, 30 Oct 2025 18:39:16 +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 v2 4/5] regcache: flat: Split ->populate() from ->init() Date: Thu, 30 Oct 2025 18:37:04 +0100 Message-ID: <20251030173915.3886882-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251030173915.3886882-1-andriy.shevchenko@linux.intel.com> References: <20251030173915.3886882-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 --- 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 Sun Feb 8 11:26:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 C780536B988 for ; Thu, 30 Oct 2025 17:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845963; cv=none; b=LKQS5NYC+RYoDl10b+RZgw+u8ds69f9qu46aY3r6h5GbNZUHFcbl1JgjaIWopjrDRF9CFDvpihgP7uXjQ1Fv8PFz423uPDuacky5vJ+ieoh965ZZbjYcTtEJm3u3zqRn4oLDyKMnXSFak/Ix9z3jUtm8l22OgweJXjUA9ASrmlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761845963; c=relaxed/simple; bh=spUqVFANeu6zA5mqKFPkIzzbgdNgivsG0RxjQcBExq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lDaNmxfdMj1GCINUnlyBCHioyaPol6G0FIYBaORsIKlzxRLEGyUGi8vqwUlCzshQcvcX6Hccgw5aiAHYl6+BnW90uB4N7zu82LK3ImlAm5zA56fz+LycohiroGQ9f9HasKIazjyNR+9ktgKpYcplhbge8k8uXmEYjLLUY05shu0= 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=kGVgiuVd; arc=none smtp.client-ip=198.175.65.13 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="kGVgiuVd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761845962; x=1793381962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=spUqVFANeu6zA5mqKFPkIzzbgdNgivsG0RxjQcBExq4=; b=kGVgiuVd5jc+5pSP5fguX5f+ZMYDw7u74RCaOzHh/sz9y86VLdEckRt4 c8mlf02MguR/4VYLU/qbd9sJFW9Lc1c6OUS/HBBbo90bUe3+QFklocRGS pOJEPxQE9x4Q8FdRd2WzaA05My4RNg6nQHcHmQWjLzlaWZPCGdfuzRmya YWlP5p7JBpmcsc4fNEXhigEy604hiwN5gXd6t+fUjuGE73Shm/Wj2NNZl SaHbyEY1tsTmYKntMYKZtYTRhtW29hHEw7+Yg1RlWTZrfJPdPWjMK02M+ NmZ7Vh4TKm8vTBODdGgzAqxVrjPS8hg0gXVMWBuMrowaDfWK5myUfd4pB g==; X-CSE-ConnectionGUID: Yp6EJE/DTbCEeadTclDDlQ== X-CSE-MsgGUID: bxBbN28rRaaVNMrp+Xdmzw== X-IronPort-AV: E=McAfee;i="6800,10657,11598"; a="75117033" X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="75117033" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 10:39:22 -0700 X-CSE-ConnectionGUID: hFB7NtryQcuZHVwlIDoaDw== X-CSE-MsgGUID: OKm4WIp4Q/WAmCH+7hOhLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,267,1754982000"; d="scan'208";a="185951817" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa007.jf.intel.com with ESMTP; 30 Oct 2025 10:39:19 -0700 Received: by black.igk.intel.com (Postfix, from userid 1003) id 7548C9A; Thu, 30 Oct 2025 18:39:16 +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 v2 5/5] regcache: maple: Split ->populate() from ->init() Date: Thu, 30 Oct 2025 18:37:05 +0100 Message-ID: <20251030173915.3886882-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251030173915.3886882-1-andriy.shevchenko@linux.intel.com> References: <20251030173915.3886882-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 --- 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