Skip to content

Commit

Permalink
remoteproc: fix rproc_check_carveout_da() returned error and comments
Browse files Browse the repository at this point in the history
Fix typo in comments.
Change returned error from ENOMEM to EINVAL as
not dealing with memory allocation.
Remove carveout forced da update and return an error
when no configuration match

Fixes: c874bf5 ("remoteproc: add helper function to check carveout device address")

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
  • Loading branch information
Loic Pallardy authored and Bjorn Andersson committed Feb 21, 2019
1 parent a987e6b commit 28d7d5c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions drivers/remoteproc/remoteproc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,39 +281,41 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...)
* @len: associated area size
*
* This function is a helper function to verify requested device area (couple
* da, len) is part of specified carevout.
* da, len) is part of specified carveout.
* If da is not set (defined as FW_RSC_ADDR_ANY), only requested length is
* checked.
*
* Return: 0 if carveout match request else -ENOMEM
* Return: 0 if carveout matches request else error
*/
int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem,
u32 da, u32 len)
static int rproc_check_carveout_da(struct rproc *rproc,
struct rproc_mem_entry *mem, u32 da, u32 len)
{
struct device *dev = &rproc->dev;
int delta = 0;
int delta;

/* Check requested resource length */
if (len > mem->len) {
dev_err(dev, "Registered carveout doesn't fit len request\n");
return -ENOMEM;
return -EINVAL;
}

if (da != FW_RSC_ADDR_ANY && mem->da == FW_RSC_ADDR_ANY) {
/* Update existing carveout da */
mem->da = da;
/* Address doesn't match registered carveout configuration */
return -EINVAL;
} else if (da != FW_RSC_ADDR_ANY && mem->da != FW_RSC_ADDR_ANY) {
delta = da - mem->da;

/* Check requested resource belongs to registered carveout */
if (delta < 0) {
dev_err(dev,
"Registered carveout doesn't fit da request\n");
return -ENOMEM;
return -EINVAL;
}

if (delta + len > mem->len) {
dev_err(dev,
"Registered carveout doesn't fit len request\n");
return -ENOMEM;
return -EINVAL;
}
}

Expand Down

0 comments on commit 28d7d5c

Please sign in to comment.