From patchwork Fri Feb 27 03:50:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 5897651 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 49BEC9F37F for ; Fri, 27 Feb 2015 03:51:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 629B6201FA for ; Fri, 27 Feb 2015 03:51:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E74A201ED for ; Fri, 27 Feb 2015 03:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753337AbbB0DvF (ORCPT ); Thu, 26 Feb 2015 22:51:05 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:33650 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753279AbbB0DvE (ORCPT ); Thu, 26 Feb 2015 22:51:04 -0500 Received: by pabli10 with SMTP id li10so3308318pab.0 for ; Thu, 26 Feb 2015 19:51:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=Sy09JETeSOsFfQ2cKDrogwqY0GSyZPCkIwnc3b2BA64=; b=InCPYMPXMHIIp6o2xr59AdlsxlFIyJeUt99/KGGZZXKQ6ZDhnTsZWq3q+yjhxWsV2P 7HIjd0i5/WcDDQ8APLq53IhnWQfaeF5zaJ5wUxWeOyv1e5S+Vo2H/Ix0IG/8ghLGEs/p eksc1Imj5vc1Mkp7xzW17uhdP6RuX9hQREukCZo4iZ0UeskjixdHwie522HA0iDxTlc3 ulpyrQGo46oVLUXgMq87XCdY5gHzpafvAnV4MZJBhOSe5mtSb4DQav+SLgry83A7V7F4 uiqBHS5m9xJi3aGUkWYr18be1IC69FzmvwLdC5f9aGDRIliEJVnZmYM4UW3jgdZ9yZs6 1+Hw== X-Gm-Message-State: ALoCoQn2xjRaepO3E8I4zIFRp7XpAK3jgAS1lBgZ/6gJ9UsbF764ab5FqXFR6tg299eCtaezzOmV X-Received: by 10.70.43.38 with SMTP id t6mr19185442pdl.97.1425009063101; Thu, 26 Feb 2015 19:51:03 -0800 (PST) Received: from [192.168.0.104] (218-164-128-147.dynamic.hinet.net. [218.164.128.147]) by mx.google.com with ESMTPSA id bc4sm2460884pac.4.2015.02.26.19.51.00 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Thu, 26 Feb 2015 19:51:02 -0800 (PST) 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 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Sylwester Nawrocki Tested-by: Sylwester Nawrocki --- 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,