From patchwork Sun Sep 25 18:36:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reza Arbab X-Patchwork-Id: 674668 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3shwx92KMpz9s5g for ; Mon, 26 Sep 2016 04:44:13 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3shwx918TYzDrYb for ; Mon, 26 Sep 2016 04:44:13 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3shwn32vyRzDrM1 for ; Mon, 26 Sep 2016 04:37:11 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8PIXTOo036369 for ; Sun, 25 Sep 2016 14:37:09 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 25p6u0unu6-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 25 Sep 2016 14:37:08 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 25 Sep 2016 12:37:08 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 25 Sep 2016 12:37:03 -0600 Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id B712B3E40047; Sun, 25 Sep 2016 12:37:02 -0600 (MDT) Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8PIb2pG15663368; Sun, 25 Sep 2016 18:37:02 GMT Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id 4908C112047; Sun, 25 Sep 2016 14:37:02 -0400 (EDT) X-IMSS-HAND-OFF-DIRECTIVE: 127.0.0.1:10026 Received: from arbab-laptop.localdomain (unknown [9.85.160.160]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 9AF93112040; Sun, 25 Sep 2016 14:36:58 -0400 (EDT) Received: by arbab-laptop.localdomain (Postfix, from userid 152845) id B54C6460527; Sun, 25 Sep 2016 13:36:56 -0500 (CDT) From: Reza Arbab To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Rob Herring , Frank Rowand , Jonathan Corbet , Andrew Morton Subject: [PATCH v3 1/5] drivers/of: introduce of_fdt_is_available() Date: Sun, 25 Sep 2016 13:36:52 -0500 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1474828616-16608-1-git-send-email-arbab@linux.vnet.ibm.com> References: <1474828616-16608-1-git-send-email-arbab@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16092518-0020-0000-0000-000009E07D37 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005813; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000185; SDB=6.00761240; UDB=6.00362465; IPR=6.00536057; BA=6.00004754; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012779; XFM=3.00000011; UTC=2016-09-25 18:37:06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16092518-0021-0000-0000-000055E9AA00 Message-Id: <1474828616-16608-2-git-send-email-arbab@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-25_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609250356 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stewart Smith , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alistair Popple , "Aneesh Kumar K.V" , Bharata B Rao , Nathan Fontenot , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" In __fdt_scan_reserved_mem(), the availability of a node is determined by testing its "status" property. Move this check into its own function, borrowing logic from the unflattened version, of_device_is_available(). Another caller will be added in a subsequent patch. Signed-off-by: Reza Arbab Acked-by: Rob Herring --- drivers/of/fdt.c | 26 +++++++++++++++++++++++--- include/linux/of_fdt.h | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 085c638..9241c6e 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -151,6 +151,23 @@ int of_fdt_match(const void *blob, unsigned long node, return score; } +bool of_fdt_is_available(const void *blob, unsigned long node) +{ + const char *status; + int statlen; + + status = fdt_getprop(blob, node, "status", &statlen); + if (!status) + return true; + + if (statlen) { + if (!strcmp(status, "okay") || !strcmp(status, "ok")) + return true; + } + + return false; +} + static void *unflatten_dt_alloc(void **mem, unsigned long size, unsigned long align) { @@ -647,7 +664,6 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, int depth, void *data) { static int found; - const char *status; int err; if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) { @@ -667,8 +683,7 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, return 1; } - status = of_get_flat_dt_prop(node, "status", NULL); - if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0) + if (!of_flat_dt_is_available(node)) return 0; err = __reserved_mem_reserve_reg(node, uname); @@ -809,6 +824,11 @@ int __init of_flat_dt_match(unsigned long node, const char *const *compat) return of_fdt_match(initial_boot_params, node, compat); } +bool __init of_flat_dt_is_available(unsigned long node) +{ + return of_fdt_is_available(initial_boot_params, node); +} + struct fdt_scan_status { const char *name; int namelen; diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 26c3302..49e0b8f 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -37,6 +37,7 @@ extern bool of_fdt_is_big_endian(const void *blob, unsigned long node); extern int of_fdt_match(const void *blob, unsigned long node, const char *const *compat); +extern bool of_fdt_is_available(const void *blob, unsigned long node); extern void *of_fdt_unflatten_tree(const unsigned long *blob, struct device_node *dad, struct device_node **mynodes); @@ -59,6 +60,7 @@ extern const void *of_get_flat_dt_prop(unsigned long node, const char *name, int *size); extern int of_flat_dt_is_compatible(unsigned long node, const char *name); extern int of_flat_dt_match(unsigned long node, const char *const *matches); +extern bool of_flat_dt_is_available(unsigned long node); extern unsigned long of_get_flat_dt_root(void); extern int of_get_flat_dt_size(void);