From patchwork Thu Jan 10 13:49:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155162 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1915895jaa; Thu, 10 Jan 2019 05:49:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN6oMR5qezVaJxhSayQrH/vF+n5S2a3ANSwvyfOkMj2CigoXnIwmHRK9Q3Mu4f7LsAz4g3AV X-Received: by 2002:a63:5b1f:: with SMTP id p31mr9380962pgb.56.1547128179251; Thu, 10 Jan 2019 05:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128179; cv=none; d=google.com; s=arc-20160816; b=IUQngfX+1hTugSWY5RLVbwq+iM/zoSLK83v/ijiUEkHfqNawDMVCUD8RqPuEY9iZKN Dkg17vAeTtCL9h1CNbKWR+aCA7TFVfsXiMjLCgJpwDmN/JrGtWKxNIA3feodW1fKh2bj B2RijlKPXX1jZ863VrKsJNi3V/P6iWnBmWVLdUVOumeEhmRsz40gHL5lCPEB37OVMZTU ssZh/7rZ+JA32SaiB+vTVtRVIB2O5+GILFtTCtrDrFkeSRtqCtKGMrlqYdj7B+1G40LF D/c6D9FqF5XoyMbgRPsYOl3lLKsUiPfZW2VUXBbpkHocKw4IlpZnf3p6rcQukq2FvHOT OC5A== 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=oc26J+isWafGaTatzwdOstAV+HdG4YtCBSFc8EzUpHE=; b=HrmFrtcgv9bEHfj7lPMQ4Y2FCVcC2KEZiKyFS8ds6y75GKHmd2NSygBfd8U3UJmZVZ whXo6X8C7phfhFEfLR5cEzCIfyHcfmMuPajkV5CkkmodTZvUrnl7ZIPPipPEVSd+IgLa ofchr+/8KKYwTy+g6WW5I7pqfWKfFsWtVWT22tVXGfGmR1VOJqiYy0RtaKVspqZWTlw3 yt6Y+RKpeIsynY+u7nYrXBDNBbC1Xx4TuOKy549Pg+lNxNa7HEKh/8xVm5wfix3gLv72 00CeXauUwaGvwclWgRErZonjhP/k7C5WOAVB3I2PvT0Zs7rn+7NJ9qjoJPN/GFjO20Df iv6A== 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 x8si9294437plo.259.2019.01.10.05.49.38; Thu, 10 Jan 2019 05:49:39 -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 S1729119AbfAJNth (ORCPT + 31 others); Thu, 10 Jan 2019 08:49:37 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:45172 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729071AbfAJNtc (ORCPT ); Thu, 10 Jan 2019 08:49:32 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADf37u008195; Thu, 10 Jan 2019 14:49:27 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ptvjg2pu5-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:27 +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 0787F38; Thu, 10 Jan 2019 13:49:27 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E4681504E; Thu, 10 Jan 2019 13:49:26 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:26 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:26 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 7/7] remoteproc: fix rproc_check_carveout_da() returned error and comments Date: Thu, 10 Jan 2019 14:49:11 +0100 Message-ID: <1547128151-44077-8-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_05:, , 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(-) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 45d97871ca69..fc9bf99cd96f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -278,25 +278,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; @@ -304,13 +306,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; } }