linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: <gregkh@linuxfoundation.org>
Cc: <kishon@ti.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 07/20] phy: exynos-mipi-video: Use spin_lock to protct state->regmap rmw operations
Date: Fri, 13 Mar 2015 17:31:44 +0530	[thread overview]
Message-ID: <1426248117-14312-8-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1426248117-14312-1-git-send-email-kishon@ti.com>

From: Axel Lin <axel.lin@ingics.com>

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>
---
 drivers/phy/phy-exynos-mipi-video.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c
index d196493..df7519a 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,11 +72,9 @@ 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);
 
-		spin_lock(&state->slock);
 		val = readl(addr);
 		if (on)
 			val |= reset;
@@ -90,9 +88,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 +156,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.7.9.5


  parent reply	other threads:[~2015-03-13 12:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 12:01 [GIT PULL 00/20] phy: for 4.0 -rc cycle Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 01/20] phy: miphy28lp: Avoid calling of_get_child_count() multiple times Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 02/20] phy: miphy365x: " Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 03/20] phy: armada375-usb2: Set drvdata for phy and use it Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 04/20] phy: xgene: Remove duplicate code to set ctx->dev Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 05/20] phy: miphy28lp: Add missing .owner field in miphy28lp_ops Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 06/20] phy: exynos-mipi-video: Fixup the test for state->regmap Kishon Vijay Abraham I
2015-03-13 12:01 ` Kishon Vijay Abraham I [this message]
2015-03-13 12:01 ` [PATCH 08/20] phy: exynos-dp-video: Kill exynos_dp_video_phy_pwr_isol function Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 09/20] phy: hix5hd2-sata: Check return value of platform_get_resource Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 10/20] phy: samsung-usb2: Remove NULL terminating entry from phys array Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 11/20] phy: ti-pipe3: Simplify ti_pipe3_dpll_wait_lock implementation Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 12/20] phy: rockchip-usb: Fixup rockchip_usb_phy_power_on failure path Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 13/20] phy: Find the right match in devm_phy_destroy() Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 14/20] phy: exynos5-usbdrd: Fix off-by-one valid value checking for args->args[0] Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 15/20] phy: twl4030-usb: Remove redundant assignment for twl->linkstat Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 16/20] phy: miphy365x: Convert to devm_kcalloc and fix wrong sizeof Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 17/20] phy: miphy28lp: Convert to devm_kcalloc and fix wrong sizof Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 18/20] phy: core: Fixup return value of phy_exit when !pm_runtime_enabled Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 19/20] phy: ti/omap: Fix modalias Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 20/20] phy: omap-usb2: Fix missing clk_prepare call when using old dt name Kishon Vijay Abraham I
2015-03-14  8:50 ` [GIT PULL 00/20] phy: for 4.0 -rc cycle Greg KH
2015-03-14 11:23   ` Kishon Vijay Abraham I
2015-03-14 11:31   ` [RESEND GIT PULL] " Kishon Vijay Abraham I
2015-03-18 16:28     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426248117-14312-8-git-send-email-kishon@ti.com \
    --to=kishon@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).