Received: by 10.192.165.148 with SMTP id m20csp508207imm; Wed, 9 May 2018 17:20:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpxDghv1N1Ullsor0lq2p6h+8kpMo5OvFWwcDOP67Wy1D0MPwtXtycsbhoSYsBMG2k3nB2H X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr46416470pla.287.1525911607789; Wed, 09 May 2018 17:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525911607; cv=none; d=google.com; s=arc-20160816; b=EWU7ZBSPdw2F2nBKpKeU4lBRn4C8j/G3UVVDqjerm9xaqqFpVqfVbi+VbOcWRqi4Pq n1Q1SigM47QvuKq8eYY3NlMgOC71Bd/tF0k6KDmdrfSD+KL1goMxnCc2KtyJGgxHUaLi ldbUiAU9EnpWheqXqcHJnCY7kCbHETlzCURqAv9OYwD4wA34BbZkqLcNlORgb0SSWp9i d0LGiTjA3br86fQtyVTVm1jMEIg1H2jQuhoKz8duFjv6Iif1iJIx5A0ZZwwxkOmoSWXR jLMqcTcYcmYUtxDrRVcdG7vWSK5nv+PNEGDswNB13k8H6rcjnlTzcEinhpDx3ZE8jWae /Fyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=BBqLoSjPIENXWs3YTVpUvdN4MaFykm3+qXUNSGg6c9g=; b=kY5OyEBY9ioQcAX2vgSfUrd/JfO3nCzLMsGGGy8eFINmaM4wKFVQCj3K1rAbncVNU0 lcG9NeiscTo0XPJtfRe0Op4q3nWEccUNGt3so4UDFGw6R9ErKJ533cQzE64PR6bOqgca go4vW2fgCqEbeu+CHh0Pdp8l51VxT0rBHYdvpIiLD5VbVJHjO/FaYADcTsNsvTdGUmAb IxdNvZyXStO5mJ0niJCIzPTeZPk4MC+t0hwowFh4CX68M6DyZcVl4mb/QgwUkP7Fh+gd adjJzrVRAijVn19bpIWFJp+Zak5sWAHt1NQGdkFrgy4ajUSr+WSHp5GWXwjAHWiGB6dg a04Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HyYWuVNr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6-v6si19248259pgv.420.2018.05.09.17.19.53; Wed, 09 May 2018 17:20:07 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=HyYWuVNr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935622AbeEJATI (ORCPT + 99 others); Wed, 9 May 2018 20:19:08 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:41048 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934234AbeEJATG (ORCPT ); Wed, 9 May 2018 20:19:06 -0400 Received: by mail-pg0-f66.google.com with SMTP id m21-v6so149830pgv.8 for ; Wed, 09 May 2018 17:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BBqLoSjPIENXWs3YTVpUvdN4MaFykm3+qXUNSGg6c9g=; b=HyYWuVNrL9XTEOarvqiBbheGaKlPzqK6myt7QQotE9qTPfVLPvvfr00mcX9UPycfn3 DHHZq8ZcWt1jftNVco4q+pQHqUBuSYSliii1K8piq+Xx6VKn1J7zSki2dSnZ+Gf8+tZR w6Ri/2gvXRUXOCD+0rxgFrVp8zuwmyKYPeHU8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=BBqLoSjPIENXWs3YTVpUvdN4MaFykm3+qXUNSGg6c9g=; b=HhhMERJYd/CGbM19zR+JTEepwHszWpvmyjhykvp33wWOCjLWB0orp8iejgPRGJKEVM MEnZkAz1Z6NfaxSC/zs3ARiDIatBl9P5pKvZD53WCLcLWs6034stw8sRDD2J9f5dHFMn wUI56xl+gzoz9yIilSS+lXDQjDQe8A0RbgLwp3tlN6Z4uYRfVGRGLBg/6z0wID/FjvaJ 65V7j5Cp1xV29aop1bfjXu9FwB/bjuRRjtjIESG4eX/OgaFPOWL+eGlQQCEJuqk8sQ0U CBmgCZ9b9BCL4e4P+W+k2VWHNUiPsJePI+cByT4U3GRZ+hLQhPXNL0peZFKq8CZPMW/m ZOsQ== X-Gm-Message-State: ALQs6tD5rXFD0HQE+KjJgGMz4eF+0KfOZ1O4idiEXQDqAc7QybvwM7s5 6BogBt7bo6coKV8V7Qq7+1IGIg== X-Received: by 2002:a63:7003:: with SMTP id l3-v6mr23819169pgc.14.1525911545703; Wed, 09 May 2018 17:19:05 -0700 (PDT) Received: from builder (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id h1sm54919492pfg.135.2018.05.09.17.19.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 17:19:05 -0700 (PDT) Date: Wed, 9 May 2018 17:19:03 -0700 From: Bjorn Andersson To: Loic Pallardy Cc: ohad@wizery.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com, benjamin.gaignard@linaro.org Subject: Re: [PATCH v3 07/13] remoteproc: introduce rproc_find_carveout_by_name function Message-ID: <20180510001903.GD29093@builder> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> <1519921440-21356-8-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519921440-21356-8-git-send-email-loic.pallardy@st.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 01 Mar 08:23 PST 2018, Loic Pallardy wrote: > This patch provides a new function to find a carveout according > to a name. > If match found, this function returns a pointer on the corresponding > carveout (rproc_mem_entry structure). > > Signed-off-by: Loic Pallardy > --- > drivers/remoteproc/remoteproc_core.c | 43 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 91aa22b..7a500cb 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -216,6 +216,49 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) > } > EXPORT_SYMBOL(rproc_da_to_va); > > +/** > + * rproc_find_carveout_by_name() - lookup the carveout region by a name > + * @rproc: handle of a remote processor > + * @name,..: carveout name to find (standard printf format) > + * > + * Platform driver has the capability to register some pre-allacoted carveout > + * (physically contiguous memory regions) before rproc firmware loading and > + * associated resource table analysis. These regions may be dedicated memory > + * regions internal to the coprocessor or specified DDR region with specific > + * attributes > + * > + * This function is a helper function with which we can go over the > + * allocated carveouts and return associated region characteristics like > + * coprocessor address, length or processor virtual address. > + * > + * The function returns a valid pointer on carveout entry on success > + * or NULL on failure. The kerneldoc format for describing the return value is * Return: description > + */ > +struct rproc_mem_entry * > +rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...) > +{ > + va_list args; > + char _name[32]; > + struct rproc_mem_entry *carveout, *mem = NULL; > + > + va_start(args, name); > + snprintf(_name, sizeof(_name), name, args); > + va_end(args); > + > + if (!name) > + return NULL; If you would like for it to actually be valid to pass NULL for name, then I think you should move this check to the top of the function. But I suspect that you're looking for (name[0] == '\0'), to check if we where passed an empty string, e.g. from a resource table without resource names. > + > + list_for_each_entry(carveout, &rproc->carveouts, node) { > + /* Compare carveout and requested names */ > + if (!strcmp(carveout->name, name)) { > + mem = carveout; > + break; Just return carveout when you find it. > + } > + } > + > + return mem; > +} > + Regards, Bjorn