bus/pci: 'RTE_PMD_REGISTER_PCI' support expand 'nm'

Message ID 20220802084839.30118-1-liulichao.09679@bytedance.com (mailing list archive)
State Rejected, archived
Delegated to: David Marchand
Headers
Series bus/pci: 'RTE_PMD_REGISTER_PCI' support expand 'nm' |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Lichao Liu Aug. 2, 2022, 8:48 a.m. UTC
  Before, 'RTE_PMD_REGISTER_PCI' can not expand nm. So, it can not
work in this situation:
    #define TEST(a, b) a##_##b
    RTE_PMD_REGISTER_PCI(TEST(a, b), test_pmd_driver)

Signed-off-by: Lichao Liu <liulichao.09679@bytedance.com>
---
 drivers/bus/pci/rte_bus_pci.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

Stephen Hemminger July 16, 2023, 6:17 p.m. UTC | #1
On Tue,  2 Aug 2022 16:48:39 +0800
Lichao Liu <liulichao.09679@bytedance.com> wrote:

> Before, 'RTE_PMD_REGISTER_PCI' can not expand nm. So, it can not
> work in this situation:
>     #define TEST(a, b) a##_##b
>     RTE_PMD_REGISTER_PCI(TEST(a, b), test_pmd_driver)
> 
> Signed-off-by: Lichao Liu <liulichao.09679@bytedance.com>

It is not clear what the problem is.
All the existing drivers work fine.

Did you follow the coding conventions and patterns of existing drivers
or try and do something different.

Recommend not accepting this patch.
If you have a more verbose example of why this won't work for you
please resubmit the patch.
  

Patch

diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h
index 1c6a8fdd7b..4f11bda19d 100644
--- a/drivers/bus/pci/rte_bus_pci.h
+++ b/drivers/bus/pci/rte_bus_pci.h
@@ -270,8 +270,7 @@  int rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable);
  */
 void rte_pci_register(struct rte_pci_driver *driver);
 
-/** Helper for PCI device registration from driver (eth, crypto) instance */
-#define RTE_PMD_REGISTER_PCI(nm, pci_drv) \
+#define _RTE_PMD_REGISTER_PCI(nm, pci_drv) \
 RTE_INIT(pciinitfn_ ##nm) \
 {\
 	(pci_drv).driver.name = RTE_STR(nm);\
@@ -279,6 +278,10 @@  RTE_INIT(pciinitfn_ ##nm) \
 } \
 RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
 
+/** Helper for PCI device registration from driver (eth, crypto) instance */
+#define RTE_PMD_REGISTER_PCI(nm, pci_drv) \
+	_RTE_PMD_REGISTER_PCI(nm, pci_drv)
+
 /**
  * Unregister a PCI driver.
  *