From patchwork Wed Dec 11 14:38: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: 11285127 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 37E98138C for ; Wed, 11 Dec 2019 14:38:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 17A81222C4 for ; Wed, 11 Dec 2019 14:38:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n/zyW7ze" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729929AbfLKOi4 (ORCPT ); Wed, 11 Dec 2019 09:38:56 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33854 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbfLKOi4 (ORCPT ); Wed, 11 Dec 2019 09:38:56 -0500 Received: by mail-pf1-f193.google.com with SMTP id l127so635229pfl.1; Wed, 11 Dec 2019 06:38:55 -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=l0g2yitOap2PZ563u5lrVGdcbHo44KhhJk/TqjJ9Bls=; b=n/zyW7zeFhMU5gj3nvHALhoD0Cni+mTg66+JciqG64jKfxuDYWCuHFshRuKw9PzcVR UPAhcWK8PMXQJvYTKwWVJxtE93sBSkxt97rrtEQIGwWkoZ1GYIbhP1dc6cBA47HAr7fq 7HZyBS8L+8zimgtYc0u2Qxogpoe9wos3NUr+I8uQNBQ2QVMH43qaylcRH6Fy7GLt4cV7 Q3DztC7PRqjIfQG8uHRpfhPlvaIVfJ23nQyyG/nE6Xu/em+ek7hvnX2atXSHwTL/ryKg m776Nu2T7ruyegOFT76AFo2uyLAC2UWE0ZgYTo6SUra3dBBLtNc3N/WoplLyovVh9w/h MbTw== 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=l0g2yitOap2PZ563u5lrVGdcbHo44KhhJk/TqjJ9Bls=; b=X3z3ZBLIMFZxvR4ua9ijL0Nml+3XlF/t+QpYloNcNtRU4fp22cgMFkjrR4j+Y2jW3U K8Spg/rH7JkoEdr6uZXnXhhroU20v3zUiprz0d4qVGYAaJeXumk+JaOUC5E/l33q/ZBN N39Lc/q8FEHL/AJQK6PqE3DRLUTHkvhzo3421F7NwFRjw/8mqfzv9xQ+eiOflfpNGMTq xPNM6iWd9gAT2Pp8zwx/u909isjg+C0ZShuMZ2Xgyp4ioMwLwwjqf4fFEDRfZC9KYGCH 02SGUMcKu/6lqVkZjYHBYp7z2vSluodzm09pQec5bP1Bq1T6hawE9nQblYzaPtDWawvi eQ8w== X-Gm-Message-State: APjAAAUnnEpjOmMkiuTrXoKEnG+wOxwh5TssAVSgCbnlVPV2gWe3nwTp gosv68uxkzcqr+5o1U/nakzDyMLIfSepCQ== X-Google-Smtp-Source: APXvYqy05/Tn9Tceh/n1VRnGu0o9MXcVLllz85EXFJwN51RkIZCmg7WXWcX4MikbeZCoqWs2pOFXqQ== X-Received: by 2002:a63:ea17:: with SMTP id c23mr4526029pgi.85.1576075135462; Wed, 11 Dec 2019 06:38:55 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.38.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:38:54 -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 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 v3 01/12] add helpers for kelvin to/from Celsius conversion Date: Wed, 11 Dec 2019 23:38:08 +0900 Message-Id: <1576075099-3441-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 Signed-off-by: Akinobu Mita --- * v3 - rename new header name from to - add milli_kelvin_to_millicelsius() and millicelsius_to_milli_kelvin() and use them for implementing other helpers - add MILLIDEGREE_PER_DEGREE and MILLIDEGREE_PER_DECIDEGREE and replace the hardcoded constants - add kelvin_to_celsius() and celsius_to_kelvin() in 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 Wed Dec 11 14:38: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: 11285133 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 336A2138C for ; Wed, 11 Dec 2019 14:39:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 07A5A2173E for ; Wed, 11 Dec 2019 14:39:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZmbMzGAV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729985AbfLKOjC (ORCPT ); Wed, 11 Dec 2019 09:39:02 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:42107 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbfLKOjC (ORCPT ); Wed, 11 Dec 2019 09:39:02 -0500 Received: by mail-pl1-f195.google.com with SMTP id x13so1495116plr.9; Wed, 11 Dec 2019 06:39: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=aMYza2espJ/tsAfz58SlTUu9MiIVLwdjN+KGLUAdlkE=; b=ZmbMzGAVOLos2wnlXjV4De+DkX0AUl8htzrbUZXvcjTz41yV8mzhq2Xh3m+J/Zla9j 55zJVO5QiBpZCbAs5gWpCCsy+rg/HZoWpr+sH5Mc9Ta5lAH/sOM7w/jAraSQS00LxkBX leXm7xaBC3XzleVMz6N9sVnthNhRcEqBY9guO4Y8rron4wVUh/cRu5XLZlPWqg/CTfga qK8D9y9qP9Cjqee46+FsICfy275Kte5NsrseywAt/0CQPNuSjgeKzhcme9IG10ccZTZx E/YRyK1J/JHwi2MS1QQpaB6/kwzWG1JAR9P+yNptzg1tMglqfgGaypUnmwaibnbJmKyU hbAw== 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=aMYza2espJ/tsAfz58SlTUu9MiIVLwdjN+KGLUAdlkE=; b=ltCnwWNzp9QeQnSLQdtSN8JjgI2yUP6Znd/0R6k+UMlYLzMhS+O7Gb9UZAnpuXJ3YR 5T/0sZVoOGIDOBeGQC9XBMmPCuX4UV3XFcvB1JL8hKIRIkG6O31kfIfZADEiFho3yn68 lDwL1XRCPT8DItb+EBV+PVGQNuTEHw7Uu5TvTqvkQ5m+BflB9Tlswvv4n+r5PF1quwxF av2zRKkhGUviZRCV5xm12zJlmlAC5LZU3mNN7v6dTmFNf6JWXU0lSumJXRBBpiFe49bc Fzm/W5bdekzX4Yy0NAHGeGUBIDPjO4BQkJ5ABnlhR10/wKc+IP/7AFSQmLU2UmPdy3ir 56sw== X-Gm-Message-State: APjAAAWhIHkpauRjQyl1aL5jm8fPbzAbFtNA5DI9QNYEYyfSz5u6Vrjb /iq8Ab0Uo8Frpcd4BjRGxB0= X-Google-Smtp-Source: APXvYqy6Lr7fbZ/IBRJirlmpGo6SxC7Xb8FPSycy3BjYlrj9ONpGAPdSZREbQPlLJFCiCP7CrAkBZg== X-Received: by 2002:a17:90b:4396:: with SMTP id in22mr3702546pjb.111.1576075141056; Wed, 11 Dec 2019 06:39:01 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39:00 -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 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 v3 02/12] ACPI: thermal: switch to use helpers Date: Wed, 11 Dec 2019 23:38:09 +0900 Message-Id: <1576075099-3441-3-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 --- * v3 - rename new header name from to 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..8a436f5 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 Wed Dec 11 14:38: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: 11285147 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 9AC43112B for ; Wed, 11 Dec 2019 14:39:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A0942464B for ; Wed, 11 Dec 2019 14:39:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D2AOHOEM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730035AbfLKOjI (ORCPT ); Wed, 11 Dec 2019 09:39:08 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35421 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbfLKOjH (ORCPT ); Wed, 11 Dec 2019 09:39:07 -0500 Received: by mail-pf1-f195.google.com with SMTP id b19so1920814pfo.2; Wed, 11 Dec 2019 06:39:06 -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=5F0PPdfZoQeR4+ehc0BK4J4+yf/kLV8FFWeTQgbLqO4=; b=D2AOHOEMCyO3k0hjvFxCCgKEqw3qsFhSE3sCThcc9FU8sN4//6ZWrWkG4W0Gw5n5Ql tnp6kAtoTrDnZfAVIlvPnYrYsz7QXKkZDhw44viq5clQ7OOY+SMTFX/cE0NORObwwHJw C4CPlUCRgN2zccpdBIat2VJElRlPGOguLM6h2WjaYzB7Hw4VCD8ljH78NdA9JrCOe5bh B2+rv7y7IQkBPBmDzviHzyAhk8WOzaLp9nk55/T4PP4tUjiDmDN6zvWs7KXdkfW7+da9 81bR72bXCAr0IbLnDyZkZcA/Zmg1Qm376KSytapK2fxSgAtL7XjJ/OyTV0lIxAZXC/42 nRIA== 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=5F0PPdfZoQeR4+ehc0BK4J4+yf/kLV8FFWeTQgbLqO4=; b=uGs7dnc01dah/RsCj9FZahlf6r7C6dXvx8oVKfVNBfwnK/8WXl1xGObk2scplGKLff QtL/OvjTqwLq5l8ZbW+bm6EXvmkV1Zvf5YwsK3HUJhzuI3lMSbVKHJowxxNejXoClBiY o3Bm98NHGtyQOCxD1BeBHYHfAJqK1bAIzLwuJGlhNSCtevqf1imvY5CZrOkRuJFHujuW oJPxMz8XibQVBhs/9p6gTqoBQL4n6tkcSHSsz9jFaNrYy0diVtISq++vnWQE8RizEp37 +gvBrnlG0z3s/VOqhOYTvl2kE9hAuIq5CY2hTYg1jNMnnTjIIhlI8itz5/fOPkm7d+kq KfTQ== X-Gm-Message-State: APjAAAUJYPH2C750jcAPpEQ4O46INmfdpH6zygHFtMU9W/jMVbEQB4ZV xXTe4YTIbEfslmPdjJ/Jc3Y= X-Google-Smtp-Source: APXvYqy+ULp0BtV8BOiWwljH1aYQKPrE2YUyS2+/jHA9IgLPTQUYtDOyRF2WZHmnIuuz2UODfEYp1Q== X-Received: by 2002:a63:184d:: with SMTP id 13mr4515647pgy.132.1576075146466; Wed, 11 Dec 2019 06:39:06 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39:05 -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 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 v3 03/12] platform/x86: asus-wmi: switch to use helpers Date: Wed, 11 Dec 2019 23:38:10 +0900 Message-Id: <1576075099-3441-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 --- * v3 - rename new header name from to 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..ed74c0d 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 Wed Dec 11 14:38: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: 11285157 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 85D8B138C for ; Wed, 11 Dec 2019 14:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6469120836 for ; Wed, 11 Dec 2019 14:39:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TD38CrYz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730055AbfLKOjN (ORCPT ); Wed, 11 Dec 2019 09:39:13 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44945 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730052AbfLKOjM (ORCPT ); Wed, 11 Dec 2019 09:39:12 -0500 Received: by mail-pl1-f196.google.com with SMTP id bh2so1487933plb.11; Wed, 11 Dec 2019 06:39:12 -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=wO3jkH+pH7VdbFARKta9bxoSsbke4b8Zl03d1mXFCcM=; b=TD38CrYzoOsQjlzXB2cRRd9HRMMDxp/xytFAH/OIzDUwWaAkxa4/eFqTBtP/67AZPk 4Cb+kTlTIFDeKa5EbUk3bL883UV4w4DnKx5+iIGYC5bjeArB1QqBJeKqt/SXfFn7m2XF XqX/7RxhHaTIJTZn7f8PKyerSkxDJR6+DutaZhebcyVWAmtxb6L0DPh/mspVZQkW5qyP WtpwxDzi8FXsr2Bg0te7lsyN58AUxi/7W7OGFKQawgqAdVsWF+TKZLpXZocEiHDha8j8 0LQWIchLb46fnZagkhhjL/h/ZgywDXrQ9noPfS9l3XIPha4u59zKcCe2mCmy52hJnNNr gfwA== 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=wO3jkH+pH7VdbFARKta9bxoSsbke4b8Zl03d1mXFCcM=; b=eQVzYgdKg9TXOaGGavFEyGB7LB5wuhAgTzM2LZ9ekCPP1jCWvU11Vo/mRU+UJLYenv wwFd8BcPH7b9iMrMwPEl6OMcC+BmmFVrsWNWRhJk+yistN+SIQ8+GNQD3Ry9E1ENjcQH npQK7C+pNzUreuXtn+CaGLY5keNcQGZscs/EkDAq2up0xtIY+XaIZ65ImY2yiDymF4p7 5M40/sldd4XvmwowqeM5alCm+Tx510EX2Ku+HXs1Q2lIvru0Uc2xPqwT6aDVWFa7XW1T 2Am/ZVV1I9DgNbQ6x2daBdlGqxZ3u2SnDUT0ZyVP4U1d1AlSdt+N1VZZt82ohY0+p0EB Bqxg== X-Gm-Message-State: APjAAAV6TfchqUoaYiWIzoHp4s6cncj2IRG5wOwIbL96KVC0nY9s170j 17tQoXU0M4kVvLNl3b6/CB/wT4zhMMc= X-Google-Smtp-Source: APXvYqxT+/d6//9eH3ZYvjUMxrZPNz60pNUqUzbihUXUSGTG82cKy/Rxgy6yRUUjVA8t32UcmaqAxw== X-Received: by 2002:a17:902:8d83:: with SMTP id v3mr3552557plo.205.1576075151675; Wed, 11 Dec 2019 06:39:11 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39:10 -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 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 v3 04/12] platform/x86: intel_menlow: switch to use helpers Date: Wed, 11 Dec 2019 23:38:11 +0900 Message-Id: <1576075099-3441-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 --- * v3 - rename new header name from to 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 Wed Dec 11 14:38: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: 11285221 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 B11DE112B for ; Wed, 11 Dec 2019 14:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86180222C4 for ; Wed, 11 Dec 2019 14:40:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lKwtyK3L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730070AbfLKOjT (ORCPT ); Wed, 11 Dec 2019 09:39:19 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39383 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729686AbfLKOjS (ORCPT ); Wed, 11 Dec 2019 09:39:18 -0500 Received: by mail-pg1-f195.google.com with SMTP id b137so10872609pga.6; Wed, 11 Dec 2019 06:39: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=LkssNv9xnqcTUQeW4rk5Aqaqz7M0e85np77FGc2j2Og=; b=lKwtyK3LHvPbGuZ5gO2dFqSx3FVmSA3+UiU4qNpfKyLsdS77OrGXzcH5/Tf+cPV7Of lSSfjD2joW9Id/QtOjlQMvFEMrCKuiL4KE9Z9Q13/OFjaFSEQEbclJzZ3YFB89hNEa7W udzJM2daCneUwMoMb1f1+X//b3YXnOI4rzAi3J8kjldYrNBEjIhzHvgilXdXZ3yFD4wX jV92IL3P3Dj9SAge1bXWpRKrim0kDLhQrMvJ3/NLNVufEMdMuC84jcv/nLfxdoPl0tmn vLhyuJcPNcQXhSV8cRKclty8GvISXuY2EMyGo7d8RZgOeJEqVTpXhOnO1r9A5iqFLzqj TYrg== 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=LkssNv9xnqcTUQeW4rk5Aqaqz7M0e85np77FGc2j2Og=; b=o3mDTX8yWvPjTulDsINtDIMg1Enu0HjON1jmO8bpQviRi9GJZqK9vsNuzcma8VHZNI xVA7nOi491aEP0rcvDPYSHBK6DSF/FxU6HIT7/c0/4reClvJvLpMDG8EekCJOreblE7D Truqr+csbp7q8ChJZbuSrUuEe99p8p3/KccOBwzgukpsYw9qBNLUgwRpB3y3tPaaVJ/O 9JnDUhMDhypWRbgIpqTCDCNfKNTpHhpjLI5lNdJSvx1PxSZ5SgaFm1qWLUPfi01BwMHk MpQJh682mFQSUs46q5ZiZc9u7tBGWw2qOAKebQdUIvfZGDM07D/XI1yXBR6HxWtHRH81 z0bA== X-Gm-Message-State: APjAAAUmp1rA3gpR9Q4yQnIkTOuLzDOLj+PKSZdxeMdDHFVwg41qP7vF ihPQvITHL+Qb6JnLmKs89RU5bv6+szo= X-Google-Smtp-Source: APXvYqxX+IBGqxdzlhJQ/pgZQaqQCCBZodhkOhhvQDd4JZ7+cFq4k8qS4IF5R/U8Rwdx9yb93TYpZg== X-Received: by 2002:aa7:951c:: with SMTP id b28mr3997505pfp.97.1576075157829; Wed, 11 Dec 2019 06:39:17 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39:16 -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 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 v3 05/12] thermal: int340x: switch to use helpers Date: Wed, 11 Dec 2019 23:38:12 +0900 Message-Id: <1576075099-3441-6-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 --- * v3 - rename new header name from to 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 Wed Dec 11 14:38: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: 11285169 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 DF139112B for ; Wed, 11 Dec 2019 14:39:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD13A20836 for ; Wed, 11 Dec 2019 14:39:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iPTNp0Ed" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730097AbfLKOjY (ORCPT ); Wed, 11 Dec 2019 09:39:24 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:33631 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729686AbfLKOjX (ORCPT ); Wed, 11 Dec 2019 09:39:23 -0500 Received: by mail-pj1-f65.google.com with SMTP id r67so9022996pjb.0; Wed, 11 Dec 2019 06:39: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=30ClsBWVMQFbgwDIq9w8WCwwNMvj/q4ymjJp8oUF1J0=; b=iPTNp0EdadO4y2qivxFKBUpzEsaPwhGKdyaPxOlJenJBVxrjZDK77cuy1xm8y3/vwo XAU33lFCH4T/3DEpnMyPFn6xvlTZdCX8Y/G3vVNDBizKWUagtzlppvbFHBKxI8/Qzgli 056XNDvIhN4ii1itJlKwXt80wjd295T2EeFmuKxHDcesF1kjQH1DUsdulYHgs8J8gmp8 InGX15hisePqvBdSawpSkTi5rAQXLdhUlmEHERSnfwz5Z3FiZ+nZFa1WP1exJSLOjypP wqQIAcTsATodjUx32eYVG4H6IPzbyD7WHdjJLcss5z7w5GHfOtNx7Sjbyizgieki1RVz OCDw== 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=30ClsBWVMQFbgwDIq9w8WCwwNMvj/q4ymjJp8oUF1J0=; b=XEnL7GaPaeT21ukAOLDLbrJCEIffd1/pPBntbnnXFAx4vEYN2D/vWSwyFzBOHJ4WjQ yumsvPYHa4/Ts8WVryCkexOC7coPFEj1nn27uPMIgXV1JJtlLTX0yt/gp/ckkHBMTZdv 2OX+34wjKinNvqzUHQhv3BivkieG+B5hVM6Vd2XjYCvJI9/hsNOKQDyTizrwH+BTceDu a8EfZAWzNKywDBaSAQbWhmNAxUsu+4OKJXcgWJ411txVWq9YuAOUQupG5W0eTEIkQhyG TCFR00OxBaB0ZRE1XxmWCYahGzsTzR61u1ReDF44ZAKQsbQLv5CK4xJeyxBLqaWqPRHM Z44A== X-Gm-Message-State: APjAAAUr1L3avFoJiqi83vC+lHapLRatgs+dzI2/CzW/13krHTeRuJoc p7rOo/LKCBJtJ5sIMteceXDfmWQatkc= X-Google-Smtp-Source: APXvYqyPc4UFSiMgsD4yZYd76DuxU8U2qOWD+TGrVH0/E0V5787xpYx4yK1YXlYV7OTuxTKh7/rsHg== X-Received: by 2002:a17:902:8507:: with SMTP id bj7mr3489251plb.69.1576075163124; Wed, 11 Dec 2019 06:39:23 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39:22 -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 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 v3 06/12] thermal: intel_pch: switch to use helpers Date: Wed, 11 Dec 2019 23:38:13 +0900 Message-Id: <1576075099-3441-7-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 --- * v3 - rename new header name from to 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 Wed Dec 11 14:38: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: 11285173 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 7E2C9188B for ; Wed, 11 Dec 2019 14:39:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 202AA20836 for ; Wed, 11 Dec 2019 14:39:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EoL2MEKy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730112AbfLKOja (ORCPT ); Wed, 11 Dec 2019 09:39:30 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37527 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729686AbfLKOj3 (ORCPT ); Wed, 11 Dec 2019 09:39:29 -0500 Received: by mail-pf1-f193.google.com with SMTP id p14so1916118pfn.4; Wed, 11 Dec 2019 06:39:29 -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=G8HIqSOZSM7ZlLEzj0GZfcJL15LCKkAAkMEEiYP0HJ8=; b=EoL2MEKylC7MRqf5P3y3JFnFsr/PlSKtVjomV2dX1/7ZSkV2+sxGzrxZgEuNx091fk BKawpY7SEcgPihrYuDNS8X4ilRtwzzhvRNz/AIAys5SXt6tk57NEE4iu7lnfD69q1MaW lM+ROlYqmBV7vWcGEdg+EBFfrBzoG9BnscbToBGTv0UUqVM6tRuIYW9y0G9yUItH0IDI 78hDdjc9KWP8qvsmAJWrfJQaJT2vvOr/fukTIe3fuetky7ZWaSF0Tm9w6MNghRv5gt0H CFFT98TRV57WRqjS6Teyv1JeMDWtMguVNnparclOk16OHVcOW1sbOMoEhNquGUAmPP7k A6+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=G8HIqSOZSM7ZlLEzj0GZfcJL15LCKkAAkMEEiYP0HJ8=; b=h+fjDRRZOS8kdz1D0mifxJx+LorQGbU8YcWYRxv3lb6uRH2ibrzkZ9UdxzFaJJEJpM odAqH6ZPeK1LhKEVEzzoINCW2v5h1hDbNGdxvbjzQxIIZdn60QhzONdDkDcsRgzkxK8w 3kxbvYgB4c9Ymo3hUfXnhizKFvHmI7l27bPAfJCMy6/60J0W97I8tWfp+w4aRbgdC/NL eOQ41eL7CT/WEoixu0Vf76l5nMAZ0aXvWACRd6Imx3L/FCFK5Gfp3xfrk4OrtZC8r3We T49oy7Urkza7szc6d8WX4EIIaOaNZUxkriqIllXRxKq1cgbP6LIL1FIcAJFmZeiXW+YG bQFQ== X-Gm-Message-State: APjAAAVvLrtd+P8p61wQmLpwAZpw63Xe517N4UpJH88SYqjrYqqL8vIJ yRp+oVmzGD2yav0DXJNfDRM= X-Google-Smtp-Source: APXvYqzLIbq4qGAJSSgC9xZ/3+iluFA3br6Tz1ZQ92AYrpH9YCceKsABt6khTNhi4u+9CunGqaDYTg== X-Received: by 2002:a63:6507:: with SMTP id z7mr4631816pgb.322.1576075169052; Wed, 11 Dec 2019 06:39:29 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39:28 -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 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 v3 07/12] nvme: hwmon: switch to use helpers Date: Wed, 11 Dec 2019 23:38:14 +0900 Message-Id: <1576075099-3441-8-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 Signed-off-by: Akinobu Mita --- * v3 - rename new header name from to 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 Wed Dec 11 14:38: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: 11285193 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 F299F188B for ; Wed, 11 Dec 2019 14:39:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C791422B48 for ; Wed, 11 Dec 2019 14:39:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cTFNRC0S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730140AbfLKOjf (ORCPT ); Wed, 11 Dec 2019 09:39:35 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:39575 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730139AbfLKOjf (ORCPT ); Wed, 11 Dec 2019 09:39:35 -0500 Received: by mail-pj1-f67.google.com with SMTP id v93so9017878pjb.6; Wed, 11 Dec 2019 06:39: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=XbYbcASd2+KhdijffyhFolrYSToXlnSKrqANevTKCr0=; b=cTFNRC0SDsTy6TOB5GAhoEjp+6Nx4jpqI/v0BumN/4YTcJP+nvYX069JP+MbzEagHr H0ef6hXStk3Qg5lCvjuLedPwtDGDXfRoB85H+g1U06dX5OfXuUM2jxLvl6Cjs9tJ1WL+ S0yPKhGp9Gb3thch8kkmllLkaCqodmqe2Sx4pEr+RL5dqATYLc3rAUoO5MLajiv7DCO3 JNeUQRpuduNY8cUkoj6eofMk5/c454aa+Ha1eoWmL458SQ2qJ+ii3tkN3pBKHkkAAY6b u0wOCJNda/YXvxTj1qSg10BkhZrqKRHmv4Z2Tw0e/Zvq2XZkBq2HeYHcgVAzWVb+uVUw R2hA== 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=XbYbcASd2+KhdijffyhFolrYSToXlnSKrqANevTKCr0=; b=F2gS3f3Q8nwmFgGR5vallu8cUdUccFy6xiFautOvd0/45t60Ziy9nKbJNR78DM1IBt XkXq2BaLGYm+E/9jbbDERIg2vhWSdVrE+QMpODlZIU8Vl9rLVv1jhEVavyXjdddA1h1w srcqaiVaXp3TpoVGqzRvFdZ5eVC6s2z4l3jmWVCQ7IrWEcRUK5ZDENn39rQRq4e8IzE9 2sRUCl2zMboOy68L3obFchQnebk/RSOLKYsx5TgGjv7J291VvZ3ABpJzRdO+dTy7bKSb EftGA0N83HKK8ar9qiv6k9xrpqI4nYgh5oCP9BqDnXZNYTD5C86iDgHhnaq+dh9Bud4Y QhoQ== X-Gm-Message-State: APjAAAXWgom63XuX0etys8LKG5SfbNptbCYH0JeQnKVY9U1dfQvHIICW l2GEdKWBS7g9AT4vHE1f5/o= X-Google-Smtp-Source: APXvYqw0ZMYCDczwvXAKv4QaKyfYTxS7oOjP0rRHfMNhKXXkmJLTUVSslEFXuouLo4HrbdvcoGIzRQ== X-Received: by 2002:a17:90a:970b:: with SMTP id x11mr3797597pjo.35.1576075174618; Wed, 11 Dec 2019 06:39:34 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39: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 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 v3 08/12] thermal: remove kelvin to/from Celsius conversion helpers from Date: Wed, 11 Dec 2019 23:38:15 +0900 Message-Id: <1576075099-3441-9-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 Signed-off-by: Akinobu Mita --- * No changes from v2 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 Wed Dec 11 14:38:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11285191 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 BDC91112B for ; Wed, 11 Dec 2019 14:39:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CA7D22B48 for ; Wed, 11 Dec 2019 14:39:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TtEhDw9m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730162AbfLKOjk (ORCPT ); Wed, 11 Dec 2019 09:39:40 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:34941 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729654AbfLKOjj (ORCPT ); Wed, 11 Dec 2019 09:39:39 -0500 Received: by mail-pj1-f66.google.com with SMTP id w23so9029136pjd.2; Wed, 11 Dec 2019 06:39: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=K3UxPRzFZME10fkLXtCYqjJd0IRSW438IJ8inomPhFc=; b=TtEhDw9mXoygh60t0P8tM7vAJ0ws8yOzln/xfqEuvUZQ+gxs9TGtjoWk4ijx+7Lhgj m/RjMwumNojsGy04ahZTfQNCqOSGq61vGvkvIu6125xhrZqtF4UylwsJXCgFrAe2H8df FxtqiaZyqXH6Pfs4MpJadnetPyQHFsOXN2WR9XEJnxurlElV4LEZ/QiIMDuEjbKxq8bG Flftq8QdH5Afm2rmNfaA0N9ZNxJCmfCMXEmJ0kzufwBpTx8PtSQrTRzrVLUIqZszZh5e fuhvH5Y8abqa1VpwIVVuvvijRYmXugdPHrEsG6aKfZ8rC5OWbcD4s8FVIZ3GyErGjt9B a7YA== 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=K3UxPRzFZME10fkLXtCYqjJd0IRSW438IJ8inomPhFc=; b=G5YuALKAJX76zaXrHJgeJl1gALMOneNl+zZNroWTbSsXFwG79FU1qd1hhuzHsKRBsb uqKIycQd27tln3kuoMnxuMlmqilkDhF0Mb/7gqtSzfGHwT3ZDlhyO1kvo7csZZTVLXK0 ZRncOpA3YKrnXfUhj1xAbR+e7BFKx0C+I+wXzAq3QSiSG8gEbhe/yKoYVwDJ878ezLj6 VfK/VisPxVn7spCp0qS6FHgdzfQu2wriMqMrvxOH+pt9p4b8H/XwmJxYSKZGdoSUou/V n2icsD2iv86npnFHKguyBzTaganNzWeWfgkOumx9iFBbSFotc7F8lu0vQLk+mjRGITXw vkHw== X-Gm-Message-State: APjAAAV/D2I8LzTxHzw7GHIpTsMArz87zDn5dGC9L/YMvyx8/ZPWYsaY MT+RKjO2827fZfKIZyoqz7E= X-Google-Smtp-Source: APXvYqwzmKMUAxLD4W5Ax2MVMn7w223/0E+Cw8F33tmd3OWRq8B/HavfEb1OCpln/HaQH8iOvd8Onw== X-Received: by 2002:a17:90a:cf07:: with SMTP id h7mr3878015pju.66.1576075178437; Wed, 11 Dec 2019 06:39:38 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39: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 Cc: Akinobu Mita , Kalle Valo , Stanislaw Gruszka Subject: [PATCH v3 09/12] wireless: iwlegacy: use helpers Date: Wed, 11 Dec 2019 23:38:16 +0900 Message-Id: <1576075099-3441-10-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This switches the iwlegacy driver to use celsius_to_kelvin() and kelvin_to_celsius() in . Cc: Kalle Valo Cc: Stanislaw Gruszka Signed-off-by: Akinobu Mita Acked-by: Kalle Valo --- * New patch from v3 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 Wed Dec 11 14:38:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11285215 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 31B29138C for ; Wed, 11 Dec 2019 14:40:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0FD5722B48 for ; Wed, 11 Dec 2019 14:40:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RyG5UBz1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730178AbfLKOjp (ORCPT ); Wed, 11 Dec 2019 09:39:45 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46248 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729654AbfLKOjn (ORCPT ); Wed, 11 Dec 2019 09:39:43 -0500 Received: by mail-pl1-f193.google.com with SMTP id k20so1484478pll.13; Wed, 11 Dec 2019 06:39:43 -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=IcdhyyyraLVUQAQ3HHOSQ6YNvDlkdwwrUN22Ki1UdWw=; b=RyG5UBz1cZHPGUqtMFB5YXFkkEdKKMiMwMxa8vnkNtXJSn70Zzja6yk3iTI/el/Ji7 7mdXDBMNf7s4VWETE4BQOzat3pRp4cFbQRhjZmJDg1kzg1dpKHj7axOgJOv1it0xkTtv 64qDc3ri9DQ3B9rGjNLH/xQ8bXwKOeK2yQtzcOL6fP1uiZBFCyaE/HbYfL64wN2sj/FP PXfUm8e3jVXPvOw7YquFCs42UtzcocoIDPdohQ/cW8UE9pEGu+OHFwa8hg2C+DL9l5p0 qGq7WkaPaYNYdqhKGd+Ea8oh+Bst+ULZgi+wmIadHtyeeZnEDTEaNlXWHo4VcdmjIp+3 ZtzQ== 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=IcdhyyyraLVUQAQ3HHOSQ6YNvDlkdwwrUN22Ki1UdWw=; b=nDKmJyxZYaJzue73y3YCBpUlVNZuvu4fIcWFJ7zdnnC0OeudT9EolMxUA65VfwDzPn DvVlxeSAT9xX13e52zPgoxFF8R+zrGhVf1gX3VawSSXUz9faIw5wEP223tqburaiMf8x F8NHB4893NU0jB05XQh9VbnGvGyxKw2G3aL1Dzcd6NSRyubzceSciKcltlcuPlCv1oiR wejQh+lAzjj91oTdL/E7mDwHEdJPUu+YQu1lLyaYOON5Ye9rN4TFEv7Xfbp2dFkuDqd8 XRuLFSJozh0m9t5zI2UBpNptQPqitZMjwZaaF7B3TqdLL9LSJzBvBncCA9IN69OniEaM U6HA== X-Gm-Message-State: APjAAAX9dRVCfOltzL7NZLksvf+63UgPgLkk56gJw0ilVthCQPF/3vCA jd3MQDSl2AG+PHBL4n+dQnU= X-Google-Smtp-Source: APXvYqxp6M46sXtPZT2HvGlWuv1Os2BTC76wIST3HLZF+6k8rsAvHXrRSJFlwIPCfdqDACr2l48xrw== X-Received: by 2002:a17:902:968b:: with SMTP id n11mr3347664plp.120.1576075182587; Wed, 11 Dec 2019 06:39:42 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39: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 Cc: Akinobu Mita , Kalle Valo , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless Subject: [PATCH v3 10/12] wireless: iwlwifi: use helpers Date: Wed, 11 Dec 2019 23:38:17 +0900 Message-Id: <1576075099-3441-11-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 Signed-off-by: Akinobu Mita Acked-by: Luca Coelho --- * New patch from v3 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 Wed Dec 11 14:38:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11285197 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 7E733112B for ; Wed, 11 Dec 2019 14:39:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D4FA22B48 for ; Wed, 11 Dec 2019 14:39:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GfB0dMl6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730199AbfLKOjr (ORCPT ); Wed, 11 Dec 2019 09:39:47 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37583 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730192AbfLKOjq (ORCPT ); Wed, 11 Dec 2019 09:39:46 -0500 Received: by mail-pg1-f195.google.com with SMTP id q127so10877412pga.4; Wed, 11 Dec 2019 06:39: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=GhXVAnhaL3dF2Pk0jAZjmHL842tdRou+nNjmrun5mDI=; b=GfB0dMl66LMji7iSDluDDgU95hFyrbLyBDa8g9R6tZQrYvzznr7sbD0EI+zx9PZa2a UPcDzuUIfU+mXjTqpj1nB/cZRBTziPKDINSxpV160A8qKLUskV7icNyoDpzGtFJ/W4WG 2iBDG2uBtjRDggXzegIdkZ21vawseCOf6qaPFh0AlPaij/VqPMZ1PrqwB4igUsER3fw9 MGwC4Bw2o1XiM61vnkvQn/3OuFljldg0RPznpVhmrQCbj2V20rgrMUe4mQ5FtASiBaVH t8gKx1S12ypjJZhGV6bC07NGCq71O6eQQkdVJ3Dpwjy0E0oVLRZkOjg1ya4ol/N4tXPC gHUA== 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=GhXVAnhaL3dF2Pk0jAZjmHL842tdRou+nNjmrun5mDI=; b=OYgwxc51CziZLzIjPtIP3tiFKoA+eSppIzupd9iGkYcQsYKTMSYNEBXllHqMJN1wgD U0LUmk2RSEHZnoPy0kGzF9wTQ2TM6R72ax3YqduEO4/10uzyh+ZOzEl9wY7cWUuZuT6A dGmUQMbNByDE6DllEyauP2d+aSY4sct18JTwe0ynYNkfg1cmWZ1+XUAo2sMqVZfp9f5D F7yqPD/RVwVMJr3gATwbJY8yT4zEoECAPgLhjrn/ikxfwM65YfWQci6xDICQZhkrZykz 6MzfiWD7U/2RnXlNLRr9hP0uO/29vRY0+EYok5PFz+X2sl2hPoVEzWnP2h/hQeBRuu+N pgUQ== X-Gm-Message-State: APjAAAVoAA2Ph83XsPeZ5PMuwkoVbTX2VFdpbbLIw8kPFct03rEYLcpn 2UCnhjjii+YOW/v99i4K2V8= X-Google-Smtp-Source: APXvYqwSkDQsttnam5DXc1gmHwbz0oD5Nrbbl83FHdZwnnYrsoV2z/G3N/ntf8aYY+yXSPtKkfWXnQ== X-Received: by 2002:a62:1883:: with SMTP id 125mr4054521pfy.166.1576075186342; Wed, 11 Dec 2019 06:39:46 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39: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 Cc: Akinobu Mita , Zhang Rui , Daniel Lezcano , Amit Kucheria Subject: [PATCH v3 11/12] thermal: armada: remove unused TO_MCELSIUS macro Date: Wed, 11 Dec 2019 23:38:18 +0900 Message-Id: <1576075099-3441-12-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This removes unused TO_MCELSIUS() macro. Cc: Zhang Rui Cc: Daniel Lezcano Cc: Amit Kucheria Signed-off-by: Akinobu Mita --- * New patch from v3 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 Wed Dec 11 14:38:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11285203 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 37B00138C for ; Wed, 11 Dec 2019 14:39:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 146502173E for ; Wed, 11 Dec 2019 14:39:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jH82xtrY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730192AbfLKOjv (ORCPT ); Wed, 11 Dec 2019 09:39:51 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45798 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729991AbfLKOjv (ORCPT ); Wed, 11 Dec 2019 09:39:51 -0500 Received: by mail-pg1-f196.google.com with SMTP id b9so10465357pgk.12; Wed, 11 Dec 2019 06:39: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=3VEcdWQti206JWCDW3qI0BTxZ1lYQXCJ5XH3cd981NQ=; b=jH82xtrYMxhgUcHQRPKqjw7ZKlvPgF+xBtcnxGsL7fh4pjdfao/pZu4Q6upvCNHIh1 a+G4WLTV+T+1yx2XyKqc1y8xCv1StbbjpoaBkIg8NeB3ZaZgozkM7fploPXJ9z4wTfQ+ Ee3DwRsSc0ZQHdjw5TCUYZzZjT/bppcgvXa+XIdYMuUnfrK1g7Ezy9pFVmVYZ5xkzhyz fcFVbP3jXuwNeaeDXX7CkGxikmhPQRcLVgS21AwByB3NK8Gi6kZ+6aaemxXGyHfeFQBX Jt2PbVWKRidv9CFTbWklTCKJjHPNRfVDQKtXDW3IQIf1C5PkhEmElEAQpjPQPl7rnVYf OMLA== 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=3VEcdWQti206JWCDW3qI0BTxZ1lYQXCJ5XH3cd981NQ=; b=jxfQBdxD65GdbDlQPpTYmT5nPdbaT9leMn5bX8Ou7FwB727x1WduhZuu8W0YzPbr+a Q7yz5E2xPtzzb0zHKuGklOVOb+BGsDn6Q7NPZY1By3xIXEk8P+DuixcDPcgFP1EW+n8S ARi+T99RAP3BYWirbZrjewXMRdvjNlowhjh2F9TSqcbUy9NsGrYnFH4bOXLU5ODoYra+ k5uqLeqjV19HSI1XFUEQx8wL6kBhDSR1u2aPn+7BA5BrOdZUj8alvZ2+xkPeokXUMpkv ZqF+4hhuanH0y0Q68yM80+8DbxgU5go/zDGJ/KorTY05Gj5UzEQNl2HwO+UTKiI+JAN5 W6Nw== X-Gm-Message-State: APjAAAXPB2U3z38ghY8H5GjgbiqxOCwKLniDFE2e08h6F2vTnH3Y5b5G aaNfdmTV71MbwQ3ihvlj+HQ= X-Google-Smtp-Source: APXvYqwgEvnp2ndBwiIE94Wh4cRVzfCw2QFRf/3PG5eerLtk1/YgeA2uxE8wypG49aWWT3GbeFUcFg== X-Received: by 2002:a63:fd43:: with SMTP id m3mr4566724pgj.164.1576075190151; Wed, 11 Dec 2019 06:39:50 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id q11sm3444239pff.111.2019.12.11.06.39.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Dec 2019 06:39: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 Cc: Akinobu Mita , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Subject: [PATCH v3 12/12] iio: adc: qcom-vadc-common: use helpers Date: Wed, 11 Dec 2019 23:38:19 +0900 Message-Id: <1576075099-3441-13-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> References: <1576075099-3441-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 Signed-off-by: Akinobu Mita --- * New patch from v3 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