From patchwork Tue Aug 16 14:38:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 74021 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp2040586qga; Tue, 16 Aug 2016 07:38:25 -0700 (PDT) X-Received: by 10.66.148.202 with SMTP id tu10mr64597790pab.52.1471358305341; Tue, 16 Aug 2016 07:38:25 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id to7si32368322pac.282.2016.08.16.07.38.25; Tue, 16 Aug 2016 07:38:25 -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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753836AbcHPOiQ (ORCPT + 27 others); Tue, 16 Aug 2016 10:38:16 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:37120 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753773AbcHPOiA (ORCPT ); Tue, 16 Aug 2016 10:38:00 -0400 Received: by mail-wm0-f43.google.com with SMTP id i5so172366874wmg.0 for ; Tue, 16 Aug 2016 07:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7RHLdoZxXKWkCFQEaolMWxtdgJiO5Su5BYelgFJjiDE=; b=U2vH0Fk3hPFNMcGG9XvfsM4T5/CWc9MGQJZLH6ZmEu6wHx6X3ZhWfLOXKbZIHKh2Oy itEVIaB9MN43A1fwsOar9s+YWLyKjcaPnwduxQQ6AGZvaZi3yrzAlIAYARaxQ/HaF7dL 5qnO5WPj0UHgN8m2I+5mW8wlHwk2tELeNJ20E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7RHLdoZxXKWkCFQEaolMWxtdgJiO5Su5BYelgFJjiDE=; b=IyjioALaYBLMUWBMonCINj/EkL6q0lN6bFKWN5aXhsDfk1RCYkaMvx+nEEyKiQm+aw WAtma5ycIfTKHFF6N9CY//dea1DMVIW0CFuPWkQ+xUbgMEckd9GrzPlvTyatyN5taYA9 UbYZAkZBB5c+722kHsZ03JVjCkyBleAu0ch5W0mQS799mE8yWkO42Isk9LqrnT196MxR 1vvqYWCAWIU9Y+EN1HrRfNS3XQFxzVPUKoard4fPy4NjAliVwuI324yqROdHnzB8BiCW daxVRk5Z2hBQ8YfI69z8ypB1lOqXYc9epar6E0YUAksCAFSGbkuY4lm/RC9iwN3gg2ih p/kg== X-Gm-Message-State: AEkoouv4XgTJMjKrYg2pNObCvAMCZ8+v6RmfR1vahxKto23iTg2ZdbGBxIrI97AmtEUVcGEB X-Received: by 10.28.212.211 with SMTP id l202mr7472485wmg.109.1471358278744; Tue, 16 Aug 2016 07:37:58 -0700 (PDT) Received: from localhost.localdomain (host81-129-169-93.range81-129.btcentralplus.com. [81.129.169.93]) by smtp.gmail.com with ESMTPSA id e5sm3768484wma.13.2016.08.16.07.37.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Aug 2016 07:37:58 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, patrice.chotard@st.com, ohad@wizery.com, bjorn.andersson@linaro.org, ssantosh@kernel.org, linux-remoteproc@vger.kernel.org, ludovic.barre@st.com, s-anna@ti.com, loic.pallardy@st.com, Lee Jones Subject: [PATCH v2 2/2] remoteproc: core: Rework obtaining a rproc from a DT phandle Date: Tue, 16 Aug 2016 15:38:24 +0100 Message-Id: <20160816143824.4120-2-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160816143824.4120-1-lee.jones@linaro.org> References: <20160816143824.4120-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In this patch we; - Use a subsystem generic phandle to obtain an rproc - We have to support TI's bespoke version for the time being - Convert wkup_m3_ipc driver to new API - Rename the call to be more like other, similar OF calls - Move feature-not-enabled inline stub to the headers - Strip out duplicate code by calling into of_get_rproc_by_index() Signed-off-by: Lee Jones --- v1 => v2: - Strip '_by_phandle' from function name drivers/remoteproc/remoteproc_core.c | 41 ++++++++---------------------------- drivers/soc/ti/wkup_m3_ipc.c | 14 +++--------- include/linux/remoteproc.h | 4 ++-- 3 files changed, 14 insertions(+), 45 deletions(-) -- 2.9.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fe362fb..1c5d5d8 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1269,47 +1269,24 @@ struct rproc *of_get_rproc_by_name(struct device_node *np, const char *name) EXPORT_SYMBOL(of_get_rproc_by_name); /** - * rproc_get_by_phandle() - find a remote processor by phandle - * @phandle: phandle to the rproc + * of_get_rproc() - lookup and obtain a reference to an rproc + * @np: node to search for rproc * - * Finds an rproc handle using the remote processor's phandle, and then - * return a handle to the rproc. + * Finds an rproc handle using the default remote processor's phandle, + * and then returns a handle to the rproc. * * This function increments the remote processor's refcount, so always * use rproc_put() to decrement it back once rproc isn't needed anymore. * - * Returns the rproc handle on success, and NULL on failure. + * Returns a pointer to the rproc struct on success or an appropriate error + * code otherwise. */ -struct rproc *rproc_get_by_phandle(phandle phandle) -{ - struct rproc *rproc = NULL, *r; - struct device_node *np; - - np = of_find_node_by_phandle(phandle); - if (!np) - return NULL; - - mutex_lock(&rproc_list_mutex); - list_for_each_entry(r, &rproc_list, node) { - if (r->dev.parent && r->dev.parent->of_node == np) { - rproc = r; - get_device(&rproc->dev); - break; - } - } - mutex_unlock(&rproc_list_mutex); - - of_node_put(np); - - return rproc; -} -#else -struct rproc *rproc_get_by_phandle(phandle phandle) +struct rproc *of_get_rproc(struct device_node *np) { - return NULL; + return of_get_rproc_by_index(np, 0); } +EXPORT_SYMBOL(of_get_rproc); #endif -EXPORT_SYMBOL(rproc_get_by_phandle); /** * rproc_add() - register a remote processor diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c index 8823cc8..8518c16 100644 --- a/drivers/soc/ti/wkup_m3_ipc.c +++ b/drivers/soc/ti/wkup_m3_ipc.c @@ -385,7 +385,6 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; int irq, ret; - phandle rproc_phandle; struct rproc *m3_rproc; struct resource *res; struct task_struct *task; @@ -430,16 +429,9 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev) return PTR_ERR(m3_ipc->mbox); } - if (of_property_read_u32(dev->of_node, "ti,rproc", &rproc_phandle)) { - dev_err(&pdev->dev, "could not get rproc phandle\n"); - ret = -ENODEV; - goto err_free_mbox; - } - - m3_rproc = rproc_get_by_phandle(rproc_phandle); - if (!m3_rproc) { - dev_err(&pdev->dev, "could not get rproc handle\n"); - ret = -EPROBE_DEFER; + m3_rproc = of_get_rproc(dev->of_node); + if (IS_ERR(m3_rproc)) { + ret = PTR_ERR(m3_rproc); goto err_free_mbox; } diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index f130938..0e1adc9 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -515,7 +515,7 @@ extern struct rproc *of_get_rproc_by_index(struct device_node *np, int index); extern struct rproc *of_get_rproc_by_name(struct device_node *np, const char *name); -extern struct rproc *rproc_get_by_phandle(phandle phandle); +extern struct rproc *of_get_rproc(struct device_node *np); #else static inline struct rproc *of_get_rproc_by_index(struct device_node *np, int index) @@ -528,7 +528,7 @@ struct rproc *of_get_rproc_by_name(struct device_node *np, const char *name) return NULL; } static inline -struct rproc *rproc_get_by_phandle(phandle phandle) +struct rproc *of_get_rproc(struct device_node *np) { return NULL; }