From patchwork Mon Aug 28 05:34:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9924169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C8A8760375 for ; Mon, 28 Aug 2017 05:34:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA01728676 for ; Mon, 28 Aug 2017 05:34:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB44A2867E; Mon, 28 Aug 2017 05:34:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5207328676 for ; Mon, 28 Aug 2017 05:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751152AbdH1Fe6 (ORCPT ); Mon, 28 Aug 2017 01:34:58 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:34791 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750865AbdH1Fe5 (ORCPT ); Mon, 28 Aug 2017 01:34:57 -0400 Received: by mail-pg0-f51.google.com with SMTP id t193so9603906pgc.1 for ; Sun, 27 Aug 2017 22:34:57 -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; bh=bFQUqDl1HpcGa4qKJ3CVQRgraR/9Laz0AUhxdJXC//E=; b=I60PbyUXrgpkank+Jyjh4n8wQMIHgANwXuC/4MTBDDwlnCvKdRIuEPDO6rwXSyr8Un 3YLirt4bZdcPsWSTcazuJdBygj3uD4O1fM3KFiPgKYcMfBuS+hl+pZF4xNntBe6Qyu2W 5pU3uX+mi1ABn5tTAffV/je9jxrkbo0SJy4Ys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bFQUqDl1HpcGa4qKJ3CVQRgraR/9Laz0AUhxdJXC//E=; b=UQtXJwNls+QukCTQ6+W7zMlsJ2bgz5k+B//Uy7dB9V/w83KHRDJ+kD01MXXbkJMb+P xzlL18iL1UTwNtwTZI9i233FMUQF1pBKKw5VfoUtuhPkSfC1644yoaP/WTyBAL3zd4q+ 3YUINMf+ECNT9FrlzkBJejLMe9vvpbIjTekp7YK7r7BRoktLI3MaBAK/BFw1NkhR9VF7 E8RZlBzCn71mJkWIy3VuSqzB10cjbNBv83kPLDKubwb/2dIYofgw7FgQ0XQ+uiXKWbDm oluXeBy6bgYR69yOak285y4rhuWLOABjWu8qR315RgmcD6CqPvfVkSldTLTgS9tXyM5F RC0A== X-Gm-Message-State: AHYfb5h5aOoGF+++wsVtBHKPvMD2iP0ssg7YMCcA9IJDesr960F27FLZ RaemJBwZ+oLUh21e X-Received: by 10.84.139.195 with SMTP id 61mr7058751plr.445.1503898496862; Sun, 27 Aug 2017 22:34:56 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id a63sm20022824pfc.165.2017.08.27.22.34.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Aug 2017 22:34:56 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] remoteproc: Introduce rproc handle accessor for children Date: Sun, 27 Aug 2017 22:34:53 -0700 Message-Id: <20170828053453.27187-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In certain circumstances rpmsg devices needs to acquire a handle to the ancestor remoteproc instance, e.g. to invoke rproc_report_crash() when a fatal error is detected. Introduce an interface that walks the device tree in search for a remoteproc instance and return this. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 18 ++++++++++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 564061dcc019..5b1b19519275 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1296,6 +1296,23 @@ struct rproc *rproc_get_by_phandle(phandle phandle) EXPORT_SYMBOL(rproc_get_by_phandle); /** + * rproc_get_by_child() - acquire rproc handle of @dev's ancestor + * @dev: child device to find ancestor of + * + * Returns the ancestor rproc instance, or NULL if not found. + */ +struct rproc *rproc_get_by_child(struct device *dev) +{ + for (dev = dev->parent; dev; dev = dev->parent) { + if (dev->type && !strcmp(dev->type->name, "remoteproc")) + return dev->driver_data; + } + + return NULL; +} +EXPORT_SYMBOL(rproc_get_by_child); + +/** * rproc_add() - register a remote processor * @rproc: the remote processor handle to register * @@ -1440,6 +1457,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, rproc->dev.parent = dev; rproc->dev.type = &rproc_type; rproc->dev.class = &rproc_class; + rproc->dev.driver_data = rproc; /* Assign a unique device index and name */ rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 81da49564ff4..44e630eb3d94 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -510,6 +510,8 @@ struct rproc_vdev { }; struct rproc *rproc_get_by_phandle(phandle phandle); +struct rproc *rproc_get_by_child(struct device *dev); + struct rproc *rproc_alloc(struct device *dev, const char *name, const struct rproc_ops *ops, const char *firmware, int len);