aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/elf.py6
-rw-r--r--tools/binman/etype/fmap.py2
-rw-r--r--tools/binman/fdt_test.py14
-rw-r--r--tools/binman/fmap_util.py3
-rw-r--r--tools/dtoc/dtb_platdata.py185
-rw-r--r--tools/dtoc/fdt.py58
-rwxr-xr-xtools/dtoc/test_dtoc.py142
-rwxr-xr-xtools/dtoc/test_fdt.py34
-rw-r--r--tools/patman/func_test.py13
-rw-r--r--tools/patman/gitutil.py3
-rw-r--r--tools/patman/series.py4
-rw-r--r--tools/patman/settings.py5
-rw-r--r--tools/patman/test_checkpatch.py28
-rw-r--r--tools/patman/tools.py85
14 files changed, 279 insertions, 303 deletions
diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 5e566e56cb..249074a334 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/binman/etype/fmap.py b/tools/binman/etype/fmap.py
index 3e9b815d11..fe81c6f64a 100644
--- a/tools/binman/etype/fmap.py
+++ b/tools/binman/etype/fmap.py
@@ -52,7 +52,7 @@ class Entry_fmap(Entry):
if pos is not None:
pos -= entry.section.GetRootSkipAtStart()
areas.append(fmap_util.FmapArea(pos or 0, entry.size or 0,
- tools.FromUnicode(entry.name), 0))
+ entry.name, 0))
entries = self.GetImage().GetEntries()
areas = []
diff --git a/tools/binman/fdt_test.py b/tools/binman/fdt_test.py
index c491d40e9e..3e12540f62 100644
--- a/tools/binman/fdt_test.py
+++ b/tools/binman/fdt_test.py
@@ -50,37 +50,37 @@ class TestFdt(unittest.TestCase):
self.assertEquals('me.bin', val)
prop = node.props['intval']
- self.assertEquals(fdt.TYPE_INT, prop.type)
+ self.assertEquals(fdt.Type.INT, prop.type)
self.assertEquals(3, fdt_util.GetInt(node, 'intval'))
prop = node.props['intarray']
- self.assertEquals(fdt.TYPE_INT, prop.type)
+ self.assertEquals(fdt.Type.INT, prop.type)
self.assertEquals(list, type(prop.value))
self.assertEquals(2, len(prop.value))
self.assertEquals([5, 6],
[fdt_util.fdt32_to_cpu(val) for val in prop.value])
prop = node.props['byteval']
- self.assertEquals(fdt.TYPE_BYTE, prop.type)
+ self.assertEquals(fdt.Type.BYTE, prop.type)
self.assertEquals(chr(8), prop.value)
prop = node.props['bytearray']
- self.assertEquals(fdt.TYPE_BYTE, prop.type)
+ self.assertEquals(fdt.Type.BYTE, prop.type)
self.assertEquals(list, type(prop.value))
self.assertEquals(str, type(prop.value[0]))
self.assertEquals(3, len(prop.value))
self.assertEquals([chr(1), '#', '4'], prop.value)
prop = node.props['longbytearray']
- self.assertEquals(fdt.TYPE_INT, prop.type)
+ self.assertEquals(fdt.Type.INT, prop.type)
self.assertEquals(0x090a0b0c, fdt_util.GetInt(node, 'longbytearray'))
prop = node.props['stringval']
- self.assertEquals(fdt.TYPE_STRING, prop.type)
+ self.assertEquals(fdt.Type.STRING, prop.type)
self.assertEquals('message2', fdt_util.GetString(node, 'stringval'))
prop = node.props['stringarray']
- self.assertEquals(fdt.TYPE_STRING, prop.type)
+ self.assertEquals(fdt.Type.STRING, prop.type)
self.assertEquals(list, type(prop.value))
self.assertEquals(3, len(prop.value))
self.assertEquals(['another', 'multi-word', 'message'], prop.value)
diff --git a/tools/binman/fmap_util.py b/tools/binman/fmap_util.py
index 25fe60a9cc..b03fc28fbb 100644
--- a/tools/binman/fmap_util.py
+++ b/tools/binman/fmap_util.py
@@ -111,8 +111,7 @@ def EncodeFmap(image_size, name, areas):
ConvertName(names, params)
return struct.pack(fmt, *params)
- values = FmapHeader(FMAP_SIGNATURE, 1, 0, 0, image_size,
- tools.FromUnicode(name), len(areas))
+ values = FmapHeader(FMAP_SIGNATURE, 1, 0, 0, image_size, name, len(areas))
blob = _FormatBlob(FMAP_HEADER_FORMAT, FMAP_HEADER_NAMES, values)
for area in areas:
blob += _FormatBlob(FMAP_AREA_FORMAT, FMAP_AREA_NAMES, area)
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 9b27aecc14..82671138a9 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -9,6 +9,8 @@
This supports converting device tree data to C structures definitions and
static data.
+
+See doc/driver-model/of-plat.rst for more informaiton
"""
import collections
@@ -19,9 +21,9 @@ import sys
from dtoc import fdt
from dtoc import fdt_util
-from patman import tools
-# When we see these properties we ignore them - i.e. do not create a structure member
+# When we see these properties we ignore them - i.e. do not create a structure
+# member
PROP_IGNORE_LIST = [
'#address-cells',
'#gpio-cells',
@@ -35,13 +37,13 @@ PROP_IGNORE_LIST = [
'u-boot,dm-spl',
]
-# C type declarations for the tyues we support
+# C type declarations for the types we support
TYPE_NAMES = {
- fdt.TYPE_INT: 'fdt32_t',
- fdt.TYPE_BYTE: 'unsigned char',
- fdt.TYPE_STRING: 'const char *',
- fdt.TYPE_BOOL: 'bool',
- fdt.TYPE_INT64: 'fdt64_t',
+ fdt.Type.INT: 'fdt32_t',
+ fdt.Type.BYTE: 'unsigned char',
+ fdt.Type.STRING: 'const char *',
+ fdt.Type.BOOL: 'bool',
+ fdt.Type.INT64: 'fdt64_t',
}
STRUCT_PREFIX = 'dtd_'
@@ -69,9 +71,9 @@ def conv_name_to_c(name):
(400ms for 1m calls versus 1000ms for the 're' version).
Args:
- name: Name to convert
+ name (str): Name to convert
Return:
- String containing the C version of this name
+ str: String containing the C version of this name
"""
new = name.replace('@', '_at_')
new = new.replace('-', '_')
@@ -83,11 +85,11 @@ def tab_to(num_tabs, line):
"""Append tabs to a line of text to reach a tab stop.
Args:
- num_tabs: Tab stop to obtain (0 = column 0, 1 = column 8, etc.)
- line: Line of text to append to
+ num_tabs (int): Tab stop to obtain (0 = column 0, 1 = column 8, etc.)
+ line (str): Line of text to append to
Returns:
- line with the correct number of tabs appeneded. If the line already
+ str: line with the correct number of tabs appeneded. If the line already
extends past that tab stop then a single space is appended.
"""
if len(line) >= num_tabs * 8:
@@ -103,27 +105,31 @@ def get_value(ftype, value):
For booleans this return 'true'
Args:
- type: Data type (fdt_util)
- value: Data value, as a string of bytes
+ ftype (fdt.Type): Data type (fdt_util)
+ value (bytes): Data value, as a string of bytes
+
+ Returns:
+ str: String representation of the value
"""
- if ftype == fdt.TYPE_INT:
+ if ftype == fdt.Type.INT:
return '%#x' % fdt_util.fdt32_to_cpu(value)
- elif ftype == fdt.TYPE_BYTE:
- return '%#x' % tools.ToByte(value[0])
- elif ftype == fdt.TYPE_STRING:
+ elif ftype == fdt.Type.BYTE:
+ char = value[0]
+ return '%#x' % (ord(char) if isinstance(char, str) else char)
+ 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
return '"%s"' % value.replace('\\', '\\\\')
- elif ftype == fdt.TYPE_BOOL:
+ elif ftype == fdt.Type.BOOL:
return 'true'
- elif ftype == fdt.TYPE_INT64:
+ else: # ftype == fdt.Type.INT64:
return '%#x' % value
def get_compat_name(node):
"""Get the node's list of compatible string as a C identifiers
Args:
- node: Node object to check
+ node (fdt.Node): Node object to check
Return:
List of C identifiers for all the compatible strings
"""
@@ -157,7 +163,7 @@ class DtbPlatdata(object):
_drivers_additional: List of additional drivers to use during scanning
"""
def __init__(self, dtb_fname, include_disabled, warning_disabled,
- drivers_additional=[]):
+ drivers_additional=None):
self._fdt = None
self._dtb_fname = dtb_fname
self._valid_nodes = None
@@ -167,7 +173,7 @@ class DtbPlatdata(object):
self._lines = []
self._drivers = []
self._driver_aliases = {}
- self._drivers_additional = drivers_additional
+ self._drivers_additional = drivers_additional or []
def get_normalized_compat_name(self, node):
"""Get a node's normalized compat name
@@ -212,7 +218,7 @@ class DtbPlatdata(object):
file.
Args:
- fname: Filename to send output to, or '-' for stdout
+ fname (str): Filename to send output to, or '-' for stdout
"""
if fname == '-':
self._outfile = sys.stdout
@@ -223,7 +229,7 @@ class DtbPlatdata(object):
"""Output a string to the output file
Args:
- line: String to output
+ line (str): String to output
"""
self._outfile.write(line)
@@ -231,7 +237,7 @@ class DtbPlatdata(object):
"""Buffer up a string to send later
Args:
- line: String to add to our 'buffer' list
+ line (str): String to add to our 'buffer' list
"""
self._lines.append(line)
@@ -239,7 +245,7 @@ class DtbPlatdata(object):
"""Get the contents of the output buffer, and clear it
Returns:
- The output buffer, which is then cleared for future use
+ list(str): The output buffer, which is then cleared for future use
"""
lines = self._lines
self._lines = []
@@ -262,9 +268,14 @@ class DtbPlatdata(object):
or not. As an interim measure, use a list of known property names.
Args:
- prop: Prop object to check
- Return:
- Number of argument cells is this is a phandle, else None
+ prop (fdt.Prop): Prop object to check
+ node_name (str): Node name, only used for raising an error
+ Returns:
+ int or None: Number of argument cells is this is a phandle,
+ else None
+ Raises:
+ ValueError: if the phandle cannot be parsed or the required property
+ is not present
"""
if prop.name in ['clocks', 'cd-gpios']:
if not isinstance(prop.value, list):
@@ -293,7 +304,7 @@ class DtbPlatdata(object):
break
if not cells:
raise ValueError("Node '%s' has no cells property" %
- (target.name))
+ (target.name))
num_args = fdt_util.fdt32_to_cpu(cells.value)
max_args = max(max_args, num_args)
args.append(num_args)
@@ -301,20 +312,20 @@ class DtbPlatdata(object):
return PhandleInfo(max_args, args)
return None
- def scan_driver(self, fn):
+ def scan_driver(self, fname):
"""Scan a driver file to build a list of driver names and aliases
This procedure will populate self._drivers and self._driver_aliases
Args
- fn: Driver filename to scan
+ fname: Driver filename to scan
"""
- with open(fn, encoding='utf-8') as fd:
+ with open(fname, encoding='utf-8') as inf:
try:
- buff = fd.read()
+ buff = inf.read()
except UnicodeDecodeError:
# This seems to happen on older Python versions
- print("Skipping file '%s' due to unicode error" % fn)
+ print("Skipping file '%s' due to unicode error" % fname)
return
# The following re will search for driver names declared as
@@ -326,8 +337,9 @@ class DtbPlatdata(object):
# The following re will search for driver aliases declared as
# U_BOOT_DRIVER_ALIAS(alias, driver_name)
- driver_aliases = re.findall('U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)',
- buff)
+ driver_aliases = re.findall(
+ 'U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)',
+ buff)
for alias in driver_aliases: # pragma: no cover
if len(alias) != 2:
@@ -343,19 +355,19 @@ class DtbPlatdata(object):
basedir = sys.argv[0].replace('tools/dtoc/dtoc', '')
if basedir == '':
basedir = './'
- for (dirpath, dirnames, filenames) in os.walk(basedir):
- for fn in filenames:
- if not fn.endswith('.c'):
+ for (dirpath, _, filenames) in os.walk(basedir):
+ for fname in filenames:
+ if not fname.endswith('.c'):
continue
- self.scan_driver(dirpath + '/' + fn)
+ self.scan_driver(dirpath + '/' + fname)
- for fn in self._drivers_additional:
- if not isinstance(fn, str) or len(fn) == 0:
+ for fname in self._drivers_additional:
+ if not isinstance(fname, str) or len(fname) == 0:
continue
- if fn[0] == '/':
- self.scan_driver(fn)
+ if fname[0] == '/':
+ self.scan_driver(fname)
else:
- self.scan_driver(basedir + '/' + fn)
+ self.scan_driver(basedir + '/' + fname)
def scan_dtb(self):
"""Scan the device tree to obtain a tree of nodes and properties
@@ -403,7 +415,7 @@ class DtbPlatdata(object):
"""Get the number of cells in addresses and sizes for this node
Args:
- node: Node to check
+ node (fdt.None): Node to check
Returns:
Tuple:
@@ -411,15 +423,15 @@ class DtbPlatdata(object):
Number of size cells for this node
"""
parent = node.parent
- na, ns = 2, 2
+ num_addr, num_size = 2, 2
if parent:
- na_prop = parent.props.get('#address-cells')
- ns_prop = parent.props.get('#size-cells')
- if na_prop:
- na = fdt_util.fdt32_to_cpu(na_prop.value)
- if ns_prop:
- ns = fdt_util.fdt32_to_cpu(ns_prop.value)
- return na, ns
+ addr_prop = parent.props.get('#address-cells')
+ size_prop = parent.props.get('#size-cells')
+ if addr_prop:
+ num_addr = fdt_util.fdt32_to_cpu(addr_prop.value)
+ if size_prop:
+ num_size = fdt_util.fdt32_to_cpu(size_prop.value)
+ return num_addr, num_size
def scan_reg_sizes(self):
"""Scan for 64-bit 'reg' properties and update the values
@@ -432,30 +444,31 @@ class DtbPlatdata(object):
reg = node.props.get('reg')
if not reg:
continue
- na, ns = self.get_num_cells(node)
- total = na + ns
+ num_addr, num_size = self.get_num_cells(node)
+ total = num_addr + num_size
- if reg.type != fdt.TYPE_INT:
+ if reg.type != fdt.Type.INT:
raise ValueError("Node '%s' reg property is not an int" %
node.name)
if len(reg.value) % total:
- raise ValueError("Node '%s' reg property has %d cells "
- 'which is not a multiple of na + ns = %d + %d)' %
- (node.name, len(reg.value), na, ns))
- reg.na = na
- reg.ns = ns
- if na != 1 or ns != 1:
- reg.type = fdt.TYPE_INT64
+ raise ValueError(
+ "Node '%s' reg property has %d cells "
+ 'which is not a multiple of na + ns = %d + %d)' %
+ (node.name, len(reg.value), num_addr, num_size))
+ reg.num_addr = num_addr
+ reg.num_size = num_size
+ if num_addr != 1 or num_size != 1:
+ reg.type = fdt.Type.INT64
i = 0
new_value = []
val = reg.value
if not isinstance(val, list):
val = [val]
while i < len(val):
- addr = fdt_util.fdt_cells_to_cpu(val[i:], reg.na)
- i += na
- size = fdt_util.fdt_cells_to_cpu(val[i:], reg.ns)
- i += ns
+ addr = fdt_util.fdt_cells_to_cpu(val[i:], reg.num_addr)
+ i += num_addr
+ size = fdt_util.fdt_cells_to_cpu(val[i:], reg.num_size)
+ i += num_size
new_value += [addr, size]
reg.value = new_value
@@ -501,14 +514,12 @@ class DtbPlatdata(object):
else:
structs[node_name] = fields
- upto = 0
for node in self._valid_nodes:
node_name, _ = self.get_normalized_compat_name(node)
struct = structs[node_name]
for name, prop in node.props.items():
if name not in PROP_IGNORE_LIST and name[0] != '#':
prop.Widen(struct[name])
- upto += 1
return structs
@@ -584,7 +595,7 @@ class DtbPlatdata(object):
"""Output the C code for a node
Args:
- node: node to output
+ node (fdt.Node): node to output
"""
def _output_list(node, prop):
"""Output the C code for a devicetree property that holds a list
@@ -601,12 +612,10 @@ class DtbPlatdata(object):
if info:
# Process the list as pairs of (phandle, id)
pos = 0
- item = 0
for args in info.args:
phandle_cell = prop.value[pos]
phandle = fdt_util.fdt32_to_cpu(phandle_cell)
target_node = self._fdt.phandle_to_node[phandle]
- name = conv_name_to_c(target_node.name)
arg_values = []
for i in range(args):
arg_values.append(
@@ -614,7 +623,6 @@ class DtbPlatdata(object):
pos += 1 + args
vals.append('\t{%d, {%s}}' % (target_node.idx,
', '.join(arg_values)))
- item += 1
for val in vals:
self.buf('\n\t\t%s,' % val)
else:
@@ -651,8 +659,8 @@ class DtbPlatdata(object):
# Add a device declaration
self.buf('U_BOOT_DEVICE(%s) = {\n' % var_name)
self.buf('\t.name\t\t= "%s",\n' % struct_name)
- self.buf('\t.platdata\t= &%s%s,\n' % (VAL_PREFIX, var_name))
- self.buf('\t.platdata_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name))
+ self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name))
+ self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name))
idx = -1
if node.parent and node.parent in self._valid_nodes:
idx = node.parent.idx
@@ -702,19 +710,26 @@ class DtbPlatdata(object):
self.out(''.join(self.get_buf()))
def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False,
- drivers_additional=[]):
+ drivers_additional=None):
"""Run all the steps of the dtoc tool
Args:
- args: List of non-option arguments provided to the problem
- dtb_file: Filename of dtb file to process
- include_disabled: True to include disabled nodes
- output: Name of output file
+ args (list): List of non-option arguments provided to the problem
+ dtb_file (str): Filename of dtb file to process
+ include_disabled (bool): True to include disabled nodes
+ output (str): Name of output file
+ warning_disabled (bool): True to avoid showing warnings about missing
+ drivers
+ _drivers_additional (list): List of additional drivers to use during
+ scanning
+ Raises:
+ ValueError: if args has no command, or an unknown command
"""
if not args:
raise ValueError('Please specify a command: struct, platdata')
- plat = DtbPlatdata(dtb_file, include_disabled, warning_disabled, drivers_additional)
+ plat = DtbPlatdata(dtb_file, include_disabled, warning_disabled,
+ drivers_additional)
plat.scan_drivers()
plat.scan_dtb()
plat.scan_tree()
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 03b86773d5..4a78c73725 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -5,6 +5,7 @@
# Written by Simon Glass <sjg@chromium.org>
#
+from enum import IntEnum
import struct
import sys
@@ -22,7 +23,25 @@ from patman import tools
# so it is fairly efficient.
# A list of types we support
-(TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, TYPE_INT64) = range(5)
+class Type(IntEnum):
+ (BYTE, INT, STRING, BOOL, INT64) = range(5)
+
+ def is_wider_than(self, other):
+ """Check if another type is 'wider' than this one
+
+ A wider type is one that holds more information than an earlier one,
+ 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).
+
+ Args:
+ other: Other type to compare against
+
+ Return:
+ True if the other type is wider
+ """
+ return self.value > other.value
def CheckErr(errnum, msg):
if errnum:
@@ -41,9 +60,9 @@ def BytesToValue(data):
Type of data
Data, either a single element or a list of elements. Each element
is one of:
- TYPE_STRING: str/bytes value from the property
- TYPE_INT: a byte-swapped integer stored as a 4-byte str/bytes
- TYPE_BYTE: a byte stored as a single-byte str/bytes
+ Type.STRING: str/bytes value from the property
+ Type.INT: a byte-swapped integer stored as a 4-byte str/bytes
+ Type.BYTE: a byte stored as a single-byte str/bytes
"""
data = bytes(data)
size = len(data)
@@ -63,21 +82,21 @@ def BytesToValue(data):
is_string = False
if is_string:
if count == 1:
- return TYPE_STRING, strings[0].decode()
+ return Type.STRING, strings[0].decode()
else:
- return TYPE_STRING, [s.decode() for s in strings[:-1]]
+ return Type.STRING, [s.decode() for s in strings[:-1]]
if size % 4:
if size == 1:
- return TYPE_BYTE, tools.ToChar(data[0])
+ return Type.BYTE, chr(data[0])
else:
- return TYPE_BYTE, [tools.ToChar(ch) for ch in list(data)]
+ return Type.BYTE, [chr(ch) for ch in list(data)]
val = []
for i in range(0, size, 4):
val.append(data[i:i + 4])
if size == 4:
- return TYPE_INT, val[0]
+ return Type.INT, val[0]
else:
- return TYPE_INT, val
+ return Type.INT, val
class Prop:
@@ -97,7 +116,7 @@ class Prop:
self.bytes = bytes(data)
self.dirty = False
if not data:
- self.type = TYPE_BOOL
+ self.type = Type.BOOL
self.value = True
return
self.type, self.value = BytesToValue(bytes(data))
@@ -128,15 +147,14 @@ class Prop:
update the current property to be like the second, since it is less
specific.
"""
- if newprop.type < self.type:
- # Special handling to convert an int into bytes
- if self.type == TYPE_INT and newprop.type == TYPE_BYTE:
+ if self.type.is_wider_than(newprop.type):
+ if self.type == Type.INT and newprop.type == Type.BYTE:
if type(self.value) == list:
new_value = []
for val in self.value:
- new_value += [tools.ToChar(by) for by in val]
+ new_value += [chr(by) for by in val]
else:
- new_value = [tools.ToChar(by) for by in self.value]
+ new_value = [chr(by) for by in self.value]
self.value = new_value
self.type = newprop.type
@@ -155,11 +173,11 @@ class Prop:
Returns:
A single value of the given type
"""
- if type == TYPE_BYTE:
+ if type == Type.BYTE:
return chr(0)
- elif type == TYPE_INT:
+ elif type == Type.INT:
return struct.pack('>I', 0);
- elif type == TYPE_STRING:
+ elif type == Type.STRING:
return ''
else:
return True
@@ -184,7 +202,7 @@ class Prop:
"""
self.bytes = struct.pack('>I', val);
self.value = self.bytes
- self.type = TYPE_INT
+ self.type = Type.INT
self.dirty = True
def SetData(self, bytes):
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index a5836e04b7..4913d95021 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -134,13 +134,13 @@ class TestDtoc(unittest.TestCase):
def test_get_value(self):
"""Test operation of get_value() function"""
self.assertEqual('0x45',
- get_value(fdt.TYPE_INT, struct.pack('>I', 0x45)))
+ get_value(fdt.Type.INT, struct.pack('>I', 0x45)))
self.assertEqual('0x45',
- get_value(fdt.TYPE_BYTE, struct.pack('<I', 0x45)))
+ get_value(fdt.Type.BYTE, struct.pack('<I', 0x45)))
self.assertEqual('0x0',
- get_value(fdt.TYPE_BYTE, struct.pack('>I', 0x45)))
- self.assertEqual('"test"', get_value(fdt.TYPE_STRING, 'test'))
- self.assertEqual('true', get_value(fdt.TYPE_BOOL, None))
+ get_value(fdt.Type.BYTE, struct.pack('>I', 0x45)))
+ self.assertEqual('"test"', get_value(fdt.Type.STRING, 'test'))
+ self.assertEqual('true', get_value(fdt.Type.BOOL, None))
def test_get_compat_name(self):
"""Test operation of get_compat_name() function"""
@@ -217,8 +217,8 @@ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = {
};
U_BOOT_DEVICE(i2c_at_0) = {
\t.name\t\t= "sandbox_i2c_test",
-\t.platdata\t= &dtv_i2c_at_0,
-\t.platdata_size\t= sizeof(dtv_i2c_at_0),
+\t.plat\t= &dtv_i2c_at_0,
+\t.plat_size\t= sizeof(dtv_i2c_at_0),
\t.parent_idx\t= -1,
};
@@ -229,8 +229,8 @@ static struct dtd_sandbox_pmic_test dtv_pmic_at_9 = {
};
U_BOOT_DEVICE(pmic_at_9) = {
\t.name\t\t= "sandbox_pmic_test",
-\t.platdata\t= &dtv_pmic_at_9,
-\t.platdata_size\t= sizeof(dtv_pmic_at_9),
+\t.plat\t= &dtv_pmic_at_9,
+\t.plat_size\t= sizeof(dtv_pmic_at_9),
\t.parent_idx\t= 0,
};
@@ -249,8 +249,8 @@ static struct dtd_sandbox_spl_test dtv_spl_test = {
};
U_BOOT_DEVICE(spl_test) = {
\t.name\t\t= "sandbox_spl_test",
-\t.platdata\t= &dtv_spl_test,
-\t.platdata_size\t= sizeof(dtv_spl_test),
+\t.plat\t= &dtv_spl_test,
+\t.plat_size\t= sizeof(dtv_spl_test),
\t.parent_idx\t= -1,
};
@@ -268,8 +268,8 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = {
};
U_BOOT_DEVICE(spl_test2) = {
\t.name\t\t= "sandbox_spl_test",
-\t.platdata\t= &dtv_spl_test2,
-\t.platdata_size\t= sizeof(dtv_spl_test2),
+\t.plat\t= &dtv_spl_test2,
+\t.plat_size\t= sizeof(dtv_spl_test2),
\t.parent_idx\t= -1,
};
@@ -281,8 +281,8 @@ static struct dtd_sandbox_spl_test dtv_spl_test3 = {
};
U_BOOT_DEVICE(spl_test3) = {
\t.name\t\t= "sandbox_spl_test",
-\t.platdata\t= &dtv_spl_test3,
-\t.platdata_size\t= sizeof(dtv_spl_test3),
+\t.plat\t= &dtv_spl_test3,
+\t.plat_size\t= sizeof(dtv_spl_test3),
\t.parent_idx\t= -1,
};
@@ -291,8 +291,8 @@ static struct dtd_sandbox_spl_test_2 dtv_spl_test4 = {
};
U_BOOT_DEVICE(spl_test4) = {
\t.name\t\t= "sandbox_spl_test_2",
-\t.platdata\t= &dtv_spl_test4,
-\t.platdata_size\t= sizeof(dtv_spl_test4),
+\t.plat\t= &dtv_spl_test4,
+\t.plat_size\t= sizeof(dtv_spl_test4),
\t.parent_idx\t= -1,
};
@@ -325,8 +325,8 @@ static struct dtd_sandbox_gpio dtv_gpios_at_0 = {
};
U_BOOT_DEVICE(gpios_at_0) = {
\t.name\t\t= "sandbox_gpio",
-\t.platdata\t= &dtv_gpios_at_0,
-\t.platdata_size\t= sizeof(dtv_gpios_at_0),
+\t.plat\t= &dtv_gpios_at_0,
+\t.plat_size\t= sizeof(dtv_gpios_at_0),
\t.parent_idx\t= -1,
};
@@ -357,8 +357,8 @@ static struct dtd_invalid dtv_spl_test = {
};
U_BOOT_DEVICE(spl_test) = {
\t.name\t\t= "invalid",
-\t.platdata\t= &dtv_spl_test,
-\t.platdata_size\t= sizeof(dtv_spl_test),
+\t.plat\t= &dtv_spl_test,
+\t.plat_size\t= sizeof(dtv_spl_test),
\t.parent_idx\t= -1,
};
@@ -392,8 +392,8 @@ static struct dtd_target dtv_phandle2_target = {
};
U_BOOT_DEVICE(phandle2_target) = {
\t.name\t\t= "target",
-\t.platdata\t= &dtv_phandle2_target,
-\t.platdata_size\t= sizeof(dtv_phandle2_target),
+\t.plat\t= &dtv_phandle2_target,
+\t.plat_size\t= sizeof(dtv_phandle2_target),
\t.parent_idx\t= -1,
};
@@ -403,8 +403,8 @@ static struct dtd_target dtv_phandle3_target = {
};
U_BOOT_DEVICE(phandle3_target) = {
\t.name\t\t= "target",
-\t.platdata\t= &dtv_phandle3_target,
-\t.platdata_size\t= sizeof(dtv_phandle3_target),
+\t.plat\t= &dtv_phandle3_target,
+\t.plat_size\t= sizeof(dtv_phandle3_target),
\t.parent_idx\t= -1,
};
@@ -414,8 +414,8 @@ static struct dtd_target dtv_phandle_target = {
};
U_BOOT_DEVICE(phandle_target) = {
\t.name\t\t= "target",
-\t.platdata\t= &dtv_phandle_target,
-\t.platdata_size\t= sizeof(dtv_phandle_target),
+\t.plat\t= &dtv_phandle_target,
+\t.plat_size\t= sizeof(dtv_phandle_target),
\t.parent_idx\t= -1,
};
@@ -429,8 +429,8 @@ static struct dtd_source dtv_phandle_source = {
};
U_BOOT_DEVICE(phandle_source) = {
\t.name\t\t= "source",
-\t.platdata\t= &dtv_phandle_source,
-\t.platdata_size\t= sizeof(dtv_phandle_source),
+\t.plat\t= &dtv_phandle_source,
+\t.plat_size\t= sizeof(dtv_phandle_source),
\t.parent_idx\t= -1,
};
@@ -441,8 +441,8 @@ static struct dtd_source dtv_phandle_source2 = {
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
-\t.platdata\t= &dtv_phandle_source2,
-\t.platdata_size\t= sizeof(dtv_phandle_source2),
+\t.plat\t= &dtv_phandle_source2,
+\t.plat_size\t= sizeof(dtv_phandle_source2),
\t.parent_idx\t= -1,
};
@@ -479,8 +479,8 @@ static struct dtd_target dtv_phandle_target = {
};
U_BOOT_DEVICE(phandle_target) = {
\t.name\t\t= "target",
-\t.platdata\t= &dtv_phandle_target,
-\t.platdata_size\t= sizeof(dtv_phandle_target),
+\t.plat\t= &dtv_phandle_target,
+\t.plat_size\t= sizeof(dtv_phandle_target),
\t.parent_idx\t= -1,
};
@@ -491,8 +491,8 @@ static struct dtd_source dtv_phandle_source2 = {
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
-\t.platdata\t= &dtv_phandle_source2,
-\t.platdata_size\t= sizeof(dtv_phandle_source2),
+\t.plat\t= &dtv_phandle_source2,
+\t.plat_size\t= sizeof(dtv_phandle_source2),
\t.parent_idx\t= -1,
};
@@ -514,8 +514,8 @@ static struct dtd_target dtv_phandle2_target = {
};
U_BOOT_DEVICE(phandle2_target) = {
\t.name\t\t= "target",
-\t.platdata\t= &dtv_phandle2_target,
-\t.platdata_size\t= sizeof(dtv_phandle2_target),
+\t.plat\t= &dtv_phandle2_target,
+\t.plat_size\t= sizeof(dtv_phandle2_target),
\t.parent_idx\t= -1,
};
@@ -525,8 +525,8 @@ static struct dtd_target dtv_phandle3_target = {
};
U_BOOT_DEVICE(phandle3_target) = {
\t.name\t\t= "target",
-\t.platdata\t= &dtv_phandle3_target,
-\t.platdata_size\t= sizeof(dtv_phandle3_target),
+\t.plat\t= &dtv_phandle3_target,
+\t.plat_size\t= sizeof(dtv_phandle3_target),
\t.parent_idx\t= -1,
};
@@ -536,8 +536,8 @@ static struct dtd_target dtv_phandle_target = {
};
U_BOOT_DEVICE(phandle_target) = {
\t.name\t\t= "target",
-\t.platdata\t= &dtv_phandle_target,
-\t.platdata_size\t= sizeof(dtv_phandle_target),
+\t.plat\t= &dtv_phandle_target,
+\t.plat_size\t= sizeof(dtv_phandle_target),
\t.parent_idx\t= -1,
};
@@ -551,8 +551,8 @@ static struct dtd_source dtv_phandle_source = {
};
U_BOOT_DEVICE(phandle_source) = {
\t.name\t\t= "source",
-\t.platdata\t= &dtv_phandle_source,
-\t.platdata_size\t= sizeof(dtv_phandle_source),
+\t.plat\t= &dtv_phandle_source,
+\t.plat_size\t= sizeof(dtv_phandle_source),
\t.parent_idx\t= -1,
};
@@ -563,8 +563,8 @@ static struct dtd_source dtv_phandle_source2 = {
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
-\t.platdata\t= &dtv_phandle_source2,
-\t.platdata_size\t= sizeof(dtv_phandle_source2),
+\t.plat\t= &dtv_phandle_source2,
+\t.plat_size\t= sizeof(dtv_phandle_source2),
\t.parent_idx\t= -1,
};
@@ -621,8 +621,8 @@ static struct dtd_test1 dtv_test1 = {
};
U_BOOT_DEVICE(test1) = {
\t.name\t\t= "test1",
-\t.platdata\t= &dtv_test1,
-\t.platdata_size\t= sizeof(dtv_test1),
+\t.plat\t= &dtv_test1,
+\t.plat_size\t= sizeof(dtv_test1),
\t.parent_idx\t= -1,
};
@@ -632,8 +632,8 @@ static struct dtd_test2 dtv_test2 = {
};
U_BOOT_DEVICE(test2) = {
\t.name\t\t= "test2",
-\t.platdata\t= &dtv_test2,
-\t.platdata_size\t= sizeof(dtv_test2),
+\t.plat\t= &dtv_test2,
+\t.plat_size\t= sizeof(dtv_test2),
\t.parent_idx\t= -1,
};
@@ -643,8 +643,8 @@ static struct dtd_test3 dtv_test3 = {
};
U_BOOT_DEVICE(test3) = {
\t.name\t\t= "test3",
-\t.platdata\t= &dtv_test3,
-\t.platdata_size\t= sizeof(dtv_test3),
+\t.plat\t= &dtv_test3,
+\t.plat_size\t= sizeof(dtv_test3),
\t.parent_idx\t= -1,
};
@@ -676,8 +676,8 @@ static struct dtd_test1 dtv_test1 = {
};
U_BOOT_DEVICE(test1) = {
\t.name\t\t= "test1",
-\t.platdata\t= &dtv_test1,
-\t.platdata_size\t= sizeof(dtv_test1),
+\t.plat\t= &dtv_test1,
+\t.plat_size\t= sizeof(dtv_test1),
\t.parent_idx\t= -1,
};
@@ -687,8 +687,8 @@ static struct dtd_test2 dtv_test2 = {
};
U_BOOT_DEVICE(test2) = {
\t.name\t\t= "test2",
-\t.platdata\t= &dtv_test2,
-\t.platdata_size\t= sizeof(dtv_test2),
+\t.plat\t= &dtv_test2,
+\t.plat_size\t= sizeof(dtv_test2),
\t.parent_idx\t= -1,
};
@@ -723,8 +723,8 @@ static struct dtd_test1 dtv_test1 = {
};
U_BOOT_DEVICE(test1) = {
\t.name\t\t= "test1",
-\t.platdata\t= &dtv_test1,
-\t.platdata_size\t= sizeof(dtv_test1),
+\t.plat\t= &dtv_test1,
+\t.plat_size\t= sizeof(dtv_test1),
\t.parent_idx\t= -1,
};
@@ -734,8 +734,8 @@ static struct dtd_test2 dtv_test2 = {
};
U_BOOT_DEVICE(test2) = {
\t.name\t\t= "test2",
-\t.platdata\t= &dtv_test2,
-\t.platdata_size\t= sizeof(dtv_test2),
+\t.plat\t= &dtv_test2,
+\t.plat_size\t= sizeof(dtv_test2),
\t.parent_idx\t= -1,
};
@@ -745,8 +745,8 @@ static struct dtd_test3 dtv_test3 = {
};
U_BOOT_DEVICE(test3) = {
\t.name\t\t= "test3",
-\t.platdata\t= &dtv_test3,
-\t.platdata_size\t= sizeof(dtv_test3),
+\t.plat\t= &dtv_test3,
+\t.plat_size\t= sizeof(dtv_test3),
\t.parent_idx\t= -1,
};
@@ -781,8 +781,8 @@ static struct dtd_test1 dtv_test1 = {
};
U_BOOT_DEVICE(test1) = {
\t.name\t\t= "test1",
-\t.platdata\t= &dtv_test1,
-\t.platdata_size\t= sizeof(dtv_test1),
+\t.plat\t= &dtv_test1,
+\t.plat_size\t= sizeof(dtv_test1),
\t.parent_idx\t= -1,
};
@@ -792,8 +792,8 @@ static struct dtd_test2 dtv_test2 = {
};
U_BOOT_DEVICE(test2) = {
\t.name\t\t= "test2",
-\t.platdata\t= &dtv_test2,
-\t.platdata_size\t= sizeof(dtv_test2),
+\t.plat\t= &dtv_test2,
+\t.plat_size\t= sizeof(dtv_test2),
\t.parent_idx\t= -1,
};
@@ -803,8 +803,8 @@ static struct dtd_test3 dtv_test3 = {
};
U_BOOT_DEVICE(test3) = {
\t.name\t\t= "test3",
-\t.platdata\t= &dtv_test3,
-\t.platdata_size\t= sizeof(dtv_test3),
+\t.plat\t= &dtv_test3,
+\t.plat_size\t= sizeof(dtv_test3),
\t.parent_idx\t= -1,
};
@@ -854,8 +854,8 @@ static struct dtd_sandbox_spl_test dtv_spl_test = {
};
U_BOOT_DEVICE(spl_test) = {
\t.name\t\t= "sandbox_spl_test",
-\t.platdata\t= &dtv_spl_test,
-\t.platdata_size\t= sizeof(dtv_spl_test),
+\t.plat\t= &dtv_spl_test,
+\t.plat_size\t= sizeof(dtv_spl_test),
\t.parent_idx\t= -1,
};
@@ -865,8 +865,8 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = {
};
U_BOOT_DEVICE(spl_test2) = {
\t.name\t\t= "sandbox_spl_test",
-\t.platdata\t= &dtv_spl_test2,
-\t.platdata_size\t= sizeof(dtv_spl_test2),
+\t.plat\t= &dtv_spl_test2,
+\t.plat_size\t= sizeof(dtv_spl_test2),
\t.parent_idx\t= -1,
};
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index cfe3e04c7a..dc6943f733 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -19,7 +19,7 @@ sys.path.insert(1, os.path.join(our_path, '..'))
from dtoc import fdt
from dtoc import fdt_util
from dtoc.fdt_util import fdt32_to_cpu
-from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, BytesToValue
+from fdt import Type, BytesToValue
import libfdt
from patman import command
from patman import test_util
@@ -46,7 +46,7 @@ def _GetPropertyValue(dtb, node, prop_name):
# Add 12, which is sizeof(struct fdt_property), to get to start of data
offset = prop.GetOffset() + 12
data = dtb.GetContents()[offset:offset + len(prop.value)]
- return prop, [tools.ToChar(x) for x in data]
+ return prop, [chr(x) for x in data]
class TestFdt(unittest.TestCase):
@@ -127,7 +127,7 @@ class TestFdt(unittest.TestCase):
def testBytesToValue(self):
self.assertEqual(BytesToValue(b'this\0is\0'),
- (TYPE_STRING, ['this', 'is']))
+ (Type.STRING, ['this', 'is']))
class TestNode(unittest.TestCase):
"""Test operation of the Node class"""
@@ -249,46 +249,46 @@ class TestProp(unittest.TestCase):
def testMakeProp(self):
"""Test we can convert all the the types that are supported"""
prop = self._ConvertProp('boolval')
- self.assertEqual(fdt.TYPE_BOOL, prop.type)
+ self.assertEqual(Type.BOOL, prop.type)
self.assertEqual(True, prop.value)
prop = self._ConvertProp('intval')
- self.assertEqual(fdt.TYPE_INT, prop.type)
+ self.assertEqual(Type.INT, prop.type)
self.assertEqual(1, fdt32_to_cpu(prop.value))
prop = self._ConvertProp('intarray')
- self.assertEqual(fdt.TYPE_INT, prop.type)
+ self.assertEqual(Type.INT, prop.type)
val = [fdt32_to_cpu(val) for val in prop.value]
self.assertEqual([2, 3, 4], val)
prop = self._ConvertProp('byteval')
- self.assertEqual(fdt.TYPE_BYTE, prop.type)
+ self.assertEqual(Type.BYTE, prop.type)
self.assertEqual(5, ord(prop.value))
prop = self._ConvertProp('longbytearray')
- self.assertEqual(fdt.TYPE_BYTE, prop.type)
+ self.assertEqual(Type.BYTE, prop.type)
val = [ord(val) for val in prop.value]
self.assertEqual([9, 10, 11, 12, 13, 14, 15, 16, 17], val)
prop = self._ConvertProp('stringval')
- self.assertEqual(fdt.TYPE_STRING, prop.type)
+ self.assertEqual(Type.STRING, prop.type)
self.assertEqual('message', prop.value)
prop = self._ConvertProp('stringarray')
- self.assertEqual(fdt.TYPE_STRING, prop.type)
+ self.assertEqual(Type.STRING, prop.type)
self.assertEqual(['multi-word', 'message'], prop.value)
prop = self._ConvertProp('notstring')
- self.assertEqual(fdt.TYPE_BYTE, prop.type)
+ self.assertEqual(Type.BYTE, prop.type)
val = [ord(val) for val in prop.value]
self.assertEqual([0x20, 0x21, 0x22, 0x10, 0], val)
def testGetEmpty(self):
"""Tests the GetEmpty() function for the various supported types"""
- self.assertEqual(True, fdt.Prop.GetEmpty(fdt.TYPE_BOOL))
- self.assertEqual(chr(0), fdt.Prop.GetEmpty(fdt.TYPE_BYTE))
- self.assertEqual(tools.GetBytes(0, 4), fdt.Prop.GetEmpty(fdt.TYPE_INT))
- self.assertEqual('', fdt.Prop.GetEmpty(fdt.TYPE_STRING))
+ self.assertEqual(True, fdt.Prop.GetEmpty(Type.BOOL))
+ self.assertEqual(chr(0), fdt.Prop.GetEmpty(Type.BYTE))
+ self.assertEqual(tools.GetBytes(0, 4), fdt.Prop.GetEmpty(Type.INT))
+ self.assertEqual('', fdt.Prop.GetEmpty(Type.STRING))
def testGetOffset(self):
"""Test we can get the offset of a property"""
@@ -304,13 +304,13 @@ class TestProp(unittest.TestCase):
# No action
prop2 = node2.props['intval']
prop.Widen(prop2)
- self.assertEqual(fdt.TYPE_INT, prop.type)
+ self.assertEqual(Type.INT, prop.type)
self.assertEqual(1, fdt32_to_cpu(prop.value))
# Convert singla value to array
prop2 = self.node.props['intarray']
prop.Widen(prop2)
- self.assertEqual(fdt.TYPE_INT, prop.type)
+ self.assertEqual(Type.INT, prop.type)
self.assertTrue(isinstance(prop.value, list))
# A 4-byte array looks like a single integer. When widened by a longer
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 74a144dc2d..e7db36a85c 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -237,27 +237,26 @@ class TestFunctional(unittest.TestCase):
if 'Cc:' not in prev:
break
self.assertEqual('To: u-boot@lists.denx.de', prev)
- self.assertEqual('Cc: %s' % tools.FromUnicode(stefan), next(lines))
+ self.assertEqual('Cc: %s' % stefan, next(lines))
self.assertEqual('Version: 3', next(lines))
self.assertEqual('Prefix:\t RFC', next(lines))
self.assertEqual('Cover: 4 lines', next(lines))
self.assertEqual(' Cc: %s' % self.fred, next(lines))
- self.assertEqual(' Cc: %s' % tools.FromUnicode(self.leb),
+ self.assertEqual(' Cc: %s' % self.leb,
next(lines))
- self.assertEqual(' Cc: %s' % tools.FromUnicode(mel), next(lines))
+ self.assertEqual(' Cc: %s' % mel, next(lines))
self.assertEqual(' Cc: %s' % rick, next(lines))
expected = ('Git command: git send-email --annotate '
'--in-reply-to="%s" --to "u-boot@lists.denx.de" '
'--cc "%s" --cc-cmd "%s send --cc-cmd %s" %s %s'
% (in_reply_to, stefan, sys.argv[0], cc_file, cover_fname,
' '.join(args)))
- self.assertEqual(expected, tools.ToUnicode(next(lines)))
+ self.assertEqual(expected, next(lines))
- self.assertEqual(('%s %s\0%s' % (args[0], rick, stefan)),
- tools.ToUnicode(cc_lines[0]))
+ self.assertEqual(('%s %s\0%s' % (args[0], rick, stefan)), cc_lines[0])
self.assertEqual(
'%s %s\0%s\0%s\0%s' % (args[1], self.fred, self.leb, rick, stefan),
- tools.ToUnicode(cc_lines[1]))
+ cc_lines[1])
expected = '''
This is a test of how the cover
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index 31fb3b2829..6c4d2417a0 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -383,7 +383,6 @@ def BuildEmailList(in_list, tag=None, alias=None, raise_on_error=True):
raw += LookupEmail(item, alias, raise_on_error=raise_on_error)
result = []
for item in raw:
- item = tools.FromUnicode(item)
if not item in result:
result.append(item)
if tag:
@@ -494,7 +493,7 @@ send --cc-cmd cc-fname" cover p1 p2'
if smtp_server:
cmd.append('--smtp-server=%s' % smtp_server)
if in_reply_to:
- cmd.append('--in-reply-to="%s"' % tools.FromUnicode(in_reply_to))
+ cmd.append('--in-reply-to="%s"' % in_reply_to)
if thread:
cmd.append('--thread')
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 1d92bdb910..a6746e87c4 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -272,7 +272,6 @@ class Series(dict):
for x in set(cc) & set(settings.bounces):
print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
cc = set(cc) - set(settings.bounces)
- cc = [tools.FromUnicode(m) for m in cc]
if limit is not None:
cc = cc[:limit]
all_ccs += cc
@@ -281,11 +280,10 @@ class Series(dict):
if cover_fname:
cover_cc = gitutil.BuildEmailList(self.get('cover_cc', ''))
- cover_cc = [tools.FromUnicode(m) for m in cover_cc]
cover_cc = list(set(cover_cc + all_ccs))
if limit is not None:
cover_cc = cover_cc[:limit]
- cc_list = '\0'.join([tools.ToUnicode(x) for x in sorted(cover_cc)])
+ cc_list = '\0'.join([x for x in sorted(cover_cc)])
print(cover_fname, cc_list, file=fd)
fd.close()
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 8c10eab264..60cdc1c102 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -112,7 +112,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
val = ConfigParser.SafeConfigParser.get(
self, section, option, *args, **kwargs
)
- return tools.ToUnicode(val)
+ return val
def items(self, section, *args, **kwargs):
"""Extend SafeConfigParser to add project_section to section.
@@ -147,8 +147,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
item_dict = dict(top_items)
item_dict.update(project_items)
- return {(tools.ToUnicode(item), tools.ToUnicode(val))
- for item, val in item_dict.items()}
+ return {(item, val) for item, val in item_dict.items()}
def ReadGitAliases(fname):
"""Read a git alias file. This is in the form used by git:
diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py
index 1f7c38c4e9..a4fec1d4c1 100644
--- a/tools/patman/test_checkpatch.py
+++ b/tools/patman/test_checkpatch.py
@@ -411,6 +411,34 @@ index 0000000..2234c87
pm.add_line('common/main.c', 'if (CONFIG_IS_ENABLED(CONFIG_CLK))')
self.checkSingleMessage(pm, 'CONFIG_IS_ENABLED_CONFIG', 'error')
+ def check_struct(self, auto, suffix, warning):
+ """Check one of the warnings for struct naming
+
+ Args:
+ auto: Auto variable name, e.g. 'per_child_auto'
+ suffix: Suffix to expect on member, e.g. '_priv'
+ warning: Warning name, e.g. 'PRIV_AUTO'
+ """
+ pm = PatchMaker()
+ pm.add_line('common/main.c', '.%s = sizeof(struct(fred)),' % auto)
+ pm.add_line('common/main.c', '.%s = sizeof(struct(mary%s)),' %
+ (auto, suffix))
+ self.checkSingleMessage(
+ pm, warning, "struct 'fred' should have a %s suffix" % suffix)
+
+ def testDmDriverAuto(self):
+ """Check for the correct suffix on 'struct driver' auto members"""
+ self.check_struct('priv_auto', '_priv', 'PRIV_AUTO')
+ self.check_struct('plat_auto', '_plat', 'PLAT_AUTO')
+ self.check_struct('per_child_auto', '_priv', 'CHILD_PRIV_AUTO')
+ self.check_struct('per_child_plat_auto', '_plat', 'CHILD_PLAT_AUTO')
+
+ def testDmUclassAuto(self):
+ """Check for the correct suffix on 'struct uclass' auto members"""
+ # Some of these are omitted since they match those from struct driver
+ self.check_struct('per_device_auto', '_priv', 'DEVICE_PRIV_AUTO')
+ self.check_struct('per_device_plat_auto', '_plat', 'DEVICE_PLAT_AUTO')
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index bbb157da87..00c7013924 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -414,8 +414,6 @@ def WriteFile(fname, data, binary=True):
def GetBytes(byte, size):
"""Get a string of bytes of a given size
- This handles the unfortunate different between Python 2 and Python 2.
-
Args:
byte: Numeric byte value to use
size: Size of bytes/string to return
@@ -423,81 +421,7 @@ def GetBytes(byte, size):
Returns:
A bytes type with 'byte' repeated 'size' times
"""
- if sys.version_info[0] >= 3:
- data = bytes([byte]) * size
- else:
- data = chr(byte) * size
- return data
-
-def ToUnicode(val):
- """Make sure a value is a unicode string
-
- This allows some amount of compatibility between Python 2 and Python3. For
- the former, it returns a unicode object.
-
- Args:
- val: string or unicode object
-
- Returns:
- unicode version of val
- """
- if sys.version_info[0] >= 3:
- return val
- return val if isinstance(val, unicode) else val.decode('utf-8')
-
-def FromUnicode(val):
- """Make sure a value is a non-unicode string
-
- This allows some amount of compatibility between Python 2 and Python3. For
- the former, it converts a unicode object to a string.
-
- Args:
- val: string or unicode object
-
- Returns:
- non-unicode version of val
- """
- if sys.version_info[0] >= 3:
- return val
- return val if isinstance(val, str) else val.encode('utf-8')
-
-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
-
- This is useful because in Python 2 bytes is an alias for str, but in
- Python 3 they are separate types. This function converts an ASCII value to
- a value with the appropriate type in either case.
-
- Args:
- byte: A byte or str value
- """
- return chr(byte) if type(byte) != str else byte
-
-def ToChars(byte_list):
- """Convert a list of bytes to a str/bytes type
-
- Args:
- byte_list: List of ASCII values representing the string
-
- Returns:
- string made by concatenating all the ASCII values
- """
- return ''.join([chr(byte) for byte in byte_list])
+ return bytes([byte]) * size
def ToBytes(string):
"""Convert a str type into a bytes type
@@ -506,12 +430,9 @@ def ToBytes(string):
string: string to convert
Returns:
- Python 3: A bytes type
- Python 2: A string type
+ A bytes type
"""
- if sys.version_info[0] >= 3:
- return string.encode('utf-8')
- return string
+ return string.encode('utf-8')
def ToString(bval):
"""Convert a bytes type into a str type