From: Minwoo Im <minwoo.im.dev@gmail.com>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org,
Keith Busch <keith.busch@intel.com>,
Sagi Grimberg <sagi@grimberg.me>, Jens Axboe <axboe@fb.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Eduardo Valentin <edubezval@gmail.com>,
Zhang Rui <rui.zhang@intel.com>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 1/2] nvme: add thermal zone infrastructure
Date: Fri, 17 May 2019 01:48:13 +0900 [thread overview]
Message-ID: <20190516164811.GF24001@minwooim-desktop> (raw)
In-Reply-To: <CAC5umyjxxWzCgyMOS=Q7BBBJY+n6xD1dg49fQ0W5okPh58Z1Kw@mail.gmail.com>
On 19-05-17 01:17:31, Akinobu Mita wrote:
> 2019年5月16日(木) 23:32 Minwoo Im <minwoo.im.dev@gmail.com>:
> >
> > > + if (sensor < 0 || sensor > 8)
> > > + return -EINVAL;
> >
> > Does we really need to check the negative case here ? Am I missing
> > something in this context ? If we really want to check it in this
> > level, can we check the invalid case in the following function?
>
> The negative case should never happen, so it can be just removed.
Cool.
>
> > > +static struct thermal_zone_device *
> > > +nvme_thermal_zone_register(struct nvme_ctrl *ctrl, int sensor)
> > > +{
> > > + struct thermal_zone_device *tzdev;
> > > + char type[THERMAL_NAME_LENGTH];
> > > + int ret;
> > > +
> > > + snprintf(type, sizeof(type), "nvme_temp%d", sensor);
> >
> > Before preparing "nvme_temp%d", maybe we can make it sure here. :)
> > What do you say?
>
> The nvme_thermal_zone_register() is only called from
> nvme_thermal_zones_register() which is defined just below, and it's very
> clear that the value of 'sensor' is from 0 to ARRAY_SIZE(ctrl->tzdev) - 1.
If so, we don't need to check the negative case above there.
>
> > > +int nvme_thermal_zones_register(struct nvme_ctrl *ctrl)
> > > +{
> > > + struct nvme_smart_log *log;
> > > + int ret;
> > > + int i;
> > > +
> > > + log = kzalloc(sizeof(*log), GFP_KERNEL);
> > > + if (!log)
> > > + return -ENOMEM;
> > > +
> > > + ret = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
> > > + log, sizeof(*log), 0);
> > > + if (ret) {
> > > + ret = ret > 0 ? -EINVAL : ret;
> > > + goto free_log;
> > > + }
> > > +
> > > + for (i = 0; i < ARRAY_SIZE(ctrl->tzdev); i++) {
> > > + struct thermal_zone_device *tzdev;
> > > +
> > > + if (i && !le16_to_cpu(log->temp_sensor[i - 1]))
> > > + continue;
> > > + if (ctrl->tzdev[i])
> > > + continue;
> > > +
> > > + tzdev = nvme_thermal_zone_register(ctrl, i);
> > > + if (!IS_ERR(tzdev))
> > > + ctrl->tzdev[i] = tzdev;
> >
> > Quenstion here. Are we okay not to print some warnings here in case
> > of error returned?
>
> I'm going to print warning in case of thermal_zone_device_register() error.
> For sysfs_create_link() error, the warning is printed by the function
> itself.
Sounds great.
Thanks,
next prev parent reply other threads:[~2019-05-16 16:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-15 15:17 [PATCH 0/2] nvme: add thermal zone devices Akinobu Mita
2019-05-15 15:17 ` [PATCH 1/2] nvme: add thermal zone infrastructure Akinobu Mita
2019-05-15 19:15 ` Keith Busch
2019-05-16 15:22 ` Akinobu Mita
2019-05-16 15:26 ` Keith Busch
2019-05-16 14:23 ` Minwoo Im
2019-05-16 14:32 ` Minwoo Im
2019-05-16 16:17 ` Akinobu Mita
2019-05-16 16:48 ` Minwoo Im [this message]
2019-05-16 14:35 ` Akinobu Mita
2019-05-16 21:22 ` Heitke, Kenneth
2019-05-17 15:01 ` Akinobu Mita
2019-05-17 15:09 ` Keith Busch
2019-05-17 15:36 ` Akinobu Mita
2019-05-16 21:25 ` Heitke, Kenneth
2019-05-17 15:03 ` Akinobu Mita
2019-05-16 23:44 ` Chaitanya Kulkarni
2019-05-17 15:35 ` Akinobu Mita
2019-05-15 15:17 ` [PATCH 2/2] nvme-pci: support thermal zone Akinobu Mita
2019-05-15 17:03 ` Keith Busch
2019-05-16 14:30 ` Akinobu Mita
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=20190516164811.GF24001@minwooim-desktop \
--to=minwoo.im.dev@gmail.com \
--cc=akinobu.mita@gmail.com \
--cc=axboe@fb.com \
--cc=daniel.lezcano@linaro.org \
--cc=edubezval@gmail.com \
--cc=hch@lst.de \
--cc=keith.busch@intel.com \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox