Commit 226f5db4 authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Bjorn Andersson

remoteproc: Get rid of tedious error path

Get rid of tedious error management by moving firmware and operation
allocation after calling device_initialize().  That way we take advantage
of the automatic call to rproc_type_release() to cleanup after ourselves
when put_device() is called.
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: default avatarSuman Anna <s-anna@ti.com>
Link: https://lore.kernel.org/r/20200420231601.16781-5-mathieu.poirier@linaro.orgSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent bf860aa1
...@@ -2084,12 +2084,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, ...@@ -2084,12 +2084,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
if (!rproc) if (!rproc)
return NULL; return NULL;
if (rproc_alloc_firmware(rproc, name, firmware))
goto free_rproc;
if (rproc_alloc_ops(rproc, ops))
goto free_firmware;
rproc->name = name; rproc->name = name;
rproc->priv = &rproc[1]; rproc->priv = &rproc[1];
rproc->auto_boot = true; rproc->auto_boot = true;
...@@ -2103,12 +2097,17 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, ...@@ -2103,12 +2097,17 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
rproc->dev.driver_data = rproc; rproc->dev.driver_data = rproc;
idr_init(&rproc->notifyids); idr_init(&rproc->notifyids);
if (rproc_alloc_firmware(rproc, name, firmware))
goto put_device;
if (rproc_alloc_ops(rproc, ops))
goto put_device;
/* Assign a unique device index and name */ /* Assign a unique device index and name */
rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL); rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
if (rproc->index < 0) { if (rproc->index < 0) {
dev_err(dev, "ida_simple_get failed: %d\n", rproc->index); dev_err(dev, "ida_simple_get failed: %d\n", rproc->index);
put_device(&rproc->dev); goto put_device;
return NULL;
} }
dev_set_name(&rproc->dev, "remoteproc%d", rproc->index); dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);
...@@ -2130,10 +2129,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, ...@@ -2130,10 +2129,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
return rproc; return rproc;
free_firmware: put_device:
kfree_const(rproc->firmware); put_device(&rproc->dev);
free_rproc:
kfree(rproc);
return NULL; return NULL;
} }
EXPORT_SYMBOL(rproc_alloc); EXPORT_SYMBOL(rproc_alloc);
......
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