From patchwork Thu Oct 19 17:05:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10017853 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 84076602C8 for ; Thu, 19 Oct 2017 17:10:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EE1B28CF0 for ; Thu, 19 Oct 2017 17:10:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63B8428D55; Thu, 19 Oct 2017 17:10:45 +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=unavailable 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 156D128CF0 for ; Thu, 19 Oct 2017 17:10:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755211AbdJSRKb (ORCPT ); Thu, 19 Oct 2017 13:10:31 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:44249 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755105AbdJSRIu (ORCPT ); Thu, 19 Oct 2017 13:08:50 -0400 Received: by mail-wm0-f66.google.com with SMTP id 196so16741250wma.1 for ; Thu, 19 Oct 2017 10:08:50 -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=dAFGnwUGcIyW+JyCLCRVbyCM5D5yhc3ufakQ1nujlr4=; b=Vqs3gldeUAr94j0LZ44Y4FHSNbGXhIn35Fw96jYtC11uQydGodG8t99K9S+iM5epWh i3RzzA17i9/TF1cr2Fo+VFCy96WtxxQ6yMDvVNEgjUMfbRoX2/XcMpOX7Be3xICYnx0+ x48OY7mi3v/wggkXkmFoSC2a4vzS7P3c+B/nE= 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=dAFGnwUGcIyW+JyCLCRVbyCM5D5yhc3ufakQ1nujlr4=; b=cHjRz3NtJ7xcHaCrSY9XHyyWY7FJQtNU0dWDZgckxpLQ60+2bJ7M2Q9VmaDr9+pBfV ZPYwy6VwxJHkV4y3jsRMRmzbAu3Tk5RG5VENh4o1+SmvzS8M4hI95RQrdYad3MLqIPMC HIhWr7MYqV2weJFN2LOk1CiXqF4rKEg2mCDiQ4dm48i3ZOKeb3ssToStnhtZnp9SbRXx iaUtsQuEsyMj22Eq0/JmU2nKPoeC8TwfmpVuJno4JXGrpplyxlcZTx9fNns4de6ibocW HoPGiVonrwUldF0unaCkiAaZgfIF8ZhUtpC/piLJ9lq2sdMDgiV0OolwBY9aSu5B4MaM giHw== X-Gm-Message-State: AMCzsaXmh8xHMc09JJmNOREc5pZu7/zTHOHH1g593y9doMAYHL6jVZ5x uUC7YMAJbQO4KgCwnPQsZIVoag== X-Google-Smtp-Source: ABhQp+QAanU5irQD+1sHieJPvXJH5tJy42fpI0luIwoCYLzzTTQlExOU74Hfl34KtpO5FeWvM+2mmQ== X-Received: by 10.28.107.17 with SMTP id g17mr2471563wmc.58.1508432929322; Thu, 19 Oct 2017 10:08:49 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:48 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, Kevin Wangtao Subject: [PATCH 14/18] thermal/drivers/hisi: Move the clk setup in the corresponding functions Date: Thu, 19 Oct 2017 19:05:56 +0200 Message-Id: <1508432760-17847-14-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-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 Tested-by: Daniel Lezcano # hikey6220 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 8d1a8be..b9e4a9a 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