regmap: Fix order of regmap write log
authorLucas Tanure <tanureal@opensource.cirrus.com>
Thu, 12 Nov 2020 15:02:17 +0000 (15:02 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 12 Nov 2020 16:05:17 +0000 (16:05 +0000)
_regmap_write can trigger a _regmap_select_page, which will call
another _regmap_write that will be executed first, but the log shows
the inverse order

Also, keep consistency with _regmap_read which only logs in case of
success

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20201112150217.459844-1-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap.c

index 5db536ccfcd6b94017e5c640e67866618caa3387..297e95be25b3b3353b20e6b9a4b4da94fb850927 100644 (file)
@@ -1924,12 +1924,15 @@ int _regmap_write(struct regmap *map, unsigned int reg,
                }
        }
 
-       if (regmap_should_log(map))
-               dev_info(map->dev, "%x <= %x\n", reg, val);
+       ret = map->reg_write(context, reg, val);
+       if (ret == 0) {
+               if (regmap_should_log(map))
+                       dev_info(map->dev, "%x <= %x\n", reg, val);
 
-       trace_regmap_reg_write(map, reg, val);
+               trace_regmap_reg_write(map, reg, val);
+       }
 
-       return map->reg_write(context, reg, val);
+       return ret;
 }
 
 /**