From patchwork Tue Oct 10 18:02:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 9996925 X-Patchwork-Delegate: eduardo.valentin@ti.com 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 B672960216 for ; Tue, 10 Oct 2017 18:07:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABF0C286C6 for ; Tue, 10 Oct 2017 18:07:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A068A28700; Tue, 10 Oct 2017 18:07:38 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 408A2286C6 for ; Tue, 10 Oct 2017 18:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932647AbdJJSHg (ORCPT ); Tue, 10 Oct 2017 14:07:36 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:49023 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932630AbdJJSFP (ORCPT ); Tue, 10 Oct 2017 14:05:15 -0400 Received: by mail-wm0-f50.google.com with SMTP id i124so7424156wmf.3 for ; Tue, 10 Oct 2017 11:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wq6Hezj/7JkVe+/wn/2eJE6QDGIqLh6oHpkdvsLPt1o=; b=S5YFtFw6/skGFIfCTCXWmU35AteREk2efwtjLTeaohW0esfgU1t3vS4VSDA7+XXZPU FSbXq0x1OPsZH6caGPc8cgX37XJdR78BnmCndU1rz6wso9ABgBBw8tix1JHdhccj/KoM k717ywvgH4/FtlSqE2yymjwafog50D+ahW3v0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wq6Hezj/7JkVe+/wn/2eJE6QDGIqLh6oHpkdvsLPt1o=; b=CLU3C26d5yHlOcjQdVXDorKz+KI5A2P2WZkD7UGqKKadPw9ZZALI91yOlxGkN+giYb ncr+rSf/wXnjj7ttAwqs0Ljo8ICZaH9+j32OxF7K3pz1/c2qxf7iF7rlSl3Y+Ubo7dha l6ckpBAWwzpXkEQUng4niuBxFJbCEX0bxbYpXrhZIESJ2bI7sd7yXoF0EUGuqJcYJjLG PbfN/tBniWMFWESyXK6ayM1sPE8wO31w9l17k0CSxw6UVDUFz0b/rVnvaUUOWAyAbkBT MBQXe301QmnURS1AJ9RMIZnytvSi8atLvMy4VerHTR1nsuFMMA6DcbQHS5ldJEhN2v8W dZmQ== X-Gm-Message-State: AMCzsaUZxPG/6OB+R3CV6V6WKjX/jaDnviEJsgmHoGzICdWqorAVnHbv LqvTvMW0/IQ0g7rA6wdyJEnuzzVGST0= X-Google-Smtp-Source: AOwi7QCNQeXFWxdTN7g+7BBS7Zob3fpvPEiJRIX9uJsHydX5+UExEQY8zpl4S6WFtrHtBTliux1b5Q== X-Received: by 10.28.29.68 with SMTP id d65mr12484111wmd.93.1507658714047; Tue, 10 Oct 2017 11:05:14 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:4f9:3ae1:43d2:31ae]) by smtp.gmail.com with ESMTPSA id l73sm12513428wmd.47.2017.10.10.11.05.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 11:05:13 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kevin.wangtao@linaro.org Subject: [PATCH 17/25] thermal/drivers/hisi: Move the clk setup in the corresponding functions Date: Tue, 10 Oct 2017 20:02:42 +0200 Message-Id: <1507658570-32675-17-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507658570-32675-1-git-send-email-daniel.lezcano@linaro.org> References: <79a5f10c-0fb7-3e4f-caac-c1625904b137@linaro.org> <1507658570-32675-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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 Signed-off-by: Daniel Lezcano --- 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 241d42c..02d0ad8 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