Commit 6b8cf940 authored by Christoph Hellwig's avatar Christoph Hellwig

nvme-hwmon: consistently ignore errors from nvme_hwmon_init

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarSerge Semin <fancer.lancer@gmail.com>
parent 6ff5ba97
...@@ -3262,8 +3262,12 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl) ...@@ -3262,8 +3262,12 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
return ret; return ret;
if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) { 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); ret = nvme_hwmon_init(ctrl);
if (ret < 0) if (ret == -EINTR)
return ret; return ret;
} }
......
...@@ -230,7 +230,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) ...@@ -230,7 +230,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
data = kzalloc(sizeof(*data), GFP_KERNEL); data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return 0; return -ENOMEM;
data->ctrl = ctrl; data->ctrl = ctrl;
mutex_init(&data->read_lock); mutex_init(&data->read_lock);
...@@ -238,8 +238,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) ...@@ -238,8 +238,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
err = nvme_hwmon_get_smart_log(data); err = nvme_hwmon_get_smart_log(data);
if (err) { if (err) {
dev_warn(dev, "Failed to read smart log (error %d)\n", err); dev_warn(dev, "Failed to read smart log (error %d)\n", err);
kfree(data); goto err_free_data;
return err;
} }
hwmon = hwmon_device_register_with_info(dev, "nvme", hwmon = hwmon_device_register_with_info(dev, "nvme",
...@@ -247,11 +246,15 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) ...@@ -247,11 +246,15 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
NULL); NULL);
if (IS_ERR(hwmon)) { if (IS_ERR(hwmon)) {
dev_warn(dev, "Failed to instantiate hwmon device\n"); dev_warn(dev, "Failed to instantiate hwmon device\n");
kfree(data); err = PTR_ERR(hwmon);
return PTR_ERR(hwmon); goto err_free_data;
} }
ctrl->hwmon_device = hwmon; ctrl->hwmon_device = hwmon;
return 0; return 0;
err_free_data:
kfree(data);
return err;
} }
void nvme_hwmon_exit(struct nvme_ctrl *ctrl) void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment