diff mbox series

[3/5] patman: Drop tools.ToByte()

Message ID 20201108203544.3.Icc8023906909d30898cb739c32ae7e2c2ded8b1a@changeid
State Accepted
Commit 6a4ccad8e0cb42d53ff7016c1d9cd53b87e4347a
Delegated to: Simon Glass
Headers show
Series patman: Tidy up some hangovers from Python 2 | expand

Commit Message

Simon Glass Nov. 9, 2020, 3:36 a.m. UTC
This is not needed in Python 3. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/elf.py        |  6 +++---
 tools/dtoc/dtb_platdata.py |  2 +-
 tools/patman/tools.py      | 15 ---------------
 3 files changed, 4 insertions(+), 19 deletions(-)

Comments

Simon Glass Dec. 10, 2020, 12:27 a.m. UTC | #1
This is not needed in Python 3. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/elf.py        |  6 +++---
 tools/dtoc/dtb_platdata.py |  2 +-
 tools/patman/tools.py      | 15 ---------------
 3 files changed, 4 insertions(+), 19 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 5e566e56cbf..249074a334a 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -158,9 +158,9 @@  def MakeElf(elf_fname, text, data):
 
     # Spilt the text into two parts so that we can make the entry point two
     # bytes after the start of the text section
-    text_bytes1 = ['\t.byte\t%#x' % tools.ToByte(byte) for byte in text[:2]]
-    text_bytes2 = ['\t.byte\t%#x' % tools.ToByte(byte) for byte in text[2:]]
-    data_bytes = ['\t.byte\t%#x' % tools.ToByte(byte) for byte in data]
+    text_bytes1 = ['\t.byte\t%#x' % byte for byte in text[:2]]
+    text_bytes2 = ['\t.byte\t%#x' % byte for byte in text[2:]]
+    data_bytes = ['\t.byte\t%#x' % byte for byte in data]
     with open(s_file, 'w') as fd:
         print('''/* Auto-generated C program to produce an ELF file for testing */
 
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index ee98010423c..0ef245397a9 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -110,7 +110,7 @@  def get_value(ftype, value):
         return '%#x' % fdt_util.fdt32_to_cpu(value)
     elif ftype == fdt.Type.BYTE:
         ch = value[0]
-        return '%#x' % ord(ch) if type(ch) == str else ch
+        return '%#x' % (ord(ch) if type(ch) == str else ch)
     elif ftype == fdt.Type.STRING:
         # Handle evil ACPI backslashes by adding another backslash before them.
         # So "\\_SB.GPO0" in the device tree effectively stays like that in C
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 55ba1e9c985..7cd58031e78 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -423,21 +423,6 @@  def GetBytes(byte, size):
     """
     return bytes([byte]) * size
 
-def ToByte(ch):
-    """Convert a character to an ASCII value
-
-    This is useful because in Python 2 bytes is an alias for str, but in
-    Python 3 they are separate types. This function converts the argument to
-    an ASCII value in either case.
-
-    Args:
-        ch: A string (Python 2) or byte (Python 3) value
-
-    Returns:
-        integer ASCII value for ch
-    """
-    return ord(ch) if type(ch) == str else ch
-
 def ToChar(byte):
     """Convert a byte to a character