drm/tests: Move test EDID data to separate .c file
Subsystems (2)
PATCH v2 1/1 drm/tests: Move test EDID data to separate .c file
Having the test EDID arrays defined in the .h directly will duplicate them across every user of the EDID arrays. This works fine as long as there's only one user, but may produce build warnings/errors when there are multiple users and not all of them use all definitions.
Move the array definitions to a new .c file, and mark the declarations in the header as "extern" to avoid the linker throwing a fit, and give them an explicit size (either 128 or 256, depending on EDID) to avoid the compiler inferring that they must be size 1.
---
Changes in v2:
- Move comment blocks to .c file
- Add EXPORT_SYMBOL for all the definitions
- Link to v1: https://patch.msgid.link/20260610-test-edid-array-definition-fix-v1-1-4467ba487886@collabora.com
--- drivers/gpu/drm/tests/Makefile | 3 +- drivers/gpu/drm/tests/drm_kunit_edid.c | 991 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/tests/drm_kunit_edid.h | 985 +------------------------------- 3 files changed, 1002 insertions(+), 977 deletions(-)
drivers/gpu/drm/tests/Makefile +2 -1
@@ -24,6 +24,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ drm_probe_helper_test.o \ drm_rect_test.o \ drm_sysfb_modeset_test.o \ - drm_fixp_test.o + drm_fixp_test.o \ + drm_kunit_edid.o CFLAGS_drm_mm_test.o := $(DISABLE_STRUCTLEAK_PLUGIN)
drivers/gpu/drm/tests/drm_kunit_edid.c new file +991 -0
991 lines not on this page · raw message
drivers/gpu/drm/tests/drm_kunit_edid.h +9 -976
990 lines not on this page · raw message
---
base-commit: 2df5efb45425b48fbf5a3c1f36a686af26871009
change-id: 20260610-test-edid-array-definition-fix-43fca4e76b0a
Best regards,
Signature · 1 line
Nicolas Frattaroli <[email protected]>
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The newly added drm_kunit_edid.c file is built as a loadable module but lacks a MODULE_LICENSE()…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The newly added drm_kunit_edid.c file is built as a loadable module but lacks a MODULE_LICENSE() declaration. --
commit 6969a389dfc7ebf286991ec9afae031d0abd753f
Author: Nicolas Frattaroli <[email protected]>
drm/tests: Move test EDID data to separate .c file
This commit moves the test EDID array definitions from a header file into a newly created drm_kunit_edid.c file. The arrays are exported so they can be shared among different KUnit tests without duplicating data across multiple users.
Quoted 11 lines
drivers/gpu/drm/tests/Makefile +2
-1@@ -24,6 +24,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ drm_probe_helper_test.o \ drm_rect_test.o \ drm_sysfb_modeset_test.o \ - drm_fixp_test.o + drm_fixp_test.o \ + drm_kunit_edid.o
[ ... ]
drivers/gpu/drm/tests/drm_kunit_edid.c line 5
Quoted 11 lines
drivers/gpu/drm/tests/drm_kunit_edid.c new file +5
-0@@ -0,0 +1,991 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/export.h> + +#include "drm_kunit_edid.h"
[Severity: Low]
Because drm_kunit_edid.o is added directly to obj-$(CONFIG_DRM_KUNIT_TEST) in the Makefile, it will be built as a standalone module when that config is set to 'm'. Does this new file need to include <linux/module.h> and provide a MODULE_LICENSE() declaration to prevent modpost warnings and a tainted kernel when loaded?
Quoted 5 lines
drivers/gpu/drm/tests/drm_kunit_edid.c new file +5
-0+ +/* +* edid-decode (hex): +* +* 00 ff ff ff ff ff ff 00 31 d8 2a 00 00 00 00 00
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260610-test-edid-array-definition-fix-v2-1-9de4605c4869@collabora.com?part=1
Quoted 7 lines · Nicolas Frattaroli
Having the test EDID arrays defined in the .h directly will duplicate them across every user of the EDID arrays. This works fine as long as there's only one user, but may produce build warnings/errors when there are multiple users and not all of them use all definitions.
[ ... ]
Thanks!
Maxime