From patchwork Thu Mar 9 05:08:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maddy X-Patchwork-Id: 736823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vdz2D6814z9sNg for ; Thu, 9 Mar 2017 16:08:52 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vdz2D5KcszDqXk for ; Thu, 9 Mar 2017 16:08:52 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@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 3vdz1r3yj8zDqXh for ; Thu, 9 Mar 2017 16:08:32 +1100 (AEDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v294wdW8059511 for ; Thu, 9 Mar 2017 00:08:22 -0500 Received: from e28smtp07.in.ibm.com (e28smtp07.in.ibm.com [125.16.236.7]) by mx0b-001b2d01.pphosted.com with ESMTP id 292havsx3p-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 09 Mar 2017 00:08:22 -0500 Received: from localhost by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Mar 2017 10:38:19 +0530 Received: from d28relay08.in.ibm.com (9.184.220.159) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Mar 2017 10:38:17 +0530 Received: from d28av07.in.ibm.com (d28av07.in.ibm.com [9.184.220.146]) by d28relay08.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v29578hG13631634 for ; Thu, 9 Mar 2017 10:37:08 +0530 Received: from d28av07.in.ibm.com (localhost [127.0.0.1]) by d28av07.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2958FHh021488 for ; Thu, 9 Mar 2017 10:38:16 +0530 Received: from SrihariSrinidhi.in.ibm.com (sriharisrinidhi.in.ibm.com [9.121.0.27]) by d28av07.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2958Etr021476; Thu, 9 Mar 2017 10:38:15 +0530 From: Madhavan Srinivasan To: stewart@linux.vnet.ibm.com Date: Thu, 9 Mar 2017 10:38:00 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489036089-6529-1-git-send-email-maddy@linux.vnet.ibm.com> References: <1489036089-6529-1-git-send-email-maddy@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17030905-0024-0000-0000-000003AFA6CF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030905-0025-0000-0000-0000112D04DB Message-Id: <1489036089-6529-2-git-send-email-maddy@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-09_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703090039 Subject: [Skiboot] [PATCH v7 01/10] dt: Add helper function for last_phandle updates X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, skiboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Add helper functions for "last_phandle" access/update and modify functions to use helper functions. Signed-off-by: Madhavan Srinivasan --- core/device.c | 4 ++-- core/fdt.c | 8 ++++---- include/device.h | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/device.c b/core/device.c index 30b31f461c45..1b9d2caf41ed 100644 --- a/core/device.c +++ b/core/device.c @@ -56,7 +56,7 @@ static struct dt_node *new_node(const char *name) list_head_init(&node->properties); list_head_init(&node->children); /* FIXME: locking? */ - node->phandle = ++last_phandle; + node->phandle = increment_return_last_phandle(); return node; } @@ -419,7 +419,7 @@ struct dt_property *dt_add_property(struct dt_node *node, assert(size == 4); node->phandle = *(const u32 *)val; if (node->phandle >= last_phandle) - last_phandle = node->phandle; + update_last_phandle(node->phandle); return NULL; } diff --git a/core/fdt.c b/core/fdt.c index eabbd5411a47..bc74b909f4b1 100644 --- a/core/fdt.c +++ b/core/fdt.c @@ -188,11 +188,11 @@ void *create_dtb(const struct dt_node *root, bool exclusive) { void *fdt = NULL; size_t len = DEVICE_TREE_MAX_SIZE; - uint32_t old_last_phandle = last_phandle; + uint32_t old_last_phandle = get_last_phandle(); int ret; do { - last_phandle = old_last_phandle; + update_last_phandle(old_last_phandle); fdt_error = 0; fdt = malloc(len); if (!fdt) { @@ -241,10 +241,10 @@ static int64_t opal_get_device_tree(uint32_t phandle, return OPAL_PARAMETER; fdt_error = 0; - old_last_phandle = last_phandle; + old_last_phandle = get_last_phandle(); ret = __create_dtb(fdt, len, root, true); if (ret) { - last_phandle = old_last_phandle; + update_last_phandle(old_last_phandle); if (ret == -FDT_ERR_NOSPACE) return OPAL_NO_MEM; diff --git a/include/device.h b/include/device.h index 1ad403f18450..f659675764df 100644 --- a/include/device.h +++ b/include/device.h @@ -61,6 +61,22 @@ struct dt_node *dt_new_root(const char *name); /* Graft a root node into this tree. */ bool dt_attach_root(struct dt_node *parent, struct dt_node *root); +/* Wrappers for last_phandle operations */ +static inline u32 get_last_phandle(void) +{ + return last_phandle; +} + +static inline void update_last_phandle(u32 phandle) +{ + last_phandle = phandle; +} + +static inline u32 increment_return_last_phandle(void) +{ + return ++last_phandle; +} + /* Add a child node. */ struct dt_node *dt_new(struct dt_node *parent, const char *name); struct dt_node *dt_new_addr(struct dt_node *parent, const char *name,