mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 13:03:25 +01:00
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>
This commit is contained in:
parent
490d88ef54
commit
3ae3cf418a
2 changed files with 5 additions and 5 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue