From patchwork Tue Jul 19 15:49:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 72341 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp151746qga; Tue, 19 Jul 2016 08:51:41 -0700 (PDT) X-Received: by 10.98.64.193 with SMTP id f62mr55001110pfd.141.1468943501286; Tue, 19 Jul 2016 08:51:41 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id l190si10068264pfc.25.2016.07.19.08.51.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jul 2016 08:51:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bPXI5-0001eX-7m; Tue, 19 Jul 2016 15:50:37 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bPXHt-00010A-GL for linux-arm-kernel@lists.infradead.org; Tue, 19 Jul 2016 15:50:26 +0000 Received: by mail-wm0-x22d.google.com with SMTP id i5so31760185wmg.0 for ; Tue, 19 Jul 2016 08:50:04 -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=IOWZ+srEwkjUWAthYxMGStJhnPX7nAT1J9VJdHuojQo=; b=RGrgV/IHVuannI4AISe+trsEse+ciWwbif5oLB1EBFpm9T3NqZA8FTuEmFGBJwMdAi FFD5ud5bY8G3s240n/iMT1md+D+WKMV7wU85uXmgm5Fto/mHxQRu257sB00wEaaAj3sH uU5eBdXbUq/aLyVfRBQvsy/ec59SpzMXutFYE= 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=IOWZ+srEwkjUWAthYxMGStJhnPX7nAT1J9VJdHuojQo=; b=CneJyCNJHQAXUUK840QUMhnxlNX12/lythDe4jexFVQ1zBYxcBGVepugvCa8NStIv7 A2k11BQ+3tAHHESfmoGrMrX7jKLI1I9WY5MgaS/VlTJvhhYDhI4FTEshUZwwUfxRlauh 5yiyLMbPLCR+FsPCjIjOg58WjHjqPxfEdi8JsYOyrBT3P6tVrYHmf/BTK676prrsZktj Lb0oismxFL8QjLjMqJ324ojkPztyLTwTFyjXzg89rzYVUfMaEO5LYNqtzuRO5JNBTlt5 vlxgd3Ptsw5SuIHv3FCZGPLQSYao20hg0cqEbodwBSOylF2/pY5YfOzuAOV2EIcGcZmS V0Mg== X-Gm-Message-State: ALyK8tISuAGezhWUIUdVfVWgs3+nIvYmG9g7Tn0XIs8SFwLsiXdqp1jy0OpvRl3lLOPGT+Lt X-Received: by 10.28.165.3 with SMTP id o3mr5477338wme.3.1468943403505; Tue, 19 Jul 2016 08:50:03 -0700 (PDT) Received: from localhost.localdomain (host81-129-170-195.range81-129.btcentralplus.com. [81.129.170.195]) by smtp.gmail.com with ESMTPSA id g184sm23904164wme.15.2016.07.19.08.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jul 2016 08:50:02 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] remoteproc: core: Rework obtaining a rproc from a DT phandle Date: Tue, 19 Jul 2016 16:49:05 +0100 Message-Id: <20160719154905.23344-2-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160719154905.23344-1-lee.jones@linaro.org> References: <20160719154905.23344-1-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160719_085025_900723_4C23B233 X-CRM114-Status: GOOD ( 19.01 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ohad@wizery.com, kernel@stlinux.com, linux-remoteproc@vger.kernel.org, patrice.chotard@st.com, bjorn.andersson@linaro.org, ssantosh@kernel.org, Lee Jones , ludovic.barre@st.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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 --- 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 6a0d158..aea29a75c 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_by_phandle() - 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_by_phandle(struct device_node *np) { - return NULL; + return of_get_rproc_by_index(np, 0); } +EXPORT_SYMBOL(of_get_rproc_by_phandle); #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..15481f3 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_by_phandle(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..3608d20 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_by_phandle(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_by_phandle(struct device_node *np) { return NULL; }