git: 8a6ec2975633 - stable/14 - LinuxKPI: Automatically enable drm support for devices named "drmn"

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Thu, 01 Aug 2024 22:27:56 UTC
The branch stable/14 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=8a6ec2975633f9649c1d8fcb92df55a8a349f554

commit 8a6ec2975633f9649c1d8fcb92df55a8a349f554
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2024-07-21 13:02:08 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2024-08-01 21:14:03 +0000

    LinuxKPI: Automatically enable drm support for devices named "drmn"
    
    This allows replace linux_pci_(un)register_drm_driver calls with driver
    renaming to FreeBSD name.
    
    Sponsored by:   Serenity CyberSecurity, LLC
    MFC after:      1 week
    Reviewed by:    manu, bz
    Differential Revision:  https://reviews.freebsd.org/D45906
    
    (cherry picked from commit 5d20075f8b9f7107aa0a246e5165d9816e816a44)
---
 sys/compat/linuxkpi/common/src/linux_pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
index 551b924d6f5e..3ed0f268d5f9 100644
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -975,10 +975,10 @@ linux_pci_register_driver(struct pci_driver *pdrv)
 {
 	devclass_t dc;
 
-	dc = devclass_find("pci");
+	pdrv->isdrm = strcmp(pdrv->name, "drmn") == 0;
+	dc = pdrv->isdrm ? devclass_create("vgapci") : devclass_find("pci");
 	if (dc == NULL)
 		return (-ENXIO);
-	pdrv->isdrm = false;
 	return (_linux_pci_register_driver(pdrv, dc));
 }
 
@@ -1165,7 +1165,7 @@ linux_pci_unregister_driver(struct pci_driver *pdrv)
 {
 	devclass_t bus;
 
-	bus = devclass_find("pci");
+	bus = devclass_find(pdrv->isdrm ? "vgapci" : "pci");
 
 	spin_lock(&pci_lock);
 	list_del(&pdrv->node);