From patchwork Tue Aug 6 01:37:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142528 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.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 462chw5j6kz9sN4 for ; Tue, 6 Aug 2019 11:38:08 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chw3LmRzDqXT for ; Tue, 6 Aug 2019 11:38:08 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (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 462chM25CCzDqXC for ; Tue, 6 Aug 2019 11:37:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au 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 ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chL72dbz9sN6; Tue, 6 Aug 2019 11:37:38 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:20 +1000 Message-Id: <20190806013723.4047-10-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 09/12] libpdbg: Initialise target class from device-tree 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@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" The target class is usually initialised from the hardware unit description. However if no hardware unit is found no class is assigned. This patch makes it possible to assign one in cases when no hardware unit is available. This is primarily useful for busses and other targets that have drivers assigned via the backend selection logic. Signed-off-by: Alistair Popple Reviewed-by: Amitay Isaacs --- libpdbg/device.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libpdbg/device.c b/libpdbg/device.c index f6d27db..428d946 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -118,6 +118,8 @@ static struct pdbg_target *pdbg_target_new(const void *fdt, int node_offset) static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int node_offset) { + struct pdbg_target_class *target_class; + const struct fdt_property *prop; struct pdbg_target *node = NULL; size_t size = sizeof(*node); @@ -132,6 +134,15 @@ static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int no abort(); } + if (fdt && !node->class) { + prop = fdt_get_property(fdt, node_offset, "class", NULL); + if (prop) { + node->class = (char *) &prop->data[0]; + target_class = get_target_class(node); + list_add_tail(&target_class->targets, &node->class_link); + } + } + node->dn_name = take_name(name); node->parent = NULL; list_head_init(&node->properties);