From: Christoph Hellwig <hch@lst.de>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org,
Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@fb.com>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH] nvme: hwmon: provide temperature min and max values for each sensor
Date: Mon, 11 Nov 2019 17:53:06 +0100 [thread overview]
Message-ID: <20191111165306.GA19814@lst.de> (raw)
In-Reply-To: <1573395466-19526-1-git-send-email-akinobu.mita@gmail.com>
On Sun, Nov 10, 2019 at 11:17:46PM +0900, Akinobu Mita wrote:
> +static int nvme_get_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under,
> + long *temp)
> +{
> + unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT;
> + int status;
> + int ret;
> +
> + if (under)
> + threshold |= NVME_TEMP_THRESH_TYPE_UNDER;
> +
> + ret = nvme_get_features(ctrl, NVME_FEAT_TEMP_THRESH, threshold, NULL, 0,
> + &status);
> + if (!ret)
> + *temp = ((status & NVME_TEMP_THRESH_MASK) - 273) * 1000;
> +
> + return ret <= 0 ? ret : -EIO;
This looks a little obsfucated. aI'd prefer something like:
if (ret > 0)
return -EIO;
if (ret < 0)
return ret;
*temp = ((status & NVME_TEMP_THRESH_MASK) - 273) * 1000;
return 0;
> + return ret <= 0 ? ret : -EIO;
Similarly here, something like:
if (ret > 0)
return -EIO;
return ret;
> + err = nvme_get_temp_thresh(data->ctrl, channel, false, val);
> + if (err)
> + *val = (data->ctrl->wctemp - 273) * 1000;
Can we have a helper for this (x - 273) * 1000 conversion? It is
repeated quite a bit over the code in this file.
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org, Jens Axboe <axboe@fb.com>,
Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>,
Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH] nvme: hwmon: provide temperature min and max values for each sensor
Date: Mon, 11 Nov 2019 17:53:06 +0100 [thread overview]
Message-ID: <20191111165306.GA19814@lst.de> (raw)
In-Reply-To: <1573395466-19526-1-git-send-email-akinobu.mita@gmail.com>
On Sun, Nov 10, 2019 at 11:17:46PM +0900, Akinobu Mita wrote:
> +static int nvme_get_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under,
> + long *temp)
> +{
> + unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT;
> + int status;
> + int ret;
> +
> + if (under)
> + threshold |= NVME_TEMP_THRESH_TYPE_UNDER;
> +
> + ret = nvme_get_features(ctrl, NVME_FEAT_TEMP_THRESH, threshold, NULL, 0,
> + &status);
> + if (!ret)
> + *temp = ((status & NVME_TEMP_THRESH_MASK) - 273) * 1000;
> +
> + return ret <= 0 ? ret : -EIO;
This looks a little obsfucated. aI'd prefer something like:
if (ret > 0)
return -EIO;
if (ret < 0)
return ret;
*temp = ((status & NVME_TEMP_THRESH_MASK) - 273) * 1000;
return 0;
> + return ret <= 0 ? ret : -EIO;
Similarly here, something like:
if (ret > 0)
return -EIO;
return ret;
> + err = nvme_get_temp_thresh(data->ctrl, channel, false, val);
> + if (err)
> + *val = (data->ctrl->wctemp - 273) * 1000;
Can we have a helper for this (x - 273) * 1000 conversion? It is
repeated quite a bit over the code in this file.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2019-11-11 16:53 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-10 14:17 [PATCH] nvme: hwmon: provide temperature min and max values for each sensor Akinobu Mita
2019-11-10 14:17 ` Akinobu Mita
2019-11-10 16:30 ` Guenter Roeck
2019-11-10 16:30 ` Guenter Roeck
2019-11-11 15:56 ` Akinobu Mita
2019-11-11 15:56 ` Akinobu Mita
2019-11-11 17:35 ` Guenter Roeck
2019-11-11 17:35 ` Guenter Roeck
2019-11-12 14:40 ` Akinobu Mita
2019-11-12 14:40 ` Akinobu Mita
2019-11-12 15:04 ` Guenter Roeck
2019-11-12 15:04 ` Guenter Roeck
2019-11-12 15:06 ` Christoph Hellwig
2019-11-12 15:06 ` Christoph Hellwig
2019-11-12 16:35 ` Guenter Roeck
2019-11-12 16:35 ` Guenter Roeck
2019-11-11 16:53 ` Christoph Hellwig [this message]
2019-11-11 16:53 ` Christoph Hellwig
2019-11-12 14:19 ` Akinobu Mita
2019-11-12 14:19 ` Akinobu Mita
2019-11-12 14:21 ` Christoph Hellwig
2019-11-12 14:21 ` Christoph Hellwig
2019-11-12 15:00 ` Akinobu Mita
2019-11-12 15:00 ` Akinobu Mita
2019-11-12 15:08 ` Christoph Hellwig
2019-11-12 15:08 ` Christoph Hellwig
2019-11-12 16:38 ` Guenter Roeck
2019-11-12 16:38 ` Guenter Roeck
2019-11-13 12:58 ` Akinobu Mita
2019-11-13 12:58 ` Akinobu Mita
2019-11-13 14:11 ` Guenter Roeck
2019-11-13 14:11 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191111165306.GA19814@lst.de \
--to=hch@lst.de \
--cc=akinobu.mita@gmail.com \
--cc=axboe@fb.com \
--cc=jdelvare@suse.com \
--cc=kbusch@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux@roeck-us.net \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.