diff mbox series

[24/63] dyndbg: hoist the range-overlap checks

Message ID 20250125064619.8305-25-jim.cromie@gmail.com (mailing list archive)
State New
Headers show
Series Fix CONFIG_DRM_USE_DYNAMIC_DEBUG=y | expand

Commit Message

Jim Cromie Jan. 25, 2025, 6:45 a.m. UTC
hoist the classmaps range-check up to ddebug_add_module() from
ddebug_module_apply_class*().  THis puts both copies of the task
together, with the other semi-init work.

this allows ddebug_module_apply_class*() to revert back to void
return, but doesn't do that yet.

this is a candidate for squashing back.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 lib/dynamic_debug.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 8e1e087e07c3..e57c05c9fb0a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1257,11 +1257,9 @@  static int ddebug_module_apply_class_maps(struct ddebug_table *dt,
 	struct ddebug_class_map *cm;
 	int i;
 
-	for_subvec(i, cm, &dt->info, maps) {
-		if (ddebug_class_range_overlap(cm, reserved_ids))
-			return -EINVAL;
+	for_subvec(i, cm, &dt->info, maps)
 		ddebug_apply_params(cm, cm->mod_name);
-	}
+
 	vpr_info("module:%s attached %d classmaps\n", dt->mod_name, dt->info.maps.len);
 	return 0;
 }
@@ -1272,11 +1270,9 @@  static int ddebug_module_apply_class_users(struct ddebug_table *dt,
 	struct ddebug_class_user *cli;
 	int i;
 
-	for_subvec(i, cli, &dt->info, users) {
-		if (ddebug_class_range_overlap(cli->map, reserved_ids))
-			return -EINVAL;
+	for_subvec(i, cli, &dt->info, users)
 		ddebug_apply_params(cli->map, cli->mod_name);
-	}
+
 	vpr_info("module:%s attached %d classmap uses\n", dt->mod_name, dt->info.users.len);
 	return 0;
 }
@@ -1322,6 +1318,13 @@  static int ddebug_add_module(struct _ddebug_info *di, const char *modname)
 	dd_mark_vector_subrange(i, dt, cm, di, maps);
 	dd_mark_vector_subrange(i, dt, cli, di, users);
 
+	for_subvec(i, cm, &dt->info, maps)
+		if (ddebug_class_range_overlap(cm, &reserved_ids))
+			return -EINVAL;
+	for_subvec(i, cli, &dt->info, users)
+		if (ddebug_class_range_overlap(cli->map, &reserved_ids))
+			return -EINVAL;
+
 	if (dt->info.maps.len) {
 		rc = ddebug_module_apply_class_maps(dt, &reserved_ids);
 		if (rc) {