Commit af69decc authored by Axel Lin's avatar Axel Lin Committed by Kishon Vijay Abraham I

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: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: default avatarSylwester 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: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent cfd565d1
...@@ -43,7 +43,6 @@ struct exynos_mipi_video_phy { ...@@ -43,7 +43,6 @@ struct exynos_mipi_video_phy {
} phys[EXYNOS_MIPI_PHYS_NUM]; } phys[EXYNOS_MIPI_PHYS_NUM];
spinlock_t slock; spinlock_t slock;
void __iomem *regs; void __iomem *regs;
struct mutex mutex;
struct regmap *regmap; struct regmap *regmap;
}; };
...@@ -59,8 +58,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state, ...@@ -59,8 +58,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state,
else else
reset = EXYNOS4_MIPI_PHY_SRESETN; reset = EXYNOS4_MIPI_PHY_SRESETN;
spin_lock(&state->slock);
if (!IS_ERR(state->regmap)) { if (!IS_ERR(state->regmap)) {
mutex_lock(&state->mutex);
regmap_read(state->regmap, offset, &val); regmap_read(state->regmap, offset, &val);
if (on) if (on)
val |= reset; val |= reset;
...@@ -72,11 +72,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state, ...@@ -72,11 +72,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state,
else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK)) else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK))
val &= ~EXYNOS4_MIPI_PHY_ENABLE; val &= ~EXYNOS4_MIPI_PHY_ENABLE;
regmap_write(state->regmap, offset, val); regmap_write(state->regmap, offset, val);
mutex_unlock(&state->mutex);
} else { } else {
addr = state->regs + EXYNOS_MIPI_PHY_CONTROL(id / 2); addr = state->regs + EXYNOS_MIPI_PHY_CONTROL(id / 2);
spin_lock(&state->slock);
val = readl(addr); val = readl(addr);
if (on) if (on)
val |= reset; val |= reset;
...@@ -90,9 +88,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state, ...@@ -90,9 +88,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state,
val &= ~EXYNOS4_MIPI_PHY_ENABLE; val &= ~EXYNOS4_MIPI_PHY_ENABLE;
writel(val, addr); writel(val, addr);
spin_unlock(&state->slock);
} }
spin_unlock(&state->slock);
return 0; return 0;
} }
...@@ -158,7 +156,6 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev) ...@@ -158,7 +156,6 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
dev_set_drvdata(dev, state); dev_set_drvdata(dev, state);
spin_lock_init(&state->slock); spin_lock_init(&state->slock);
mutex_init(&state->mutex);
for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) { for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
struct phy *phy = devm_phy_create(dev, NULL, struct phy *phy = devm_phy_create(dev, NULL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment