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: 116424 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp723578qgn; Thu, 19 Oct 2017 10:10:35 -0700 (PDT) X-Received: by 10.84.252.141 with SMTP id y13mr1957615pll.295.1508433035056; Thu, 19 Oct 2017 10:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508433035; cv=none; d=google.com; s=arc-20160816; b=qrhf8VdHSHTEdr2/UOIU1eOp6oTy3GxfqkupzcryW3+Sn4D6UI/3x41zDFrTQtTuMG FslgRYn9aqVD9zaeXTlADUyhIU/VWxXT16nK2AfX3/SSt9C+0IIe+ep0fSnTLaCOt1Jo PX/d33CkU/6jvmW8il6Iv/nFoqGpaA8Ac03mHCe9tdoah3SPTo6PZlbIBmNUz/xHGf+9 2bYrBnIjM2WlD6GcGBu8V6CiUTwaWv3ltLQxafTVgnkwrnUQGWqFDZ3YkYTJDsclbERz q5iJsnDCwKdohhTHrcp7nA+YNVfHYn5rTW+YaP/Ce9Mg0bP6MjI8kgZi0BUg9ZDAzeBK N9UA== 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=dAFGnwUGcIyW+JyCLCRVbyCM5D5yhc3ufakQ1nujlr4=; b=hk7U299DtdcNYbIsCq8uMc0ipsmyO2rl3dPhi40msuTHUfM91ind/bq3Z4IgX82+bX IcJv2X8Itoz/Ycz7+04peQkgGMnYXNoikJiHjtY70EHeg/XjV3Cmf3v5foIWpE4//KbK /14eridHRdWraSwHduP2srl3oqXgKa6B8WNF7QJFGtcBVk40Nrc5jzrv+gu/a38iVvF4 TGBkg47BRtDIdoZ7RvhD6S7L+V1ZyJ/0eRSpJ4dV5/OPI+cPJiFCZVPsjnZ6uwCttuFE a7F57KX1vOu/f8RZC+gvK9gYzzXkuUPLJECzRTEG1ZWLQQIFzmOCVjgRoN4mCkAnE/Fe mdVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vqs3glde; 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; 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 30si6518071plf.786.2017.10.19.10.10.34; Thu, 19 Oct 2017 10:10:35 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Vqs3glde; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932082AbdJSRKc (ORCPT + 27 others); Thu, 19 Oct 2017 13:10:32 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:43414 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755106AbdJSRIu (ORCPT ); Thu, 19 Oct 2017 13:08:50 -0400 Received: by mail-wm0-f67.google.com with SMTP id m72so16806035wmc.0 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=alGJouKLMyMCCBsttGrIEELpyGYClvuLFEP+VbCed23CUake07ipU3LvIm7//ehFny +cQsDaMFZmmREJ5OrVCp6pgVX8cr6TbPsizlg1RxFLvsUxsTw3l//BquytekCnmIzVol fBVL7sefCTYbrrM6CAKCb3AP5WqogjORU1xT/NXMfRSLMrl5tqbeHbSUYDGgU/wM0PCg rn3OZBZ0sNLqfKHMOklIzB5ydPdzzAXNlVIJHNeM4tQhzmsRFj3yc1CGaHXcMH8NT9Ly BpifoUn4TNQUssO+XDiohsRzfFb1qduhlI0ntaPfoHvKsYyv0DnRRGvPgVQAsOnD4KnJ fglQ== X-Gm-Message-State: AMCzsaXy0uksAZqciXYisW+ugnhdRehVMBQaCrNAyRRjwmYzPQKujtI/ ZH8UZtkl1Kqs6xfGs7kOK2STag== 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-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 Tested-by: Daniel Lezcano # hikey6220 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 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