From patchwork Sun Dec 15 05:16:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292617 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DDEC112B for ; Sun, 15 Dec 2019 05:16:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D52EC21D7E for ; Sun, 15 Dec 2019 05:16:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lgIq0zqI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726135AbfLOFQv (ORCPT ); Sun, 15 Dec 2019 00:16:51 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:34149 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfLOFQv (ORCPT ); Sun, 15 Dec 2019 00:16:51 -0500 Received: by mail-pl1-f196.google.com with SMTP id x17so3027279pln.1; Sat, 14 Dec 2019 21:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n0KhyDCT2TCIrEIHc5SljPjq7/DPKAvuDMKsxr9T9Ug=; b=lgIq0zqICEGkShIiMlrRjg7wcHEI9dK51w0R58Dh9CwsqNaakn38i5+2w5nWs5CH7X w2EKVfs7d8XmlDi3EvBlHgX4T/0wVMtgsl0hwYaEz0Aqe0B6GRB0D9xdckPZCrNzQG2f v2x4eesrgQGuTq/s1TIoLj7PEJqYcFbmeSZYPe3p7W6DSo/IPcTtI3k6cv3OjCI/Frs/ pHc+af0QUGv3Oj0XSK7fAtkIUrtuyNcs50ocYSusYWnBTqaCDN6CN7wrY0nNgiwLscBG LJ7lG7D5f/5pbURcyx8x4ZqGsBr7/1kpP2jYiui9QXPdmr95VB/CrW+WuX2GkhpC23s+ ZI+Q== 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=n0KhyDCT2TCIrEIHc5SljPjq7/DPKAvuDMKsxr9T9Ug=; b=U8Q26I8IB5UT8sAdkulIcSjo6/F0vEs45URHNTNjqU1uHqAB+D1h2i8ToyaEowIThF h0u4sBzWMnIy1cK1u9zFoNjzGB41B+8gDLgI53d/pW/VmDPdVEUeWPGyLh+j/LgZi/z5 AYYDEg9Y60gQrwtovh7y9EvzuHMmP1HjqooS9U+Ti0vRQvDj6CUC4FcBTfWEqW3X5dPJ hbh3jMn8DWOjZsA89xtGbOipAjecRUWHyFAQOQV79OmhYUB3LoTOvwNXAvQbHogM1BfU OUL0rpM1gj/r4oOjH5TRlWxePBR+zmBFAx0CeEHbudGXozngYNYT3UFSSA2POu13pucx oCfA== X-Gm-Message-State: APjAAAWCFxNahHjSLM+YTep0kESEEUnEV6U4dTXgLuWLcE+Us4lU+Oqo KaXiHmAcN/c9ms9SgVXdea8= X-Google-Smtp-Source: APXvYqx/G9Lcdyqm7bOXicjyPxETdKBX/bMleOf2pzp/lJbLyACAZhxo8XIP/QCbx34gj5XMJ7UO5w== X-Received: by 2002:a17:902:a516:: with SMTP id s22mr9160425plq.89.1576387010091; Sat, 14 Dec 2019 21:16:50 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.16.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:16:49 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Kalle Valo , Stanislaw Gruszka , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Subject: [PATCH v4 01/12] add helpers for kelvin to/from Celsius conversion Date: Sun, 15 Dec 2019 14:16:04 +0900 Message-Id: <1576386975-7941-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org There are several helper macros to convert kelvin to/from Celsius in for thermal drivers. These are useful for any other drivers or subsystems, but it's odd to include just for the helpers. This adds a new that provides the equivalent inline functions for any drivers or subsystems. It is intended to replace the helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Kalle Valo Cc: Stanislaw Gruszka Cc: Johannes Berg Cc: Emmanuel Grumbach Cc: Luca Coelho Cc: Intel Linux Wireless Cc: Jonathan Cameron Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Reviewed-by: Andy Shevchenko Signed-off-by: Akinobu Mita --- * v4 - add Reviewed-by tag include/linux/units.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 include/linux/units.h diff --git a/include/linux/units.h b/include/linux/units.h new file mode 100644 index 0000000..aaf7163 --- /dev/null +++ b/include/linux/units.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_UNITS_H +#define _LINUX_UNITS_H + +#include + +#define ABSOLUTE_ZERO_MILLICELSIUS -273150 + +static inline long milli_kelvin_to_millicelsius(long t) +{ + return t + ABSOLUTE_ZERO_MILLICELSIUS; +} + +static inline long millicelsius_to_milli_kelvin(long t) +{ + return t - ABSOLUTE_ZERO_MILLICELSIUS; +} + +#define MILLIDEGREE_PER_DEGREE 1000 +#define MILLIDEGREE_PER_DECIDEGREE 100 + +static inline long kelvin_to_millicelsius(long t) +{ + return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DEGREE); +} + +static inline long millicelsius_to_kelvin(long t) +{ + t = millicelsius_to_milli_kelvin(t); + + return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE); +} + +static inline long deci_kelvin_to_celsius(long t) +{ + t = milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DECIDEGREE); + + return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE); +} + +static inline long celsius_to_deci_kelvin(long t) +{ + t = millicelsius_to_milli_kelvin(t * MILLIDEGREE_PER_DEGREE); + + return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DECIDEGREE); +} + +/** + * deci_kelvin_to_millicelsius_with_offset - convert Kelvin to Celsius + * @t: temperature value in decidegrees Kelvin + * @offset: difference between Kelvin and Celsius in millidegrees + * + * Return: temperature value in millidegrees Celsius + */ +static inline long deci_kelvin_to_millicelsius_with_offset(long t, long offset) +{ + return t * MILLIDEGREE_PER_DECIDEGREE - offset; +} + +static inline long deci_kelvin_to_millicelsius(long t) +{ + return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DECIDEGREE); +} + +static inline long millicelsius_to_deci_kelvin(long t) +{ + t = millicelsius_to_milli_kelvin(t); + + return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DECIDEGREE); +} + +static inline long kelvin_to_celsius(long t) +{ + return t + DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS, + MILLIDEGREE_PER_DEGREE); +} + +static inline long celsius_to_kelvin(long t) +{ + return t - DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS, + MILLIDEGREE_PER_DEGREE); +} + +#endif /* _LINUX_UNITS_H */ From patchwork Sun Dec 15 05:16:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292621 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEC41112B for ; Sun, 15 Dec 2019 05:16:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A161724654 for ; Sun, 15 Dec 2019 05:16:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f/OUThot" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726232AbfLOFQ5 (ORCPT ); Sun, 15 Dec 2019 00:16:57 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38975 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfLOFQ4 (ORCPT ); Sun, 15 Dec 2019 00:16:56 -0500 Received: by mail-pg1-f194.google.com with SMTP id b137so1723509pga.6; Sat, 14 Dec 2019 21:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+ni+XvUfeKyfzr2yd/pJZb0s5CL2FQmAH0qUgXjirMQ=; b=f/OUThotWQpXaPGbzZ5R2FFLQ9ZUuy00n1PH97c9VUEl75bjGc9e0sh4S8N0ybzh2n qMJB8Bm9YAiCGqFwp3vDbHJ0xpZ8jEdF/uLy4Alyt3KKPeEo7fQwbL4cnyGigGd5bc8u GtiocPYRjuw8KZon5ULZi9jVlmgPoADTR2ntVtsAUdxzVQq/7iWq5Meu4KkHjL8w60FI iBeFKiN4y48MNQW7DYPIU/98OSOoGsJXtRB8hq4I65KzxdtwjprvTSRnZarEskRf5+by /tVG6bXx5Qn/RUBGtMlwu/9C7yUUCmvHm/Bhsa/AihPo04Ym0Xqdn8C+FjS5DQuavmxk ymsg== 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=+ni+XvUfeKyfzr2yd/pJZb0s5CL2FQmAH0qUgXjirMQ=; b=Z2DaRucLW8jLkOKf5XErl5TccVBPOPmSkQqq3RkWHNGNkGbZc1AdxMTuIQVrQz23Ev oOE+AjMMFpsbfQ2VjfgzY2aUxFkNbt32848sixxQgRUbYlO31BMPd2bStvwoOm7qauP4 mSbiyX3WIPhiMvsX82Cc/vSvSohAU0QWPDNxbQLpDtNMVAxhHN0ETjliS/jt6eNb8YOQ n3q7F2NgndMNxKM6BcU8WCkM4KAiP/HBpz4Z34Ioc/V3MvGcSXj23VccIKv9BCu24N7V Lgx0+4oI4JRXFl03lLNTFeUx/v4gNjAjml/Jp/ughziykna3b4VE9ovjoPx44sHlem3y U1Ew== X-Gm-Message-State: APjAAAU6G4jIh56R2x4bQSUB0hXZdgScLzCxBeY7M0wunk7SGBOx0dCA 4mHn1ljsZS4wwhM3Wscvxxc= X-Google-Smtp-Source: APXvYqxRB7OPbFfVEFAxX9HKfb1NP04PbmHKjMIQqfZChZstN8X4ZFRN9baeNaRgyvH4MwVUoPUBEw== X-Received: by 2002:a63:d544:: with SMTP id v4mr9985261pgi.288.1576387015843; Sat, 14 Dec 2019 21:16:55 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.16.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:16:55 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH v4 02/12] ACPI: thermal: switch to use helpers Date: Sun, 15 Dec 2019 14:16:05 +0900 Message-Id: <1576386975-7941-3-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the ACPI thermal zone driver to use celsius_to_deci_kelvin(), deci_kelvin_to_celsius(), and deci_kelvin_to_millicelsius_with_offset() in instead of helpers in . This is preparation for centralizing the kelvin to/from Celsius conversion helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita --- * v4 - change include order - keep the line over 80 characters because this change doesn't make it longer drivers/acpi/thermal.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index d831a61..19067a5 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -27,6 +27,7 @@ #include #include #include +#include #define PREFIX "ACPI: " @@ -172,7 +173,7 @@ struct acpi_thermal { struct acpi_handle_list devices; struct thermal_zone_device *thermal_zone; int tz_enabled; - int kelvin_offset; + int kelvin_offset; /* in millidegrees */ struct work_struct thermal_check_work; }; @@ -297,7 +298,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) if (crt == -1) { tz->trips.critical.flags.valid = 0; } else if (crt > 0) { - unsigned long crt_k = CELSIUS_TO_DECI_KELVIN(crt); + unsigned long crt_k = celsius_to_deci_kelvin(crt); + /* * Allow override critical threshold */ @@ -333,7 +335,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) if (psv == -1) { status = AE_SUPPORT; } else if (psv > 0) { - tmp = CELSIUS_TO_DECI_KELVIN(psv); + tmp = celsius_to_deci_kelvin(psv); status = AE_OK; } else { status = acpi_evaluate_integer(tz->device->handle, @@ -413,7 +415,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) break; if (i == 1) tz->trips.active[0].temperature = - CELSIUS_TO_DECI_KELVIN(act); + celsius_to_deci_kelvin(act); else /* * Don't allow override higher than @@ -421,9 +423,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) */ tz->trips.active[i - 1].temperature = (tz->trips.active[i - 2].temperature < - CELSIUS_TO_DECI_KELVIN(act) ? + celsius_to_deci_kelvin(act) ? tz->trips.active[i - 2].temperature : - CELSIUS_TO_DECI_KELVIN(act)); + celsius_to_deci_kelvin(act)); break; } else { tz->trips.active[i].temperature = tmp; @@ -519,7 +521,7 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) if (result) return result; - *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(tz->temperature, + *temp = deci_kelvin_to_millicelsius_with_offset(tz->temperature, tz->kelvin_offset); return 0; } @@ -624,7 +626,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, if (tz->trips.critical.flags.valid) { if (!trip) { - *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( + *temp = deci_kelvin_to_millicelsius_with_offset( tz->trips.critical.temperature, tz->kelvin_offset); return 0; @@ -634,7 +636,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, if (tz->trips.hot.flags.valid) { if (!trip) { - *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( + *temp = deci_kelvin_to_millicelsius_with_offset( tz->trips.hot.temperature, tz->kelvin_offset); return 0; @@ -644,7 +646,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, if (tz->trips.passive.flags.valid) { if (!trip) { - *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( + *temp = deci_kelvin_to_millicelsius_with_offset( tz->trips.passive.temperature, tz->kelvin_offset); return 0; @@ -655,7 +657,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid; i++) { if (!trip) { - *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( + *temp = deci_kelvin_to_millicelsius_with_offset( tz->trips.active[i].temperature, tz->kelvin_offset); return 0; @@ -672,7 +674,7 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal, struct acpi_thermal *tz = thermal->devdata; if (tz->trips.critical.flags.valid) { - *temperature = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( + *temperature = deci_kelvin_to_millicelsius_with_offset( tz->trips.critical.temperature, tz->kelvin_offset); return 0; @@ -692,7 +694,7 @@ static int thermal_get_trend(struct thermal_zone_device *thermal, if (type == THERMAL_TRIP_ACTIVE) { int trip_temp; - int temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET( + int temp = deci_kelvin_to_millicelsius_with_offset( tz->temperature, tz->kelvin_offset); if (thermal_get_trip_temp(thermal, trip, &trip_temp)) return -EINVAL; @@ -1043,9 +1045,9 @@ static void acpi_thermal_guess_offset(struct acpi_thermal *tz) { if (tz->trips.critical.flags.valid && (tz->trips.critical.temperature % 5) == 1) - tz->kelvin_offset = 2731; + tz->kelvin_offset = 273100; else - tz->kelvin_offset = 2732; + tz->kelvin_offset = 273200; } static void acpi_thermal_check_fn(struct work_struct *work) @@ -1087,7 +1089,7 @@ static int acpi_thermal_add(struct acpi_device *device) INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), - acpi_device_bid(device), DECI_KELVIN_TO_CELSIUS(tz->temperature)); + acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); goto end; free_memory: From patchwork Sun Dec 15 05:16:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C9AE112B for ; Sun, 15 Dec 2019 05:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 680B421D7E for ; Sun, 15 Dec 2019 05:17:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FPmAVeP2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726470AbfLOFRD (ORCPT ); Sun, 15 Dec 2019 00:17:03 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42630 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfLOFRC (ORCPT ); Sun, 15 Dec 2019 00:17:02 -0500 Received: by mail-pg1-f196.google.com with SMTP id s64so1716349pgb.9; Sat, 14 Dec 2019 21:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s9X4iPd0KnMa5KIyBgavR+hocptaY6HIdK2blzLDzaA=; b=FPmAVeP2mdUVq6DwLRYvd9CvKLYcTHemjyCqjRrlXZl9WEmrF1z0xAHiQoxS9gc67/ zhyEge0e40HIR579wURSSHamNti6CIEe7Gosq5ThBuDc4iSqL+Bqd0yPAIjDCq9rnlI6 8PwmLVKxAwFVNQtYO4DHbtwS8NuO/oTO8cTsrj17hfr0YVizOwfT7bcMGxj581fLb4fF Q+EBHdUwJJKg5IUx05aEP4gRRpMp/8AI+/qxNIwj/N2wI5FJzbeULUdGFDd3Js5WUsL0 hgFLna4w1PwiOvokEp3QJXp1owK24s/6XM+zZMa90nP8X+GQhl06fAkKxNhLc4Orehyf TpZg== 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=s9X4iPd0KnMa5KIyBgavR+hocptaY6HIdK2blzLDzaA=; b=AWkURdWa+/hZh9c/V16kdCB9kZ/6Dleysgm2WlwMzP6V1BLrGBDyY1iYK7Ywm9RDcJ 9tvnZjk0MNuGyPAQ0xEl/LDz4E6BmmdeyNRcfJsdu2zy3BQ6Wv5ByndIW89rK2Uy7BxG eclfDyjdP+1kXPv3orxggionoXUoiFVDE/zW+ZYWNlkHoNHVOvSRnM7G+VQ5GtaLaG47 WxZytEFM3d3urgkxd1VljO9qVWN5wk2ky/1//Il31MWHuZ7nre75s+Ujjj8HKZDVvqo+ WnXyAdqd5XMfETZdapEFDyjF0i3TAjxS0GYdFXqE9nouIosPhR/SBwLiZX3FrsMlgJg/ j0Ig== X-Gm-Message-State: APjAAAX51IUX5fVA+a5rg3/9BfgFedcF7a4SU916FD5LD42fZcXVKLQ1 d2gvI5/S2lw88UUBFN7nbps= X-Google-Smtp-Source: APXvYqwaYLWaptacVXVwa4TActC1oLxGg8wUZKowyGri7WYpGP5PtlqW2c8tyhGBSdvFWauo1nBjCw== X-Received: by 2002:a63:a53:: with SMTP id z19mr10191253pgk.267.1576387021783; Sat, 14 Dec 2019 21:17:01 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.16.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:01 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH v4 03/12] platform/x86: asus-wmi: switch to use helpers Date: Sun, 15 Dec 2019 14:16:06 +0900 Message-Id: <1576386975-7941-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The asus-wmi driver doesn't implement the thermal device functionality directly, so including just for DECI_KELVIN_TO_CELSIUS() is a bit odd. This switches the asus-wmi driver to use deci_kelvin_to_millicelsius() in . The format string is changed from %d to %ld due to function returned type. Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Acked-by: Andy Shevchenko Signed-off-by: Akinobu Mita --- * v4 - change include order drivers/platform/x86/asus-wmi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 821b08e..b254f9f 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -33,9 +33,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -1512,9 +1512,8 @@ static ssize_t asus_hwmon_temp1(struct device *dev, if (err < 0) return err; - value = DECI_KELVIN_TO_CELSIUS((value & 0xFFFF)) * 1000; - - return sprintf(buf, "%d\n", value); + return sprintf(buf, "%ld\n", + deci_kelvin_to_millicelsius(value & 0xFFFF)); } /* Fan1 */ From patchwork Sun Dec 15 05:16:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E166139A for ; Sun, 15 Dec 2019 05:17:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A5782465B for ; Sun, 15 Dec 2019 05:17:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="raWQVX5O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbfLOFRI (ORCPT ); Sun, 15 Dec 2019 00:17:08 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:43506 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbfLOFRI (ORCPT ); Sun, 15 Dec 2019 00:17:08 -0500 Received: by mail-pj1-f68.google.com with SMTP id g4so1515536pjs.10; Sat, 14 Dec 2019 21:17:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3my8RP+3u7n3veq9PtxCL/LXumnZQKbolrNqeQogkFY=; b=raWQVX5OuOc2bkMiheKyKPwiClD8x0+EfjKFf0qMGEo02vguYoQC8ljPwoMX+4CxO4 vciGC7KJx8rxr6LPTal0qb/QPClRVMM1DzL436GYGp7hk17/XWGuH+bFCvc6dslVRPvU Nm1JdWz2Dn7wwGVYEFRWyFZ/BnALUs8vorqsQzt1kkAxHtVuACbCxT51IiLUXbTig2sy Oy4242wsqTyNwxEioMiTl82h607aQcWJ2H9jyGm4msb+IK5FjYiGaOvzRPMqGXuv+08Z 2oB76QVhTlJU8vJtOdFjrQkUhBNR/DNhkv8dy0dyxNZvqhjKtCRkcVLyaXaFboKOZi7n MRWw== 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=3my8RP+3u7n3veq9PtxCL/LXumnZQKbolrNqeQogkFY=; b=fRkflNfQx2SM83ynqi2XjQdqDvIFljMwysM/RA8CnyXDyVVNC+gkMw0acLbyt2VEGk QB6MoHHWGsCHfnzUx1aQyGhGjraSRISzyzioCdWzu94BSk58deZV4gp+Pg4ASWeLK5h2 Vkr+rgcXC1CBkWH6IIN4tRaW1e9BlyRSdf/TXf5BRfG5toCUk6wR/N/r3F89ei6Acv/i zYZaWXF1ZnciciFeuqqo8stkMwWRl+h1SMOkxoVVFUwnX8l7m+NswUs5ZaWY2lAAwa58 xxAb3BZCGIz5BFEDoGLaZcoiHcMDpF1l/7qnFgQg1RreLGMLMFX18Nm+bX8gOmOYL53b LySA== X-Gm-Message-State: APjAAAXMJphEGGPolW24MqD+Lg1x0/pRJXDXhf89cZNm8hNbL/zF0/LQ D3wme86MGXGs1oex99hgIkE= X-Google-Smtp-Source: APXvYqwQKHV1f9EJqmr0sZGc75iS/LgVRptZfafPMXcin6IZi+sZoqSA1EcyfrXp8opQVtB8978ijw== X-Received: by 2002:a17:90a:b94b:: with SMTP id f11mr10518148pjw.5.1576387027338; Sat, 14 Dec 2019 21:17:07 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:06 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH v4 04/12] platform/x86: intel_menlow: switch to use helpers Date: Sun, 15 Dec 2019 14:16:07 +0900 Message-Id: <1576386975-7941-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the intel_menlow driver to use deci_kelvin_to_celsius() and celsius_to_deci_kelvin() in instead of helpers in . This is preparation for centralizing the kelvin to/from Celsius conversion helpers in . This also removes a trailing space, while we're at it. Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Reviewed-by: Andy Shevchenko Signed-off-by: Akinobu Mita --- * No changes from v3 drivers/platform/x86/intel_menlow.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c index b102f6d..101d7e7 100644 --- a/drivers/platform/x86/intel_menlow.c +++ b/drivers/platform/x86/intel_menlow.c @@ -22,6 +22,7 @@ #include #include #include +#include MODULE_AUTHOR("Thomas Sujith"); MODULE_AUTHOR("Zhang Rui"); @@ -302,8 +303,10 @@ static ssize_t aux_show(struct device *dev, struct device_attribute *dev_attr, int result; result = sensor_get_auxtrip(attr->handle, idx, &value); + if (result) + return result; - return result ? result : sprintf(buf, "%lu", DECI_KELVIN_TO_CELSIUS(value)); + return sprintf(buf, "%lu", deci_kelvin_to_celsius(value)); } static ssize_t aux0_show(struct device *dev, @@ -332,8 +335,8 @@ static ssize_t aux_store(struct device *dev, struct device_attribute *dev_attr, if (value < 0) return -EINVAL; - result = sensor_set_auxtrip(attr->handle, idx, - CELSIUS_TO_DECI_KELVIN(value)); + result = sensor_set_auxtrip(attr->handle, idx, + celsius_to_deci_kelvin(value)); return result ? result : count; } From patchwork Sun Dec 15 05:16:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292647 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 687D1139A for ; Sun, 15 Dec 2019 05:17:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45CEF2465B for ; Sun, 15 Dec 2019 05:17:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bQvf50Mv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbfLOFRO (ORCPT ); Sun, 15 Dec 2019 00:17:14 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38989 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfLOFRN (ORCPT ); Sun, 15 Dec 2019 00:17:13 -0500 Received: by mail-pg1-f196.google.com with SMTP id b137so1723691pga.6; Sat, 14 Dec 2019 21:17:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HoM44YO7jKpFM5Bt686W03V+vIzdOR1TWUFJVxsK0iw=; b=bQvf50MvBu50bzcy5vOGO4uBYMf9uKla1LUKwxCJkyto5/NGMdf3Tp91MzlfL6sBET UfJH9M5g0IhJWYBxQR3K2+zKcF8+fIfQbNn+U7Q/bO5oZGY7JJicPp13WCP49M2D1xZ5 4pMI9mLCDH1Qrx09uoA9y5Di16KiupsO7XuXUUC90JSJaXmRY0XGJePvIwZ62u1YmLP9 UR1lezZtd6rQnu3n0XftzclCqSsnTRT5UMe5bZFvV+9Lg4iJDykx6336E/FzikHd+NUi 6GKCu9ETSkaLNyn1vRk/sIVbMQHLuKvweESCi9ro4XeddFzJS1kvkligms8YTC0+aX0M s/AA== 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=HoM44YO7jKpFM5Bt686W03V+vIzdOR1TWUFJVxsK0iw=; b=ZH+TxRut6yerSJs4JWHOOjpqzm7vOLXq+WkTOWFkeWFEWKRzJ+QKrpoGxtUUUSKo88 QuvfrglKUT8QLD1lF1YEtYDkWGYj2lBba4jv7wQRYYV6wWXboja2Fu0Nr5Lk3p1a/bDU n8aXXvwYEOIxmYlP1Fd6P/yYGMSCOPBafEjNj+ogr+gAThCEeUijmcTWgUT2wqmjjfQA /xU86s6UOwYTeW5PWCGMAyjT1yIJcS3YGxTFgvMhxzzEnE6q7aWS3vS1iuT4UQE2g8/c OQfxsPu23YInjxf5RvvSQapU3TTjMMXrfjfbsBOMUqX0sWwz7yB6nnDxXwou9yiVYl9a 5Amg== X-Gm-Message-State: APjAAAW5ix+PuXR+ZCOHZijWivbhMoo86X9NsZzKbyCHKbWpTqD00vCi 4K/9WNG6tdZ51P09U8aYk7E= X-Google-Smtp-Source: APXvYqxw27ngbpk0CKdXZvBZxaaAZi+AM67S8O8H2tETPVHPLmfGtOrWh4fm4fGLIcNlgSc4KcQahg== X-Received: by 2002:a63:5162:: with SMTP id r34mr10283755pgl.227.1576387033003; Sat, 14 Dec 2019 21:17:13 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:12 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH v4 05/12] thermal: int340x: switch to use helpers Date: Sun, 15 Dec 2019 14:16:08 +0900 Message-Id: <1576386975-7941-6-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the int340x thermal zone driver to use deci_kelvin_to_millicelsius() and millicelsius_to_deci_kelvin() in instead of helpers in . This is preparation for centralizing the kelvin to/from Celsius conversion helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Reviewed-by: Andy Shevchenko Signed-off-by: Akinobu Mita --- * v4 - add Reviewed-by tag drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 75484d6..4322132 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "int340x_thermal_zone.h" static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, @@ -34,7 +35,7 @@ static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, *temp = (unsigned long)conv_temp * 10; } else /* _TMP returns the temperature in tenths of degrees Kelvin */ - *temp = DECI_KELVIN_TO_MILLICELSIUS(tmp); + *temp = deci_kelvin_to_millicelsius(tmp); return 0; } @@ -116,7 +117,7 @@ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, snprintf(name, sizeof(name), "PAT%d", trip); status = acpi_execute_simple_method(d->adev->handle, name, - MILLICELSIUS_TO_DECI_KELVIN(temp)); + millicelsius_to_deci_kelvin(temp)); if (ACPI_FAILURE(status)) return -EIO; @@ -163,7 +164,7 @@ static int int340x_thermal_get_trip_config(acpi_handle handle, char *name, if (ACPI_FAILURE(status)) return -EIO; - *temp = DECI_KELVIN_TO_MILLICELSIUS(r); + *temp = deci_kelvin_to_millicelsius(r); return 0; } From patchwork Sun Dec 15 05:16:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292657 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A209D112B for ; Sun, 15 Dec 2019 05:17:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E8C82465B for ; Sun, 15 Dec 2019 05:17:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NC5Q3xlh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbfLOFRU (ORCPT ); Sun, 15 Dec 2019 00:17:20 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:46345 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfLOFRT (ORCPT ); Sun, 15 Dec 2019 00:17:19 -0500 Received: by mail-pj1-f65.google.com with SMTP id z21so1511001pjq.13; Sat, 14 Dec 2019 21:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dFlnRv0hadsugtVajyHRe0JC+tPOCVnj6GsrCbBgD3o=; b=NC5Q3xlhCVYDD/m31UtBzIc7GqULlCKQs5ldsS8eMSO7ocTrRah48V7JueoBaZjRfF dFYazkMieceVvYDQVsuOkcDgcQgV+R2s3QkTvDH852AG/HAOg/6bmXHwqA+hQrAtvcTY B/45nLwULGUuOdCwfUMpOuU0WmNIRaRqaEEXgijAWVFt0CCjv1PAXYcA+jkp2IDrAGBN zKWV0O1HL9cnFQ8NQnCN/BvouZMcLq7yOazxwoBEjJMZ//2o82FHAP0v2bFXLdAqt0Lk 34CbQTdrvH938tKYyDddbbw1RfXz1UJTkIppwnsQSEyG1kyk26wdD9HbuxJJgfkJsY5Y 3Wvw== 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=dFlnRv0hadsugtVajyHRe0JC+tPOCVnj6GsrCbBgD3o=; b=CU+rFoo41a+wA4K+gdeayZxE5Mni+TQjqPs7PkgYVDEgcVIvjDysrOz2sP6PEJd7Pc ZLCceEUFFgKW6Nl6hLiT0xc3OtcqPJ/Tnv/BNfk2h87tdWobcLfpgRpUKcY9NEFEwJA6 y6kmIlWl/kxsOczeo60qMYAR6osYvLOYBFU5FxCQVpF4lX6y0k5LS6okORior8danCBs LMNeg+ChTJYxOqwRnUWLUqf1r+kEHFXBkKhm5h1TYKd3Sb7eE6elM2tVPX0yMaVwtxyM eifJifzMskA7GUiwXWWaOUWIT1hcM51fiQzSTZh4i1WGoL6WjdCFEED3esvjGALqQq/5 cuKQ== X-Gm-Message-State: APjAAAUA+NY9saGTgTFAh/rMXdqUw4D6ftqxcAdAyb4L7ROGQK7j3aJO P2B355O+EHnHV9jxX8WtXqs= X-Google-Smtp-Source: APXvYqwbGw831TCHknZkFd89BpDoeV5W4jcrJR7PjtyCCgpjaIW4I9/0mOvOtFg2s6Cbv4FQ3LiZFQ== X-Received: by 2002:a17:90a:f84:: with SMTP id 4mr10440876pjz.74.1576387038837; Sat, 14 Dec 2019 21:17:18 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:18 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH v4 06/12] thermal: intel_pch: switch to use helpers Date: Sun, 15 Dec 2019 14:16:09 +0900 Message-Id: <1576386975-7941-7-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the intel pch thermal driver to use deci_kelvin_to_millicelsius() in instead of helpers in . This is preparation for centralizing the kelvin to/from Celsius conversion helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Reviewed-by: Andy Shevchenko Signed-off-by: Akinobu Mita --- * v4 - add Reviewed-by tag drivers/thermal/intel/intel_pch_thermal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c index 4f0bb8f..b118611 100644 --- a/drivers/thermal/intel/intel_pch_thermal.c +++ b/drivers/thermal/intel/intel_pch_thermal.c @@ -13,6 +13,7 @@ #include #include #include +#include #include /* Intel PCH thermal Device IDs */ @@ -92,7 +93,7 @@ static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, if (ACPI_SUCCESS(status)) { unsigned long trip_temp; - trip_temp = DECI_KELVIN_TO_MILLICELSIUS(r); + trip_temp = deci_kelvin_to_millicelsius(r); if (trip_temp) { ptd->psv_temp = trip_temp; ptd->psv_trip_id = *nr_trips; From patchwork Sun Dec 15 05:16:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BE92139A for ; Sun, 15 Dec 2019 05:17:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0834D24654 for ; Sun, 15 Dec 2019 05:17:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N4CbPu6f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbfLOFRZ (ORCPT ); Sun, 15 Dec 2019 00:17:25 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39916 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfLOFRZ (ORCPT ); Sun, 15 Dec 2019 00:17:25 -0500 Received: by mail-pf1-f194.google.com with SMTP id 2so3758321pfx.6; Sat, 14 Dec 2019 21:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yyoE/kJT7Za8oOamE8LAfuYOwDLTmHlQFdtd0CuJ34k=; b=N4CbPu6fl9qY4tyGJ0tQFP8vj5OWJLuktbW6f/YyYtElFDPg0L6iPbWlqQakJuy8e7 tTzV3KjkXuGVcoQt5Emmir0+p/P7qL/ZZBZhJmhwP6oL1nwdkjxUMHjusjoJPgdRGx9z /XQVX5oH5xkWXa9NBmnAYiU/+CrOqduGAcw2UeJvDaYOirsO0IyoYt1Wt/e+Zs1JUNly xLiu7BZXozvgfoYzc8bdKq3Rg+il2wTHFloMdTvVHeTEFZ7tUQZ3w5JHXt5ZMpYdDCn8 6UsGDqNo/rYSrt05bQT6p21UdUXssIDE92iyshielrqWwUEdSC/qQvE1gmRAixv4nl51 e1RA== 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=yyoE/kJT7Za8oOamE8LAfuYOwDLTmHlQFdtd0CuJ34k=; b=IeBi9GUYYZQdCHWGxqmuR2RkQCByOu8tP5vc1grP1krxXUDBdF3k6iB+AE91G8X5wg vL2sKBKvoChQ2VD1vmssosYxBg0LjIPrRxCZ+HDpOMU2YLENugEso7/wVH/lfpW69O/F /Zye2CZ+LSE5ysTlmyn8qh8OyqgSVe6sR/Qz4iHSaLrdlE9VR1eEHuYGYPGX+3DnmiOe tfCZQKdN9mEHlOeprSNyoFUePcy5hW8yr/EeYKCz4JDuILdHHRj0kY1BuuQqFqfcDwTe spOoR5xNH3HajZtGCD+f79m4DWGnMh5FS1Mdl30ltS1dlSsl5xumRU+xMx8zeuyUgORy akIA== X-Gm-Message-State: APjAAAXigSFFaBNmrB7PklYXvLh5cFCT4y42izcEFUaFh9nD0kaA7fND WybGMytjcYI6gBmh+ZPfI5M= X-Google-Smtp-Source: APXvYqx3VkY0cSg/7bN0Y0W5G2/U6JBARCdKWa0nOQSgon43lbz4BsIfhgC4OCM7Owt5n+zvtJvdnQ== X-Received: by 2002:a63:cc4f:: with SMTP id q15mr10235784pgi.159.1576387044564; Sat, 14 Dec 2019 21:17:24 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:23 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH v4 07/12] nvme: hwmon: switch to use helpers Date: Sun, 15 Dec 2019 14:16:10 +0900 Message-Id: <1576386975-7941-8-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the nvme driver to use kelvin_to_millicelsius() and millicelsius_to_kelvin() in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Reviewed-by: Christoph Hellwig Reviewed-by: Guenter Roeck Reviewed-by: Keith Busch Reviewed-by: Andy Shevchenko Signed-off-by: Akinobu Mita --- * v4 - add Reviewed-by tags drivers/nvme/host/hwmon.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c index a5af21f..2e6477e 100644 --- a/drivers/nvme/host/hwmon.c +++ b/drivers/nvme/host/hwmon.c @@ -5,14 +5,11 @@ */ #include +#include #include #include "nvme.h" -/* These macros should be moved to linux/temperature.h */ -#define MILLICELSIUS_TO_KELVIN(t) DIV_ROUND_CLOSEST((t) + 273150, 1000) -#define KELVIN_TO_MILLICELSIUS(t) ((t) * 1000L - 273150) - struct nvme_hwmon_data { struct nvme_ctrl *ctrl; struct nvme_smart_log log; @@ -35,7 +32,7 @@ static int nvme_get_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, return -EIO; if (ret < 0) return ret; - *temp = KELVIN_TO_MILLICELSIUS(status & NVME_TEMP_THRESH_MASK); + *temp = kelvin_to_millicelsius(status & NVME_TEMP_THRESH_MASK); return 0; } @@ -46,7 +43,7 @@ static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT; int ret; - temp = MILLICELSIUS_TO_KELVIN(temp); + temp = millicelsius_to_kelvin(temp); threshold |= clamp_val(temp, 0, NVME_TEMP_THRESH_MASK); if (under) @@ -88,7 +85,7 @@ static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type, case hwmon_temp_min: return nvme_get_temp_thresh(data->ctrl, channel, true, val); case hwmon_temp_crit: - *val = KELVIN_TO_MILLICELSIUS(data->ctrl->cctemp); + *val = kelvin_to_millicelsius(data->ctrl->cctemp); return 0; default: break; @@ -105,7 +102,7 @@ static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type, temp = get_unaligned_le16(log->temperature); else temp = le16_to_cpu(log->temp_sensor[channel - 1]); - *val = KELVIN_TO_MILLICELSIUS(temp); + *val = kelvin_to_millicelsius(temp); break; case hwmon_temp_alarm: *val = !!(log->critical_warning & NVME_SMART_CRIT_TEMPERATURE); From patchwork Sun Dec 15 05:16:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DEE817F0 for ; Sun, 15 Dec 2019 05:17:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DED9F2253D for ; Sun, 15 Dec 2019 05:17:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CARqNQEG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbfLOFRb (ORCPT ); Sun, 15 Dec 2019 00:17:31 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42653 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfLOFRb (ORCPT ); Sun, 15 Dec 2019 00:17:31 -0500 Received: by mail-pg1-f194.google.com with SMTP id s64so1716676pgb.9; Sat, 14 Dec 2019 21:17:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wNtUm+SbN+0a8GrjUSZCRK4zHG4L4L6an0ip7ptF0d0=; b=CARqNQEGgXO6NPLDpqfdZ8o0UQ+3RuRnE7NqTCXaWSswkmnp/+HkwkITZstEhn/nmX HcevBsy0kEg3sUHjdGc0RqmDxfCBhjAM8THzFd+Xvl67sT7JSUzI73iuR2E/l4+ncAGJ HjGYI+FzFACe1DhH/ZzpHu+m/62n2xsZzbLMSt/ANKN1fEsj+jZhvTx/XWi1q6glBfat kYon/9k2+Ja8NrZx4yY7DMLTmeFx1SwyhBN/NPot2bJVbU54KE/kdEqad/8zdTZi7F3+ 00KDKKCOxU3RqpVpKwJdp4THa1xZJgS+GTAdj9pFAj13S4HJn1Vb6GsDPNKClSLR7Khe yOZg== 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=wNtUm+SbN+0a8GrjUSZCRK4zHG4L4L6an0ip7ptF0d0=; b=eHfuyC11sgqLUNqFNf3fC+9JJdns+302kfnsvtV3rgen9JATYqGhce0ptSDHfqPMaa 36TQZ1mrZbTNVcurcCcZy0JTslpXSkoyKuD75MqgorvLEb278/HhGPN/w8m9hc4CM9ho T35GC+Q30M8tBlO7EhJ3e51RNTKafPrvIFIbWd8TIWg24rCBtnK6eTkpIo6ZqFjpHdwR x4ZQq+vH9aouR4GDqaT3BpQIfAXtDEbbKu6PtP1ACXueSlnnQFH1Xfyaxe0RZH3cdii/ fQsUtqw+bLzAkjs9MrA214Nu21B+JwqoEMbVjHJ/thBtVtCCAe1fKxFqaDLUpU8cOAvj zUXA== X-Gm-Message-State: APjAAAUiKk3y34SCOFXWI23wtAomfV7sXR0LY4k346YEZDi7K6CeYJ46 XFO5Lwzjs8HpLtJe9VQyfYg= X-Google-Smtp-Source: APXvYqyRvp6w8dX6QbBOEnKG62KgsdB7W7pSUy/KgK7EVQbEeUeuesZYikCPANPFgyHy/nhytxOxug== X-Received: by 2002:a65:4106:: with SMTP id w6mr4234387pgp.347.1576387050494; Sat, 14 Dec 2019 21:17:30 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:29 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH v4 08/12] thermal: remove kelvin to/from Celsius conversion helpers from Date: Sun, 15 Dec 2019 14:16:11 +0900 Message-Id: <1576386975-7941-9-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This removes the kelvin to/from Celsius conversion helper macros in which were switched to the inline helper functions in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Reviewed-by: Andy Shevchenko Signed-off-by: Akinobu Mita --- * v4 - add Reviewed-by tag include/linux/thermal.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/linux/thermal.h b/include/linux/thermal.h index d9111ae..126913c6 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -32,17 +32,6 @@ /* use value, which < 0K, to indicate an invalid/uninitialized temperature */ #define THERMAL_TEMP_INVALID -274000 -/* Unit conversion macros */ -#define DECI_KELVIN_TO_CELSIUS(t) ({ \ - long _t = (t); \ - ((_t-2732 >= 0) ? (_t-2732+5)/10 : (_t-2732-5)/10); \ -}) -#define CELSIUS_TO_DECI_KELVIN(t) ((t)*10+2732) -#define DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, off) (((t) - (off)) * 100) -#define DECI_KELVIN_TO_MILLICELSIUS(t) DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, 2732) -#define MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, off) (((t) / 100) + (off)) -#define MILLICELSIUS_TO_DECI_KELVIN(t) MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, 2732) - /* Default Thermal Governor */ #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) #define DEFAULT_THERMAL_GOVERNOR "step_wise" From patchwork Sun Dec 15 05:16:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 806CE139A for ; Sun, 15 Dec 2019 05:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D5742467A for ; Sun, 15 Dec 2019 05:17:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D81//jzp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725861AbfLOFRf (ORCPT ); Sun, 15 Dec 2019 00:17:35 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35662 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726865AbfLOFRe (ORCPT ); Sun, 15 Dec 2019 00:17:34 -0500 Received: by mail-pg1-f193.google.com with SMTP id l24so1731245pgk.2; Sat, 14 Dec 2019 21:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7AK/TlaexQptYohFbIUq4KsseUGVisXwtLl1qNBNNIk=; b=D81//jzpc2vjR9Hw1Wax/s98TMZnO0WTjxCpQd4gOBTR5Wohhaz2TIwEwns2odGc1G 6dtjro67Y37h7nFo/p5998Vs4glqeZyplsBRJR6kVRmHcKXz2pcQVbk/10HqsrEtO8Ch YpQXvVbntOfa2ngfgW6aFR8RII72nUFGrRkn6B1Ga0U8YjP+H1FLpqRnwg4fZFOUKu+C EpcSKFf6f9m5QDojhaPHSVtYNU1etCLSQzRFvUu+WKqoU1rbDZNvVn7NH1FH8Iwk2ng2 1xDjkvz1fR8SktIraMOjjS7dsAmbGjJKeMX5iLHXjnn5TCnP4UweLtrK9284v7foqOZs nnSA== 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=7AK/TlaexQptYohFbIUq4KsseUGVisXwtLl1qNBNNIk=; b=XRNp1LQAlhzAWRKGjHSx+VhteNOFxqeAiCRMoFU4tBla9hPqUH1aZvDPPJvqETaQKB 8aZNp6gQ+1di/8Yn3gKRizXF482evIYJJOdnB8RBOQ/ZJMjbQEVqROZr9w0as1Ldfy89 9IGg03qdQ9I4SafyAYQp9xwCasz2JStUgRVdRmcRPjGFOwQGikJP7gfe3gEf8yDinbIq Ls3kkWBtd/W7YaZfFVAZk/PH+tCrHZIHtnKy4JXpb1HLRUGbPzR+4bE7rbLhYAxxinW1 Z9bDkId85YHT/0hLfLcm9n4hNA4hoh9wxkoVnWzokcA8alWGs6jLKJGXtrh8dudi3EKL 7HgA== X-Gm-Message-State: APjAAAVIoz1clIOSdKV5Ee1XOS+0ibt+IkYrQzDZHqdgI/sBbgO2ciIH oK0wglDzIirjpBnpr9y1B3wuimqhz9c= X-Google-Smtp-Source: APXvYqxBRv2wn/eiGSZO0EPNa37cbHfApIbzp5cD39XlP29sX6Ug2mD7Qmiq5o6dpS3hCLz8ic6akg== X-Received: by 2002:a62:e215:: with SMTP id a21mr9141541pfi.208.1576387054256; Sat, 14 Dec 2019 21:17:34 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:33 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Kalle Valo , Stanislaw Gruszka Subject: [PATCH v4 09/12] iwlegacy: use helpers Date: Sun, 15 Dec 2019 14:16:12 +0900 Message-Id: <1576386975-7941-10-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the iwlegacy driver to use celsius_to_kelvin() and kelvin_to_celsius() in . Cc: Kalle Valo Cc: Stanislaw Gruszka Reviewed-by: Andy Shevchenko Acked-by: Kalle Valo Signed-off-by: Akinobu Mita --- * v4 - add Reviewed-by and Acked-by tags - remove "wireless: " in the title drivers/net/wireless/intel/iwlegacy/4965-mac.c | 3 ++- drivers/net/wireless/intel/iwlegacy/4965.c | 11 ++++++----- drivers/net/wireless/intel/iwlegacy/common.h | 3 --- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/wireless/intel/iwlegacy/4965-mac.c index 3664f56..d6766eb 100644 --- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -6467,7 +6468,7 @@ il4965_set_hw_params(struct il_priv *il) il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; il->hw_params.ct_kill_threshold = - CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); + celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY); il->hw_params.sens = &il4965_sensitivity; il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; diff --git a/drivers/net/wireless/intel/iwlegacy/4965.c b/drivers/net/wireless/intel/iwlegacy/4965.c index 32699b6..31b346c 100644 --- a/drivers/net/wireless/intel/iwlegacy/4965.c +++ b/drivers/net/wireless/intel/iwlegacy/4965.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1104,7 +1105,7 @@ il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, u8 is_ht40, /* get current temperature (Celsius) */ current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); - current_temp = KELVIN_TO_CELSIUS(current_temp); + current_temp = kelvin_to_celsius(current_temp); /* select thermal txpower adjustment params, based on channel group * (same frequency group used for mimo txatten adjustment) */ @@ -1611,7 +1612,7 @@ il4965_hw_get_temperature(struct il_priv *il) (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; D_TEMP("Calibrated temperature: %dK, %dC\n", temperature, - KELVIN_TO_CELSIUS(temperature)); + kelvin_to_celsius(temperature)); return temperature; } @@ -1671,11 +1672,11 @@ il4965_temperature_calib(struct il_priv *il) if (il->temperature != temp) { if (il->temperature) D_TEMP("Temperature changed " "from %dC to %dC\n", - KELVIN_TO_CELSIUS(il->temperature), - KELVIN_TO_CELSIUS(temp)); + kelvin_to_celsius(il->temperature), + kelvin_to_celsius(temp)); else D_TEMP("Temperature " "initialized to %dC\n", - KELVIN_TO_CELSIUS(temp)); + kelvin_to_celsius(temp)); } il->temperature = temp; diff --git a/drivers/net/wireless/intel/iwlegacy/common.h b/drivers/net/wireless/intel/iwlegacy/common.h index e7fb8e6..bc9cd7e 100644 --- a/drivers/net/wireless/intel/iwlegacy/common.h +++ b/drivers/net/wireless/intel/iwlegacy/common.h @@ -779,9 +779,6 @@ struct il_sensitivity_ranges { u16 nrg_th_cca; }; -#define KELVIN_TO_CELSIUS(x) ((x)-273) -#define CELSIUS_TO_KELVIN(x) ((x)+273) - /** * struct il_hw_params * @bcast_id: f/w broadcast station ID From patchwork Sun Dec 15 05:16:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DC17112B for ; Sun, 15 Dec 2019 05:17:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A11622B48 for ; Sun, 15 Dec 2019 05:17:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="erojmZQu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726916AbfLOFRj (ORCPT ); Sun, 15 Dec 2019 00:17:39 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32815 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726865AbfLOFRj (ORCPT ); Sun, 15 Dec 2019 00:17:39 -0500 Received: by mail-pf1-f194.google.com with SMTP id y206so3773767pfb.0; Sat, 14 Dec 2019 21:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o0nAQcnsb+T5h9bhgeYIzbak+OeGPv1PHTKsTeCIoXY=; b=erojmZQu2yIt3sG10pk8q7D162SAcRjxoBKbUaHuIhQ9qCS8Ovsrir9CSC6ymhCozZ FqJbFyL+b7YifQFa/0j7JxpknZq8Q2X9TeL1mjAJCnQEZo0ZaUgUDC3SmpcLnC97qrcz 6+zdTV3ejXQXKXZW4bWUv3pwgL4xdnBcdl4GiSkW2HOo6e+sUTG07tQiiOZOVyEKlvGZ 8LWNoxfJfejbBmxVEhjyX3vtC9aLJQopm1lxsyysNlSrJnFGkIcEn/CigYEybtUr7B++ WTxENH/IzJk+aDB4t8OozPOkKfLmn3HRsMt9cVmg1exjUHP4KQqCK1sXC5J6ExTdjFWA aPRw== 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=o0nAQcnsb+T5h9bhgeYIzbak+OeGPv1PHTKsTeCIoXY=; b=gJxgYzzKjQdG5b50t6ibHdYqQda8tbwwL++OY8pSECbwjdAqIlYPfoOi+p/0jarzqx 8IMb1iEGqaL0R9EkiQ0fSRC3NHMbGAT8dtGi1tTf/oYFCowqAw9zKa9YyzFw9ibDFxE1 y+mhQF4wDaqQ/AR5Sj0LuDSNSt3VFQli7j19q3Xc0qEJWhQtbyvWDMIONneccr1B+xcS igU7Qdx4SOF+R6L4lo/9QWmbtrp3JP6mK0VtMuJxXFE4b1riW0KugrcEf3mQTmkhFT9S Osw2KXOkaZq4mdIZ3VYjVkus62Bj0/K+MfgYHh2rj6rHFgdVNwcB+RFgs328zGhNWLRT L/gw== X-Gm-Message-State: APjAAAUNl9+bPoQ2q71wXpXOtLkmPARHsfw57GzaDctc0NBRFEBuWGh0 4j96MUvnWsbbOnq7ynCbU2Q= X-Google-Smtp-Source: APXvYqxoUa7OEVWIs7gSylEoHGyOHkaN4si8hTmYB1eDQDWpbT6CBXJiWnAxrimODPovU2iUuCMwpg== X-Received: by 2002:a63:7705:: with SMTP id s5mr9996843pgc.379.1576387058498; Sat, 14 Dec 2019 21:17:38 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:37 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Kalle Valo , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless Subject: [PATCH v4 10/12] iwlwifi: use helpers Date: Sun, 15 Dec 2019 14:16:13 +0900 Message-Id: <1576386975-7941-11-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the iwlwifi driver to use celsius_to_kelvin() and kelvin_to_celsius() in . Cc: Kalle Valo Cc: Johannes Berg Cc: Emmanuel Grumbach Cc: Luca Coelho Cc: Intel Linux Wireless Reviewed-by: Andy Shevchenko Acked-by: Luca Coelho Signed-off-by: Akinobu Mita --- * v4 - add Reviewed-by and Acked-by tags - remove "wireless: " in the title drivers/net/wireless/intel/iwlwifi/dvm/dev.h | 5 ----- drivers/net/wireless/intel/iwlwifi/dvm/devices.c | 6 ++++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/dev.h b/drivers/net/wireless/intel/iwlwifi/dvm/dev.h index be5ef4c..8d83800 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/dev.h +++ b/drivers/net/wireless/intel/iwlwifi/dvm/dev.h @@ -237,11 +237,6 @@ struct iwl_sensitivity_ranges { u16 nrg_th_cca; }; - -#define KELVIN_TO_CELSIUS(x) ((x)-273) -#define CELSIUS_TO_KELVIN(x) ((x)+273) - - /****************************************************************************** * * Functions implemented in core module which are forward declared here diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/devices.c b/drivers/net/wireless/intel/iwlwifi/dvm/devices.c index dc3f197..d42bc46 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/devices.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/devices.c @@ -10,6 +10,8 @@ * *****************************************************************************/ +#include + /* * DVM device-specific data & functions */ @@ -345,7 +347,7 @@ static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv) static void iwl5150_set_ct_threshold(struct iwl_priv *priv) { const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF; - s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) - + s32 threshold = (s32)celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY) - iwl_temp_calib_to_offset(priv); priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef; @@ -381,7 +383,7 @@ static void iwl5150_temperature(struct iwl_priv *priv) vt = le32_to_cpu(priv->statistics.common.temperature); vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset; /* now vt hold the temperature in Kelvin */ - priv->temperature = KELVIN_TO_CELSIUS(vt); + priv->temperature = kelvin_to_celsius(vt); iwl_tt_handler(priv); } From patchwork Sun Dec 15 05:16:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55674112B for ; Sun, 15 Dec 2019 05:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 324C622B48 for ; Sun, 15 Dec 2019 05:17:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Id8NfdTF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726299AbfLOFRp (ORCPT ); Sun, 15 Dec 2019 00:17:45 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:33858 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfLOFRn (ORCPT ); Sun, 15 Dec 2019 00:17:43 -0500 Received: by mail-pj1-f68.google.com with SMTP id j11so1532808pjs.1; Sat, 14 Dec 2019 21:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iJPFiDdoTrBrSdqjTpE+VPFHmC8ax0pLThG7IGKangk=; b=Id8NfdTFPUPB+fc7GWUtnaZycNxT1n/743f1r4mmprU8vigdUiO+qwV5Rrz9bb5cvS JFpw4kpX7F7iUhfnq57t+ScMl4f95d3tqi8LeBRCdyGMExAcUz/W8rfHTPc1pfSrXXti PMZTllluPehaVveLsU7xboTHQ5CkDcPhifUoApxdDmxQ0gAQqd5oYjDFsEAUunFDK7mP TgcWBy3rf9x/fCIN+Yd/BB4jRXSBr+guHfyatZ7v7cIomD3n8NclP80repjcNSP2ECzf CQnlPaqXdr5iEeQn0VfsxWvGaI4UFf1hAQLbeaaVRYg/4hB/8zQGjBw3kzQd6RWBhlRU G1hQ== 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=iJPFiDdoTrBrSdqjTpE+VPFHmC8ax0pLThG7IGKangk=; b=Yxuw4TE52sHPoJf2HuP820He3Ll3M6Y31MXPV8EFu/4tSjBr2t0Yg/Kheiytcj1p4X 8gRI65q0JzPXvr+cuedFdX0sXDiImNa7haKlmE4z4Y0MomGjIvuEIy2V4E1Z9C5Wq9lL xh8Icbyd3MS7jyTBz8FiwheBTcHxo/9OEr1Wjl8IrpO5HoFhJWTwpw95SUUDeO8VPo0P l77SMG38d7Q+aRnPk56WNV81DeofkCoQ93V5WR81GvxD1zOYqTMZbp4WZxn9j2C48mcn jgJlUbgdTYVEUxOl+yJ9AGWFnFmZ7O62QzskqON84QIMhPZHmnftwCafTI3y2CARS6S9 9Bxg== X-Gm-Message-State: APjAAAVQQeiIsp22nEXdysvI/55P8smopliF2C8WEfdJQTe6V35DNXd+ P1AwiGSRV36nFz38wRQkYHY= X-Google-Smtp-Source: APXvYqxTG4dxeNv2aoSLu1cumiV7gAuV9hcPKvGjbWfymM/Tqr7q01DvKziXiVpBQtLaPO5sHG9+HQ== X-Received: by 2002:a17:902:bd8e:: with SMTP id q14mr9152361pls.199.1576387062386; Sat, 14 Dec 2019 21:17:42 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:41 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Zhang Rui , Daniel Lezcano , Amit Kucheria Subject: [PATCH v4 11/12] thermal: armada: remove unused TO_MCELSIUS macro Date: Sun, 15 Dec 2019 14:16:14 +0900 Message-Id: <1576386975-7941-12-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This removes unused TO_MCELSIUS() macro. Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Reviewed-by: Andy Shevchenko Signed-off-by: Akinobu Mita --- * v4 - add Reviewed-by tag drivers/thermal/armada_thermal.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index 709a22f..fc6dc10 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -21,8 +21,6 @@ #include "thermal_core.h" -#define TO_MCELSIUS(c) ((c) * 1000) - /* Thermal Manager Control and Status Register */ #define PMU_TDC0_SW_RST_MASK (0x1 << 1) #define PMU_TM_DISABLE_OFFS 0 From patchwork Sun Dec 15 05:16:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11292693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7325139A for ; Sun, 15 Dec 2019 05:17:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 840CE24683 for ; Sun, 15 Dec 2019 05:17:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PrmuGguM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbfLOFRs (ORCPT ); Sun, 15 Dec 2019 00:17:48 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45563 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbfLOFRr (ORCPT ); Sun, 15 Dec 2019 00:17:47 -0500 Received: by mail-pg1-f193.google.com with SMTP id b9so1707582pgk.12; Sat, 14 Dec 2019 21:17:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rs+ph61PgowUB2wxJYFFkBstw61v/JyioJPVFcT1dTo=; b=PrmuGguMd8I2icLDPcfOnUjhxgAkYI89eucLm58rL6pWLvQL2jZxJTUV6iNRcYSoQ2 sKk2OHbbVJPQZZq8MT2heyABgtzLtkONYwt26Zk+TkTkAYRNziB7w4K8Q5suhmYOXkR3 POykAo/0yD/76gVPmRSp7biObXx0ma7YjYqyoVxlPQ1JTyhH6KpJ6H6Jnz94BeV/15du cwtfk9+BTmygl5heycnwix988ik+j1JV7n6H5L4OTWXP+GKoFXjVCQy4x2NB/4vNQaOA eoYdoyMlUaHLlo+pSFsk56d5j/vVEZ5cSa73TgiJO85GCfq+XhKbVxnbyPrRf8JLKn9b /OUw== 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=rs+ph61PgowUB2wxJYFFkBstw61v/JyioJPVFcT1dTo=; b=qWb+Y6dN2mIreYPFr1ecn8zetJA+4a/dEgeET+hVxH00DoEhfYknGvlobLI8J2un67 YQsS2GEJiUMXYJ53PM7MoWZ3l/GhkvboKRapq/EJbsAWqhGC7+EAet4QlChOEogBpcpt 3LvPeOOsOjwRiCWwLkzpcpfDWQEJKHyRtk5UtHt/D/HJTd8P8WrQV4GCHD0UaDVXrUo5 d+ubOxA+y0WO/Ap9ytxmj+2hjPiLr0rdvGzeTLRJdaIjW7IkWQbYg6Qbbln472ZiAFtQ CIXkh4b5RvuPMSPyx7VprSmgjPuHN6FEssjOPtId4CZj8aTcyrcXMaGFRINlqjWlZnAG lCWg== X-Gm-Message-State: APjAAAXgeEUMGY930CoFBQuhhPkZfL4PPPS8vw5m0qc9Zx/GYzZ8LBq0 mT6xAF5YGJNa7M8ScB9tWU4= X-Google-Smtp-Source: APXvYqyz2b9p5as0HpR/8ZvYU3LMjgqtKZ/4OlUPaESNc9g0DwHCBTVHwRTYyxlafrFwiY2Ib4eY4g== X-Received: by 2002:a63:3104:: with SMTP id x4mr9984060pgx.369.1576387066555; Sat, 14 Dec 2019 21:17:46 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id u10sm16596528pgg.41.2019.12.14.21.17.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Dec 2019 21:17:45 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-wireless@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Subject: [PATCH v4 12/12] iio: adc: qcom-vadc-common: use helpers Date: Sun, 15 Dec 2019 14:16:15 +0900 Message-Id: <1576386975-7941-13-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> References: <1576386975-7941-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the qcom-vadc-common to use milli_kelvin_to_millicelsius() in . Cc: Jonathan Cameron Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Reviewed-by: Andy Shevchenko Signed-off-by: Akinobu Mita Acked-by: Jonathan Cameron --- * v4 - add Reviewed-by tag drivers/iio/adc/qcom-vadc-common.c | 6 +++--- drivers/iio/adc/qcom-vadc-common.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c index dcd7fb5..2bb78d1 100644 --- a/drivers/iio/adc/qcom-vadc-common.c +++ b/drivers/iio/adc/qcom-vadc-common.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "qcom-vadc-common.h" @@ -236,8 +237,7 @@ static int qcom_vadc_scale_die_temp(const struct vadc_linear_graph *calib_graph, voltage = 0; } - voltage -= KELVINMIL_CELSIUSMIL; - *result_mdec = voltage; + *result_mdec = milli_kelvin_to_millicelsius(voltage); return 0; } @@ -325,7 +325,7 @@ static int qcom_vadc_scale_hw_calib_die_temp( { *result_mdec = qcom_vadc_scale_code_voltage_factor(adc_code, prescale, data, 2); - *result_mdec -= KELVINMIL_CELSIUSMIL; + *result_mdec = milli_kelvin_to_millicelsius(*result_mdec); return 0; } diff --git a/drivers/iio/adc/qcom-vadc-common.h b/drivers/iio/adc/qcom-vadc-common.h index bbb1fa0..e074902a 100644 --- a/drivers/iio/adc/qcom-vadc-common.h +++ b/drivers/iio/adc/qcom-vadc-common.h @@ -38,7 +38,6 @@ #define VADC_AVG_SAMPLES_MAX 512 #define ADC5_AVG_SAMPLES_MAX 16 -#define KELVINMIL_CELSIUSMIL 273150 #define PMIC5_CHG_TEMP_SCALE_FACTOR 377500 #define PMIC5_SMB_TEMP_CONSTANT 419400 #define PMIC5_SMB_TEMP_SCALE_FACTOR 356