Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 374245
b: refs/heads/master
c: 232fcdb
h: refs/heads/master
i:
  374243: 9888853
v: v3
  • Loading branch information
Sjur Brændeland authored and Ohad Ben-Cohen committed Apr 5, 2013
1 parent 2f1d155 commit 68948b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e4b51414813faf5cdc89e373b2e44cdbead09459
refs/heads/master: 232fcdbb450000850bef8ff7e022cde2b4053f67
52 changes: 12 additions & 40 deletions trunk/drivers/remoteproc/remoteproc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,16 +673,21 @@ static int rproc_handle_carveout(struct rproc *rproc,
* A lookup table for resource handlers. The indices are defined in
* enum fw_resource_type.
*/
static rproc_handle_resource_t rproc_handle_rsc[] = {
static rproc_handle_resource_t rproc_loading_handlers[RSC_LAST] = {
[RSC_CARVEOUT] = (rproc_handle_resource_t)rproc_handle_carveout,
[RSC_DEVMEM] = (rproc_handle_resource_t)rproc_handle_devmem,
[RSC_TRACE] = (rproc_handle_resource_t)rproc_handle_trace,
[RSC_VDEV] = NULL, /* VDEVs were handled upon registrarion */
};

static rproc_handle_resource_t rproc_vdev_handler[RSC_LAST] = {
[RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev,
};

/* handle firmware resource entries before booting the remote processor */
static int
rproc_handle_boot_rsc(struct rproc *rproc, struct resource_table *table, int len)
static int rproc_handle_resources(struct rproc *rproc,
struct resource_table *table, int len,
rproc_handle_resource_t handlers[RSC_LAST])
{
struct device *dev = &rproc->dev;
rproc_handle_resource_t handler;
Expand All @@ -707,7 +712,7 @@ rproc_handle_boot_rsc(struct rproc *rproc, struct resource_table *table, int len
continue;
}

handler = rproc_handle_rsc[hdr->type];
handler = handlers[hdr->type];
if (!handler)
continue;

Expand All @@ -719,40 +724,6 @@ rproc_handle_boot_rsc(struct rproc *rproc, struct resource_table *table, int len
return ret;
}

/* handle firmware resource entries while registering the remote processor */
static int
rproc_handle_virtio_rsc(struct rproc *rproc, struct resource_table *table, int len)
{
struct device *dev = &rproc->dev;
int ret = 0, i;

for (i = 0; i < table->num; i++) {
int offset = table->offset[i];
struct fw_rsc_hdr *hdr = (void *)table + offset;
int avail = len - offset - sizeof(*hdr);
struct fw_rsc_vdev *vrsc;

/* make sure table isn't truncated */
if (avail < 0) {
dev_err(dev, "rsc table is truncated\n");
return -EINVAL;
}

dev_dbg(dev, "%s: rsc type %d\n", __func__, hdr->type);

if (hdr->type != RSC_VDEV)
continue;

vrsc = (struct fw_rsc_vdev *)hdr->data;

ret = rproc_handle_vdev(rproc, vrsc, avail);
if (ret)
break;
}

return ret;
}

/**
* rproc_resource_cleanup() - clean up and free all acquired resources
* @rproc: rproc handle
Expand Down Expand Up @@ -832,7 +803,8 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
}

/* handle fw resources which are required to boot rproc */
ret = rproc_handle_boot_rsc(rproc, table, tablesz);
ret = rproc_handle_resources(rproc, table, tablesz,
rproc_loading_handlers);
if (ret) {
dev_err(dev, "Failed to process resources: %d\n", ret);
goto clean_up;
Expand Down Expand Up @@ -887,7 +859,7 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
goto out;

/* look for virtio devices and register them */
ret = rproc_handle_virtio_rsc(rproc, table, tablesz);
ret = rproc_handle_resources(rproc, table, tablesz, rproc_vdev_handler);
if (ret)
goto out;

Expand Down

0 comments on commit 68948b1

Please sign in to comment.