[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1337693217-15466-4-git-send-email-sjur.brandeland@stericsson.com>
Date: Tue, 22 May 2012 15:26:54 +0200
From: sjur.brandeland@...ricsson.com
To: Ohad Ben-Cohen <ohad@...ery.com>
Cc: Loic PALLARDY <loic.pallardy@...ricsson.com>,
Ludovic BARRE <ludovic.barre@...ricsson.com>,
linux-kernel@...r.kernel.org, Arnd Bergmann <arnd@...db.de>,
Linus Walleij <linus.walleij@...aro.org>,
Sjur Brændeland <sjurbren@...il.com>,
Sjur Brændeland <sjur.brandeland@...ricsson.com>
Subject: [RFC 3/6] remoteproc: Move fw sanity check to find_rsc_table.
From: Sjur Brændeland <sjur.brandeland@...ricsson.com>
Prepare for pluggable firmware handling by calling firmware
sanity check from function find_rsc_table.
Signed-off-by: Sjur Brændeland <sjur.brandeland@...ricsson.com>
---
drivers/remoteproc/remoteproc_core.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 3d980ea..785d66b 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -43,6 +43,7 @@
#include "remoteproc_internal.h"
+static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw);
static void klist_rproc_get(struct klist_node *n);
static void klist_rproc_put(struct klist_node *n);
@@ -848,6 +849,9 @@ rproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
int i;
const u8 *elf_data = fw->data;
+ if (rproc_fw_sanity_check(rproc, fw) < 0)
+ return NULL;
+
ehdr = (struct elf32_hdr *)elf_data;
shdr = (struct elf32_shdr *)(elf_data + ehdr->e_shoff);
name_table = elf_data + shdr[ehdr->e_shstrndx].sh_offset;
@@ -1021,10 +1025,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
struct resource_table *table;
int ret, tablesz;
- ret = rproc_fw_sanity_check(rproc, fw);
- if (ret)
- return ret;
-
ehdr = (struct elf32_hdr *)fw->data;
dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size);
@@ -1041,8 +1041,10 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
/* look for the resource table */
table = rproc_find_rsc_table(rproc, fw, &tablesz);
- if (!table)
+ if (!table) {
+ ret = -EINVAL;
goto clean_up;
+ }
/* handle fw resources which are required to boot rproc */
ret = rproc_handle_boot_rsc(rproc, table, tablesz);
@@ -1091,9 +1093,6 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
struct resource_table *table;
int ret, tablesz;
- if (rproc_fw_sanity_check(rproc, fw) < 0)
- goto out;
-
/* look for the resource table */
table = rproc_find_rsc_table(rproc, fw, &tablesz);
if (!table)
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists