Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2986906imu; Thu, 29 Nov 2018 13:33:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/VzGyDrO6BZnTytpWpiTFDZpBqmNs46+ebhfJ33ci7cyW+5B/KoWsL6erZF0WQbVSP6LynZ X-Received: by 2002:a63:36c4:: with SMTP id d187mr2582496pga.404.1543527181518; Thu, 29 Nov 2018 13:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543527181; cv=none; d=google.com; s=arc-20160816; b=Z+aCDduEWFWQ5C1M6bDt7DsM1Ej4jddUAag6MvW13cOs6xPOvow7V0VEDwpLCs0GWK 0rll0m/O4i0AvfNgj4/GJg0Xz6jB5FV2jPYzWOiTLngoCVDXqAkYbaIs5LpvzrVVJCeK fIXObkdexoEzpbFyZTiOVzxgszGAfiqVIXK/aZn+wkwxxOHW/CQyCzySKxRc/4gFIqbc mG48xs1o+m7j2LDAdFdDIvQ/ckMIT9iJJ1eYgiUl5X3LaGC4UDIeXYFgcE4A6lk0whV2 sxFzoH3rHvdMYKyGwiyaeEr4oMfZNzPbv5hkoCuqyWtcFVSyNI7FZ4fkYVyA8FdN972M xk0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=b87iNikHj6/s4M3IQbTHwkfIiMxUQnUAb5kyNsNPTBs=; b=Z4XYpzlo1F9mo9z8Kqp6CBBLH/B5PrEyQqDfxwFW/8nM2dV3dsZtSJT30+9vDHHl1f m7PYQ7eqQb0yux2y+jeNngEYl5phqJcdHBxoo0kqUKzbsOAS2o9ee2g6n7sEUZmwwKI5 HZ/9Drz63/B9/mwKxzpOLquKyQqR6Vm4pEnYAVv90h3o08BGv/60l2/5PJfHnZ+9Bz7g +cj4EkURGU/7n8yhkNIOWA7PeFz4Ca8BLzBDv0lzA4bU8JzeTX99yT/VuE47lUp1B0Za JbC8qA/0BDS8y7qgAPcymcK75yXPC2dJGsNFxSQxKLMf/lqIiYUEACrYMOPB7m6ASiXf tmZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h91si3158224pld.411.2018.11.29.13.32.46; Thu, 29 Nov 2018 13:33:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727172AbeK3IhI (ORCPT + 99 others); Fri, 30 Nov 2018 03:37:08 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:31895 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726932AbeK3IhI (ORCPT ); Fri, 30 Nov 2018 03:37:08 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wATLSxoC023175; Thu, 29 Nov 2018 22:30:15 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2nxw02wvt5-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Nov 2018 22:30:15 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 38ED1468; Thu, 29 Nov 2018 22:29:45 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 76A365986; Thu, 29 Nov 2018 21:30:14 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:30:14 +0100 Received: from localhost (10.129.6.191) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:30:13 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH 7/7] remoteproc: fix rproc_check_carveout_da() returned error and comments Date: Thu, 29 Nov 2018 22:29:28 +0100 Message-ID: <1543526968-56091-8-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> References: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.129.6.191] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-29_13:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/remoteproc/remoteproc_core.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9dbcc16f8782..b69ce5bff732 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -276,25 +276,27 @@ 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; @@ -302,13 +304,13 @@ int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem, 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; } } -- 2.7.4