Skip to content

Commit bda79f8

Browse files
PatrickRudolphlinusw
authored andcommitted
pinctrl: cy8c95x0: Update cache modification
In the previous review cycle the regmap cache update code was questioned since it seems and odd way of using regmap_update_bits(). Thus update the regmap cache modification code to better explain what it does and why it's done. This is no functional change, but it's improving code maintainability. Signed-off-by: Patrick Rudolph <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 710894c commit bda79f8

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

drivers/pinctrl/pinctrl-cy8c95x0.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
475475
bool *change, bool async,
476476
bool force)
477477
{
478-
int ret, off, i, read_val;
478+
int ret, off, i;
479479

480480
/* Caller should never modify PORTSEL directly */
481481
if (reg == CY8C95X0_PORTSEL)
@@ -497,24 +497,20 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
497497
if (ret < 0)
498498
return ret;
499499

500-
/* Update the cache when a WC bit is written */
500+
/* Mimic what hardware does and update the cache when a WC bit is written.
501+
* Allows to mark the registers as non-volatile and reduces I/O cycles.
502+
*/
501503
if (cy8c95x0_wc_register(reg) && (mask & val)) {
504+
/* Writing a 1 clears set bits in the other drive mode registers */
505+
regcache_cache_only(chip->regmap, true);
502506
for (i = CY8C95X0_DRV_PU; i <= CY8C95X0_DRV_HIZ; i++) {
503507
if (i == reg)
504508
continue;
505-
off = CY8C95X0_MUX_REGMAP_TO_OFFSET(i, port);
506-
507-
ret = regmap_read(chip->regmap, off, &read_val);
508-
if (ret < 0)
509-
continue;
510509

511-
if (!(read_val & mask & val))
512-
continue;
513-
514-
regcache_cache_only(chip->regmap, true);
515-
regmap_update_bits(chip->regmap, off, mask & val, 0);
516-
regcache_cache_only(chip->regmap, false);
510+
off = CY8C95X0_MUX_REGMAP_TO_OFFSET(i, port);
511+
regmap_clear_bits(chip->regmap, off, mask & val);
517512
}
513+
regcache_cache_only(chip->regmap, false);
518514
}
519515

520516
return ret;

0 commit comments

Comments
 (0)