git: 63ec5947474a - releng/13.1 - LinuxKPI: allow bsddriver name to be set for PCI

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 30 Mar 2022 15:49:45 UTC
The branch releng/13.1 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=63ec5947474a545bb2733647e8a88d5da5e4cde9

commit 63ec5947474a545bb2733647e8a88d5da5e4cde9
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-30 15:47:18 +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.
    
    Approved by:    re (gjb)
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    emaste, hselasky
    Differential Revision: https://reviews.freebsd.org/D34653
    
    (cherry picked from commit 81d058df6d255b7f551564f6d29a03692b51fe5a)
    (cherry picked from commit 00450eeab2465d6dc800680158b2cc67c1a7d9fc)
---
 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 bc169425c6a8..0734acac60ac 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);