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: 115436 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4041669qgn; Tue, 10 Oct 2017 11:07:38 -0700 (PDT) X-Received: by 10.99.104.67 with SMTP id d64mr13181683pgc.164.1507658858455; Tue, 10 Oct 2017 11:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507658858; cv=none; d=google.com; s=arc-20160816; b=EJZSUQX59IUpWeGhPdr7Dw2aGuROkx8lHiR5g1FpPiihVIhQBSGG3j9DFjgMrxHj0f dCvVOEF6LDLYF9C9TwJOWewn7Z0lWl6cdUnlo6HEALfK32v5f4UmpBk7HAIt0n4rvaTL S/q74NtiyzJE9TATwkzAqWQFYkvGGv8P9dbu5iwJL0dJm4vPHJ4f/VgvtMvxSfm4p+MP ISPTncemM0nPs0+DVBk5XJ2kTEisEY2CDHA+N6zEwV9hBv8s/HP6jwqk5CxuihjzDlFE DKBcxUuJXrRLKEMAF3LTCIx74BYD+RM8Lt178GNP3Amvrg7VfkyqeqzY4mqBBfwiQTlM XrnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Wq6Hezj/7JkVe+/wn/2eJE6QDGIqLh6oHpkdvsLPt1o=; b=zmUxmXMFyMlbRv9qoZhyzPo1NbyBqPpyiIh3rgwDkUhOpqeNXuL0eYl+Ai8dI0+ghm isXhq48QgPe+Y2mmT10U9BeVJMWmQTyz3zDuvs5615w0enq/Q2p3Gp5O2HZ3ajpMcpRQ F5Hlcsrx/T8oVXEn7+HwUpCCIt1Y38Q2hdJCpfN3EZq7xDRqZd1SpT5VubU9RuBifQpi lsg6AStjLdB/R+O+D1v3P4Vs/OLsPYPKWeI/kUbE4fUpfFhPCayy3A5hBabxGQvPtk/a 35MilezD9zJ6omlpReQY3/FY7iQKK+TA+yRJ5LnsulQhrCxuO3eYjdWZvE05xAT3x+C+ aCWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S5YFtFw6; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44si9460332pla.680.2017.10.10.11.07.38; Tue, 10 Oct 2017 11:07:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S5YFtFw6; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932647AbdJJSHg (ORCPT + 12 others); 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 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(-) -- 2.7.4 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