From patchwork Fri Jul 6 16:27:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 940607 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 41MgLG0d1fz9s4V for ; Sat, 7 Jul 2018 02:34:46 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C0C8EC22055; Fri, 6 Jul 2018 16:32:51 +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 0C19FC21FB3; Fri, 6 Jul 2018 16:28:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 44FAAC22058; Fri, 6 Jul 2018 16:28:43 +0000 (UTC) Received: from mail-vk0-f73.google.com (mail-vk0-f73.google.com [209.85.213.73]) by lists.denx.de (Postfix) with ESMTPS id 27A66C22064 for ; Fri, 6 Jul 2018 16:28:39 +0000 (UTC) Received: by mail-vk0-f73.google.com with SMTP id q184-v6so4761518vke.23 for ; Fri, 06 Jul 2018 09:28:39 -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=/qWl0fzRqMsTgD5h5+HwOLH0sxAcw2MWzcOd4xMxJvI=; b=mWd5jNB7rgYGyOkfgdMRttsOXxI6unpPe8gZvvxy4SddGbhUNRX17WwNwgNVvw248m PTVCSB5XgC/kiH6gfAz9XB8tx+f3cjgZNEiRrUUyso1OuoukC9gdezEIV3qxW3QOd9GM twlAj25LtGMBpTqqRUim/0o9xpXhAe/ikC91tc4oyFyJn6ZEUMhvFWuD3gU2MWtgTDHs OgkRWfL0j9Cxrdfckh++frS6ZXhqfo4TClQKgxwYnDaHedixP4+LnNU4kbGVK2joyQGh E/So7PL6byjfrnV6V3Gci7k0o8ViMwAIlymSb8dyUL+HfaHpI34KXVb1H8gOY8G/ArCb KnBQ== X-Gm-Message-State: APt69E3tzTPg9G/QZ0c1muXYgCTJtxO7m0FK8jsEUUL5hnPtrwK+ddNS TrNZus/s/BYuSrpZ+O0b/Ym4Ukw= X-Google-Smtp-Source: AAOMgpfRZJ0aNENBkTS2eg9BIVfq0NEtCuVftrQmjMsfbv8I5q/+lo8chHmjXxVZ7WeUOc9vVjjM5i8= MIME-Version: 1.0 X-Received: by 2002:ab0:4ee0:: with SMTP id x32-v6mr4706566uah.41.1530894518299; Fri, 06 Jul 2018 09:28:38 -0700 (PDT) Date: Fri, 6 Jul 2018 10:27:31 -0600 In-Reply-To: <20180706162742.186950-1-sjg@chromium.org> Message-Id: <20180706162742.186950-19-sjg@chromium.org> References: <20180706162742.186950-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 v2 18/29] dtoc: Fix properties with a single zero-arg phandle 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 a property with a single phandle looks like an integer value to dtoc. Correct this by adjusting it in the phandle-processing code. Add a test for this. Signed-off-by: Simon Glass --- Changes in v2: - Update to cope with GetPhandle() being removed tools/dtoc/dtb_platdata.py | 12 ++++++++---- tools/dtoc/dtoc_test_phandle.dts | 6 ++++++ tools/dtoc/test_dtoc.py | 10 ++++++++++ tools/dtoc/test_fdt.py | 4 +++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py index 2f7302e529..b1323aef19 100644 --- a/tools/dtoc/dtb_platdata.py +++ b/tools/dtoc/dtb_platdata.py @@ -211,15 +211,21 @@ class DtbPlatdata(object): Number of argument cells is this is a phandle, else None """ if prop.name in ['clocks']: + if not isinstance(prop.value, list): + prop.value = [prop.value] val = prop.value - if not isinstance(val, list): - val = [val] i = 0 max_args = 0 args = [] while i < len(val): phandle = fdt_util.fdt32_to_cpu(val[i]) + # If we get to the end of the list, stop. This can happen + # since some nodes have more phandles in the list than others, + # but we allocate enough space for the largest list. So those + # nodes with shorter lists end up with zeroes at the end. + if not phandle: + break target = self._fdt.phandle_to_node.get(phandle) if not target: raise ValueError("Cannot parse '%s' in node '%s'" % @@ -400,8 +406,6 @@ class DtbPlatdata(object): continue info = self.get_phandle_argc(prop, node.name) if info: - if not isinstance(prop.value, list): - prop.value = [prop.value] # Process the list as pairs of (phandle, id) pos = 0 for args in info.args: diff --git a/tools/dtoc/dtoc_test_phandle.dts b/tools/dtoc/dtoc_test_phandle.dts index 91dfec5c63..a71acffc69 100644 --- a/tools/dtoc/dtoc_test_phandle.dts +++ b/tools/dtoc/dtoc_test_phandle.dts @@ -33,4 +33,10 @@ compatible = "source"; clocks = <&phandle &phandle_1 11 &phandle_2 12 13 &phandle>; }; + + phandle-source2 { + u-boot,dm-pre-reloc; + compatible = "source"; + clocks = <&phandle>; + }; }; diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 20fea522c4..11cac3fc7a 100644 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -323,6 +323,16 @@ U_BOOT_DEVICE(phandle_source) = { \t.platdata_size\t= sizeof(dtv_phandle_source), }; +static struct dtd_source dtv_phandle_source2 = { +\t.clocks\t\t\t= { +\t\t\t{&dtv_phandle_target, {}},}, +}; +U_BOOT_DEVICE(phandle_source2) = { +\t.name\t\t= "source", +\t.platdata\t= &dtv_phandle_source2, +\t.platdata_size\t= sizeof(dtv_phandle_source2), +}; + ''', data) def test_aliases(self): diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 9fef8ed549..49d188b1c1 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -210,7 +210,9 @@ class TestProp(unittest.TestCase): def testPhandle(self): dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts') - node = dtb.GetNode('/phandle-source') + node = dtb.GetNode('/phandle-source2') + prop = node.props['clocks'] + self.assertTrue(fdt32_to_cpu(prop.value) > 0) def _ConvertProp(self, prop_name): """Helper function to look up a property in self.node and return it