From patchwork Thu Oct 6 18:36:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reza Arbab X-Patchwork-Id: 679029 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 3sqhLB3pD4z9s2Q for ; Fri, 7 Oct 2016 05:40:50 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3sqhLB308szDsxW for ; Fri, 7 Oct 2016 05:40:50 +1100 (AEDT) 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 3sqhFX0lt6zDrSK for ; Fri, 7 Oct 2016 05:36:47 +1100 (AEDT) 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 u96IXW3V091761 for ; Thu, 6 Oct 2016 14:36:43 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 25wu5h2qwf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 06 Oct 2016 14:36:43 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Oct 2016 12:36:42 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 6 Oct 2016 12:36:38 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 23E233E40060; Thu, 6 Oct 2016 12:36:38 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u96Iabs315466902; Thu, 6 Oct 2016 11:36:37 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBF0778047; Thu, 6 Oct 2016 12:36:37 -0600 (MDT) Received: from arbab-laptop.localdomain (unknown [9.53.92.230]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id A8C477804D; Thu, 6 Oct 2016 12:36:37 -0600 (MDT) Received: by arbab-laptop.localdomain (Postfix, from userid 152845) id 73056460514; Thu, 6 Oct 2016 13:36:35 -0500 (CDT) From: Reza Arbab To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Rob Herring , Frank Rowand , Andrew Morton Subject: [PATCH v4 1/5] drivers/of: introduce of_fdt_device_is_available() Date: Thu, 6 Oct 2016 13:36:31 -0500 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1475778995-1420-1-git-send-email-arbab@linux.vnet.ibm.com> References: <1475778995-1420-1-git-send-email-arbab@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16100618-8235-0000-0000-00000958E899 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005864; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000186; SDB=6.00765136; UDB=6.00365562; IPR=6.00540998; BA=6.00004791; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012897; XFM=3.00000011; UTC=2016-10-06 18:36:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16100618-8236-0000-0000-0000356FD893 Message-Id: <1475778995-1420-2-git-send-email-arbab@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-06_08:, , 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-1609300000 definitions=main-1610060324 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-kernel@vger.kernel.org, Tang Chen , 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..b138efb 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_device_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_device_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_device_is_available(unsigned long node) +{ + return of_fdt_device_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..4ff8c8e 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_device_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_device_is_available(unsigned long node); extern unsigned long of_get_flat_dt_root(void); extern int of_get_flat_dt_size(void);