key: Driver alias declared with
DM_DRIVER_ALIAS(driver_alias, driver_name)
value: Driver name declared with U_BOOT_DRIVER(driver_name)
- _warning_disabled: true to disable warnings about driver names not found
_drivers_additional (list or str): List of additional drivers to use
during scanning
_of_match: Dict holding information about compatible strings
_phase: The phase of U-Boot that we are generating data for, e.g. 'spl'
or 'tpl'. None if not known
"""
- def __init__(self, basedir, warning_disabled, drivers_additional, phase=''):
+ def __init__(self, basedir, drivers_additional, phase=''):
"""Set up a new Scanner
"""
if not basedir:
self._drivers = {}
self._driver_aliases = {}
self._drivers_additional = drivers_additional or []
- self._warning_disabled = warning_disabled
+ self._missing_drivers = set()
self._of_match = {}
self._compat_to_driver = {}
self._uclass = {}
aliases_c.remove(compat_c)
return compat_c, aliases_c
- if not self._warning_disabled:
- print('WARNING: the driver %s was not found in the driver list'
- % (compat_list_c[0]))
+ self._missing_drivers.add(compat_list_c[0])
return compat_list_c[0], compat_list_c[1:]
self._drivers[driver.name] = driver
self._of_match.update(of_match)
+ def show_warnings(self):
+ """Show any warnings that have been collected"""
+ for name in sorted(list(self._missing_drivers)):
+ print('WARNING: the driver %s was not found in the driver list'
+ % name)
+
def scan_driver(self, fname):
"""Scan a driver file to build a list of driver names and aliases
def test_simple(self):
"""Simple test of scanning drivers"""
- scan = src_scan.Scanner(None, True, None)
+ scan = src_scan.Scanner(None, None)
scan.scan_drivers()
self.assertIn('sandbox_gpio', scan._drivers)
self.assertIn('sandbox_gpio_alias', scan._driver_aliases)
def test_additional(self):
"""Test with additional drivers to scan"""
scan = src_scan.Scanner(
- None, True,
- [None, '', 'tools/dtoc/test/dtoc_test_scan_drivers.cxx'])
+ None, [None, '', 'tools/dtoc/test/dtoc_test_scan_drivers.cxx'])
scan.scan_drivers()
self.assertIn('sandbox_gpio_alias2', scan._driver_aliases)
self.assertEqual('sandbox_gpio',
with open(driver_fn, 'wb+') as fout:
fout.write(b'\x81')
- scan = src_scan.Scanner(None, True, [driver_fn])
+ scan = src_scan.Scanner(None, [driver_fn])
with test_util.capture_sys_output() as (stdout, _):
scan.scan_drivers()
self.assertRegex(stdout.getvalue(),
# Mock out scan_driver and check that it is called with the
# expected files
with mock.patch.object(src_scan.Scanner, "scan_driver") as mocked:
- scan = src_scan.Scanner(indir, True, None)
+ scan = src_scan.Scanner(indir, None)
scan.scan_drivers()
self.assertEqual(2, len(mocked.mock_calls))
self.assertEqual(mock.call(fname_list[0]),
"""Test scanning of a driver"""
fname = os.path.join(OUR_PATH, '..', '..', 'drivers/i2c/tegra_i2c.c')
buff = tools.ReadFile(fname, False)
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
scan._parse_driver(fname, buff)
self.assertIn('i2c_tegra', scan._drivers)
drv = scan._drivers['i2c_tegra']
# get_normalized_compat_name() uses this to check for root node
node.parent = FakeNode()
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
with test_util.capture_sys_output() as (stdout, _):
name, aliases = scan.get_normalized_compat_name(node)
self.assertEqual('rockchip_rk3288_grf', name)
self.assertEqual([], aliases)
- self.assertEqual(
- 'WARNING: the driver rockchip_rk3288_grf was not found in the driver list',
- stdout.getvalue().strip())
+ self.assertEqual(1, len(scan._missing_drivers))
+ self.assertEqual({'rockchip_rk3288_grf'}, scan._missing_drivers)
+ #'WARNING: the driver rockchip_rk3288_grf was not found in the driver list',
+ #stdout.getvalue().strip())
i2c = 'I2C_UCLASS'
compat = {'rockchip,rk3288-grf': 'ROCKCHIP_SYSCON_GRF',
.of_match = tegra_i2c_ids,
};
'''
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
with self.assertRaises(ValueError) as exc:
scan._parse_driver('file.c', buff)
self.assertIn(
.of_match = of_match_ptr(tegra_i2c_ids),
};
'''
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
scan._parse_driver('file.c', buff)
self.assertIn('i2c_tegra', scan._drivers)
drv = scan._drivers['i2c_tegra']
DM_HEADER(<asm/clk.h>)
};
'''
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
scan._parse_driver('file.c', buff)
self.assertIn('testing', scan._drivers)
drv = scan._drivers['testing']
};
'''
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
scan._parse_uclass_driver('file.c', buff)
self.assertIn('UCLASS_I2C', scan._uclass)
drv = scan._uclass['UCLASS_I2C']
};
'''
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
with self.assertRaises(ValueError) as exc:
scan._parse_uclass_driver('file.c', buff)
self.assertIn("file.c: Cannot parse uclass ID in driver 'i2c'",
uint nmsgs;
};
'''
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
scan._basedir = os.path.join(OUR_PATH, '..', '..')
scan._parse_structs('arch/arm/include/asm/file.h', buff)
self.assertIn('some_struct1', scan._structs)
output = tools.GetOutputFilename('output.h')
tools.WriteFile(output, b'struct this is a test \x81 of bad unicode')
- scan = src_scan.Scanner(None, False, None)
+ scan = src_scan.Scanner(None, None)
with test_util.capture_sys_output() as (stdout, _):
scan.scan_header(output)
self.assertIn('due to unicode error', stdout.getvalue())
.of_match = test_ids,
};
''' % name
- scan = src_scan.Scanner(None, False, None, phase)
+ scan = src_scan.Scanner(None, None, phase)
scan._parse_driver('file1.c', driver1)
self.assertIn(name, scan._drivers)
drv1 = scan._drivers[name]
def test_sequence(self):
"""Test assignment of sequence numnbers"""
- scan = src_scan.Scanner(None, False, None, '')
+ scan = src_scan.Scanner(None, None, '')
node = FakeNode()
uc = src_scan.UclassDriver('UCLASS_I2C')
node.uclass = uc