From patchwork Sun Nov 24 14:08:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259203 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 7B9C4138C for ; Sun, 24 Nov 2019 14:09:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D3772075E for ; Sun, 24 Nov 2019 14:09:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Kz9sL7W0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbfKXOJp (ORCPT ); Sun, 24 Nov 2019 09:09:45 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34802 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJp (ORCPT ); Sun, 24 Nov 2019 09:09:45 -0500 Received: by mail-pl1-f194.google.com with SMTP id h13so5285254plr.1; Sun, 24 Nov 2019 06:09:44 -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=U1P9v0dgTe+tqKEsZgzPVW6SYco9pFADyOLzbri3i3o=; b=Kz9sL7W0b88wM7v84z7h9smblf5jN9O8ktOA2awNOw8mBpflPc+/KSgNWvJtEN9Ys9 F4f/oAx+sunNNg1ZCGyUoZ0cRahUe7xMkKoBBzzVL83qK04vDVVayv/fI572plwAZAVt QcWAv2kgKRwnNRcmwZej3IE7khJ3gNLjgY3taNMMwSC87PUZMYnLER+H6Ho5WDt2MAX+ Dv5wZ6nj2hqLceXsekhF2bJ5GKXM9524Y2jZeLp6KaQLn9GGF/dsvC9mg7zmdStAiEuH KoZX83cxCGrf+U3VhwMQ1D1ymU6lYc59Kv9iEwZzprN8ENNvO24N0mBR/rvarKRQTg2B 7IVg== 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=U1P9v0dgTe+tqKEsZgzPVW6SYco9pFADyOLzbri3i3o=; b=hQltJdN49mbplScsQ9MY2h+PWouhJp+mNIVSMoc6XmnJLOg9bGzEXY4Ccbc61xv/+M OCP+4tpZ4279Ul1BrIrICIDQaZ7RyaZK3ncu+6Q/nVUpNB0NK1L6PY4oM4K1nsjmh7BA nUZxjI8T6Inx60GPoQo0Ohk9X9CCINzsgTuX2B2+0kEhcHFHxuxz4KPIrNr6LfXJ1EmS zNuzld7DYVHzVficNmPJFDyU8Y5jpBUbhdA5jR4o0e3MwSl+qz+qrUkACqYqAvel8QRz EVEvTwHVcFJAqW1d+P8Oba5Id2WB8A++D59sTb6/mPZsn0i9TyTbTGBLbyPRNn9d2ytT B9dg== X-Gm-Message-State: APjAAAVmbLV27tMM04hW9RKo5jXxOZTUCBISrbol/M0lf3s5845Z7LLJ 9qc3k3r7Y+xPLn6yTzneMdY= X-Google-Smtp-Source: APXvYqxcF5r37Oiwyu5+ys9DsjUH1+Liw6DJ02nCZXdgEGvValZg9tQzOwytoD8owu4j8zGYh/CBlA== X-Received: by 2002:a17:902:7c8f:: with SMTP id y15mr23001423pll.341.1574604584222; Sun, 24 Nov 2019 06:09:44 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:43 -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 , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 7/8] nvme: hwmon: switch to use helpers Date: Sun, 24 Nov 2019 23:08:49 +0900 Message-Id: <1574604530-9024-8-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This switches the nvme driver to use kelvin_to_millicelsius() and millicelsius_to_kelvin() in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin 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: Christoph Hellwig --- 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);