From patchwork Wed Jan 15 05:18:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1223181 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47yFy45bczz9sRm for ; Wed, 15 Jan 2020 16:19:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=wo4tNGHD; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47yFy447SnzDqJt for ; Wed, 15 Jan 2020 16:19:56 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47yFxM2k1mzDqDl for ; Wed, 15 Jan 2020 16:19:19 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=wo4tNGHD; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 47yFxM0KFnz9sNx; Wed, 15 Jan 2020 16:19:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1579065559; bh=8KCpcMrKySd0KuiJlt9WFxgF7JWZH8xQ29OmOF0sMhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wo4tNGHDEsauLVfv/qSOcNJNXxRY1bbBpa8kWbemXW33T40oQ+FTTcRoLNMFb2Ujp V3Oxo7/aR0f3qhofsh/Omf7qLEOUYjuQ8OaL6rnAwsjsX/bfCi62ADv8HkCd4toRES PoWSqlrzLVXICWmMHUsjKHoLIif525/ciF2t8k98IOyLkr/iq9r4xr5Z84kll+ZgnQ oJuAFXKXC2lJAX/uzaJpED2Mf2V94olVuY+vcOxarO2+HDx0xhCQwwrrv/Vyk3c76I e6g5q3ti3dYaoGwJ+Iw6IoVIJlUQYFKCogWLwPYfpnWIjZRLqr6CidLFkogUCYtLCR w88ZgOrrJen5g== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Wed, 15 Jan 2020 16:18:55 +1100 Message-Id: <20200115051901.17514-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200115051901.17514-1-amitay@ozlabs.org> References: <20200115051901.17514-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 07/13] libpdbg: Do not store properties in linked list X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" ... instead the properties will be accessed directly from the device tree. dt_add_property(), in addition to adding properties to a linked list, assigned value to phandle if defined in device tree. So change the name of the function to reflect the functionality. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 54 +++--------------------------------------------- 1 file changed, 3 insertions(+), 51 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 91ad258..c5fdc4e 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -331,40 +331,9 @@ static struct dt_property *dt_find_property(const struct pdbg_target *node, return NULL; } -static struct dt_property *new_property(struct pdbg_target *node, - const char *name, size_t size) +static void dt_add_phandle(struct pdbg_target *node, const char *name, + const void *val, size_t size) { - struct dt_property *p = malloc(sizeof(*p) + size); - char *path; - - if (!p) { - path = dt_get_path(node); - prerror("Failed to allocate property \"%s\" for %s of %zu bytes\n", - name, path, size); - free(path); - abort(); - } - if (dt_find_property(node, name)) { - path = dt_get_path(node); - prerror("Duplicate property \"%s\" in node %s\n", - name, path); - free(path); - abort(); - - } - - p->name = take_name(name); - p->len = size; - list_add_tail(&node->properties, &p->list); - return p; -} - -static struct dt_property *dt_add_property(struct pdbg_target *node, - const char *name, - const void *val, size_t size) -{ - struct dt_property *p; - /* * Filter out phandle properties, we re-generate them * when flattening @@ -375,13 +344,7 @@ static struct dt_property *dt_add_property(struct pdbg_target *node, node->phandle = *(const u32 *)val; if (node->phandle >= last_phandle) last_phandle = node->phandle; - return NULL; } - - p = new_property(node, name, size); - if (size) - memcpy(p->prop, val, size); - return p; } bool pdbg_target_set_property(struct pdbg_target *target, const char *name, const void *val, size_t size) @@ -573,7 +536,7 @@ static int dt_expand_node(struct pdbg_target *node, void *fdt, int fdt_node) if (strcmp("status", name) == 0) node->status = str_to_status(prop->data); - dt_add_property(node, name, prop->data, + dt_add_phandle(node, name, prop->data, fdt32_to_cpu(prop->len)); break; case FDT_BEGIN_NODE: @@ -684,19 +647,8 @@ static struct pdbg_target *dt_new_virtual(struct pdbg_target *root, const char * static void dt_link_virtual(struct pdbg_target *node, struct pdbg_target *vnode) { - struct dt_property *prop = NULL, *next; - node->vnode = vnode; vnode->vnode = node; - - /* Move any properties on virtual node to real node */ - list_for_each_safe(&vnode->properties, prop, next, list) { - if (!strcmp(prop->name, "#address-cells") || !strcmp(prop->name, "#size-cells")) - continue; - - list_del(&prop->list); - list_add_tail(&node->properties, &prop->list); - } } static void pdbg_targets_init_virtual(struct pdbg_target *node, struct pdbg_target *root)