From patchwork Tue Jul 17 19:25:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 945289 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41VW0v6NJZz9s0w for ; Wed, 18 Jul 2018 05:43:27 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 99EABC21C27; Tue, 17 Jul 2018 19:43:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7898AC21EC2; Tue, 17 Jul 2018 19:27:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 621F4C21E0B; Tue, 17 Jul 2018 19:27:08 +0000 (UTC) Received: from mail-yw0-f201.google.com (mail-yw0-f201.google.com [209.85.161.201]) by lists.denx.de (Postfix) with ESMTPS id 40E36C21F89 for ; Tue, 17 Jul 2018 19:26:54 +0000 (UTC) Received: by mail-yw0-f201.google.com with SMTP id z200-v6so1078906ywd.22 for ; Tue, 17 Jul 2018 12:26:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=uBTNqHQJhrDeB5vl6I8QKC5DnXx9NYlvPN9hDiq1dZg=; b=UpNufJexI6gnsDt5Wo2llCFALvTDVzJGKp53F5+g4kcKvvK0elxeCSXus4X76HDw29 mz6rzeuCJ64LWEPBGO6ILtWv1IWRkBUl52ZsLaPdnpk2O9qko1fiKcUCuyDKO+kv+PZp EkqWFBEEO0mPfBeZ56R5q1SptgpCuG7dA8hl98S23b9BXaGp1vrqJEwxzLxEfGFoa8Qo WPXcS6qL/R95bs7cjkEK4KPmrgZEag9JnBNaZudzgUQeGd4X2bIbNoMf4pRV+YpBFC9w 6I9RDeDQW8+dYWSeX3ElA98mkfRImAWidK5Aotc3f2hk4oHbKtEacrJzmu4hzyphcRD7 fnpQ== X-Gm-Message-State: AOUpUlFIukLfIANy8Pm5iw868Ck/xGNMFrcpE0CiRdN5UZic0wuqVBh9 98ihSc0U+iZ7uNjxuRH+xLP/6vE= X-Google-Smtp-Source: AAOMgpcUfGKddvgoDl6Q4PW9l26QhmlzB4t6l6ltuLe6+sgikJiA3PRTMxVS48ZTupy7bYG45TUnpOA= MIME-Version: 1.0 X-Received: by 2002:a81:328f:: with SMTP id y137-v6mr920992ywy.148.1531855613361; Tue, 17 Jul 2018 12:26:53 -0700 (PDT) Date: Tue, 17 Jul 2018 13:25:52 -0600 In-Reply-To: <20180717192552.198496-1-sjg@chromium.org> Message-Id: <20180717192552.198496-30-sjg@chromium.org> References: <20180717192552.198496-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH 29/29] binman: Adjust _GetPropTree() parameters X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present this function takes a filename, but it is better to use an Fdt object so that the caller can control this, perhaps obtainint the device tree from a bytearray. Update the method accordingly and also fix a confusing parameter name. Signed-off-by: Simon Glass --- tools/binman/ftest.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 3d5f23558c..a8456c2615 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -353,21 +353,19 @@ class TestFunctional(unittest.TestCase): """ return struct.unpack('>L', dtb[4:8])[0] - def _GetPropTree(self, dtb_data, node_names): + def _GetPropTree(self, dtb, prop_names): def AddNode(node, path): if node.name != '/': path += '/' + node.name for subnode in node.subnodes: for prop in subnode.props.values(): - if prop.name in node_names: + if prop.name in prop_names: prop_path = path + '/' + subnode.name + ':' + prop.name tree[prop_path[len('/binman/'):]] = fdt_util.fdt32_to_cpu( prop.value) AddNode(subnode, path) tree = {} - dtb = fdt.Fdt(dtb_data) - dtb.Scan() AddNode(dtb.GetRoot(), '') return tree @@ -1092,11 +1090,9 @@ class TestFunctional(unittest.TestCase): """Test that we can update the device tree with offset/size info""" _, _, _, out_dtb_fname = self._DoReadFileDtb('60_fdt_update.dts', update_dtb=True) - props = self._GetPropTree(out_dtb_fname, ['offset', 'size', - 'image-pos']) - with open('/tmp/x.dtb', 'wb') as outf: - with open(out_dtb_fname) as inf: - outf.write(inf.read()) + dtb = fdt.Fdt(out_dtb_fname) + dtb.Scan() + props = self._GetPropTree(dtb, ['offset', 'size', 'image-pos']) self.assertEqual({ 'image-pos': 0, 'offset': 0,