summaryrefslogtreecommitdiffstats
path: root/drivers/spmi
diff options
context:
space:
mode:
authorFei Shao <fshao@chromium.org>2023-12-06 15:17:30 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-15 17:27:04 +0100
commit3ae3cf418a01203c33113e19cc1029ac434c96b5 (patch)
tree8143877932a4272227c564e9932831f2f289fac9 /drivers/spmi
parent490d88ef548d463c85bd75ef5300b25c92d71e5a (diff)
downloadlinux-3ae3cf418a01203c33113e19cc1029ac434c96b5.tar.gz
linux-3ae3cf418a01203c33113e19cc1029ac434c96b5.tar.bz2
linux-3ae3cf418a01203c33113e19cc1029ac434c96b5.zip
spmi: Return meaningful errors in spmi_controller_alloc()
spmi_controller_alloc() currently returns NULL to all types of errors, which can be improved. Use appropriate error code in returns and pass the errors from used functions where possible. Signed-off-by: Fei Shao <fshao@chromium.org> Link: https://lore.kernel.org/r/20230824104101.4083400-6-fshao@chromium.org Signed-off-by: Stephen Boyd <sboyd@kernel.org> Link: https://lore.kernel.org/r/20231206231733.4031901-8-sboyd@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/spmi')
-rw-r--r--drivers/spmi/spmi-devres.c4
-rw-r--r--drivers/spmi/spmi.c6
2 files changed, 5 insertions, 5 deletions
diff --git a/drivers/spmi/spmi-devres.c b/drivers/spmi/spmi-devres.c
index 7683e6fdb18f..62c4b3f24d06 100644
--- a/drivers/spmi/spmi-devres.c
+++ b/drivers/spmi/spmi-devres.c
@@ -20,9 +20,9 @@ struct spmi_controller *devm_spmi_controller_alloc(struct device *parent, size_t
return ERR_PTR(-ENOMEM);
ctrl = spmi_controller_alloc(parent, size);
- if (!ctrl) {
+ if (IS_ERR(ctrl)) {
devres_free(ptr);
- return ERR_PTR(-ENOMEM);
+ return ctrl;
}
*ptr = ctrl;
diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
index 93cd4a34debc..3a60fd2e09e1 100644
--- a/drivers/spmi/spmi.c
+++ b/drivers/spmi/spmi.c
@@ -448,11 +448,11 @@ struct spmi_controller *spmi_controller_alloc(struct device *parent,
int id;
if (WARN_ON(!parent))
- return NULL;
+ return ERR_PTR(-EINVAL);
ctrl = kzalloc(sizeof(*ctrl) + size, GFP_KERNEL);
if (!ctrl)
- return NULL;
+ return ERR_PTR(-ENOMEM);
device_initialize(&ctrl->dev);
ctrl->dev.type = &spmi_ctrl_type;
@@ -466,7 +466,7 @@ struct spmi_controller *spmi_controller_alloc(struct device *parent,
dev_err(parent,
"unable to allocate SPMI controller identifier.\n");
spmi_controller_put(ctrl);
- return NULL;
+ return ERR_PTR(id);
}
ctrl->nr = id;