From patchwork Thu May 2 10:43:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kao X-Patchwork-Id: 10926541 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 CCDC81390 for ; Thu, 2 May 2019 10:44:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B62B428D60 for ; Thu, 2 May 2019 10:44:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A38F328D9E; Thu, 2 May 2019 10:44:39 +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 5175A28D60 for ; Thu, 2 May 2019 10:44:39 +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=XsdfwBBtvUDtSs0Q7xnhnvyjjjZrj29yngaQmOsyduI=; b=mDp+rm3CuH864j 1j6fzd0g1m1cghuWmLVyUYXFWOH/r/TD8gdW5LsiqJU+ydKKBCaStG3vml+Kjjyp9WIGaeX4iskPE SMAtCG6eFkHVetuZeEU0fyhG6++NAfo0N2TzwlqswSH4KS/BuRNTcrw1qa9gM0ePbahGjuUn7OtpT y9/3rI6wvmfUrV+2epvnRMedU66X/SrkQy7ihl8KxIDjqGSOsMCDXtwYD4dBVXHslasA2xG4JmiX9 I3OK8pMTcihP47SXkraH+3KXQq2b1NeGRfuBc8azD73l0OzmrrBr5j7641Hs8zS2VKcypwRUBtCnC VQDacYQXi1O8IYUmrgIA==; 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 1hM9Cc-0001aB-13; Thu, 02 May 2019 10:44:34 +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 1hM9Bb-0008WB-Aa; Thu, 02 May 2019 10:43:37 +0000 X-UUID: f8a850102dcd4bc4893aa30684edd36e-20190502 X-UUID: f8a850102dcd4bc4893aa30684edd36e-20190502 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 1064754334; Thu, 02 May 2019 02:43:22 -0800 Received: from mtkmbs08n2.mediatek.inc (172.21.101.56) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 2 May 2019 03:43:22 -0700 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 2 May 2019 18:43:19 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 2 May 2019 18:43:19 +0800 From: michael.kao To: , , , , , , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Rob Herring , Mark Rutland , Matthias Brugger Subject: [PATCH 8/8] thermal: mediatek: use spinlock to protect PTPCORESEL Date: Thu, 2 May 2019 18:43:15 +0800 Message-ID: <1556793795-25204-9-git-send-email-michael.kao@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556793795-25204-1-git-send-email-michael.kao@mediatek.com> References: <1556793795-25204-1-git-send-email-michael.kao@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: C476A56E0311D429C33F6297EED0AD4001822EA84EA791DBBB2F07404E67FFB72000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190502_034331_947959_AE341409 X-CRM114-Status: GOOD ( 11.12 ) X-BeenThere: linux-arm-kernel@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-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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);