pinctrl: cy8c95x0: Lock register accesses in cy8c95x0_set_mux()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 16 Sep 2022 20:54:48 +0000 (23:54 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 20 Sep 2022 09:22:12 +0000 (11:22 +0200)
It seems that cy8c95x0_set_mux() missed serialization of IO access.
And its implementation looks half-baked. Add locking to the function.

Fixes: e6cbbe42944d ("pinctrl: Add Cypress cy8c95x0 support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220916205450.86278-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-cy8c95x0.c

index 79f73d364f3f9d725a9941bfad6bd85478e0c21d..75be06d29dc1485532ee7fcb48340b3e428202ff 100644 (file)
@@ -1152,8 +1152,13 @@ static int cy8c95x0_set_mux(struct pinctrl_dev *pctldev, unsigned int selector,
                            unsigned int group)
 {
        struct cy8c95x0_pinctrl *chip = pinctrl_dev_get_drvdata(pctldev);
+       int ret;
 
-       return cy8c95x0_pinmux_cfg(chip, selector, group);
+       mutex_lock(&chip->i2c_lock);
+       ret = cy8c95x0_pinmux_cfg(chip, selector, group);
+       mutex_unlock(&chip->i2c_lock);
+
+       return ret;
 }
 
 static const struct pinmux_ops cy8c95x0_pmxops = {