aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoic Pallardy <loic.pallardy@st.com>2019-01-10 08:49:11 -0500
committerBjorn Andersson <bjorn.andersson@linaro.org>2019-02-21 00:34:19 -0500
commit28d7d5c66d560730fdfe021b129e7d3f72a4b97f (patch)
tree81bf065d7e1f0d3ac1eb653c431b8b13293f9265
parenta987e6b91a5ac0e08782506b1f879e37dab3b605 (diff)
remoteproc: fix rproc_check_carveout_da() returned error and comments
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: c874bf59add0 ("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>
-rw-r--r--drivers/remoteproc/remoteproc_core.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 16cd54324246..48feebd6d0a2 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -281,25 +281,27 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...)
281 * @len: associated area size 281 * @len: associated area size
282 * 282 *
283 * This function is a helper function to verify requested device area (couple 283 * This function is a helper function to verify requested device area (couple
284 * da, len) is part of specified carevout. 284 * da, len) is part of specified carveout.
285 * If da is not set (defined as FW_RSC_ADDR_ANY), only requested length is
286 * checked.
285 * 287 *
286 * Return: 0 if carveout match request else -ENOMEM 288 * Return: 0 if carveout matches request else error
287 */ 289 */
288int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem, 290static int rproc_check_carveout_da(struct rproc *rproc,
289 u32 da, u32 len) 291 struct rproc_mem_entry *mem, u32 da, u32 len)
290{ 292{
291 struct device *dev = &rproc->dev; 293 struct device *dev = &rproc->dev;
292 int delta = 0; 294 int delta;
293 295
294 /* Check requested resource length */ 296 /* Check requested resource length */
295 if (len > mem->len) { 297 if (len > mem->len) {
296 dev_err(dev, "Registered carveout doesn't fit len request\n"); 298 dev_err(dev, "Registered carveout doesn't fit len request\n");
297 return -ENOMEM; 299 return -EINVAL;
298 } 300 }
299 301
300 if (da != FW_RSC_ADDR_ANY && mem->da == FW_RSC_ADDR_ANY) { 302 if (da != FW_RSC_ADDR_ANY && mem->da == FW_RSC_ADDR_ANY) {
301 /* Update existing carveout da */ 303 /* Address doesn't match registered carveout configuration */
302 mem->da = da; 304 return -EINVAL;
303 } else if (da != FW_RSC_ADDR_ANY && mem->da != FW_RSC_ADDR_ANY) { 305 } else if (da != FW_RSC_ADDR_ANY && mem->da != FW_RSC_ADDR_ANY) {
304 delta = da - mem->da; 306 delta = da - mem->da;
305 307
@@ -307,13 +309,13 @@ int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem,
307 if (delta < 0) { 309 if (delta < 0) {
308 dev_err(dev, 310 dev_err(dev,
309 "Registered carveout doesn't fit da request\n"); 311 "Registered carveout doesn't fit da request\n");
310 return -ENOMEM; 312 return -EINVAL;
311 } 313 }
312 314
313 if (delta + len > mem->len) { 315 if (delta + len > mem->len) {
314 dev_err(dev, 316 dev_err(dev,
315 "Registered carveout doesn't fit len request\n"); 317 "Registered carveout doesn't fit len request\n");
316 return -ENOMEM; 318 return -EINVAL;
317 } 319 }
318 } 320 }
319 321