From patchwork Thu Nov 28 14:54:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11266125 X-Patchwork-Delegate: rui.zhang@intel.com 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 0D03513B6 for ; Thu, 28 Nov 2019 14:55:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E009821775 for ; Thu, 28 Nov 2019 14:55:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uiVu1qxs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726694AbfK1OzC (ORCPT ); Thu, 28 Nov 2019 09:55:02 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:42303 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726401AbfK1OzB (ORCPT ); Thu, 28 Nov 2019 09:55:01 -0500 Received: by mail-pj1-f65.google.com with SMTP id y21so11998139pjn.9; Thu, 28 Nov 2019 06:55:01 -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=g0HiFEqIr34ap3Bh6iBqZPv3kmztxiAkeFZgF3cKXMU=; b=uiVu1qxsLxyPYPoq+O64OM6AHYD3Bo6KqoMZ3JLMT5lLAJOhBs5sZYiog6g3UcNpht 4TR1HNXXKqSgpj+SWe7c7HEulw0LAiORFfq0cChrdGDGczV+SsU2JZ7HQ+ziNQT9wJ4Y MB7NcLDAssHLAZzKKyWDhP1JsLR1j4AN2Z7uedi3TVVqn0N6kDtsGenJktAVbo9yd0Ld WfHv7NZjr2/nBCN4P6UZVcHEHfRC/JE18aY7IkPJTJBFHWQcbHN6RXbLLujov3a+Sda0 PZpGMBGIANYl3N1CGMyOPYLww9mOgZtSxc+1CSWJ9aAa3WfuFENMCy2tpfPz6GWN1MQI y+Bw== 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=g0HiFEqIr34ap3Bh6iBqZPv3kmztxiAkeFZgF3cKXMU=; b=gK/iEPe7fqXa5fGKQB+IisAaIL224COts3oCmnasqahfgAt+PsuyE7gMjEh8xWI88b boctQfI9pNV1TIY3PP6gyKfz4zEx+4gQQl+7mmj8BxP9cXbXr9TnZ3X0NmUY2dqLO8z1 BiW13UDoC3jjnKlIrzjPgGAIddDiARs6ZQ82UC8fWIfLp0Q5dmK/KkqVa9R3c6ZQVogD Ue78WqQ+lgYo7LrHoeeI0+5tgrfHzRbLsEDNwguJg7xh9R3l/FAARPgJXodtwp0WA7Nj AuN7aY4KJXsqEo3s4QzOuv34LPsTXTm9uViXZ9+sUjgYD3I9ezGkHKNW+vQ7st7XRIB5 cImA== X-Gm-Message-State: APjAAAVnZbWJyGyl1MqngiLs9R9v394H3sw5goJneQBMGEGodZm5kgNA EmtCNtrMZ0vwEGkmNFoS8WOvuqwIWvs= X-Google-Smtp-Source: APXvYqxwvjfJwJ9RVZBGU55qS1UZ7w101xpLRriZKYh/OSQlyuip6R8NkJJ+WBD7ODgUVFOLfSnyGg== X-Received: by 2002:a17:90a:330c:: with SMTP id m12mr13090381pjb.18.1574952900858; Thu, 28 Nov 2019 06:55:00 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8015:e854:5ef0:f52e]) by smtp.gmail.com with ESMTPSA id z11sm22282563pfg.117.2019.11.28.06.54.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Nov 2019 06:55:00 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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 v2 1/8] add header file for kelvin to/from Celsius conversion helpers Date: Thu, 28 Nov 2019 23:54:32 +0900 Message-Id: <1574952879-7200-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> References: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Signed-off-by: Akinobu Mita --- * v2 - add deci_kelvin_to_millicelsius_with_offset() in linux/temperature.h - stop including linux/temperature.h from linux/thermal.h include/linux/temperature.h | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/linux/temperature.h diff --git a/include/linux/temperature.h b/include/linux/temperature.h new file mode 100644 index 0000000..679e70a --- /dev/null +++ b/include/linux/temperature.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TEMPERATURE_H +#define _LINUX_TEMPERATURE_H + +#include + +#define ABSOLUTE_ZERO_MILLICELSIUS -273150 + +static inline long kelvin_to_millicelsius(long t) +{ + return t * 1000 + ABSOLUTE_ZERO_MILLICELSIUS; +} + +static inline long millicelsius_to_kelvin(long t) +{ + return DIV_ROUND_CLOSEST(t - ABSOLUTE_ZERO_MILLICELSIUS, 1000); +} + +static inline long deci_kelvin_to_celsius(long t) +{ + return DIV_ROUND_CLOSEST(t * 100 + ABSOLUTE_ZERO_MILLICELSIUS, 1000); +} + +static inline long celsius_to_deci_kelvin(long t) +{ + return t * 10 - DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS, 100); +} + +/** + * 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 * 100 - offset; +} + +static inline long deci_kelvin_to_millicelsius(long t) +{ + return t * 100 + ABSOLUTE_ZERO_MILLICELSIUS; +} + +static inline long millicelsius_to_deci_kelvin(long t) +{ + return DIV_ROUND_CLOSEST(t - ABSOLUTE_ZERO_MILLICELSIUS, 100); +} + +#endif /* _LINUX_TEMPERATURE_H */ From patchwork Thu Nov 28 14:54:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11266133 X-Patchwork-Delegate: rui.zhang@intel.com 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 DD68814B7 for ; Thu, 28 Nov 2019 14:55:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4E3021787 for ; Thu, 28 Nov 2019 14:55:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lJ5RWnOc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbfK1OzH (ORCPT ); Thu, 28 Nov 2019 09:55:07 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45897 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726401AbfK1OzG (ORCPT ); Thu, 28 Nov 2019 09:55:06 -0500 Received: by mail-pg1-f196.google.com with SMTP id k1so13001947pgg.12; Thu, 28 Nov 2019 06:55:05 -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=Tz6cOySRhhfYX2f36nBxCYaBCi3b9m633gEDdn5gfjw=; b=lJ5RWnOcf9hz2ftj8KTcQGPpf3wmYM+buvrM43OU3L8IBdlJvDoFySEr6Ue1r2NAvW OYp1QSPl6ahDR1CDkXEivs4ODAvYZug9dj9HhQTY1LKZrNkuxAnh401HCWVlZZSFeidX rUtYPWdE7gSSX9CMXKAudZf05NeeGvzR6WCiFrrU/rKincHxgWuxSj8IVbwlZ51tUPfY HuwA1o5s2Om+mh2dF27jNNQtMZ/mBieMAnprCgL7ckqtM10ghRMSDhDaxqLqg/JtLSWK Zq1onyweBBJgqzDy5KgcLWV4MrjHdSxuiDFUhIrcVBHJMpftNWDdngWfHB7G8EWQ+riY aCuQ== 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=Tz6cOySRhhfYX2f36nBxCYaBCi3b9m633gEDdn5gfjw=; b=ae/fE14PBnnP+UluEfSitdnMWmNgfT4e96ftFyJ1LjQ2ABJpPxKhBXFXWcaUSJ10Nt O9XL7s/TNP2edMpwKdlExglccLWcXgwo3GdPxIGZ6jiZHQTj+iuMTtaTkJb7PTsa7Mz1 42wqnXnEUMVz58OQoAGsCE8QHRN5EF1qkrxsvI+4yaM4H7+PECNlmDwdrirZ8R2Z3WC7 T9g0Bj1WT3oMVAUl0SLobrPLs9T7PDkxMSfsYZnwxr8k3TdUDCaIkZNJD4/375CkVWyy +sdhHBy9HpjiAhUJ9bkuDkOfiJsRxPIHKImFm/8ypLE1qqbhorUKkB08THOxSndv7G9d 1cHg== X-Gm-Message-State: APjAAAXuhU0dbXQqycYP4z07KIQkRsB43jbvay1mXraOJjp/FOtiKGJS KTWCoYtwdhAbHfmRD/eYj2k= X-Google-Smtp-Source: APXvYqxXpb6vyYoRS/aQShEZodxv0UryrA00GtVnoBcusA/RH5RFqbeXCJm2b9a9wHzCXw69HHgjWg== X-Received: by 2002:a65:6916:: with SMTP id s22mr11388523pgq.244.1574952905215; Thu, 28 Nov 2019 06:55:05 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8015:e854:5ef0:f52e]) by smtp.gmail.com with ESMTPSA id z11sm22282563pfg.117.2019.11.28.06.55.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Nov 2019 06:55:04 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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 v2 2/8] ACPI: thermal: switch to use helpers Date: Thu, 28 Nov 2019 23:54:33 +0900 Message-Id: <1574952879-7200-3-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> References: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 --- * v2 - include explicitly from thermal drivers - fix s/temprature/temperature/ typo in commit log - use deci_kelvin_to_millicelsius_with_offset() drivers/acpi/thermal.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index d831a61..9f96e66 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -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,9 @@ 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 +336,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 +416,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 +424,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 +522,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 +627,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 +637,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 +647,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 +658,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 +675,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 +695,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 +1046,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 +1090,8 @@ 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 Thu Nov 28 14:54:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11266137 X-Patchwork-Delegate: rui.zhang@intel.com 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 5104B14B7 for ; Thu, 28 Nov 2019 14:55:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31040217AB for ; Thu, 28 Nov 2019 14:55:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b+A0daFB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbfK1OzL (ORCPT ); Thu, 28 Nov 2019 09:55:11 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36033 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbfK1OzK (ORCPT ); Thu, 28 Nov 2019 09:55:10 -0500 Received: by mail-pf1-f194.google.com with SMTP id b19so13280989pfd.3; Thu, 28 Nov 2019 06:55:10 -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=7KKKKjGEFkR1SZnk4/a5jY9T/FwK0zSdmITwZXojgTQ=; b=b+A0daFBKQNfri8HQ2Q7cGR8yVFHZWPi34/Bisw6NXiroctpWAIBBZSMjDUC0UffkD UbqbJlDUILM6iU2yQwiVi1CYPlyPzIYxQ5nsy+/uU8fWwl+TvDucXD3st6juFY+osGra DFG03yi9evpjwIYOWp1eGgzpoGt3D3ziBlGQJrYW2c5PYSSwbQgbVnJFCFTRVnXAEJDc 0Gzv+YdPsqL0v79gY9JlbwCsRdyUgqqrNy3PT/srXpDXsg3ZJk13/zngvaxr/UssAavP mD47472O5gmTBa4mRxze8atPA9zWNOTvyzxFpOaS4o8z/mVGkN+mSjmRtwCa+JVGfqYq jXhw== 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=7KKKKjGEFkR1SZnk4/a5jY9T/FwK0zSdmITwZXojgTQ=; b=m/sfPlMzqh6zdpJFwrJxBRYqk/P7D4YssKiCjef1SLctgWR7F3eZ7cgBcSDyRYAnlp Kk91Xhh3UXa67SH/4p9EFEtl0bDvv3gRypBD+mOYuO2xFTckea2lPB3NZqgFU0OxSd+/ Lx1QF978k+yQN4wzAwA+tOYLgkafrQd2AvhVbFiLmQLT1jXk4aR5RnQJ2b5mCt8xjcmd LXxs5mBAmDA2gQkjGlSdukRd9zBAshfab4Kd3ebt+00Z0/sQqnoYjYrQMvhP66uin3/4 CY+w05Bc/6T3oxe1ltWzKr2TF6sZFeIaXt9fp7RnbZ7QbY2SjZrbUwM1oDAiXzynmizV RLMA== X-Gm-Message-State: APjAAAVXaMJlvrOCmWplUG2TuaB0KopyYCMBaCqZfpC3m0G0rT/0l+ky BNP6z3TwDOzwpHjyBJuLG8s= X-Google-Smtp-Source: APXvYqypnawADf67Fr6UMIh3dr5nN4MKDxVHUVaoWAhJayCpe2CG3j8GYcbi5A395taCn6KVEARtOg== X-Received: by 2002:a65:62cc:: with SMTP id m12mr11002643pgv.397.1574952909701; Thu, 28 Nov 2019 06:55:09 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8015:e854:5ef0:f52e]) by smtp.gmail.com with ESMTPSA id z11sm22282563pfg.117.2019.11.28.06.55.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Nov 2019 06:55:08 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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 v2 3/8] platform/x86: asus-wmi: switch to use helpers Date: Thu, 28 Nov 2019 23:54:34 +0900 Message-Id: <1574952879-7200-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> References: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 . 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 --- * v2 - add Acked-by tag 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..6a1a2f9 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -33,7 +33,7 @@ #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 Thu Nov 28 14:54:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11266139 X-Patchwork-Delegate: rui.zhang@intel.com 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 C433E17F0 for ; Thu, 28 Nov 2019 14:55:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A43E221787 for ; Thu, 28 Nov 2019 14:55:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OZfJdX6w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727070AbfK1OzP (ORCPT ); Thu, 28 Nov 2019 09:55:15 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40003 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbfK1OzO (ORCPT ); Thu, 28 Nov 2019 09:55:14 -0500 Received: by mail-pf1-f196.google.com with SMTP id i187so9091763pfc.7; Thu, 28 Nov 2019 06:55:14 -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=XLU+RhnbOLO++kk3A2l2hX8YNotokH7UjGIfreihyFk=; b=OZfJdX6whHMuR6GPApqn8rRuOEAnRf3w5c08IbXIUPnDI1gkAXOeEWealwKTYg1aLG 11ye6u77N8A2CX+effHDLr1fku3ylPiH3hhhZqlmY3KN0gbLXXS6Z5Q0bAE2f/jcTSwn nMLvypyNuRxsTBdEVODvH8U/Xz+FQe4c88fqRuKFL9/BzSY2weg1rA8zg+63sqyQXNvb skqYPRd7XR+mT1G/dHIBao98RWWhcDBBTI9lehVrwK79KZyGhK4oyWwj9nGRV3b2spmU 7cS5vO2Dk3x4plo5u9YFJLUgfjBJ8lKXFcEo7khVKhPa+AlMyTxPh4yq7QCck4JXmJlV dlNg== 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=XLU+RhnbOLO++kk3A2l2hX8YNotokH7UjGIfreihyFk=; b=aQVb0Sf5PYx4Kijc09TdCLPCaEX4Z4JbZ5raxfxEVUDYDd5UndUv7R37hmRp/RqSVM 04HXzdaLAEmlnndYdbYmIYJXFUqkj7dkgVj1FDeO3P+eZPdrDRsZhJzybleo/rGEg+xp Ph7ZnGq7wOcDMDEL4Z/V58gmiOgWE9nkhIvnzkoWkSN9Ahzhfq1S/gRBdH+iVOv2J/67 cKge7KO5ksnJKv5/5+CXZK+uX9KBMWZInmq2xaPATJr1iydngwG8LVmDRVqIITjyuMW+ OqOzPRZpNRKOqg2O0CnfPxtHiR5H+dAfC20orwypbsAxVshVAHglOxnZP5DA6pC6sEa2 UB2A== X-Gm-Message-State: APjAAAX9nvkSTbmoPCjuR5L4LfVAfkgO62ohcdpLVhPnbh6V/8jf4Rei pbYOte47k9wQQJmGJGsgSkg= X-Google-Smtp-Source: APXvYqwzpYgJ9dVAN3Isp6uQaRiApCWUSpADNNzkXMrApBhMnK2khllI7c2bFpkogeF4MiSUBjiHaw== X-Received: by 2002:aa7:8aca:: with SMTP id b10mr13507218pfd.213.1574952914062; Thu, 28 Nov 2019 06:55:14 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8015:e854:5ef0:f52e]) by smtp.gmail.com with ESMTPSA id z11sm22282563pfg.117.2019.11.28.06.55.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Nov 2019 06:55:13 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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 v2 4/8] platform/x86: intel_menlow: switch to use helpers Date: Thu, 28 Nov 2019 23:54:35 +0900 Message-Id: <1574952879-7200-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> References: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Signed-off-by: Akinobu Mita Reviewed-by: Andy Shevchenko --- * v2 - include explicitly from thermal drivers - fix s/temprature/temperature/ typo in commit log - don't mix up another fix (format string for cellsius value) 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..12c1094 100644 --- a/drivers/platform/x86/intel_menlow.c +++ b/drivers/platform/x86/intel_menlow.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -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 Thu Nov 28 14:54:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11266145 X-Patchwork-Delegate: rui.zhang@intel.com 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 9991514B7 for ; Thu, 28 Nov 2019 14:55:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79A90217AB for ; Thu, 28 Nov 2019 14:55:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VNGiuixp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbfK1OzU (ORCPT ); Thu, 28 Nov 2019 09:55:20 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34421 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfK1OzT (ORCPT ); Thu, 28 Nov 2019 09:55:19 -0500 Received: by mail-pl1-f194.google.com with SMTP id h13so11722208plr.1; Thu, 28 Nov 2019 06:55:18 -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=Rl/Muaad0JKZvHEYUN/4/vVrZyhpWqkrNfXezrDAyeU=; b=VNGiuixpHdhZlKCdI1lUbF3zqtjKhA8JjC+y8CfCWFSPFQ0BQz3Lmb0QLJTeQzeeOp I3MeGV7hUuAKdiWZjr9nz5YeeVEaBxxsWo7QfzwE5sJCF8N4jcodOUIv88gm2xsi9+R7 +BQRtKJq5MV1L8ufJnXe56xOngFxMRJyrlT/Nc8R94EMwK7GJn8AooBCxywnqUUpcvPZ yksVDGyhleVo0RnEBJS31FGBfySon8G+y0S1+6NAYU4EZpHqlqBPdZ3qbFskqmJ4z874 pzMm7HaYHErXanglixeEhcaG4g6dNNTXqgAj/Pc2fw8A1uCma13Pr826ept1srbPcqFL 74TQ== 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=Rl/Muaad0JKZvHEYUN/4/vVrZyhpWqkrNfXezrDAyeU=; b=R2rruXsmDqp4XijQIlyW2B3ma/CyU1F96wp/A3VmJsxA4YPiWNhaOT1GSPWClbj3PW YHNy3krA1DfDNyavtd47/cQhfFtyNnNbrit2MKaAdJoiJiA2wMHIBbS28zrbnwx/NtPg KwVQjX6I/o7x+3HTsa1o3Vil0JvIOmGLaIJCbEHqmo2hLZKnj2idPvJT0pVRVvSp/0sR cR7AqnRNKz/NKNyuO/pVHbyKyXXh9mzOU6WkuVnhpqeDqtYepVE/gty9tbEi8ZmyX1lc wFLqPz25JQkXz+ZSD9ri109dp3VVa9ltSO1IEqnoxY5vIlAyBaAY/AcO68I5orGCROdf PNzA== X-Gm-Message-State: APjAAAUfyyaORh4MiTeb2bkTFKRIy23GdKPswXhwykgqf+H2A7s4Q6ul 2B0iGozseDT1gZPGO41TNplLdbQUQbA= X-Google-Smtp-Source: APXvYqwR27zrU/EiAbDRNlN1A8TmOl4w2Fmgs7jCyn1WoiQAAB82sxWB2twhBCfOfzKVYrGHmqrS8Q== X-Received: by 2002:a17:90a:48:: with SMTP id 8mr12600637pjb.82.1574952918403; Thu, 28 Nov 2019 06:55:18 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8015:e854:5ef0:f52e]) by smtp.gmail.com with ESMTPSA id z11sm22282563pfg.117.2019.11.28.06.55.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Nov 2019 06:55:17 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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 v2 5/8] thermal: int340x: switch to use helpers Date: Thu, 28 Nov 2019 23:54:36 +0900 Message-Id: <1574952879-7200-6-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> References: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Signed-off-by: Akinobu Mita --- * v2 - include explicitly from thermal drivers - fix s/temprature/temperature/ typo in commit log 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..6658cc7 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "int340x_thermal_zone.h" @@ -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 Thu Nov 28 14:54:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11266149 X-Patchwork-Delegate: rui.zhang@intel.com 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 C109F13B6 for ; Thu, 28 Nov 2019 14:55:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A22C52178F for ; Thu, 28 Nov 2019 14:55:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PUx6zKO3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfK1OzY (ORCPT ); Thu, 28 Nov 2019 09:55:24 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:37259 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfK1OzX (ORCPT ); Thu, 28 Nov 2019 09:55:23 -0500 Received: by mail-pj1-f65.google.com with SMTP id bb19so8455023pjb.4; Thu, 28 Nov 2019 06:55:23 -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=KOk1Zu1Ql454tFPs2kZw5FfHjnyPTzMrmCfexC/lRs8=; b=PUx6zKO3n9KG7pm9Qk5LBg/cFVNRMxPNChPn/sB7wL8qLgLFBctSNutljHfYN60Uzj 6z+GKH89YGgLqCEzGu5GAw7Z6kdiScXCHYIav+6bXSRzfMz5qr43OBlvdbLH0uTZfvT1 KqMC854IvMpRm2UaBumtVDBNTF8qTtOyC50qjHeAwpNHLfIXyY12rX2f0PrYRSA3O03R POQCifcpPOoiUbUIhmcrfSUMMv3Sgraxn/v34nM6/767YYyTUB6qetrVpIuAfIIsSW+z CM7K11Jey8gqcjfknmDVk1zui1u3VzlQU+me6AXnOQ76YCFa13zhDnuc31Q9kh8fvOS/ jflw== 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=KOk1Zu1Ql454tFPs2kZw5FfHjnyPTzMrmCfexC/lRs8=; b=EUbTtPpTvaFklOFX7Y8CehA1iHMCPDD187Iu1X0hsZheyX/76/TZ4ls9YNYTULQjO0 P0Lx3PR4sTkfxEoJ1kss3Yyi02wa9kAnOXhO4+871zsBilkL8jGh1nO695PGzBzowRRv fVrVvmB3pVCU16ZZkfgLpesx9sM8d7b9XvbTPkEn2IYLngfg04ChR3q7aVp0WhFHBYe8 NnQBqieyMRwMVM73qtIZmkTXNQ0D5tKPhkXrEyoov/1QrGvXbRPK8ymRCRAVLOWs60fn J3tULzDgxDzpqTi57s+o5VIDT36F6n7z36IgApv9RecRLFcAuWTp0Gzr/0ou7Qno7ayb NnNw== X-Gm-Message-State: APjAAAUh1AGehoxmIViY6oW789e4cwyWTXl09xEGYo3U2P9WWaMp3Qe6 JJJjI0IqZncZfDOaxFiXXx8= X-Google-Smtp-Source: APXvYqz4ojDDuagtER2KZtGw/qJt9x/inm9T4ft8+dEsuEU1iGQ6cYCvDasNxYdsCl3BC1bGnjHbNg== X-Received: by 2002:a17:902:8d81:: with SMTP id v1mr9881555plo.289.1574952922811; Thu, 28 Nov 2019 06:55:22 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8015:e854:5ef0:f52e]) by smtp.gmail.com with ESMTPSA id z11sm22282563pfg.117.2019.11.28.06.55.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Nov 2019 06:55:21 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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 v2 6/8] thermal: intel_pch: switch to use helpers Date: Thu, 28 Nov 2019 23:54:37 +0900 Message-Id: <1574952879-7200-7-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> References: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Signed-off-by: Akinobu Mita --- * v2 - include explicitly from thermal drivers - fix s/temprature/temperature/ typo in commit log 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..505a5d2 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 Thu Nov 28 14:54:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11266151 X-Patchwork-Delegate: rui.zhang@intel.com 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 2287414B7 for ; Thu, 28 Nov 2019 14:55:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01E652178F for ; Thu, 28 Nov 2019 14:55:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dSadCgTf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727156AbfK1Oz2 (ORCPT ); Thu, 28 Nov 2019 09:55:28 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37471 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfK1Oz2 (ORCPT ); Thu, 28 Nov 2019 09:55:28 -0500 Received: by mail-pg1-f196.google.com with SMTP id b10so13024679pgd.4; Thu, 28 Nov 2019 06:55:27 -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=dhRdimY0ajJJ9jrRtSdV+vAbveAqfBoDwJI+XgU6bco=; b=dSadCgTfPIzB/jo2hoLbcB24fHUPWvOniDsvlEf5K+KMHM2DCeUUDhJd9Ix7uawrTV vJw7l2PcXrbB2AzJEx3HGoHeaGzwFWmJL4//qbhF9XjGkLf/pQQZZrxLWFN8gOzLUpFQ UHWwS//72DeBUawtIyMPbBenUK6DFxHUc8fmvowpiHo0Xkyzm5nSDXPI0/uiJGbcWGzT wz8dQW2OMdkhS4dq8B84DO/eaXvFedaGQm4dGKbB/yyuq1kWzrgJWwSw/yXBZbs8/pNi DmrsvlGEvm7YIDKQgvF2S6qivSuhIqRJMizM4/htZvoduJO7Im2Jw9XUIjzfkpDUSRh6 /TCA== 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=dhRdimY0ajJJ9jrRtSdV+vAbveAqfBoDwJI+XgU6bco=; b=HUINRWZZcapPA/S0xTkQy1qxwTWwfl/bYa/EgeX1rgBtcnBuuxt3EzoVmp2fEOMX40 nw/T9TlmoGy9AEfWEVjQF13wbdw3QWzdlXWfKO+7VA/nXFOU7svpcX08/Zeyb/hXc8d4 A7L4vbhpeTeCSI18BNvlXy2S8GbSW9nfX0pG39svlYMGp6dTj7goTVN8KCWY4n4lWSWn SHD/Fcz1scbJrpMYx4flyRIsRn4FPYXB4IcWPxVbi+yA/eTKdd5zRJmULlAH018rwhrv B7r9JNlwFAffjRKlJWxClL6EsuPpYmdD2TkjlEqB2T2UiadQvv1P7IOG2Gv74b0+UBS2 A3Xg== X-Gm-Message-State: APjAAAWUwk+7pVoo/jv/Bdmy8e8YJcfdpXBmNiX/6na3XGAZznv5NdUn 38IRYzhW3co94tsOJ4Ld+88= X-Google-Smtp-Source: APXvYqzjoubKYiDf0NpWSlRmLegHRj8zhl2/+1eD1xhEeY/kOJ/MNltJD2eQHDC4GImOSmRRLo4KpQ== X-Received: by 2002:a65:40ca:: with SMTP id u10mr11404387pgp.432.1574952927279; Thu, 28 Nov 2019 06:55:27 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8015:e854:5ef0:f52e]) by smtp.gmail.com with ESMTPSA id z11sm22282563pfg.117.2019.11.28.06.55.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Nov 2019 06:55:26 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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 v2 7/8] nvme: hwmon: switch to use helpers Date: Thu, 28 Nov 2019 23:54:38 +0900 Message-Id: <1574952879-7200-8-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> References: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Signed-off-by: Akinobu Mita Reviewed-by: Guenter Roeck Reviewed-by: Keith Busch --- * v2 - add Reviewed-by tag 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..14720c1 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 Thu Nov 28 14:54:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11266155 X-Patchwork-Delegate: rui.zhang@intel.com 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 93A2513B6 for ; Thu, 28 Nov 2019 14:55:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73BC2217AB for ; Thu, 28 Nov 2019 14:55:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CTpe8s2x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727187AbfK1Ozd (ORCPT ); Thu, 28 Nov 2019 09:55:33 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46669 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfK1Ozc (ORCPT ); Thu, 28 Nov 2019 09:55:32 -0500 Received: by mail-pf1-f196.google.com with SMTP id 193so13242710pfc.13; Thu, 28 Nov 2019 06:55:32 -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=9drT9CU5cZN6dzbiFt4dm2bln4hYnigDIHpJhrBGGI4=; b=CTpe8s2xCUn55c5tx7AZUMZmQFZTo7qTzSlyyhWDRNZHydZxvqwsQmL6ogW1652b52 OACTjH44RQmVeLfHQbVyDLx8Vd83i7kIhU5hCKICNON6BtISh6E/d89zNjqNe/4t6PCt DkGm6SqPiTF7LJLoBwW5c/DTDfeYgEdPZalDfSNxcqcytKwwumIHhYnxLeZzeXSQEbzQ 7I+e22yZDZ2zGxogtzTv46Lxa5jBexMH65DJUi/Ypu9ToRrl0FwiB5zOuH4NCj3syD97 8By4nqa2uYdz6Hv17AqYwA/K9SbsTu5rqes1cHVKZr6Q/aXZ4/NiU2A8noQ8XiorPir+ 8u0A== 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=9drT9CU5cZN6dzbiFt4dm2bln4hYnigDIHpJhrBGGI4=; b=BXGpvhBNQG0pXLeVreNhwIjkx9sNlvGeG+e2Wuxib5wBUScXaAN1hSLvTjCg6b84rb jhTf3mm6cYjvINiaGkBPH+/trlwDryf3dI35QYFUFyaOXPCcCoMt8D8KM5kZ5me7KHx/ XL6zirjkJmZC2a0NoVNoh1jp8OQ41df+Ik2iNvKHc2+E1QWKTxpO4ZCanH4qBddtdos6 PhQyD3yIyrccIAfrZOf23E58tjfQafZnZdM3P8fPuaf3alyusC1/NW0CZYuo6GmZONHP k6RQrAI2HEBS1vJ5U7bp9k/e/842xp+6v4wfJAQFR+YBXuQLS8ruNm2Wj1k8HQZ0OO6l r5Fw== X-Gm-Message-State: APjAAAXjDDRe7G9B6nNPfTSIs5Qcej8CjiFgwqi9wyp1/fCqKjj2dwlp aWLB8qA/+JGB6fzFnI/CQC4= X-Google-Smtp-Source: APXvYqz5GDqSUvR11svaKL3mV9F7NGqWfJiFhxG9BLX8Gx4vc1cLuLg0Od4+rsbz5kbxFJNVK+mzmA== X-Received: by 2002:a63:642:: with SMTP id 63mr6907260pgg.73.1574952931743; Thu, 28 Nov 2019 06:55:31 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8015:e854:5ef0:f52e]) by smtp.gmail.com with ESMTPSA id z11sm22282563pfg.117.2019.11.28.06.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Nov 2019 06:55:30 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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 v2 8/8] thermal: remove kelvin to/from Celsius conversion helpers from Date: Thu, 28 Nov 2019 23:54:39 +0900 Message-Id: <1574952879-7200-9-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> References: <1574952879-7200-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This removes the kelvin to/from Celsius conversion helpers in which were switched to helpers. 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 --- * v2 - don't preserve DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET() include/linux/thermal.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/linux/thermal.h b/include/linux/thermal.h index e45659c..da272fa 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"