Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: exynos-mipi-video: Use spin_lock to protct state->regmap rmw operations

The state->regmap is initialized by devm_regmap_init_mmio().
So it's fine to use spin_lock rather than mutex to protct state->regmap rmw
operations.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
[Julia.Lawall@lip6.fr: Found an issue with the original patch w.r.t unbalanced
spin_lock call]
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Axel Lin and committed by
Kishon Vijay Abraham I
af69decc cfd565d1

+3 -6
+3 -6
drivers/phy/phy-exynos-mipi-video.c
··· 43 43 } phys[EXYNOS_MIPI_PHYS_NUM]; 44 44 spinlock_t slock; 45 45 void __iomem *regs; 46 - struct mutex mutex; 47 46 struct regmap *regmap; 48 47 }; 49 48 ··· 58 59 else 59 60 reset = EXYNOS4_MIPI_PHY_SRESETN; 60 61 62 + spin_lock(&state->slock); 63 + 61 64 if (!IS_ERR(state->regmap)) { 62 - mutex_lock(&state->mutex); 63 65 regmap_read(state->regmap, offset, &val); 64 66 if (on) 65 67 val |= reset; ··· 72 72 else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK)) 73 73 val &= ~EXYNOS4_MIPI_PHY_ENABLE; 74 74 regmap_write(state->regmap, offset, val); 75 - mutex_unlock(&state->mutex); 76 75 } else { 77 76 addr = state->regs + EXYNOS_MIPI_PHY_CONTROL(id / 2); 78 77 79 - spin_lock(&state->slock); 80 78 val = readl(addr); 81 79 if (on) 82 80 val |= reset; ··· 88 90 val &= ~EXYNOS4_MIPI_PHY_ENABLE; 89 91 90 92 writel(val, addr); 91 - spin_unlock(&state->slock); 92 93 } 93 94 95 + spin_unlock(&state->slock); 94 96 return 0; 95 97 } 96 98 ··· 156 158 157 159 dev_set_drvdata(dev, state); 158 160 spin_lock_init(&state->slock); 159 - mutex_init(&state->mutex); 160 161 161 162 for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) { 162 163 struct phy *phy = devm_phy_create(dev, NULL,