diff --git a/module/evdi_drm_drv.h b/module/evdi_drm_drv.h index 71803d3..ea4bf4e 100644 --- a/module/evdi_drm_drv.h +++ b/module/evdi_drm_drv.h @@ -38,6 +38,23 @@ #include #include +/* + * drm-next (>= 7.1.0) renamed the global atomic-state object and its helpers: + * struct drm_atomic_state -> struct drm_atomic_commit + * drm_atomic_state_alloc/clear/put -> drm_atomic_commit_alloc/clear/put + * The atomic-helper vtable callbacks (.atomic_flush/.atomic_update/...) and the + * state accessors (drm_atomic_get_{new,old}_*_state) now take a + * struct drm_atomic_commit *. evdi's source still uses the historical names, so + * alias them. The old identifiers are fully gone from the tree, so these + * whole-token macros are collision-free. + */ +#if KERNEL_VERSION(7, 1, 0) <= LINUX_VERSION_CODE +#define drm_atomic_state drm_atomic_commit +#define drm_atomic_state_alloc drm_atomic_commit_alloc +#define drm_atomic_state_clear drm_atomic_commit_clear +#define drm_atomic_state_put drm_atomic_commit_put +#endif + #include "evdi_debug.h" #include "tests/evdi_test.h" diff --git a/module/evdi_platform_dev.c b/module/evdi_platform_dev.c index 35d3811..86f92fa 100644 --- a/module/evdi_platform_dev.c +++ b/module/evdi_platform_dev.c @@ -140,7 +140,7 @@ void evdi_platform_device_link(struct platform_device *pdev, } } -void evdi_platform_device_unlink_if_linked_with(struct platform_device *pdev, +bool evdi_platform_device_unlink_if_linked_with(struct platform_device *pdev, struct device *parent) { struct evdi_platform_device_data *data = platform_get_drvdata(pdev); @@ -150,5 +150,7 @@ void evdi_platform_device_unlink_if_linked_with(struct platform_device *pdev, data->symlinked = false; data->parent = NULL; EVDI_INFO("Detached from parent device\n"); + return true; } + return false; } diff --git a/module/evdi_platform_dev.h b/module/evdi_platform_dev.h index 9c178ab..9d8ea94 100644 --- a/module/evdi_platform_dev.h +++ b/module/evdi_platform_dev.h @@ -41,7 +41,7 @@ int evdi_platform_device_remove(struct platform_device *pdev); bool evdi_platform_device_is_free(struct platform_device *pdev); void evdi_platform_device_link(struct platform_device *pdev, struct device *parent); -void evdi_platform_device_unlink_if_linked_with(struct platform_device *pdev, +bool evdi_platform_device_unlink_if_linked_with(struct platform_device *pdev, struct device *parent); #endif diff --git a/module/evdi_platform_drv.c b/module/evdi_platform_drv.c index b83f12f..f52aed3 100644 --- a/module/evdi_platform_drv.c +++ b/module/evdi_platform_drv.c @@ -55,15 +55,15 @@ static int evdi_platform_drv_usb(__always_unused struct notifier_block *nb, if (!usb_dev) return 0; - if (action != BUS_NOTIFY_DEL_DEVICE) + if (action != USB_DEVICE_REMOVE) return 0; for (i = 0; i < EVDI_DEVICE_COUNT_MAX; ++i) { pdev = g_ctx.devices[i]; if (!pdev) continue; - evdi_platform_device_unlink_if_linked_with(pdev, &usb_dev->dev); - if (pdev->dev.parent == &usb_dev->dev) { + if (evdi_platform_device_unlink_if_linked_with(pdev, &usb_dev->dev) && + i >= evdi_initial_device_count) { EVDI_INFO("Parent USB removed. Removing evdi.%d\n", i); evdi_platform_dev_destroy(pdev); evdi_platform_drv_context_lock((&g_ctx));