[PATCH] RDMS/hns: Use named initializer for pci_device_id array
From: Uwe Kleine-König (The Capable Hub)
Date: Thu May 07 2026 - 03:54:59 EST
While being more verbose using a named initializer yields easier to
understand code and doesn't rely on the two hidden zeros in the
PCI_VDEVICE macro.
While at it, also drop the explicit zero in the terminating entry.
This doesn't introduce any changes to the compiled result of the array,
which was confirmed on x86 and arm64.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@xxxxxxxxxxxx>
---
Hello,
while being a cleanup that can stand on its own this is also a
preparation for making driver_data an anonymous union that requires that
.driver_data is initialized by name and not by list order. The union
allows to make better use of the C type system (see
https://lore.kernel.org/all/20260507074102.2654314-2-u.kleine-koenig@xxxxxxxxxxxx/
for an example), but inifiniband won't profit as no driver uses a
pointer for driver_data.
Best regards
Uwe
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 32 ++++++++++++++++------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index fa36700d0db2..cfe5269ba6a8 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -7249,16 +7249,30 @@ static const struct hns_roce_hw hns_roce_hw_v2 = {
};
static const struct pci_device_id hns_roce_hw_v2_pci_tbl[] = {
- {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA), 0},
- {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA_MACSEC), 0},
- {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA), 0},
- {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC), 0},
- {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), 0},
- {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_200G_RDMA), 0},
- {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_RDMA_DCB_PFC_VF),
- HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},
+ {
+ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA),
+ .driver_data = 0,
+ }, {
+ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA_MACSEC),
+ .driver_data = 0,
+ }, {
+ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA),
+ .driver_data = 0,
+ }, {
+ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC),
+ .driver_data = 0,
+ }, {
+ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC),
+ .driver_data = 0,
+ }, {
+ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_200G_RDMA),
+ .driver_data = 0,
+ }, {
+ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_RDMA_DCB_PFC_VF),
+ .driver_data = HNAE3_DEV_SUPPORT_ROCE_DCB_BITS,
+ },
/* required last entry */
- {0, }
+ { }
};
MODULE_DEVICE_TABLE(pci, hns_roce_hw_v2_pci_tbl);
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
--
2.47.3