From patchwork Sat Mar 9 20:15:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2242291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 834113FCF6 for ; Sat, 9 Mar 2013 20:19:03 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UEQBb-0003Wu-FC; Sat, 09 Mar 2013 20:16:07 +0000 Received: from mail-we0-x229.google.com ([2a00:1450:400c:c03::229]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UEQBU-0003VP-Rm for linux-arm-kernel@lists.infradead.org; Sat, 09 Mar 2013 20:16:04 +0000 Received: by mail-we0-f169.google.com with SMTP id t11so2371771wey.28 for ; Sat, 09 Mar 2013 12:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=zyO+u3YOmzVRjCF76vUTDGlJkH2GZw0G4mbrnTA5DLo=; b=IXWIhZYuc5rPc4KZAjVWjRnJTBjOFoPHpTqI9u5v0xAIx4iJEbCJaJDnS0N2BuU7Ar 0CjG+WrmL2Ocjdxy1Nuzlu2i3m2XagA0k8OA6/Hq7oUlX6CC2wU9BIL17TnrxjdsHcHj mYcP6zSMvbLw5oQgldAYomLZzOtS3v4Mfx7mHO3551ZuLhoRKDvBvkjWU8dPf8Uq984p ZOefUIh19vELLlEHWzlBsvrvAUFEK1hY+sGkrszQBuhlCb+slJra1edzDk3BaqTm9BJS SGUK1U4qnR8bYEBtwRNIR2m8BwRygHhfkKfX/Hl6SQkPMdeGD0UI1BuevmgpQo0GHaA/ 91uQ== X-Received: by 10.194.77.129 with SMTP id s1mr11281677wjw.17.1362860158820; Sat, 09 Mar 2013 12:15:58 -0800 (PST) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPS id n10sm6871555wia.0.2013.03.09.12.15.57 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 09 Mar 2013 12:15:57 -0800 (PST) From: Tomasz Figa To: devicetree-discuss@lists.ozlabs.org Subject: [PATCH] of: Add missing node iteration stubs for disabled CONFIG_OF Date: Sat, 9 Mar 2013 21:15:54 +0100 Message-Id: <1362860154-3089-1-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.1.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130309_151602_830337_1BFAD693 X-CRM114-Status: GOOD ( 11.90 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomasz.figa[at]gmail.com) -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_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 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: grant.likely@secretlab.ca, Kukjin Kim , rob.herring@calxeda.com, linux-arm-kernel@lists.infradead.org, Tomasz Figa 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch moves several for_each macros out of the #ifdef CONFIG_OF block and adds inline stubs for functions used by these macros, compiled conditionally when CONFIG_OF is not enabled. This eliminates the need to explicitly check for CONFIG_OF in driver code using mentioned functions and macros. Signed-off-by: Tomasz Figa --- include/linux/of.h | 92 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 29 deletions(-) diff --git a/include/linux/of.h b/include/linux/of.h index a0f1292..7a736b8 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -86,6 +86,31 @@ static inline struct device_node *of_node_get(struct device_node *node) static inline void of_node_put(struct device_node *node) { } #endif /* !CONFIG_OF_DYNAMIC */ +#define for_each_node_by_name(dn, name) \ + for (dn = of_find_node_by_name(NULL, name); dn; \ + dn = of_find_node_by_name(dn, name)) +#define for_each_node_by_type(dn, type) \ + for (dn = of_find_node_by_type(NULL, type); dn; \ + dn = of_find_node_by_type(dn, type)) +#define for_each_compatible_node(dn, type, compatible) \ + for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ + dn = of_find_compatible_node(dn, type, compatible)) +#define for_each_matching_node(dn, matches) \ + for (dn = of_find_matching_node(NULL, matches); dn; \ + dn = of_find_matching_node(dn, matches)) +#define for_each_matching_node_and_match(dn, matches, match) \ + for (dn = of_find_matching_node_and_match(NULL, matches, match); \ + dn; dn = of_find_matching_node_and_match(dn, matches, match)) +#define for_each_child_of_node(parent, child) \ + for (child = of_get_next_child(parent, NULL); child != NULL; \ + child = of_get_next_child(parent, child)) +#define for_each_available_child_of_node(parent, child) \ + for (child = of_get_next_available_child(parent, NULL); child != NULL; \ + child = of_get_next_available_child(parent, child)) +#define for_each_node_with_property(dn, prop_name) \ + for (dn = of_find_node_with_property(NULL, prop_name); dn; \ + dn = of_find_node_with_property(dn, prop_name)) + #ifdef CONFIG_OF /* Pointer for first entry in chain of all nodes. */ @@ -167,19 +192,10 @@ static inline const char *of_node_full_name(const struct device_node *np) extern struct device_node *of_find_node_by_name(struct device_node *from, const char *name); -#define for_each_node_by_name(dn, name) \ - for (dn = of_find_node_by_name(NULL, name); dn; \ - dn = of_find_node_by_name(dn, name)) extern struct device_node *of_find_node_by_type(struct device_node *from, const char *type); -#define for_each_node_by_type(dn, type) \ - for (dn = of_find_node_by_type(NULL, type); dn; \ - dn = of_find_node_by_type(dn, type)) extern struct device_node *of_find_compatible_node(struct device_node *from, const char *type, const char *compat); -#define for_each_compatible_node(dn, type, compatible) \ - for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ - dn = of_find_compatible_node(dn, type, compatible)) extern struct device_node *of_find_matching_node_and_match( struct device_node *from, const struct of_device_id *matches, @@ -190,12 +206,6 @@ static inline struct device_node *of_find_matching_node( { return of_find_matching_node_and_match(from, matches, NULL); } -#define for_each_matching_node(dn, matches) \ - for (dn = of_find_matching_node(NULL, matches); dn; \ - dn = of_find_matching_node(dn, matches)) -#define for_each_matching_node_and_match(dn, matches, match) \ - for (dn = of_find_matching_node_and_match(NULL, matches, match); \ - dn; dn = of_find_matching_node_and_match(dn, matches, match)) extern struct device_node *of_find_node_by_path(const char *path); extern struct device_node *of_find_node_by_phandle(phandle handle); extern struct device_node *of_get_parent(const struct device_node *node); @@ -207,14 +217,6 @@ extern struct device_node *of_get_next_available_child( extern struct device_node *of_get_child_by_name(const struct device_node *node, const char *name); -#define for_each_child_of_node(parent, child) \ - for (child = of_get_next_child(parent, NULL); child != NULL; \ - child = of_get_next_child(parent, child)) - -#define for_each_available_child_of_node(parent, child) \ - for (child = of_get_next_available_child(parent, NULL); child != NULL; \ - child = of_get_next_available_child(parent, child)) - static inline int of_get_child_count(const struct device_node *np) { struct device_node *child; @@ -228,10 +230,6 @@ static inline int of_get_child_count(const struct device_node *np) extern struct device_node *of_find_node_with_property( struct device_node *from, const char *prop_name); -#define for_each_node_with_property(dn, prop_name) \ - for (dn = of_find_node_with_property(NULL, prop_name); dn; \ - dn = of_find_node_with_property(dn, prop_name)) - extern struct property *of_find_property(const struct device_node *np, const char *name, int *lenp); @@ -353,13 +351,28 @@ static inline struct device_node *of_find_node_by_name(struct device_node *from, return NULL; } +static inline struct device_node *of_find_node_by_type(struct device_node *from, + const char *type) +{ + return NULL; +} + static inline bool of_have_populated_dt(void) { return false; } -#define for_each_child_of_node(parent, child) \ - while (0) +static inline struct device_node *of_get_next_child(const struct device_node *node, + struct device_node *prev) +{ + return NULL; +} + +static inline struct device_node *of_get_next_available_child( + const struct device_node *node, struct device_node *prev) +{ + return NULL; +} static inline struct device_node *of_get_child_by_name( const struct device_node *node, @@ -373,6 +386,12 @@ static inline int of_get_child_count(const struct device_node *np) return 0; } +static inline struct device_node *of_find_node_with_property( + struct device_node *from, const char *prop_name) +{ + return NULL; +} + static inline int of_device_is_compatible(const struct device_node *device, const char *name) { @@ -394,6 +413,21 @@ static inline struct device_node *of_find_compatible_node( return NULL; } +static inline struct device_node *of_find_matching_node_and_match( + struct device_node *from, + const struct of_device_id *matches, + const struct of_device_id **match) +{ + return NULL; +} + +static inline struct device_node *of_find_matching_node( + struct device_node *from, + const struct of_device_id *matches) +{ + return NULL; +} + static inline int of_property_read_u8_array(const struct device_node *np, const char *propname, u8 *out_values, size_t sz) {