git: 81d058df6d25 - main - LinuxKPI: allow bsddriver name to be set for PCI

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Thu, 24 Mar 2022 15:21:08 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=81d058df6d255b7f551564f6d29a03692b51fe5a

commit 81d058df6d255b7f551564f6d29a03692b51fe5a
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-03-24 01:45:36 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-03-24 15:19:15 +0000

    LinuxKPI: allow bsddriver name to be set for PCI
    
    Allow a driver to overwrite the bsddriver name (we use for pci and
    for wlan parent devices).  This allows us to to set
    .bsddriver.name in struct pci_driver passed to module_pci_driver()
    and with that set the BSD driver name while retaining the Linux .name
    one.
    
    This is helpful for divers which have different parts depending on
    chipset and with that would change driver names which is highly
    confusing especially for configuration.   One example is an upcoming
    rtw88 driver which would be rtw_8822be or rtw_8822ce depending on
    chipset.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
    Reviewed by:    emaste, hselasky
    Differential Revision: https://reviews.freebsd.org/D34653
---
 sys/compat/linuxkpi/common/src/linux_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
index b4f4a2219bb4..f8ae03d2bf28 100644
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -654,7 +654,8 @@ _linux_pci_register_driver(struct pci_driver *pdrv, devclass_t dc)
 	spin_lock(&pci_lock);
 	list_add(&pdrv->node, &pci_drivers);
 	spin_unlock(&pci_lock);
-	pdrv->bsddriver.name = pdrv->name;
+	if (pdrv->bsddriver.name == NULL)
+		pdrv->bsddriver.name = pdrv->name;
 	pdrv->bsddriver.methods = pci_methods;
 	pdrv->bsddriver.size = sizeof(struct pci_dev);