From patchwork Tue Aug 6 01:37:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142529 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 462chy6prXz9sN4 for ; Tue, 6 Aug 2019 11:38:10 +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 462chy4QcBzDqXW for ; Tue, 6 Aug 2019 11:38:10 +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 462chN23jnzDqWh for ; Tue, 6 Aug 2019 11:37:40 +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 462chM6dF3z9sN1; Tue, 6 Aug 2019 11:37:39 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:21 +1000 Message-Id: <20190806013723.4047-11-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 10/12] libpdbg: Make probe result matches the backend status 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" If a target has a backend assigned make sure the status reflects the status of the selected backend. Signed-off-by: Alistair Popple --- libpdbg/target.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index 73ad98f..d6604c2 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -402,15 +402,16 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) } /* At this point any parents must exist and have already been probed */ - if (target->probe && target->probe(target)) { - /* Could not find the target */ - assert(pdbg_target_status(target) != PDBG_TARGET_MUSTEXIST); + if (target->backend && target->backend->probe && target->backend->probe(target->backend)) + target->backend->status = target->status = PDBG_TARGET_NONEXISTENT; + else if (target->probe && target->probe(target)) target->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } + else + target->status = PDBG_TARGET_ENABLED; + + assert(target->status != PDBG_TARGET_NONEXISTENT && target->status != PDBG_TARGET_MUSTEXIST); - target->status = PDBG_TARGET_ENABLED; - return PDBG_TARGET_ENABLED; + return target->status; } /* Releases a target by first recursively releasing all its children */