From patchwork Tue Oct 10 18:02:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 115423 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4038720qgn; Tue, 10 Oct 2017 11:04:52 -0700 (PDT) X-Received: by 10.84.131.66 with SMTP id 60mr12970069pld.341.1507658692400; Tue, 10 Oct 2017 11:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507658692; cv=none; d=google.com; s=arc-20160816; b=ESwP+Y9VE0oQKXTulek54/jfSJRzEt/nM2hjm7jnSYGKb+PWFVqR8qzFM/08RP1hPo LugPMEUtul6oHctlvR4aV3a49OSvdbPOjvtZrBE/QuhG4H38ssDzNx4atmJDXzyU+mcL rHkpzmjSoneUy5MQVugcyTsdhprO3X3zu/Vn1Run10PvfqVxwrwecfXt8oIarhNNDYOH Ioinq87hXricg+NXq/I605CUMdqVMfL3pW5JxJHHWOjMv2voz+CJ48STVCtvXdMRCSue lIH6KZUtqzLAZYSz+DsOZuQr6dpH38a108mbAaSF46E1FjH9hJp9z6sEnE0M1C4mfOMl yW7A== 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=/+R8+WARc0bg2kwO5tllsXPzLLUBegXV48E2koztXnQ=; b=Lf1ESCWI0y/f9OYmICDIAnRfxIGpd+1cK+h4ukqN69gDejFwxjTjweeNUBUbr2kx6J 0Hz3j2BhxNfyz5ZehVtMHUPKYMHr1VrYhJdDfsAwUdNrWHXL9KkyIj5TW4HWjHruVL/h GAsCeoMy8vhwSidA8mTkZ7UE3OmA3pDNJvOmyQvgXuc1gOtBv6bNO8SkT48lUglMO5yQ c+jvpF+jSm74uRYqv4kIT4kopod3qrvHYgqAwOL385KxUspKPlRCK4aqFjSnciFLzoV/ XLul4MDAGw+y862Gs5xHOfqeOzLQvS68C4CoDxMkFAqJow82N3xQQeJrG7nU0eXhj0G9 291Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DaGKuJLf; 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 bh5si9251169plb.432.2017.10.10.11.04.52; Tue, 10 Oct 2017 11:04:52 -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=DaGKuJLf; 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 S1756353AbdJJSEu (ORCPT + 12 others); Tue, 10 Oct 2017 14:04:50 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:57149 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756288AbdJJSEt (ORCPT ); Tue, 10 Oct 2017 14:04:49 -0400 Received: by mail-wm0-f52.google.com with SMTP id l68so7682935wmd.5 for ; Tue, 10 Oct 2017 11:04:49 -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=/+R8+WARc0bg2kwO5tllsXPzLLUBegXV48E2koztXnQ=; b=DaGKuJLfz6GY/KTfCUTv6skTAlmn8omtYzBLsTMtAf8TDGce9Qqbwu3jaXVjswYoaO Yjz1y7APiSFRpqyc/jDsbuNXCznORg22ay06pzrIuZL317Oj/wdOeiap5TNE0DFwhzHz gVPXbvBRjDEFfsx+nb29scVRp3IH6vylq0WPY= 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=/+R8+WARc0bg2kwO5tllsXPzLLUBegXV48E2koztXnQ=; b=TqznWbvV0znBg/TW7JBrVP8RXAlc/mtV/5zBoFV64ESdBtT5ocEwiPd4JKn560Fme1 4U25c2Noy1ujLndeUFfrMknEpKvhTYirK4GdBQNbARPab18Tr93gDjWkw/274Y8Rj3jp LuR2wG3FVNRgqIIdQ+7ctixT73rO6l5iKI0PuDZd+OsFF21wzzBfCpRIkZxAiE+XPpih 5UYJecnt86eR++rmHOJ8sZp2pCBFiGh9+aTHksmWW1BddwA4AoeCqr0xAK7rcgGpqPvF upb04A2ZdetkzI55A2Rs/G4BDZNVIbVCSQ1uyB1HaWk+SgVybZCgdiu709kxwucMUQwk 5sTA== X-Gm-Message-State: AMCzsaW/B6JRMcCHtfhWNU3WA9E2HImojZClJjYK4H7P5w/cW1hxTlGq mC/CKTmFjVgYNisg/wyFnrsMow== X-Google-Smtp-Source: AOwi7QBgUPb1fkfe4T23qWhR68/hyf7b11aPAlgSYvC6uH1kiLkNaNkfbzjxwF/AR+e+JQvw4I7sRA== X-Received: by 10.223.160.119 with SMTP id l52mr10639483wrl.38.1507658688622; Tue, 10 Oct 2017 11:04:48 -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.04.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 11:04:47 -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, Leo Yan Subject: [PATCH 01/25] thermal/drivers/hisi: Fix missing interrupt enablement Date: Tue, 10 Oct 2017 20:02:26 +0200 Message-Id: <1507658570-32675-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <79a5f10c-0fb7-3e4f-caac-c1625904b137@linaro.org> References: <79a5f10c-0fb7-3e4f-caac-c1625904b137@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The interrupt for the temperature threshold is not enabled at the end of the probe function, enable it after the setup is complete. On the other side, the irq_enabled is not correctly set as we are checking if the interrupt is masked where 'yes' means irq_enabled=false. irq_get_irqchip_state(data->irq, IRQCHIP_STATE_MASKED, &data->irq_enabled); As we are always enabling the interrupt, it is pointless to check if the interrupt is masked or not, just set irq_enabled to 'true'. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan Tested-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 9c3ce34..f3b50b0 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -345,8 +345,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) } hisi_thermal_enable_bind_irq_sensor(data); - irq_get_irqchip_state(data->irq, IRQCHIP_STATE_MASKED, - &data->irq_enabled); + data->irq_enabled = true; for (i = 0; i < HISI_MAX_SENSORS; ++i) { ret = hisi_thermal_register_sensor(pdev, data, @@ -358,6 +357,8 @@ static int hisi_thermal_probe(struct platform_device *pdev) hisi_thermal_toggle_sensor(&data->sensors[i], true); } + enable_irq(data->irq); + return 0; } From patchwork Tue Oct 10 18:02:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 115424 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4038796qgn; Tue, 10 Oct 2017 11:04:57 -0700 (PDT) X-Received: by 10.98.223.15 with SMTP id u15mr14293881pfg.115.1507658697093; Tue, 10 Oct 2017 11:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507658697; cv=none; d=google.com; s=arc-20160816; b=T9hDcQhaEHxVK/X7Ro4Bwd8e/uUkHIslqcZ80PjSshy/8vXlqzL9aozcqpfTN32iXy W2UP2tQzEE0JvDBXHqmZs1bh7yitnd9uskutWVhqw5CQOEYi6Zcf+VvAl7SV52azNQpb 5OPo7S+LD60cSKgAXqz6AqdlTBJaCjq8qy0ojh3yw7bwmlVXcsRApQQo7VeD608MLRbw bVB/AMdoKdeGIpdV6zBJFLGxu3ZZlf2kW2Wyx9zrIAmJzLfMl2YBdi87pVOwdm1Cyk6B xD3mDFARfqTPkRR2h6/Nbh7xBebTzDCDsCjs5e1dbl4AcTMQ90CiEE5GUCHkMUxwADbl cPeA== 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=/G7VRossjOz2nJ1cUs/GSwJYQAD4x98zKuSQTeH8F/c=; b=FULkmTzFmfzojioDnPGSSaV/yy/Q3SlzybN/7s8tL8R572JzotbGS16NQS9HAutgGw nJ1zoEX9bIwT4yF8fiJH5jlJzhJb76pNLWvZF0+Sln477QNmGQZtMGx5k4DOUodHlxYS xXyrhg6BoTiXcRr8Tp9rCbTNNijEvZ+u8XTPLxCDbDHM9eUzlypfc16FJSh+cEFh58iP gQmK/ZH6edPwy4PJjPTagycmhY/YYwPLGlEJ37Lu2uidqpdpiyvC6zMek8WawzrCUzMb lZ416Ght3zImpR401DtIgXMDThDEsCXhaI8NbTx/EtvS12E+f7vaqv/hATdfrhzPKXYl AxHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RTxnLGte; 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 x1si9101286pln.594.2017.10.10.11.04.56; Tue, 10 Oct 2017 11:04:57 -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=RTxnLGte; 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 S1756521AbdJJSEx (ORCPT + 12 others); Tue, 10 Oct 2017 14:04:53 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:53951 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756327AbdJJSEv (ORCPT ); Tue, 10 Oct 2017 14:04:51 -0400 Received: by mail-wm0-f54.google.com with SMTP id q132so7694735wmd.2 for ; Tue, 10 Oct 2017 11:04: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=/G7VRossjOz2nJ1cUs/GSwJYQAD4x98zKuSQTeH8F/c=; b=RTxnLGterHkc0cMexAL+n9DHdxH0YeRR2MEVo7fp16nJRIoR6BuQfZmY0jloLLG6nq eoTfAy8Xd76vARes5LvviR2udBXx8CYlrF4AfUZ7PVvljTlk2PZ9MQngVN6ASdlOQKWF dcZ0FrFh5XXrjuj4XO7A5jHNdGEGYl2J6Qf7Q= 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=/G7VRossjOz2nJ1cUs/GSwJYQAD4x98zKuSQTeH8F/c=; b=VegmE8SktUfKllAY5tNxrkPWTRKmN0lpbtw9e2Pw176G0D38LCRioGJyQDLxSG2M0C RugQox/VvG2WrWBf3Y871OVdoXbtzdwTmcAfIRdDyuFItUDF60XGgF0VH4WxMNjBFgMt z+wsXpRmVDE0lU85QRWHA5os2h6FeESxUBE84yVaiIQ2unlBmmSwQJjnr0Cy/0sOJuBM Uqyeqnm2JPl1P96ZZbM9ZHg7IgH4isDtegER54FdQwF1FzoavnK3k0kY0ki1qmcGcep0 YNiGSrZfn5TE3WR8H/HQH3uMmq18ndPtJKFzSMIu+vYP79APGO4xtBxlpxriylFV/2+D 6Qww== X-Gm-Message-State: AMCzsaUR3gUgKePVj8ZBjJ2jBeI4xDr5ayCA7wU+7tSa3wWk9ERM8eeU i7Ve+iFsoELcMmoZABxaQ6R/yA== X-Google-Smtp-Source: AOwi7QBOp7h8vsr7SZHmkMQbJrZMzEqKEuRRZ2ElEhaBlqh3hia2XTyafyZe9ihM5M9X97qInpsnWA== X-Received: by 10.223.178.144 with SMTP id g16mr14562102wrd.76.1507658690164; Tue, 10 Oct 2017 11:04:50 -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.04.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 11:04:49 -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 02/25] thermal/drivers/hisi: Remove the multiple sensors support Date: Tue, 10 Oct 2017 20:02:27 +0200 Message-Id: <1507658570-32675-2-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 By essence, the tsensor does not really support multiple sensor at the same time. It allows to set a sensor and use it to get the temperature, another sensor could be switched but with a delay of 3-5ms. It is difficult to read simultaneously several sensors without a big delay. Today, just one sensor is used, it is not necessary to deal with multiple sensors in the code. Remove them and if it is needed in the future add them on top of a code which will be clean up in the meantime. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 75 +++++++++++------------------------------- 1 file changed, 19 insertions(+), 56 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index f3b50b0..687efd4 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -39,6 +39,7 @@ #define HISI_TEMP_RESET (100000) #define HISI_MAX_SENSORS 4 +#define HISI_DEFAULT_SENSOR 2 struct hisi_thermal_sensor { struct hisi_thermal_data *thermal; @@ -53,9 +54,8 @@ struct hisi_thermal_data { struct mutex thermal_lock; /* protects register data */ struct platform_device *pdev; struct clk *clk; - struct hisi_thermal_sensor sensors[HISI_MAX_SENSORS]; - - int irq, irq_bind_sensor; + struct hisi_thermal_sensor sensors; + int irq; bool irq_enabled; void __iomem *regs; @@ -113,7 +113,7 @@ static void hisi_thermal_enable_bind_irq_sensor mutex_lock(&data->thermal_lock); - sensor = &data->sensors[data->irq_bind_sensor]; + sensor = &data->sensors; /* setting the hdak time */ writel(0x0, data->regs + TEMP0_CFG); @@ -160,31 +160,8 @@ static int hisi_thermal_get_temp(void *_sensor, int *temp) struct hisi_thermal_sensor *sensor = _sensor; struct hisi_thermal_data *data = sensor->thermal; - int sensor_id = -1, i; - long max_temp = 0; - *temp = hisi_thermal_get_sensor_temp(data, sensor); - sensor->sensor_temp = *temp; - - for (i = 0; i < HISI_MAX_SENSORS; i++) { - if (!data->sensors[i].tzd) - continue; - - if (data->sensors[i].sensor_temp >= max_temp) { - max_temp = data->sensors[i].sensor_temp; - sensor_id = i; - } - } - - /* If no sensor has been enabled, then skip to enable irq */ - if (sensor_id == -1) - return 0; - - mutex_lock(&data->thermal_lock); - data->irq_bind_sensor = sensor_id; - mutex_unlock(&data->thermal_lock); - dev_dbg(&data->pdev->dev, "id=%d, irq=%d, temp=%d, thres=%d\n", sensor->id, data->irq_enabled, *temp, sensor->thres_temp); /* @@ -197,7 +174,7 @@ static int hisi_thermal_get_temp(void *_sensor, int *temp) return 0; } - if (max_temp < sensor->thres_temp) { + if (*temp < sensor->thres_temp) { data->irq_enabled = true; hisi_thermal_enable_bind_irq_sensor(data); enable_irq(data->irq); @@ -224,22 +201,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { struct hisi_thermal_data *data = dev; struct hisi_thermal_sensor *sensor; - int i; mutex_lock(&data->thermal_lock); - sensor = &data->sensors[data->irq_bind_sensor]; + sensor = &data->sensors; dev_crit(&data->pdev->dev, "THERMAL ALARM: T > %d\n", sensor->thres_temp / 1000); mutex_unlock(&data->thermal_lock); - for (i = 0; i < HISI_MAX_SENSORS; i++) { - if (!data->sensors[i].tzd) - continue; - - thermal_zone_device_update(data->sensors[i].tzd, - THERMAL_EVENT_UNSPECIFIED); - } + thermal_zone_device_update(data->sensors.tzd, + THERMAL_EVENT_UNSPECIFIED); return IRQ_HANDLED; } @@ -296,7 +267,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) { struct hisi_thermal_data *data; struct resource *res; - int i; int ret; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); @@ -347,16 +317,17 @@ static int hisi_thermal_probe(struct platform_device *pdev) hisi_thermal_enable_bind_irq_sensor(data); data->irq_enabled = true; - for (i = 0; i < HISI_MAX_SENSORS; ++i) { - ret = hisi_thermal_register_sensor(pdev, data, - &data->sensors[i], i); - if (ret) - dev_err(&pdev->dev, - "failed to register thermal sensor: %d\n", ret); - else - hisi_thermal_toggle_sensor(&data->sensors[i], true); + ret = hisi_thermal_register_sensor(pdev, data, + &data->sensors, + HISI_DEFAULT_SENSOR); + if (ret) { + dev_err(&pdev->dev, "failed to register thermal sensor: %d\n", + ret); + return ret; } + hisi_thermal_toggle_sensor(&data->sensors, true); + enable_irq(data->irq); return 0; @@ -365,17 +336,9 @@ static int hisi_thermal_probe(struct platform_device *pdev) static int hisi_thermal_remove(struct platform_device *pdev) { struct hisi_thermal_data *data = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < HISI_MAX_SENSORS; i++) { - struct hisi_thermal_sensor *sensor = &data->sensors[i]; - - if (!sensor->tzd) - continue; - - hisi_thermal_toggle_sensor(sensor, false); - } + struct hisi_thermal_sensor *sensor = &data->sensors; + hisi_thermal_toggle_sensor(sensor, false); hisi_thermal_disable_sensor(data); clk_disable_unprepare(data->clk); From patchwork Tue Oct 10 18:02:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 115446 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4047512qgn; Tue, 10 Oct 2017 11:13:43 -0700 (PDT) X-Received: by 10.159.244.4 with SMTP id x4mr3413622plr.182.1507659223681; Tue, 10 Oct 2017 11:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507659223; cv=none; d=google.com; s=arc-20160816; b=FHyCZ05PSfw56SONp8625Vw4OztLGg6LVV51mbQlhLFnrrkd84PCqBQFkdiUpKwjTu 7l+GzO/R2WOO4R1L5zNaPlajAlJvtDlZwFKodvoMpc/2RIFbGaMBdGb4wCc2/DMeIyRa CSLjFu3mpNc+VGF3jV8cn8iY3jwFT76kkpDfxMm85GNa5p1S+CeoMU7lzbebxKF1sh45 7r9k75qbXyROqdgbkazvh9i0QbczFz/p4eqlVTi2kIl+JEnAM/6TyV3EVsEpxmhSDHtI KNGutb2EbvhJ7d3N7KPDhaeSYGF0jaS+aJ8QmtLvy2ugMyl/fVrf5hW4fgsxDf+OHuI0 ATww== 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=RXq2HM2wsx+XsSvP5yIIgV1sF/W7OK4M6nuLfQ5ydXg=; b=uOqybWJSVImQhaa4RI1vn17BrLFmsXhE6HFZx14XnHdMDs2uBomICq1ISd8tultDSh koVcWq2arIgWQ4bBwl+lsjU3+PNISqpbmRQgMn+G2IMu4gtM28oUssiGCQv4/Hx8d+LQ fN6ZRAtwh0WEC9nPE0VCRI7q59/uPB2qkJEMwx/iVorw2b9d1eYm8vVqm4bF25mNvhHS mpGySupFjj66O4bfSuYd4cs6Xqv8xcjs23dXSt8Q0pCqQzRnCmd/80uVLPTT0qNKX5x2 +nsRXjMEj8tvtAZvhYt+VScWYImjtnOqRxEDo+yysZ68OBhNV3vMSVB/iRSB8M4EHUh9 Hkow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VW3bnQcY; 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 b3si5164584plr.706.2017.10.10.11.13.43; Tue, 10 Oct 2017 11:13:43 -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=VW3bnQcY; 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 S932406AbdJJSNk (ORCPT + 12 others); Tue, 10 Oct 2017 14:13:40 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:45641 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932257AbdJJSE5 (ORCPT ); Tue, 10 Oct 2017 14:04:57 -0400 Received: by mail-wm0-f41.google.com with SMTP id q124so7514849wmb.0 for ; Tue, 10 Oct 2017 11:04:57 -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=RXq2HM2wsx+XsSvP5yIIgV1sF/W7OK4M6nuLfQ5ydXg=; b=VW3bnQcYOBcSQ1COk3TADLu3xmnMCcx5z+nXvg8DFFIJ/Svs6k/xJv0qRHsedaPU3q 4b0k5Y3ws4SWFz3tIF0xj2d4UhAKOHohyUhKJf18NhKhbioYb3lBN9RV4ocEG8vxbgfc tfURKu8xFsPkEAb1S1tUQEJWmb8Hj/qUjVzro= 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=RXq2HM2wsx+XsSvP5yIIgV1sF/W7OK4M6nuLfQ5ydXg=; b=uZQcJF4qUrjlBqsTieC2YNgLVs+euGaLLMMGO7RAyjNYUv3vl3o5iPigLlRT7t6gzW Rc/yKoHICJb+eSTB5mS/fICyAV/LQL9KijOO5WSAgcIhNyntHbcVWcANRXnM/DxnVIA9 qH7BWcrmQJ0icb4+Ts76GduKBRNQbYI24lu5IO8rieNKbUHRcDG4jMY06xKBNN1rtgXZ qOO7XRlOCk/UG7YexC/Qi7wvDOKEa+2AtEl5V1T7cKedMWdoshx9s6/h/WcAShRqk250 v9+HEbU4y8rq7fRm8M+Wopg7IBJVxJRy//9l0JogEfxHp0dEP9ytFy3mBn/XxsyN9irV gV/A== X-Gm-Message-State: AMCzsaWsnsY59CbR3BS7Q7BMotU+ZByhUGtH9YDtX/Qu4IlaWsOEziDG pCSz/tHLXqpZmR+XxgIyYILWcw== X-Google-Smtp-Source: AOwi7QAU90zDyicY6hGRCcB6j/zuXK4H+uSJsBXXtUT8ZEHFrQ2Z6EvJvGda3y1GbcUSmXXckW/9BQ== X-Received: by 10.28.127.206 with SMTP id a197mr10981979wmd.12.1507658696360; Tue, 10 Oct 2017 11:04:56 -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.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 11:04:55 -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 06/25] thermal/drivers/hisi: Remove pointless lock Date: Tue, 10 Oct 2017 20:02:31 +0200 Message-Id: <1507658570-32675-6-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 The threaded interrupt inspect the sensors structure to look in the temp threshold field, but this field is read-only in all the code, except in the probe function before the threaded interrupt is set. In other words there is not race window in the threaded interrupt when reading the field value. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 1b44bfe..b657ae4 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -221,14 +221,10 @@ static irqreturn_t hisi_thermal_alarm_irq(int irq, void *dev) static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { struct hisi_thermal_data *data = dev; - struct hisi_thermal_sensor *sensor; - - mutex_lock(&data->thermal_lock); - sensor = &data->sensors; + struct hisi_thermal_sensor *sensor = &data->sensors; dev_crit(&data->pdev->dev, "THERMAL ALARM: T > %d\n", sensor->thres_temp); - mutex_unlock(&data->thermal_lock); thermal_zone_device_update(data->sensors.tzd, THERMAL_EVENT_UNSPECIFIED); From patchwork Tue Oct 10 18:02:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 115444 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4047223qgn; Tue, 10 Oct 2017 11:13:24 -0700 (PDT) X-Received: by 10.99.125.23 with SMTP id y23mr13458266pgc.333.1507659204131; Tue, 10 Oct 2017 11:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507659204; cv=none; d=google.com; s=arc-20160816; b=icb14p2fLNn2lGx8UPTOGdNb8N7XJyxh5jh68uMOYC43sHniRmzoso2HXPvigcC8PR 9SZjhSTe2vbJc8Dg8QnyZOIaZAZCDhFfwD7w5P4+hhdCEf0LH0pikNASEMObJEmy/auw x3u+fiwms6sGFkmR33iQ2JQ4ZmVmzjeFAYVjDPfsXzhdQZ9O0RAg3IRZuconADoBdm7c w+V2Wd7yyW2RYEJHUbeA4+ADy38M1+kYmka3IIC4Ce3JY9usg3Ue1RQMSiftJ1suLGF4 tDNJpmptW3TerNN0/XNNcx7HgXszwn9chEnQX4KgVREAaC5cUfM3UIRIUjHvUTOb3cN5 gvPw== 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=myNl1kd3kkDnlKDudMbJudZ0nM85VsriuAjESUtGHGE=; b=SUvARAyx6EuIlE3IoE8ULdMxmF/0O2eyrnwx0wdYK3g5jMXJq5CM3R2tUed3WLQRce 9JOcOdqoDt/mNlCZkVf8XXEYfEyOWdBF2+oOMRECvUnkQ+znquLy7W9K5zduloQgWCCM ENdwnENfTStEXEWXEO+RrsoBKjif6y8eAfpRIqd4QRbEBZTxgJOKf4Kgmm/QqRK/f+Yh AZ4929mtgn/QMInPqFz/SetCLnhouHeeQEidBSz3gZ1i+TNikbeHOsVfF7vSlnsNSvrx ezxFiCk/IfSwWcA1et62q3WSGaT8VEkZGh//naCSVWkK22ETZkmgMQDyKSG2yY+lP3kr T4GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gUm0PaNw; 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 q81si9081475pfg.32.2017.10.10.11.13.23; Tue, 10 Oct 2017 11:13:24 -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=gUm0PaNw; 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 S932499AbdJJSNV (ORCPT + 12 others); Tue, 10 Oct 2017 14:13:21 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:53988 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932408AbdJJSE7 (ORCPT ); Tue, 10 Oct 2017 14:04:59 -0400 Received: by mail-wm0-f50.google.com with SMTP id q132so7695597wmd.2 for ; Tue, 10 Oct 2017 11:04:58 -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=myNl1kd3kkDnlKDudMbJudZ0nM85VsriuAjESUtGHGE=; b=gUm0PaNwKo3iuoGME7g8eog+wM47CvfieB7tsIdBATxviEB/OoEYZ1jBP2dEBqKJ5Z lGJksThUgZJ26l9I1mT1enIw5uy3VGn8I23t/ZAzE5ryZ2BKgINp934lXYVWA4xS81fw 8fEuMxs8/KNgFvnMJzSOuR27W2game2ULdgBg= 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=myNl1kd3kkDnlKDudMbJudZ0nM85VsriuAjESUtGHGE=; b=W7yOF8JUeT1WJU5A89Hf586CnhXgJGNT1dIkrBfXBG9Kd1r7q8NkzG7Lp0kPsX+gIR 8r2Mc/zyATNtOxbybNzsaGk05Fu/ueyrssPu+cLdZVH697M+yqnISwCVleJq686W0ikM Oz2vlBLUlsmH/yytwFoPFT4nd4U5HaadHAbvRgxi9wohPMWhx9ukf5Pwq15xGt+GwwF+ WH/+4wGDQIcVuOIVnYyTDXm2nVDA5Ut3WDC5ivglVNHLtxGAdCsBFZ82NN6xs7dcvVmb P0nM8cyFQ5iOE15iLFwnxl6maIUWR0t7F7tfzRD2DH23Bz0gw0IhuoSoW9XoiCibyvZG GuHg== X-Gm-Message-State: AMCzsaV2d6YK1nQ+DTqxV+F7+ImnPN758wrfwGyk8NZstBHsHztFa5lE 2mvhR35T5WxLYdGp+EwtAeeRpQ== X-Google-Smtp-Source: AOwi7QBXT2MWoATe+YRxKo6Wgy5I8tq3HGyN1RQ2bDmHQq5Ywl1pmBxpdWhuxa0o8QpE0QPHd8IaBg== X-Received: by 10.28.12.65 with SMTP id 62mr13393223wmm.129.1507658697850; Tue, 10 Oct 2017 11:04:57 -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.04.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 11:04:57 -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 07/25] thermal/drivers/hisi: Encapsulate register writes into helpers Date: Tue, 10 Oct 2017 20:02:32 +0200 Message-Id: <1507658570-32675-7-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 Hopefully, the function name can help to clarify the semantic of the operations when writing in the register. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 92 ++++++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index b657ae4..8e8a117 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -26,6 +26,7 @@ #include "thermal_core.h" +#define TEMP0_LAG (0x0) #define TEMP0_TH (0x4) #define TEMP0_RST_TH (0x8) #define TEMP0_CFG (0xC) @@ -96,6 +97,56 @@ static inline long hisi_thermal_round_temp(int temp) hisi_thermal_temp_to_step(temp)); } +static inline void hisi_thermal_set_lag(void __iomem *addr, int value) +{ + writel(value, addr + TEMP0_LAG); +} + +static inline void hisi_thermal_alarm_clear(void __iomem *addr, int value) +{ + writel(value, addr + TEMP0_INT_CLR); +} + +static inline void hisi_thermal_alarm_enable(void __iomem *addr, int value) +{ + writel(value, addr + TEMP0_INT_EN); +} + +static inline void hisi_thermal_alarm_set(void __iomem *addr, int temp) +{ + writel(hisi_thermal_temp_to_step(temp) | 0x0FFFFFF00, addr + TEMP0_TH); +} + +static inline void hisi_thermal_reset_set(void __iomem *addr, int temp) +{ + writel(hisi_thermal_temp_to_step(temp), addr + TEMP0_RST_TH); +} + +static inline void hisi_thermal_reset_enable(void __iomem *addr, int value) +{ + writel(value, addr + TEMP0_RST_MSK); +} + +static inline void hisi_thermal_enable(void __iomem *addr, int value) +{ + writel(value, addr + TEMP0_EN); +} + +static inline void hisi_thermal_sensor_select(void __iomem *addr, int sensor) +{ + writel((sensor << 12), addr + TEMP0_CFG); +} + +static inline int hisi_thermal_get_temperature(void __iomem *addr) +{ + return hisi_thermal_step_to_temp(readl(addr + TEMP0_VALUE)); +} + +static inline void hisi_thermal_hdak_set(void __iomem *addr, int value) +{ + writel(value, addr + TEMP0_CFG); +} + static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data, struct hisi_thermal_sensor *sensor) { @@ -104,22 +155,21 @@ static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data, mutex_lock(&data->thermal_lock); /* disable interrupt */ - writel(0x0, data->regs + TEMP0_INT_EN); - writel(0x1, data->regs + TEMP0_INT_CLR); + hisi_thermal_alarm_enable(data->regs, 0); + hisi_thermal_alarm_clear(data->regs, 1); /* disable module firstly */ - writel(0x0, data->regs + TEMP0_EN); + hisi_thermal_enable(data->regs, 0); /* select sensor id */ - writel((sensor->id << 12), data->regs + TEMP0_CFG); + hisi_thermal_sensor_select(data->regs, sensor->id); /* enable module */ - writel(0x1, data->regs + TEMP0_EN); + hisi_thermal_enable(data->regs, 1); usleep_range(3000, 5000); - val = readl(data->regs + TEMP0_VALUE); - val = hisi_thermal_step_to_temp(val); + val = hisi_thermal_get_temperature(data->regs); mutex_unlock(&data->thermal_lock); @@ -136,28 +186,26 @@ static void hisi_thermal_enable_bind_irq_sensor sensor = &data->sensors; /* setting the hdak time */ - writel(0x0, data->regs + TEMP0_CFG); + hisi_thermal_hdak_set(data->regs, 0); /* disable module firstly */ - writel(0x0, data->regs + TEMP0_RST_MSK); - writel(0x0, data->regs + TEMP0_EN); + hisi_thermal_reset_enable(data->regs, 0); + hisi_thermal_enable(data->regs, 0); /* select sensor id */ - writel((sensor->id << 12), data->regs + TEMP0_CFG); + hisi_thermal_sensor_select(data->regs, sensor->id); /* enable for interrupt */ - writel(hisi_thermal_temp_to_step(sensor->thres_temp) | 0x0FFFFFF00, - data->regs + TEMP0_TH); + hisi_thermal_alarm_set(data->regs, sensor->thres_temp); - writel(hisi_thermal_temp_to_step(HISI_TEMP_RESET), - data->regs + TEMP0_RST_TH); + hisi_thermal_reset_set(data->regs, HISI_TEMP_RESET); /* enable module */ - writel(0x1, data->regs + TEMP0_RST_MSK); - writel(0x1, data->regs + TEMP0_EN); + hisi_thermal_reset_enable(data->regs, 1); + hisi_thermal_enable(data->regs, 1); - writel(0x0, data->regs + TEMP0_INT_CLR); - writel(0x1, data->regs + TEMP0_INT_EN); + hisi_thermal_alarm_clear(data->regs, 0); + hisi_thermal_alarm_enable(data->regs, 1); usleep_range(3000, 5000); @@ -169,9 +217,9 @@ static void hisi_thermal_disable_sensor(struct hisi_thermal_data *data) mutex_lock(&data->thermal_lock); /* disable sensor module */ - writel(0x0, data->regs + TEMP0_INT_EN); - writel(0x0, data->regs + TEMP0_RST_MSK); - writel(0x0, data->regs + TEMP0_EN); + hisi_thermal_enable(data->regs, 0); + hisi_thermal_alarm_enable(data->regs, 0); + hisi_thermal_reset_enable(data->regs, 0); mutex_unlock(&data->thermal_lock); } From patchwork Tue Oct 10 18:02:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 115440 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4045926qgn; Tue, 10 Oct 2017 11:11:56 -0700 (PDT) X-Received: by 10.159.218.9 with SMTP id v9mr2930289plp.92.1507659116894; Tue, 10 Oct 2017 11:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507659116; cv=none; d=google.com; s=arc-20160816; b=tYbRi9iSk87MXOCnjmncKRLMJIQgYQ6e1lGXO3JIp7QYzY/+650AK3jKL/CwqG4umP AMdIUtfG0nzXsb86hZTeElFG8dvKNXl82F3ikzAFAaftuP7iA33Fe85qPy70hUdWpRxO pdAeNSbQIaGahiyejMmQZiL2vjcmfVapbjLBVFNt5ub/6FQ2OLIGK9Z7KzOfZAz6EOmr SK3NBj10J/uNEGpLL4X/Jc6XAwr1ay9xR87Cf4jNK4Ign2nIZ2i7SiNIWh00TDsAseX+ QftCmi6wCG/w+eFEZmyzDVdAkYd1MTDXpph0HTGSZU5gFR8bL6SY8vFijpx92RdDiuwq 9nRw== 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=8tlFkhzvnYbROhWQTnLeyuuETSlHmvgdSfYQC4eh5q0=; b=eZt93C1KuksVfuAL18z+2nNlSxqXFyzd7gnRfNgAsQ6ZlUXPyq1s+HrSdMEOlhrKhH I2lq87V3Gl+1qJbKI+dwnxCcqr+iqJpOEwHcmovovAsQ/ZKen+yNoshISFdU7d97OTiP qQCO65hYWGodVEq/VhGuAkLA94i7KKpr+HqWGjjaPWiZkzjp9qXvy2FQIhlSeQnrZjJc /N/p6isAxVuL9S1MIzJwiVbrV+9QWVIX1CJ91YVwfZmhA7bJAL0Xdf+pvC7/d0jYI6nA wfCMT+iLe/Lng4an/88CfLFOr8N81U3mb8oaTQ+TSMWeHh1OPU7bc+vG/VTSpn0Fm0Z/ pX+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zf6Ywt+j; 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 l3si2358810pgs.468.2017.10.10.11.11.56; Tue, 10 Oct 2017 11:11:56 -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=Zf6Ywt+j; 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 S932316AbdJJSLy (ORCPT + 12 others); Tue, 10 Oct 2017 14:11:54 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:52099 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932572AbdJJSFG (ORCPT ); Tue, 10 Oct 2017 14:05:06 -0400 Received: by mail-wm0-f50.google.com with SMTP id f4so7717381wme.0 for ; Tue, 10 Oct 2017 11:05:05 -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=8tlFkhzvnYbROhWQTnLeyuuETSlHmvgdSfYQC4eh5q0=; b=Zf6Ywt+jn2LJECScQ3IgtoVT+LotCYdfmL87SgyzyNdPLRM13zFtbo1nAn+so+TUl7 QlfMo5PDZh9ruKT3s5qEEtV+99eGUmVq6IC4ZwOg2f7yy/pJ6CNt3U+ZyvHojYClkNvW wT6HrbCWfhGdNJ9rE04bGa5n95u/jT7RZ2K5s= 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=8tlFkhzvnYbROhWQTnLeyuuETSlHmvgdSfYQC4eh5q0=; b=bL30QjU8kUablGaLhCZkEP9w6RcoCwlbF90DG9+6C2QQ0D0BaFWOyt9XJdjWKVhdsc gU0mXwCGVFj0xdrEZIk1utQNDHtCUlnZpcnzf/GKxli+DHbOOGmK6BLYtaSKCj4w0WhZ DqNdC4La8tyG7Rr4eae2barS/vzb0TJ0Cd2zWo2+R1FqkzT52q99rn5ZJCXYJYQsSt7I lrAR/0g7AWvmJN8MGhTbvhZsNWiNpok3k3KYdQDR8isP2LRz5uSKgmS8K2MVLhVeQanq 6icLTCZinl4cnvplA+DsFGP39jDh1Nj/3kXsZxXYouga1IY8Bn5WPWIrT5MAquKp5r+d Jwcw== X-Gm-Message-State: AMCzsaXAX4u3wvkerc4AAcOqs2qBPzADwO0awYWhtdp2LH5RyVEUbd81 YVf+1qXqY7Q+hvQ7An6AJ5PBZw== X-Google-Smtp-Source: AOwi7QC5mOH6tgBfVzZSpNpjlbue41F/1ICU3vCDvJnTlgYgjWWYtRP3fuG0LEMXWKZv5Va8A9s4Gw== X-Received: by 10.28.36.212 with SMTP id k203mr10564874wmk.127.1507658704762; Tue, 10 Oct 2017 11:05:04 -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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Oct 2017 11:05:04 -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 11/25] thermal/drivers/hisi: Convert long to int Date: Tue, 10 Oct 2017 20:02:36 +0200 Message-Id: <1507658570-32675-11-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 There is no point to specify the temperature as long variable, the int is enough. Replace all long variables to int, so making the code consistent. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 70dc373..dabe9a8 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -85,12 +85,12 @@ static inline int hisi_thermal_step_to_temp(int step) return HISI_TEMP_BASE + (step * HISI_TEMP_STEP); } -static inline long hisi_thermal_temp_to_step(long temp) +static inline int hisi_thermal_temp_to_step(int temp) { return (temp - HISI_TEMP_BASE) / HISI_TEMP_STEP; } -static inline long hisi_thermal_round_temp(int temp) +static inline int hisi_thermal_round_temp(int temp) { return hisi_thermal_step_to_temp( hisi_thermal_temp_to_step(temp)); 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