From patchwork Fri May 10 13:27:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kao X-Patchwork-Id: 10938841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D85892A for ; Fri, 10 May 2019 13:29:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BC9328BCE for ; Fri, 10 May 2019 13:29:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FB3A28BE2; Fri, 10 May 2019 13:29:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C01A328BCE for ; Fri, 10 May 2019 13:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tcWH4R688Ra1GUq3j7eiSvqVhEyA2eqKLkiYgu2D3vI=; b=sHeHyk2dhzm32j TEUho59lq4d1N85xoC9/lVhVx6+UPbtyxJlN4Pelr4BZsbFdyikCQtkaYvAvZFItDwJ9V24sjEdI8 85T6EdjJy5GtN9gO9M1N1QyDVnTbNqXVSBk62JAnF6RalGa6yvJMBpl5m/iKCC1LNrSuL1rYNsm0e O5ubBTk8ENqV0VCkP2DPYS2M909pOylBb0m2O60olbFOUB1/Y/nSzrYUIXZeLcbwwAzBCjYnsSkVu tRn8zpRdlNzr1WIFGhyAxEApXrGA8lAbA4u/qcNQuIo9Oxw8VAkAJt2JbKrMmyoFr00lYE7JZUO2v ONvWcvBVXpwKp3b4Vd/A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hP5ab-00044F-Fz; Fri, 10 May 2019 13:29:29 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hP5aR-0003tS-W6; Fri, 10 May 2019 13:29:21 +0000 X-UUID: 965e7d71d4ef4e2d9c223dbc56f912e2-20190510 X-UUID: 965e7d71d4ef4e2d9c223dbc56f912e2-20190510 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 373171395; Fri, 10 May 2019 05:27:26 -0800 Received: from MTKMBS01N2.mediatek.inc (172.21.101.79) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 10 May 2019 06:27:26 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 10 May 2019 21:27:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 10 May 2019 21:27:11 +0800 From: michael.kao To: Zhang Rui , Eduardo Valentin , Daniel Lezcano , Rob Herring , Mark Rutland , Matthias Brugger , Subject: [PATCH v2 8/8] thermal: mediatek: use spinlock to protect PTPCORESEL Date: Fri, 10 May 2019 21:27:06 +0800 Message-ID: <1557494826-6044-9-git-send-email-michael.kao@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557494826-6044-1-git-send-email-michael.kao@mediatek.com> References: <1557494826-6044-1-git-send-email-michael.kao@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 31D7B78B317839C87C3E2961C6190345EB6543F46075DED937CAA031FAC50A042000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190510_062920_031948_939230D2 X-CRM114-Status: GOOD ( 11.78 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "michael.kao" , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The driver of thermal and svs will use the same register for the project which should select bank before reading sensor value. Signed-off-by: Michael.Kao --- drivers/thermal/mtk_thermal.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index d5c78b0..6d7e839 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -30,6 +30,7 @@ #include #include #include +#include /* AUXADC Registers */ #define AUXADC_CON1_SET_V 0x008 @@ -267,7 +268,7 @@ struct mtk_thermal { struct clk *clk_peri_therm; struct clk *clk_auxadc; /* lock: for getting and putting banks */ - struct mutex lock; + unsigned long flags; /* Calibration values */ s32 adc_ge; @@ -566,7 +567,7 @@ static void mtk_thermal_get_bank(struct mtk_thermal_bank *bank) u32 val; if (mt->conf->need_switch_bank) { - mutex_lock(&mt->lock); + mt->flags = claim_mtk_svs_lock(); val = readl(mt->thermal_base + PTPCORESEL); val &= ~0xf; @@ -586,7 +587,7 @@ static void mtk_thermal_put_bank(struct mtk_thermal_bank *bank) struct mtk_thermal *mt = bank->mt; if (mt->conf->need_switch_bank) - mutex_unlock(&mt->lock); + release_mtk_svs_lock(mt->flags); } /** @@ -941,8 +942,6 @@ static int mtk_thermal_probe(struct platform_device *pdev) if (ret) return ret; - mutex_init(&mt->lock); - mt->dev = &pdev->dev; auxadc = of_parse_phandle(np, "mediatek,auxadc", 0);