aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Poirier <[email protected]>2020-04-15 14:48:54 -0600
committerBjorn Andersson <[email protected]>2020-04-19 22:24:54 -0700
commit4df4f8be8b3e9ce807ba47c030893d711abe6ee3 (patch)
tree406ade534939dfd98f76d8366fd94370c0b44c41
parent0c2ae2b1afdfffa5e485614569d2ff12dee97fc5 (diff)
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: Alex Elder <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Suggested-by: Bjorn Andersson <[email protected]> Signed-off-by: Mathieu Poirier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
-rw-r--r--drivers/remoteproc/remoteproc_core.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 4dee63f319ba..9899467fa1cf 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -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;