From patchwork Mon Oct 13 05:39:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 399046 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E18471400A0 for ; Mon, 13 Oct 2014 16:41:43 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 186E8A78A6; Mon, 13 Oct 2014 07:41:11 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LpRIgEyF+Jix; Mon, 13 Oct 2014 07:41:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7E45FA78AF; Mon, 13 Oct 2014 07:40:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 47447A785F for ; Mon, 13 Oct 2014 07:40:13 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vcRup43ZvlXB for ; Mon, 13 Oct 2014 07:40:13 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ig0-f201.google.com (mail-ig0-f201.google.com [209.85.213.201]) by theia.denx.de (Postfix) with ESMTPS id 34E75A7850 for ; Mon, 13 Oct 2014 07:40:06 +0200 (CEST) Received: by mail-ig0-f201.google.com with SMTP id h15so1483319igd.0 for ; Sun, 12 Oct 2014 22:40:05 -0700 (PDT) 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=QFT0B5+GmB6zv/h2VypRmEVvxKZtMqJCtDgwwbSWydw=; b=anqGmGidUQd/+Jnjzn8hdhoDMCzIl3nKXZtfE6Xg0FMMXfDyrFS9I7SYEZDJDmjagC 0PBjSGFhfpxgBa8A+dWoz0FFhNnINfSWNhRABhTSe4m8ktQd1Xcq7OblheSlkPJ63QMR wQfHNZSWToVCeWYGCbu4HEit4nNKTM89g46KodFYqyzYETW40KDmoZLQzuQfEz9+Zj0q 8ISecflqcDe1rNy4OskL8cit+nrDE16k2oqtLnqn9s6UURW922VvKdhqD+uVlCzNBSrb uFzmYsE+BONkDdE9aiSAFovBHyASybdG5xySFwrZ0hlT9e1CyAKVSDOMCCrB92TJFEeY +Fag== X-Gm-Message-State: ALoCoQkySz89YLOxoXQPHhxEWBjdKuoOUXHM+uOBEUh3OZuI9Sg88oV0IsBTijnFpTi2G2fz8ztb X-Received: by 10.43.107.14 with SMTP id dw14mr9872573icc.23.1413178805071; Sun, 12 Oct 2014 22:40:05 -0700 (PDT) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id k66si675624yho.7.2014.10.12.22.40.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Oct 2014 22:40:05 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id UYeJlVbs.1; Sun, 12 Oct 2014 22:40:05 -0700 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 558EC220A6C; Sun, 12 Oct 2014 23:40:04 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 12 Oct 2014 23:39:28 -0600 Message-Id: <1413178778-30846-3-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1413178778-30846-1-git-send-email-sjg@chromium.org> References: <1413178778-30846-1-git-send-email-sjg@chromium.org> Cc: u-boot-review@google.com Subject: [U-Boot] [RFC PATCH 02/12] dm: core: Add functions to find parent and OF data X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add dev_get_parent() as a convenience to obtain the parent of a device. Signed-off-by: Simon Glass --- drivers/core/device.c | 5 +++++ include/dm/device.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/core/device.c b/drivers/core/device.c index 0d84776..76b29fd 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -549,6 +549,11 @@ int device_find_next_child(struct udevice **devp) return 0; } +struct udevice *dev_get_parent(struct udevice *child) +{ + return child->parent; +} + ulong dev_get_of_data(struct udevice *dev) { return dev->of_id->data; diff --git a/include/dm/device.h b/include/dm/device.h index a712156..e8b7fcf 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -202,6 +202,14 @@ void *dev_get_parentdata(struct udevice *dev); void *dev_get_priv(struct udevice *dev); /** + * struct dev_get_parent() - Get the parent of a device + * + * @child: Child to check + * @return parent of child, or NULL if this is the root device + */ +struct udevice *dev_get_parent(struct udevice *child); + +/** * dev_get_of_data() - get the device tree data used to bind a device * * When a device is bound using a device tree node, it matches a