From patchwork Mon Apr 3 07:41:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maddy X-Patchwork-Id: 746290 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 3vxPGB2wmpz9s7r for ; Mon, 3 Apr 2017 17:42:42 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vxPGB2033zDqJ2 for ; Mon, 3 Apr 2017 17:42:42 +1000 (AEST) 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 3vxPFp2mpNzDq7Z for ; Mon, 3 Apr 2017 17:42:22 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v337Xx41142044 for ; Mon, 3 Apr 2017 03:42:10 -0400 Received: from e28smtp06.in.ibm.com (e28smtp06.in.ibm.com [125.16.236.6]) by mx0a-001b2d01.pphosted.com with ESMTP id 29kdr9x06u-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 03 Apr 2017 03:42:09 -0400 Received: from localhost by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Apr 2017 13:12:06 +0530 Received: from d28relay07.in.ibm.com (9.184.220.158) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 3 Apr 2017 13:12:04 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay07.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v337ejMZ10682584 for ; Mon, 3 Apr 2017 13:10:45 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v337g1vG009464 for ; Mon, 3 Apr 2017 13:12:02 +0530 Received: from SrihariSrinidhi.in.ibm.com ([9.79.210.235]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v337fxlr009412; Mon, 3 Apr 2017 13:12:01 +0530 From: Madhavan Srinivasan To: stewart@linux.vnet.ibm.com Date: Mon, 3 Apr 2017 13:11:38 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491205307-20408-1-git-send-email-maddy@linux.vnet.ibm.com> References: <1491205307-20408-1-git-send-email-maddy@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17040307-0020-0000-0000-000000DE7048 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17040307-0021-0000-0000-0000029D9FC9 Message-Id: <1491205307-20408-2-git-send-email-maddy@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-03_05:, , 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-1704030070 Subject: [Skiboot] [PATCH v8 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 76c2f8481b9f..170e0ee7bbb5 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,