From patchwork Mon Oct 19 02:41:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1383954 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=PlaJ2yva; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4CF1Jg3s3Yz9sSG for ; Mon, 19 Oct 2020 13:42:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F11282429; Mon, 19 Oct 2020 04:42:04 +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="PlaJ2yva"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4CEEC823E0; Mon, 19 Oct 2020 04:41:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 307698236F for ; Mon, 19 Oct 2020 04:41:51 +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-io1-xd44.google.com with SMTP id u19so11334694ion.3 for ; Sun, 18 Oct 2020 19:41:51 -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=RaPkjFcn/49WXb8FQG0WHW+lYSv+dXYjEvO4eclAQd0=; b=PlaJ2yvaHLtxRyvOfbL5UdPVi/pmF3I8AEo48AHuzCGFlxMmRU9PSueTqmKPWLJ5MI YMk4jv/v9iWiI4RF4+dKDVjTkagudgk4IVIiNqykiVc0w824ZaEXWxtMJnHkKECgP71+ chAPskvbnmSp94yq2pWDZySb5qpme86ecxD3U= 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=RaPkjFcn/49WXb8FQG0WHW+lYSv+dXYjEvO4eclAQd0=; b=XHVwC7KJcJE2AFdAjVFZYsgJNED+w9z2uFTX/Xl41YWRUhWmocay/jE1xzOCIuOJCd uqNtfjjmM1WDlVXq+0sgmByvCa66+Ihndw/fTs3UXHEJKjTOnflmY17TNMvA4dQYETv1 /3ZrML0n8NlPaz6W8E55JKBno2Yg9+9eYS8Dis64CdrYwZKcb075X9xMalYd39dBwD7y ZC0rCsgjoxA85gZC9HD8e57wTuKsZ1nN36xlEIS0dw8S/Lo4xt4RtX/shKhAPp6Jb/7z 6ariyVzQb4HGQ9Q26iyQmDfQcWKrGTs2sCiOxU3RL8SYr/D5m6YrWqY+TXg+U5o2CvEe cMAA== X-Gm-Message-State: AOAM532Ibt6vUcmCuW6Wwtu8Q6CZVC7bAVwERE8uVR1WMU/NKOHgOitA K/7bEgpSukwOOXU/gp8zP/iOvqZQJ1JaVt82 X-Google-Smtp-Source: ABdhPJwdXEiMCxhkPBBlkprAGWen4bkF/hNEOSx/kYjNvJBLRK71LrgstRW0KhzJH5wY3R0+a5wqaQ== X-Received: by 2002:a02:cce6:: with SMTP id l6mr9939818jaq.32.1603075309930; Sun, 18 Oct 2020 19:41:49 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id g185sm9750871ilh.35.2020.10.18.19.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2020 19:41:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andy Shevchenko , Bin Meng Subject: [PATCH 05/25] binman: Move CompressData() into Entry base class Date: Sun, 18 Oct 2020 20:41:18 -0600 Message-Id: <20201018204115.5.Ic9d88753747c0ece1716ee5b006c38282fc6f040@changeid> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201019024138.3804540-1-sjg@chromium.org> References: <20201019024138.3804540-1-sjg@chromium.org> MIME-Version: 1.0 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present this is only used by blobs. To allow it to be used by other entry types (such as sections), move it into the base class. Also read the compression type in the base class. Signed-off-by: Simon Glass --- tools/binman/entry.py | 17 +++++++++++++++++ tools/binman/etype/blob.py | 7 ------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index f7adc3b1abb..173c9131cbb 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -180,6 +180,9 @@ class Entry(object): self.expand_size = fdt_util.GetBool(self._node, 'expand-size') self.missing_msg = fdt_util.GetString(self._node, 'missing-msg') + # This is only supported by blobs and sections at present + self.compress = fdt_util.GetString(self._node, 'compress', 'none') + def GetDefaultFilename(self): return None @@ -836,3 +839,17 @@ features to produce new behaviours. list of possible tags, most desirable first """ return list(filter(None, [self.missing_msg, self.name, self.etype])) + + def CompressData(self, indata): + """Compress data according to the entry's compression method + + Args: + indata: Data to compress + + Returns: + Compressed data (first word is the compressed size) + """ + if self.compress != 'none': + self.uncomp_size = len(indata) + data = tools.Compress(indata, self.compress) + return data diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py index ecfb1e476e8..301ac55e3b2 100644 --- a/tools/binman/etype/blob.py +++ b/tools/binman/etype/blob.py @@ -33,7 +33,6 @@ class Entry_blob(Entry): def __init__(self, section, etype, node): super().__init__(section, etype, node) self._filename = fdt_util.GetString(self._node, 'filename', self.etype) - self.compress = fdt_util.GetString(self._node, 'compress', 'none') def ObtainContents(self): self._filename = self.GetDefaultFilename() @@ -48,12 +47,6 @@ class Entry_blob(Entry): self.ReadBlobContents() return True - def CompressData(self, indata): - if self.compress != 'none': - self.uncomp_size = len(indata) - data = tools.Compress(indata, self.compress) - return data - def ReadBlobContents(self): """Read blob contents into memory