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: 111097 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4373270qge; Sun, 27 Aug 2017 22:35:02 -0700 (PDT) X-Received: by 10.84.216.82 with SMTP id f18mr7178630plj.154.1503898501918; Sun, 27 Aug 2017 22:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503898501; cv=none; d=google.com; s=arc-20160816; b=ndnaYV+PN584vVfcxcyMC2NlfeIoMZ+bYhhLZZ2Y9pXqDPHnai1DR+e7oAua+teWZO nTFMMAv8VR0zhuV11jHtp0vFaLDIMKqBdrg5Y6itVIX5+PQ4STP1zEVleYeAaZu0SLmR 9mqLHAJqpN1ValEmc9M5OVCsu058WyVaWDdFC9gflcU9uQpUpsSznPTxtVpPs9IwabM4 SqoA2HgIv48cmybfNVZwQipKb1hurMYx/6285TiZ9PYKLoKXFYTKRC2aNADhtSLJoL9f FYbJMVjRd4ISy9m8LuAwgi9o/rke4qJjxevEZgk90G7IH+16Z9kwhk65yDQyFVW/qwh8 m/lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=bFQUqDl1HpcGa4qKJ3CVQRgraR/9Laz0AUhxdJXC//E=; b=VN3GM5/avTqnIt1/+VsB2S/QHJgds2FCG9A7M4cJJM3LFcZqre0cAO0kdwpzDD7qhj e6OoXRReLEYSBqdNM8ltWglLtCDISKYoU4wDHC3Xk3MWThBrJ1HDSKRFZzSjEmkxKoD4 jbTBwhpMwh12HfzukQg4OdIGaeABMiPpLXNIoR7CcctVVSDogwRqALN05fa7qXXWIIjC vzh1mRGsX+5a1yRUOOs3vfQsjDoAEPE4racQ+ZbSwq54Bhk0Nu5xhtS/nGeUS59IZ/W2 xNqfPnebGqf1FqY9LEPl+2jiXvob1fsDrvRXlJMrTyPi9d52GJcBwTir3BoegI/TfAoN db0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I60PbyUX; 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 o6si9861744plh.208.2017.08.27.22.35.01; Sun, 27 Aug 2017 22:35:01 -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=I60PbyUX; 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 S1751197AbdH1Fe7 (ORCPT + 26 others); Mon, 28 Aug 2017 01:34:59 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:32872 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750871AbdH1Fe5 (ORCPT ); Mon, 28 Aug 2017 01:34:57 -0400 Received: by mail-pg0-f51.google.com with SMTP id t3so20841186pgt.0 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=D6e75P1H0PeGBl9YHG1D83j+zieQD+z+gu3DAWxJpzTzB05+KEdWCFG6gUh68aUe1S +L/EzpcDDHjy5A0ysfy0uikgDlXM2oXHUVBWqnCKwiaaOYlKMIR64JRDHG5pvu0WW+6T xWrx+8sPnKdYMJrB53s3BnwUysWhXNZSsbbyDa7dGzAWe3083rrRWq5bTG4rpninnlDq mDHD2vi+pGIMwXNchWTK9ioRJjSYk3dWRuF3Dw6qJ89A4cdyq5W47kXhUUmkGiLaZ3HI MUnjmsCR5UB3J/L02O70OZYMXBP54gLiFo9ZS5n8ryb8z7OcKSsTBxue/qwMHvOhghnG edsA== X-Gm-Message-State: AHYfb5h1xKf8wo9Jvrk47XtxGS2lz2+aH2BeP1srH/MmPmYT84qmfKTq KE74gQSPtvl0+a+n 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 2.12.0 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);