regmap: Drop early readability check

Message ID 20230615-regmap-drop-early-readability-v1-1-8135094362de@kernel.org
State New
Headers
Series regmap: Drop early readability check |

Commit Message

Mark Brown June 15, 2023, 11:04 p.m. UTC
  We have some drivers that have a use case for cached write only
registers, doing read/modify/writes on read only registers in order to
work more easily with bitfields.  Go back to trying the cache before we
check if we can read from the device.

Fixes: eab5abdeb79f0 ("regmap: Check for register readability before checking cache during read")
Reported-by: Konrad Dybcio <konradybcio@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/base/regmap/regmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


---
base-commit: 505cb70cd27abde24bd48b2c9a539cca485d722f
change-id: 20230615-regmap-drop-early-readability-3832b755ae14

Best regards,
  

Comments

Mark Brown June 16, 2023, 1:22 p.m. UTC | #1
On Fri, 16 Jun 2023 00:04:40 +0100, Mark Brown wrote:
> We have some drivers that have a use case for cached write only
> registers, doing read/modify/writes on read only registers in order to
> work more easily with bitfields.  Go back to trying the cache before we
> check if we can read from the device.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: Drop early readability check
      commit: 3e47b8877d6c0f60943b00f3112756ca3b572cd6

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
  

Patch

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index fad66b309ef9..89a7f1c459c1 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2897,9 +2897,6 @@  static int _regmap_read(struct regmap *map, unsigned int reg,
 	int ret;
 	void *context = _regmap_map_get_context(map);
 
-	if (!regmap_readable(map, reg))
-		return -EIO;
-
 	if (!map->cache_bypass) {
 		ret = regcache_read(map, reg, val);
 		if (ret == 0)
@@ -2909,6 +2906,9 @@  static int _regmap_read(struct regmap *map, unsigned int reg,
 	if (map->cache_only)
 		return -EBUSY;
 
+	if (!regmap_readable(map, reg))
+		return -EIO;
+
 	ret = map->reg_read(context, reg, val);
 	if (ret == 0) {
 		if (regmap_should_log(map))