Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A92BC4338F for ; Thu, 29 Jul 2021 01:23:38 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A33976103A for ; Thu, 29 Jul 2021 01:23:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A33976103A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D4E882DDE; Thu, 29 Jul 2021 03:23:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Mg4/2o0F"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0D47882DDA; Thu, 29 Jul 2021 03:23:24 +0200 (CEST) Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1A00982D9C for ; Thu, 29 Jul 2021 03:23:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x230.google.com with SMTP id 21so6237285oin.8 for ; Wed, 28 Jul 2021 18:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K0eRk2iauxjYyHiGZEmKLDwGLzwuEQlcscZD/bf+H/s=; b=Mg4/2o0Fai4VPqevO0HR1xvYny4qNBMhM2eOIpR39xxL2Emcksn//SfLtqBKqAL+2E bhomvX4PABue6GKIL8rKl8uBiwHPY4OhN5YXoN21Fowrq3n6ANYd2zVyznfRFZGhdWEj H8jY0h5x9nF/yKi2pCgP3sAHEclsnhmTRroak= 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:mime-version:content-transfer-encoding; bh=K0eRk2iauxjYyHiGZEmKLDwGLzwuEQlcscZD/bf+H/s=; b=Zu8b3B/mdyM4ujQPJ/lyGdE7zuUW62WKKlabORgrRpNg1tH1IoDLipbzt78pcrB7Qd ARxKdBfzyuFbtnwmGCxb7BClXcOqKbD+KE9KJWVMprqc1UXmz9sPQtJG5WdIFXUU+IRZ nFCahHyLHQgMcWXO38x0wFpLRr3bCs//drOaLbNGflz+KSyXNT7BxaqBBR8Ka/GlQRIO 4+wtjbduNzcrDShAvrr3ScZp+hKsMNv5A4QIO2zoBW/N4bM15a+3B1AJHwKOu9V8sayf c0IR9tH1DQnOBBtB466HgEdrCqnsms64KNo7bPKhdiRhI2o/1ty/fcTpznQku4K0PcFn AZuw== X-Gm-Message-State: AOAM5329Zp13KzTnLj63GYhdOH8SBGmWXrvsayVipJZM2WQISY5i3hNk wk1L+5rWAIhserCGstt+cpVPz91OvMH//Bfn X-Google-Smtp-Source: ABdhPJxbGpDtof+15B7ts777iUR0EpYgN37YtVUiQZfsM0SfviUG4MRMarpISn7U25F4jDaS/WehFg== X-Received: by 2002:aca:4b8e:: with SMTP id y136mr8736594oia.48.1627521797083; Wed, 28 Jul 2021 18:23:17 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l11sm308867otf.1.2021.07.28.18.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 18:23:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH 1/3] dtoc: Rename is_wider_than() to reduce confusion Date: Wed, 28 Jul 2021 19:23:09 -0600 Message-Id: <20210729012311.1406847-2-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog In-Reply-To: <20210729012311.1406847-1-sjg@chromium.org> References: <20210729012311.1406847-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean The current name is confusing because the logic is actually backwards from what you might expect. Rename it to needs_widening() and update the comments. Signed-off-by: Simon Glass --- tools/dtoc/fdt.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 3996971e39c..9749966d5fb 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -24,16 +24,19 @@ from patman import tools # A list of types we support class Type(IntEnum): + # Types in order from widest to narrowest (BYTE, INT, STRING, BOOL, INT64) = range(5) - def is_wider_than(self, other): - """Check if another type is 'wider' than this one + def needs_widening(self, other): + """Check if this type needs widening to hold a value from another type - A wider type is one that holds more information than an earlier one, - similar to the concept of type-widening in C. + A wider type is one that can hold a wider array of information than + another one, or is less restrictive, so it can hold the information of + another type as well as its own. This is similar to the concept of + type-widening in C. This uses a simple arithmetic comparison, since type values are in order - from narrowest (BYTE) to widest (INT64). + from widest (BYTE) to narrowest (INT64). Args: other: Other type to compare against @@ -149,7 +152,7 @@ class Prop: update the current property to be like the second, since it is less specific. """ - if self.type.is_wider_than(newprop.type): + if self.type.needs_widening(newprop.type): if self.type == Type.INT and newprop.type == Type.BYTE: if type(self.value) == list: new_value = [] -- 2.32.0.432.gabb21c7263-goog