summaryrefslogtreecommitdiff
path: root/drivers/remoteproc
diff options
context:
space:
mode:
authorRobert Tivy <rtivy@ti.com>2013-03-28 18:41:44 -0700
committerOhad Ben-Cohen <ohad@wizery.com>2013-04-07 15:40:04 +0300
commit8b4aec9ac7b59754df9c594569af9ae8f456ee07 (patch)
tree2ccfb6df12fc10d3c4219184202c9d8246e5bfe1 /drivers/remoteproc
parente5bc0294ca03a684f322a1a37538ebc3c121d86a (diff)
downloadlinux-3.10-8b4aec9ac7b59754df9c594569af9ae8f456ee07.tar.gz
linux-3.10-8b4aec9ac7b59754df9c594569af9ae8f456ee07.tar.bz2
linux-3.10-8b4aec9ac7b59754df9c594569af9ae8f456ee07.zip
remoteproc: support default firmware name in rproc_alloc()
If rproc_alloc isn't given a firmware name, look for a default one using the "rproc-%s-fw" template. Signed-off-by: Robert Tivy <rtivy@ti.com> [add commit log, document change, use snprintf, minor style change] Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/remoteproc_core.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 7c357370083..56a0f8d6855 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1236,11 +1236,11 @@ static struct device_type rproc_type = {
* @dev: the underlying device
* @name: name of this remote processor
* @ops: platform-specific handlers (mainly start/stop)
- * @firmware: name of firmware file to load
+ * @firmware: name of firmware file to load, can be NULL
* @len: length of private data needed by the rproc driver (in bytes)
*
* Allocates a new remote processor handle, but does not register
- * it yet.
+ * it yet. if @firmware is NULL, a default name is used.
*
* This function should be used by rproc implementations during initialization
* of the remote processor.
@@ -1259,19 +1259,39 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
const char *firmware, int len)
{
struct rproc *rproc;
+ char *p, *template = "rproc-%s-fw";
+ int name_len = 0;
if (!dev || !name || !ops)
return NULL;
- rproc = kzalloc(sizeof(struct rproc) + len, GFP_KERNEL);
+ if (!firmware)
+ /*
+ * Make room for default firmware name (minus %s plus '\0').
+ * If the caller didn't pass in a firmware name then
+ * construct a default name. We're already glomming 'len'
+ * bytes onto the end of the struct rproc allocation, so do
+ * a few more for the default firmware name (but only if
+ * the caller doesn't pass one).
+ */
+ name_len = strlen(name) + strlen(template) - 2 + 1;
+
+ rproc = kzalloc(sizeof(struct rproc) + len + name_len, GFP_KERNEL);
if (!rproc) {
dev_err(dev, "%s: kzalloc failed\n", __func__);
return NULL;
}
+ if (!firmware) {
+ p = (char *)rproc + sizeof(struct rproc) + len;
+ snprintf(p, name_len, template, name);
+ } else {
+ p = (char *)firmware;
+ }
+
+ rproc->firmware = p;
rproc->name = name;
rproc->ops = ops;
- rproc->firmware = firmware;
rproc->priv = &rproc[1];
device_initialize(&rproc->dev);