From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>,
Guenter Roeck <linux@roeck-us.net>,
Serge Semin <fancer.lancer@gmail.com>,
Sasha Levin <sashal@kernel.org>,
kbusch@kernel.org, axboe@fb.com, sagi@grimberg.me,
linux-nvme@lists.infradead.org
Subject: [PATCH AUTOSEL 5.15 18/19] nvme-hwmon: consistently ignore errors from nvme_hwmon_init
Date: Tue, 1 Nov 2022 07:29:18 -0400 [thread overview]
Message-ID: <20221101112919.799868-18-sashal@kernel.org> (raw)
In-Reply-To: <20221101112919.799868-1-sashal@kernel.org>
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 6b8cf94005187952f794c0c4ed3920a1e8accfa3 ]
An NVMe controller works perfectly fine even when the hwmon
initialization fails. Stop returning errors that do not come from a
controller reset from nvme_hwmon_init to handle this case consistently.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/nvme/host/core.c | 6 +++++-
drivers/nvme/host/hwmon.c | 13 ++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3527a0667568..92fe67bd2457 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3088,8 +3088,12 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
return ret;
if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) {
+ /*
+ * Do not return errors unless we are in a controller reset,
+ * the controller works perfectly fine without hwmon.
+ */
ret = nvme_hwmon_init(ctrl);
- if (ret < 0)
+ if (ret == -EINTR)
return ret;
}
diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c
index 0a586d712920..23918bb7bdca 100644
--- a/drivers/nvme/host/hwmon.c
+++ b/drivers/nvme/host/hwmon.c
@@ -230,7 +230,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
- return 0;
+ return -ENOMEM;
data->ctrl = ctrl;
mutex_init(&data->read_lock);
@@ -238,8 +238,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
err = nvme_hwmon_get_smart_log(data);
if (err) {
dev_warn(dev, "Failed to read smart log (error %d)\n", err);
- kfree(data);
- return err;
+ goto err_free_data;
}
hwmon = hwmon_device_register_with_info(dev, "nvme",
@@ -247,11 +246,15 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
NULL);
if (IS_ERR(hwmon)) {
dev_warn(dev, "Failed to instantiate hwmon device\n");
- kfree(data);
- return PTR_ERR(hwmon);
+ err = PTR_ERR(hwmon);
+ goto err_free_data;
}
ctrl->hwmon_device = hwmon;
return 0;
+
+err_free_data:
+ kfree(data);
+ return err;
}
void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
--
2.35.1
next prev parent reply other threads:[~2022-11-01 11:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 11:29 [PATCH AUTOSEL 5.15 01/19] media: rkisp1: Don't pass the quantization to rkisp1_csm_config() Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 02/19] media: rkisp1: Initialize color space on resizer sink and source pads Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 03/19] media: rkisp1: Use correct macro for gradient registers Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 04/19] media: rkisp1: Zero v4l2_subdev_format fields in when validating links Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 05/19] media: s5p_cec: limit msg.len to CEC_MAX_MSG_SIZE Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 06/19] media: cros-ec-cec: " Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 07/19] media: dvb-frontends/drxk: initialize err to 0 Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 08/19] media: meson: vdec: fix possible refcount leak in vdec_probe() Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 09/19] media: v4l: subdev: Fail graciously when getting try data for NULL state Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 10/19] media: atomisp: Fix VIDIOC_TRY_FMT Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 11/19] media: atomisp: Ensure that USERPTR pointers are page aligned Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 12/19] media: atomisp: Fix v4l2_fh resource leak on open errors Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 13/19] ACPI: APEI: Fix integer overflow in ghes_estatus_pool_init() Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 14/19] hwrng: bcm2835 - use hwrng_msleep() instead of cpu_relax() Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 15/19] scsi: core: Restrict legal sdev_state transitions via sysfs Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 16/19] HID: saitek: add madcatz variant of MMO7 mouse device ID Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 17/19] drm/amdgpu: set vm_update_mode=0 as default for Sienna Cichlid in SRIOV case Sasha Levin
2022-11-01 11:29 ` Sasha Levin [this message]
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 19/19] i2c: xiic: Add platform module alias Sasha Levin
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=20221101112919.799868-18-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=axboe@fb.com \
--cc=fancer.lancer@gmail.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux@roeck-us.net \
--cc=sagi@grimberg.me \
--cc=stable@vger.kernel.org \
/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