Commit 4df4f8be authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Bjorn Andersson

remoteproc: Simplify default name allocation

In an effort to cleanup firmware name allocation, replace the
cumbersome mechanic used to allocate a default firmware name with
function kasprintf().
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Suggested-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20200415204858.2448-4-mathieu.poirier@linaro.orgSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 0c2ae2b1
......@@ -1982,24 +1982,19 @@ static const struct device_type rproc_type = {
static int rproc_alloc_firmware(struct rproc *rproc,
const char *name, const char *firmware)
{
char *p, *template = "rproc-%s-fw";
int name_len;
char *p;
if (!firmware) {
if (!firmware)
/*
* If the caller didn't pass in a firmware name then
* construct a default name.
*/
name_len = strlen(name) + strlen(template) - 2 + 1;
p = kmalloc(name_len, GFP_KERNEL);
if (!p)
return -ENOMEM;
snprintf(p, name_len, template, name);
} else {
p = kasprintf(GFP_KERNEL, "rproc-%s-fw", name);
else
p = kstrdup(firmware, GFP_KERNEL);
if (!p)
return -ENOMEM;
}
if (!p)
return -ENOMEM;
rproc->firmware = p;
......
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