From patchwork Mon Jun 19 07:05:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maddy X-Patchwork-Id: 777605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wrhqG2Q7dz9s71 for ; Mon, 19 Jun 2017 17:06:50 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wrhqG182RzDqhN for ; Mon, 19 Jun 2017 17:06:50 +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 3wrhpY0rTFzDqgY for ; Mon, 19 Jun 2017 17:06:12 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5J73xdE113982 for ; Mon, 19 Jun 2017 03:06:10 -0400 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by mx0b-001b2d01.pphosted.com with ESMTP id 2b64r22u8t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 19 Jun 2017 03:06:10 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 Jun 2017 17:06:07 +1000 Received: from d23relay07.au.ibm.com (202.81.31.226) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 19 Jun 2017 17:06:05 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v5J765nm262636 for ; Mon, 19 Jun 2017 17:06:05 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v5J763Yd029244 for ; Mon, 19 Jun 2017 17:06:04 +1000 Received: from localhost.localdomain (sriharisrinidhi.in.ibm.com [9.124.31.225] (may be forged)) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v5J75rF1028823; Mon, 19 Jun 2017 17:06:02 +1000 From: Madhavan Srinivasan To: stewart@linux.vnet.ibm.com Date: Mon, 19 Jun 2017 12:35:41 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497855947-11113-1-git-send-email-maddy@linux.vnet.ibm.com> References: <1497855947-11113-1-git-send-email-maddy@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17061907-1617-0000-0000-000001E7BD93 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17061907-1618-0000-0000-0000482E80A3 Message-Id: <1497855947-11113-4-git-send-email-maddy@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-19_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706190120 Subject: [Skiboot] [PATCH v13 3/9] 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. Acked-by: Michael Neuling 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 f3ee63fbc423..7211570e1b3c 100644 --- a/core/device.c +++ b/core/device.c @@ -57,7 +57,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 = new_phandle(); return node; } @@ -469,7 +469,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; + set_last_phandle(node->phandle); return NULL; } diff --git a/core/fdt.c b/core/fdt.c index eabbd5411a47..c62fb79e286f 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; + set_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; + set_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 5155daadc7ee..c51b3eea298e 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 set_last_phandle(u32 phandle) +{ + last_phandle = phandle; +} + +static inline u32 new_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,