Skip to content

Commit 653f1bf

Browse files
tbursztykakartben
authored andcommitted
scripts: Removing init function pointer from check_init_priorities.py
As the pointer has been removed from struct init_entry, there is no point to look for it nor to display any information about it (obviously). Fixing the test script as well. Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
1 parent 175da6b commit 653f1bf

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

scripts/build/check_init_priorities.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,14 @@ def _process_initlevels(self):
202202
raise ValueError(f"no symbol at addr {addr:08x}")
203203
obj, size, shidx = self._objects[addr]
204204

205-
arg0_name = self._object_name(self._initlevel_pointer(addr, 0, shidx))
206-
arg1_name = self._object_name(self._initlevel_pointer(addr, 1, shidx))
205+
arg_name = self._object_name(self._initlevel_pointer(addr, 0, shidx))
207206

208-
self.initlevels[level].append(f"{obj}: {arg0_name}({arg1_name})")
207+
self.initlevels[level].append(f"{obj}: {arg_name}")
209208

210-
ordinal = self._device_ord_from_name(arg1_name)
209+
ordinal = self._device_ord_from_name(arg_name)
211210
if ordinal:
212211
prio = Priority(level, priority)
213-
self.devices[ordinal] = (prio, arg0_name)
212+
self.devices[ordinal] = prio
214213

215214
addr += size
216215
priority += 1
@@ -256,8 +255,8 @@ def _check_dep(self, dev_ord, dep_ord):
256255
self.log.info(f"Ignoring priority: {dev_node._binding.compatible}")
257256
return
258257

259-
dev_prio, dev_init = self._obj.devices.get(dev_ord, (None, None))
260-
dep_prio, dep_init = self._obj.devices.get(dep_ord, (None, None))
258+
dev_prio = self._obj.devices.get(dev_ord, None)
259+
dep_prio = self._obj.devices.get(dep_ord, None)
261260

262261
if not dev_prio or not dep_prio:
263262
return
@@ -272,12 +271,12 @@ def _check_dep(self, dev_ord, dep_ord):
272271
"the devicetree dependencies.")
273272
self.errors += 1
274273
self.log.error(
275-
f"{dev_node.path} <{dev_init}> is initialized before its dependency "
276-
f"{dep_node.path} <{dep_init}> ({dev_prio} < {dep_prio})")
274+
f"{dev_node.path} is initialized before its dependency "
275+
f"{dep_node.path} ({dev_prio} < {dep_prio})")
277276
else:
278277
self.log.info(
279-
f"{dev_node.path} <{dev_init}> {dev_prio} > "
280-
f"{dep_node.path} <{dep_init}> {dep_prio}")
278+
f"{dev_node.path} {dev_prio} > "
279+
f"{dep_node.path} {dep_prio}")
281280

282281
def check_edt(self):
283282
"""Scan through all known devices and validate the init priorities."""

scripts/build/check_init_priorities_test.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,8 @@ def test_process_initlevels(self, mock_zilinit, mock_ip, mock_on):
215215

216216
def mock_obj_name(*args):
217217
if args[0] == (0, 0, 0):
218-
return "i0"
219-
elif args[0] == (0, 1, 0):
220218
return "__device_dts_ord_11"
221219
elif args[0] == (4, 0, 0):
222-
return "i1"
223-
elif args[0] == (4, 1, 0):
224220
return "__device_dts_ord_22"
225221
return f"name_{args[0][0]}_{args[0][1]}"
226222
mock_on.side_effect = mock_obj_name
@@ -230,14 +226,15 @@ def mock_obj_name(*args):
230226
self.assertDictEqual(obj.initlevels, {
231227
"EARLY": [],
232228
"PRE_KERNEL_1": [],
233-
"PRE_KERNEL_2": ["a: i0(__device_dts_ord_11)", "b: i1(__device_dts_ord_22)"],
234-
"POST_KERNEL": ["c: name_8_0(name_8_1)"],
229+
"PRE_KERNEL_2": ["a: __device_dts_ord_11", "b: __device_dts_ord_22"],
230+
"POST_KERNEL": ["c: name_8_0"],
235231
"APPLICATION": [],
236232
"SMP": [],
237233
})
234+
238235
self.assertDictEqual(obj.devices, {
239-
11: (check_init_priorities.Priority("PRE_KERNEL_2", 0), "i0"),
240-
22: (check_init_priorities.Priority("PRE_KERNEL_2", 1), "i1"),
236+
11: check_init_priorities.Priority("PRE_KERNEL_2", 0),
237+
22: check_init_priorities.Priority("PRE_KERNEL_2", 1),
241238
})
242239

243240
class testValidator(unittest.TestCase):
@@ -303,14 +300,14 @@ def test_check(self, mock_vinit):
303300
validator._ord2node[2]._binding = None
304301
validator._ord2node[2].path = "/2"
305302

306-
validator._obj.devices = {1: (10, "i1"), 2: (20, "i2")}
303+
validator._obj.devices = {1: 10, 2: 20}
307304

308305
validator._check_dep(2, 1)
309306
validator._check_dep(1, 2)
310307

311-
validator.log.info.assert_called_once_with("/2 <i2> 20 > /1 <i1> 10")
308+
validator.log.info.assert_called_once_with("/2 20 > /1 10")
312309
validator.log.error.assert_has_calls([
313-
mock.call("/1 <i1> is initialized before its dependency /2 <i2> (10 < 20)")
310+
mock.call("/1 is initialized before its dependency /2 (10 < 20)")
314311
])
315312
self.assertEqual(validator.errors, 1)
316313

@@ -327,7 +324,7 @@ def test_check_same_prio_assert(self, mock_vinit):
327324
validator._ord2node[2]._binding = None
328325
validator._ord2node[2].path = "/2"
329326

330-
validator._obj.devices = {1: (10, "i1"), 2: (10, "i2")}
327+
validator._obj.devices = {1: 10, 2: 10,}
331328

332329
with self.assertRaises(ValueError):
333330
validator._check_dep(1, 2)

0 commit comments

Comments
 (0)