From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753722AbbB0DvG (ORCPT ); Thu, 26 Feb 2015 22:51:06 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:46288 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753209AbbB0DvE (ORCPT ); Thu, 26 Feb 2015 22:51:04 -0500 Message-ID: <1425009057.12126.1.camel@phoenix> Subject: [PATCH RFT] phy: exynos-mipi-video: Use spin_lock to protct state->regmap rmw operations From: Axel Lin To: Kishon Vijay Abraham I Cc: Sylwester Nawrocki , Kyungmin Park , "linux-samsung-soc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Date: Fri, 27 Feb 2015 11:50:57 +0800 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Hi Sylwester, I don't have this hardware handy, so can you test if this patch works. This patch is on top of my previous patch (phy: exynos-mipi-video: Fixup the test for state->regmap) Thanks, Axel drivers/phy/phy-exynos-mipi-video.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c index d196493..8d6d117 100644 --- a/drivers/phy/phy-exynos-mipi-video.c +++ b/drivers/phy/phy-exynos-mipi-video.c @@ -43,7 +43,6 @@ struct exynos_mipi_video_phy { } phys[EXYNOS_MIPI_PHYS_NUM]; spinlock_t slock; void __iomem *regs; - struct mutex mutex; struct regmap *regmap; }; @@ -59,8 +58,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state, else reset = EXYNOS4_MIPI_PHY_SRESETN; + spin_lock(&state->slock); + if (!IS_ERR(state->regmap)) { - mutex_lock(&state->mutex); regmap_read(state->regmap, offset, &val); if (on) val |= reset; @@ -72,7 +72,6 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state, else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK)) val &= ~EXYNOS4_MIPI_PHY_ENABLE; regmap_write(state->regmap, offset, val); - mutex_unlock(&state->mutex); } else { addr = state->regs + EXYNOS_MIPI_PHY_CONTROL(id / 2); @@ -90,9 +89,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state, val &= ~EXYNOS4_MIPI_PHY_ENABLE; writel(val, addr); - spin_unlock(&state->slock); } + spin_unlock(&state->slock); return 0; } @@ -158,7 +157,6 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev) dev_set_drvdata(dev, state); spin_lock_init(&state->slock); - mutex_init(&state->mutex); for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) { struct phy *phy = devm_phy_create(dev, NULL, -- 1.9.1