From patchwork Fri Sep 22 09:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Wang X-Patchwork-Id: 9965747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D2B73600C5 for ; Fri, 22 Sep 2017 09:56:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D478829841 for ; Fri, 22 Sep 2017 09:56:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C924929845; Fri, 22 Sep 2017 09:56:44 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 5D0F629841 for ; Fri, 22 Sep 2017 09:56:44 +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=JPqdGtWVAHzZqKZ6X3ZzPwxq76Yy7JsbgGUer0gaLNA=; b=a/A0oBaJR8O9HU D9Y8rD2JHtOpJUj1/0PDSEZSiu4Abd/SIeYy5VbQJxiR0m2jWo2TDJwQfpkmgDLdNzrM1EqlPvmEY HBrepUqip5dLWENUhu+gPMX+ww9AcJfBYIgDAqIERWZNz/hBQPz+l6FTcKnSXWs5+/cqTY0mcUuV1 YcqL0w3XKh3qH3K5LYDo3DEk8Cs3nSORdqdwsJeBgtSVix9zjxE2mcfQGwCoQK7SvYPfpKmyR3F96 yrsdvvaAbQqJqbyd1LbW0JhRFE8/DTiPZUKnrm+w+MOEWSuKHG81S9c229D6fH52ekHhCXXvJnqwP fVo47iArF9lDFDFQmFdw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dvKhK-0002s1-O3; Fri, 22 Sep 2017 09:56:38 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dvKga-0002BU-Mn for linux-arm-kernel@bombadil.infradead.org; Fri, 22 Sep 2017 09:55:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PdPsBR43mUDLvXvkaOlSYYsAk1rOXQpjiB6dERHCJTo=; b=Su5JVWRJHyzEol6SVd5PubDov i+exZ6/c7MIoT4ZXVZ5GgJfnSojXim9kI//P4BLA0mz4x1LWwjQ76eVqEsu0MjJrAANQ2lMNSMszK PNXfBFHQlrwoY4rhNMsBj0wFyY+gWo7+c0wgEIcFt67LmIFsNoaaMU5+K1gBs2Ibc7DzqNof1D2c+ Y4PqXRR8ZNZDOcMV7i+DLNth7W8iWl2QwVVNz1gwiz80EgIRMeHMdd5d9orwCyO0pbNM5JfKV4inl wZl0OqsZgTDGJqaSKjkXghrwnpU9hugL7wwWT7b4+mUq9Lp2ofZBF2MjhNWzIVFeoPBwXpcm+6iX7 KD8fHQPCg==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dvKeS-0004c2-F2 for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2017 09:53:46 +0000 Received: from 172.30.72.60 (EHLO DGGEMS403-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DHV05218; Fri, 22 Sep 2017 17:49:15 +0800 (CST) Received: from HSH1000038028.huawei.com (10.177.161.152) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.301.0; Fri, 22 Sep 2017 17:49:07 +0800 From: Tao Wang To: , , , , , , Subject: [PATCH 1/9] thermal/drivers/hisi: move clk operation to related function Date: Fri, 22 Sep 2017 17:42:04 +0800 Message-ID: <1506073332-92438-2-git-send-email-kevin.wangtao@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1506073332-92438-1-git-send-email-kevin.wangtao@hisilicon.com> References: <1506073332-92438-1-git-send-email-kevin.wangtao@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.177.161.152] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.59C4DC9B.0117, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 44ffc5a624a2ee0dd4beae52f299aff2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170922_105342_380601_722B11FD X-CRM114-Status: GOOD ( 14.94 ) 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, vincent.guittot@linaro.org, gengyanping@hisilicon.com, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, lonela.Voinescu@arm.com, linux-kernel@vger.kernel.org, Kevin Wangtao , leo.yan@linaro.org, sunzhaosheng@hisilicon.com, Valentin.Schneider@arm.com, linux-arm-kernel@lists.infradead.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 From: Kevin Wangtao The sensor's clock is enabled and disabled outside of the probe and disable function. Moving the corresponding action in the hisi_thermal_setup() and hisi_thermal_disable_sensor(), factors out some lines of code and makes the code more symmetric. Signed-off-by: Kevin Wangtao --- drivers/thermal/hisi_thermal.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 39f4627..c43e3df 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -203,6 +203,8 @@ static void hisi_thermal_disable_sensor(struct hisi_thermal_data *data) hisi_thermal_enable(data->regs, 0); hisi_thermal_alarm_enable(data->regs, 0); hisi_thermal_reset_enable(data->regs, 0); + + clk_disable_unprepare(data->clk); } static int hisi_thermal_get_temp(void *__data, int *temp) @@ -297,9 +299,13 @@ static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, static int hisi_thermal_setup(struct hisi_thermal_data *data) { - struct hisi_thermal_sensor *sensor; + struct hisi_thermal_sensor *sensor = &data->sensor; + int ret; - sensor = &data->sensor; + /* enable clock for tsensor */ + ret = clk_prepare_enable(data->clk); + if (ret) + return ret; /* disable module firstly */ hisi_thermal_reset_enable(data->regs, 0); @@ -363,13 +369,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) return ret; } - /* enable clock for thermal */ - ret = clk_prepare_enable(data->clk); - if (ret) { - dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret); - return ret; - } - ret = hisi_thermal_register_sensor(pdev, data, &data->sensor, HISI_DEFAULT_SENSOR); @@ -405,7 +404,6 @@ static int hisi_thermal_remove(struct platform_device *pdev) hisi_thermal_toggle_sensor(sensor, false); hisi_thermal_disable_sensor(data); - clk_disable_unprepare(data->clk); return 0; } @@ -417,23 +415,14 @@ static int hisi_thermal_suspend(struct device *dev) hisi_thermal_disable_sensor(data); - clk_disable_unprepare(data->clk); - return 0; } static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - int ret; - ret = clk_prepare_enable(data->clk); - if (ret) - return ret; - - hisi_thermal_setup(data); - - return 0; + return hisi_thermal_setup(data); } #endif