From: Simon Glass <simon.glass@canonical.com> Add a pre_remove() handler to unregister the video_idle() cyclic when the last video device is removed. This ensures the cyclic won't run after driver model is reinited by the test framework. This complements the uclass_find() fix by properly cleaning up the cyclic registration rather than just gracefully handling the orphaned state. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- (no changes since v1) drivers/video/video-uclass.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 383be0d96b8..3e02c48d399 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -874,6 +874,23 @@ __maybe_unused static int video_destroy(struct uclass *uc) return 0; } +__maybe_unused static int video_pre_remove(struct udevice *dev) +{ + struct video_uc_priv *uc_priv = uclass_get_priv(dev->uclass); + + /* + * Unregister the cyclic before removing the last video device. This + * ensures the cyclic won't run after driver model is reinitialised + * by the test framework. + */ + if (uc_priv->cyc_active && uclass_id_count(UCLASS_VIDEO) == 1) { + cyclic_unregister(&uc_priv->cyc); + uc_priv->cyc_active = false; + } + + return 0; +} + void video_set_manual_sync(bool enable) { struct video_uc_priv *uc_priv; @@ -897,5 +914,6 @@ UCLASS_DRIVER(video) = { .priv_auto = sizeof(struct video_uc_priv), .per_device_auto = sizeof(struct video_priv), .per_device_plat_auto = sizeof(struct video_uc_plat), + CONFIG_IS_ENABLED(CYCLIC, (.pre_remove = video_pre_remove, )) CONFIG_IS_ENABLED(CYCLIC, (.destroy = video_destroy, )) }; -- 2.43.0