From patchwork Mon Apr 28 17:57:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 29259 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3CD5E20553 for ; Mon, 28 Apr 2014 17:59:48 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id hz1sf14022501pad.0 for ; Mon, 28 Apr 2014 10:59:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=hCtI5bp0l2axZt+VVpubyauc0ERc827Khi2fo1RW3Dc=; b=IR0O1WJvD6gEhQYf0wpOFOBr9hVnHZRUzxs/wu2pRRog+nrA8cDZq9jZf6gem6lfZt Avp1wGyiFnoxGgaAHIdN7x8fLwaimce37mIE4OhGoLZUe+qTdYYlvIy/jzxjVxOlGo+A qEKFRf2tGHzsQHq9qZjkUjJWq/67qo4azUL1E0jVZXvS4h/z+ShbzSoLnKL6onJcjm3M ikXLnKHfG+phshQFZ9Laxx6XEyuwtWcQH44bbfkrTPBjjBfVhfOa4v0Vrk17ps+LaAnF OW8TaWd0WLwiETJLFV3SNoLXAJPcwKFxmccJ3llbtwwozFyU0RAnyJc5t6SzqrLq4xmO xfQw== X-Gm-Message-State: ALoCoQm/SMmtY2Ro3SfQ96WEEjViByJNckThDGu3qF4t20H2YSRnTMKqI4B8TEs8o7AV7wRIvnwH X-Received: by 10.68.133.75 with SMTP id pa11mr13629318pbb.2.1398707986926; Mon, 28 Apr 2014 10:59:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.145 with SMTP id 17ls1240768qgn.21.gmail; Mon, 28 Apr 2014 10:59:46 -0700 (PDT) X-Received: by 10.58.55.170 with SMTP id t10mr2672297vep.29.1398707986715; Mon, 28 Apr 2014 10:59:46 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id ru8si3827988vcb.29.2014.04.28.10.59.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Apr 2014 10:59:46 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id lc6so8591965vcb.35 for ; Mon, 28 Apr 2014 10:59:46 -0700 (PDT) X-Received: by 10.58.179.115 with SMTP id df19mr1335734vec.41.1398707986527; Mon, 28 Apr 2014 10:59:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp136017vcb; Mon, 28 Apr 2014 10:59:46 -0700 (PDT) X-Received: by 10.224.16.69 with SMTP id n5mr35261380qaa.7.1398707986024; Mon, 28 Apr 2014 10:59:46 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id a1si8208196qar.74.2014.04.28.10.59.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Apr 2014 10:59:46 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wepov-00033k-Oq; Mon, 28 Apr 2014 17:58:25 +0000 Received: from fw-tnat.austin.arm.com ([217.140.110.23] helo=collaborate-mta1.arm.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wepor-0002y5-L3 for linux-arm-kernel@lists.infradead.org; Mon, 28 Apr 2014 17:58:21 +0000 Received: from hornet.Cambridge.Arm.com (hornet.cambridge.arm.com [10.2.201.45]) by collaborate-mta1.arm.com (Postfix) with ESMTP id 158A013FD9D; Mon, 28 Apr 2014 12:57:59 -0500 (CDT) From: Pawel Moll To: Grant Likely , Rob Herring , Samuel Ortiz , Lee Jones , Arnd Bergmann , Greg Kroah-Hartman , Russell King Subject: [PATCH 01/10] of: Keep track of populated platform devices Date: Mon, 28 Apr 2014 18:57:48 +0100 Message-Id: <1398707877-22596-2-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1398707877-22596-1-git-send-email-pawel.moll@arm.com> References: <1398707877-22596-1-git-send-email-pawel.moll@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140428_105821_734606_C47C82FF X-CRM114-Status: GOOD ( 13.17 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record Cc: devicetree@vger.kernel.org, arm@kernel.org, Pawel Moll , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pawel.moll@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In "Device Tree powered" systems, platform devices are usually massively populated with of_platform_populate() call, executed at some level of initcalls, either by generic architecture or by platform-specific code. There are situations though where certain devices must be created (and bound with drivers) before all the others. This presents a challenge, as devices created explicitly would be created again by of_platform_populate(). This patch tries to solve that issue in a generic way, adding a "populated" flag for a DT node description. Once set, this device will never be created again via of_* API, so of_platform_populate() will skip such nodes (and its children) in a similar way to the non-available ones. Cc: devicetree@vger.kernel.org Signed-off-by: Pawel Moll --- drivers/of/platform.c | 10 ++++++++-- include/linux/of.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 404d1da..0ae757a 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -204,7 +204,8 @@ static struct platform_device *of_platform_device_create_pdata( { struct platform_device *dev; - if (!of_device_is_available(np)) + if (!of_device_is_available(np) || + of_node_check_flag(np, OF_POPULATED)) return NULL; dev = of_device_alloc(np, bus_id, parent); @@ -230,6 +231,8 @@ static struct platform_device *of_platform_device_create_pdata( return NULL; } + of_node_set_flag(np, OF_POPULATED); + return dev; } @@ -262,7 +265,8 @@ static struct amba_device *of_amba_device_create(struct device_node *node, pr_debug("Creating amba device %s\n", node->full_name); - if (!of_device_is_available(node)) + if (!of_device_is_available(node) || + of_node_check_flag(node, OF_POPULATED)) return NULL; dev = amba_device_alloc(NULL, 0, 0); @@ -305,6 +309,8 @@ static struct amba_device *of_amba_device_create(struct device_node *node, goto err_free; } + of_node_set_flag(node, OF_POPULATED); + return dev; err_free: diff --git a/include/linux/of.h b/include/linux/of.h index 3bad8d1..fd3aaee 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -197,6 +197,7 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) /* flag descriptions */ #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ #define OF_DETACHED 2 /* node has been detached from the device tree */ +#define OF_POPULATED 3 /* device already created for the node */ #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)