From nobody Wed Feb 11 08:11:33 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 1CBE83876CE for ; Tue, 10 Feb 2026 16:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770739864; cv=none; b=UgeBd055qQ427UOyLaCCt+POd2WgTEowjVd9sGJVwBeCE7pc0hywpjQO13bMZ20+NmV0PuApqgotAoReIEj7bYYjmf5/GJAu/LVIbizBafLPcOjs7tFDKkIB8UZmW9p3uriw6C9KYCJhl/EFSBKhifAU3Zw9fH1ej38AGwh26LY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770739864; c=relaxed/simple; bh=rfBvButiI95wT+I0XsLNxGztV9PqXS8BtBk7utYsw+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P2recURpMt+aP5ATtZs+a9fRDKOMmgA22a9S7XFUWFIBfEPnqyDBvozYPoBj8f5h7JcRvCvA/RwpZCerDOh7RWuIMeISkXQl5h1agqQs0o+tMtEm5zG31y9znXT+ghJ8Hev2vBQW58uY8GFOLFOXUUW7r1RLh6kiXG1KHLVObWw= 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=JZZMxiQd; arc=none smtp.client-ip=198.175.65.9 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="JZZMxiQd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770739863; x=1802275863; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rfBvButiI95wT+I0XsLNxGztV9PqXS8BtBk7utYsw+A=; b=JZZMxiQdPOLuCC8jTY5DmH68MxJ+lpEUTOIHQhairOs4ihoQBcFuXr6+ Whs9w7tJw066ilMydI2Z8ea2Iw4HWbDWtoJquUvhuJZPnPtaSq859rL9j 5bhN9W7oeT2PR02B6XZJwsvOPo0dyRNi74JgwTG116OknPFkf9mPajGfb hKiui7MdVqRExkRtnKY1A1oUJ5WPwm8FJw5LU6iIXhE0lfE+N33pErDjT SCtJihbwzRfRZ+9JeAyBSaS2bp89rncFZiOK5UTKhTW5HrppIyTR1dcOo h9e0UF8BimUqm92Ir/yWCFDo/yXqscs0GoHLo9Q8k9ZfjlxKDckLiala5 A==; X-CSE-ConnectionGUID: cJnd8QbCT4+H88W8b+reOw== X-CSE-MsgGUID: uuXYAmJ4T6WhJF4yYC8isw== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="94514475" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="94514475" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:11:01 -0800 X-CSE-ConnectionGUID: 86EQMSmJRemQapAHIs18DQ== X-CSE-MsgGUID: GmWJgvKqQa+TeLpDXiOv/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="211594023" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa008.fm.intel.com with ESMTP; 10 Feb 2026 08:10:59 -0800 Received: by black.igk.intel.com (Postfix, from userid 1003) id 815829D; Tue, 10 Feb 2026 17:10:58 +0100 (CET) From: Andy Shevchenko To: linux-kernel@vger.kernel.org, Oleksij Rempel Cc: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Subject: [PATCH v1 3/3] regcache: Move HW readback after cache initialisation Date: Tue, 10 Feb 2026 17:09:10 +0100 Message-ID: <20260210161058.53093-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260210161058.53093-1-andriy.shevchenko@linux.intel.com> References: <20260210161058.53093-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" Make sure that cache is initialised before calling any IO using regmap, this makes sure that we won't access NULL or invalid pointers in the cache which hasn't been initialised. Signed-off-by: Andy Shevchenko --- drivers/base/regmap/regcache.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 0a78ab0dc9fb..3101f19e411b 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -203,14 +203,6 @@ int regcache_init(struct regmap *map, const struct reg= map_config *config) count =3D regcache_count_cacheable_registers(map); if (map->cache_bypass) return 0; - - /* Some devices such as PMICs don't have cache defaults, - * we cope with this by reading back the HW registers and - * crafting the cache defaults by hand. - */ - ret =3D regcache_hw_init(map, count); - if (ret < 0) - return ret; } =20 if (!map->max_register_is_set && map->num_reg_defaults_raw) { @@ -228,6 +220,17 @@ int regcache_init(struct regmap *map, const struct reg= map_config *config) goto err_free; } =20 + if (count) { + /* + * Some devices such as PMICs don't have cache defaults, + * we cope with this by reading back the HW registers and + * crafting the cache defaults by hand. + */ + ret =3D regcache_hw_init(map, count); + if (ret < 0) + goto err_exit; + } + 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); --=20 2.50.1