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: "Wangtao \(Kevin, Kirin\)" X-Patchwork-Id: 114000 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3082108qgf; Fri, 22 Sep 2017 02:49:34 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCP1cMkE0PxITN/lcnvsVmO2MOI16ZL4so6Nwg77/ERWFZVSlAVMp0SKo7/6t5T3/gWn5J4 X-Received: by 10.98.89.6 with SMTP id n6mr8542336pfb.27.1506073773892; Fri, 22 Sep 2017 02:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506073773; cv=none; d=google.com; s=arc-20160816; b=mTKULcBSASCHiA14Y1V/tDUTnwZFpR+qjrw5TuL7YEQX0MGCV373jZTUjLLiuzi2f1 F9/Y21NInspj03au2TwrE4qlw0qA8OHE6wSDaH6l6E5YB7ISmG48QSRQsESZFdufJbr9 SYg0E6/f7orQonWMyYhdFeAku0ptJn5+FDoS+53yv5EsnmPnlWvk6gw4W8dGaeTEaQGI idLQGy1DzVfBmUj0ij3G6LBla1r5/XdLgMucBGaPP2WUdesRk93Uab4xIq4xcG4oWycO FrlcdePq8qs/LKQp2mZ2v7DS9sT+0w5zJJ+hLt/ycw5pR7N8V+TzmmfRt4PrTzX9uklA vkgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=PdPsBR43mUDLvXvkaOlSYYsAk1rOXQpjiB6dERHCJTo=; b=j4umh56TAPwu+MYktY0xBqbP0R/T7Rplq6jZir4CdFJKb8u0QEKC5sm6rkdzyxclHm UydIJkat2cUw3A8WoFv0Fx1rO66q5xqtRXV2PP+2jezGofRDR+Fsz3DJpyzGBH8vI6XZ 8NGD2KP/kbznLvK8Q/63emGqpev6V4fDeP1cWUJihy4OS/lhBbx1j8VgEYTDs2Xd2OJ7 QSl3p+iZTwiWuLXOweHnVC4ndmXPG2BxWXrOoHU9OjEpDYXEUbIaBwIv6TzRGto4lYHR jdYS5nER9TXTxbhiSVrmBMN/m+m+J2DFQoXa0JUg9nquqBqenKSfRL/NibrSYVmjrIzb ereA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f186si2518011pgc.744.2017.09.22.02.49.33; Fri, 22 Sep 2017 02:49:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752128AbdIVJta (ORCPT + 26 others); Fri, 22 Sep 2017 05:49:30 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6544 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbdIVJtZ (ORCPT ); Fri, 22 Sep 2017 05:49:25 -0400 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: , , , , , , CC: , , , , , , , , , , , Kevin Wangtao 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.8.1 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