From patchwork Fri Oct 6 05:30:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 822231 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 3y7dXT26rBz9t3m for ; Fri, 6 Oct 2017 16:31:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JPEsx4Nt"; 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 3y7dXT0xjJzDqlP for ; Fri, 6 Oct 2017 16:31:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JPEsx4Nt"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c05::241; helo=mail-pg0-x241.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JPEsx4Nt"; dkim-atps=neutral Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3y7dXN3XQYzDqks for ; Fri, 6 Oct 2017 16:31:00 +1100 (AEDT) Received: by mail-pg0-x241.google.com with SMTP id o1so16052287pga.4 for ; Thu, 05 Oct 2017 22:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zBK+osgDeyrvqpZ9N1qh+s3L0L+yNGDAe3BpErS0viQ=; b=JPEsx4NtAxltq0trJjVIV0w0avMtVBbIIxD1rTx86RZG8X29SbpuOPO5DczKmvRDlZ VuYLXSu4ISYn8l/Rvk22sK5NGJunRiz2Ex5YlaN7bnBh6uh3it5fR40Wu11U7ChyqHNu TfqyyMgzxKCJVI52Qmak6qnFAaApDnMvNZlV+ffiQlmIwlcraceIhiteo0fmltyuDEPZ 8rcMGOGYyky8nYmbqUhKcwgI4yt6wIarRt7nQEiBJb6JZM92H2B5y7rruUVGaiTFk7kV xAu37BovHH4Q1gTWYImwgvp6FN5Ed8CVoAsBlNJdt/PNRAjosY0t4crYA83BT1qQjUb4 loQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zBK+osgDeyrvqpZ9N1qh+s3L0L+yNGDAe3BpErS0viQ=; b=JlzDXVJgL0PZnFTyKhKWb1iOnuHvGGZ4bGzgbzmImjbArZ3BOyfQ3o6Er6xkLDl1yj fWtgnv4WNikgimXL0g1ktgZnYGIBnOMvprwbrUaX+DvBvKC1Ak+LLkFoQSfBS30V11TI K0GyJvSN0SJZN6saH09RDdQr5qqdoX/I3b9Lnd3kFZjU+voBIB9N/9bjqW/XaYRb/zbO AA5e/rzv+6HMwLcvtGQ2fD3UOsD00ZuqIFBbAQ4aQ/yCKiZ3UJy+EQroBpL1EbGxILZp d/ZeZBeVjYQahDHzSr2iuJfrPqm5ykZD3HWHtZ4QYuxxaTwZDF5G6fWC1+flhBRRl08d E0dw== X-Gm-Message-State: AMCzsaVdtVJOdXBPrKhjWZG4Gpv/6EhOZzO+louiViDgXK12HldhnXWQ n8DoETp2C9AngEG1WiEj1g/xAw== X-Google-Smtp-Source: AOwi7QAxrprnyfbMG1BYwpiXDvRHxOo5Au/5TagWeiDNP734V/WhqQm+UVmwlIPS26UrTsfAqm9kIA== X-Received: by 10.99.100.134 with SMTP id y128mr969537pgb.45.1507267858241; Thu, 05 Oct 2017 22:30:58 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id z89sm1067276pff.21.2017.10.05.22.30.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 22:30:57 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Fri, 6 Oct 2017 16:30:29 +1100 Message-Id: <20171006053029.1118-2-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171006053029.1118-1-oohall@gmail.com> References: <20171006053029.1118-1-oohall@gmail.com> Subject: [Skiboot] [RFC PATCH 2/2] EXAMPLE: Print full DT path when adding a node X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" An example of how to use the custom printf specifiers. In this case it will print out the full node path when adding a node to the device-tree, like so: [ 0.001493894,3] Added /ibm,opal to tree [ 0.001504982,3] Added /ibm,opal/event to tree [ 0.001512892,3] Added /ibm,opal/firmware to tree [ 0.001521920,3] Added /ibm,opal/firmware/exports to tree [ 0.001535936,3] Added /ibm,opal/power-mgt to tree Not-signed-off-by: Oliver O'Halloran --- core/device.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/device.c b/core/device.c index fc1db5689a73..44463a9398a5 100644 --- a/core/device.c +++ b/core/device.c @@ -153,6 +153,8 @@ struct dt_node *dt_new(struct dt_node *parent, const char *name) dt_destroy(new); return NULL; } + + prerror("Added %pD to tree\n", new); return new; } @@ -1107,3 +1109,24 @@ void dt_adjust_subtree_phandle(struct dt_node *dev, set_last_phandle(max_phandle); } + +static int print_dt_node_path(char **buffer, size_t bufsize, const void *value) +{ + char *path = dt_get_path(value); + char *into = *buffer; + int i; + + for (i = 0; path[i] && i < bufsize; i++) + into[i] = path[i]; + + *buffer += i; + free(path); + + /* return the number of characters added to the buffer */ + return i; +} + +DECLARE_PRINTFMT(dt_node_path) = { + .specifier = "D", + .func = &print_dt_node_path, +};