The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] RDMS/hns: Use named initializer for pci_device_id array
@ 2026-05-07  7:54 Uwe Kleine-König (The Capable Hub)
  2026-05-11  1:53 ` Junxian Huang
  2026-05-13 18:51 ` Leon Romanovsky
  0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-07  7:54 UTC (permalink / raw)
  To: Chengchang Tang, Junxian Huang, Jason Gunthorpe, Leon Romanovsky
  Cc: Markus Schneider-Pargmann, linux-rdma, linux-kernel

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@baylibre.com>
---
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@baylibre.com/
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMS/hns: Use named initializer for pci_device_id array
  2026-05-07  7:54 [PATCH] RDMS/hns: Use named initializer for pci_device_id array Uwe Kleine-König (The Capable Hub)
@ 2026-05-11  1:53 ` Junxian Huang
  2026-05-13 18:51 ` Leon Romanovsky
  1 sibling, 0 replies; 4+ messages in thread
From: Junxian Huang @ 2026-05-11  1:53 UTC (permalink / raw)
  To: Uwe Kleine-König (The Capable Hub), Chengchang Tang,
	Jason Gunthorpe, Leon Romanovsky
  Cc: Markus Schneider-Pargmann, linux-rdma, linux-kernel



On 2026/5/7 15:54, Uwe Kleine-König (The Capable Hub) wrote:
> 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@baylibre.com>
> ---
> 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@baylibre.com/
> for an example), but inifiniband won't profit as no driver uses a
> pointer for driver_data.
> 
> Best regards
> Uwe

There is a small typo in the patch subject, it should be "RDMA/hns".
The patch itself looks good to me.

Reviewed-by: Junxian Huang <huangjunxian6@hisilicon.com>

Thanks,
Junxian

> 
>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMS/hns: Use named initializer for pci_device_id array
  2026-05-07  7:54 [PATCH] RDMS/hns: Use named initializer for pci_device_id array Uwe Kleine-König (The Capable Hub)
  2026-05-11  1:53 ` Junxian Huang
@ 2026-05-13 18:51 ` Leon Romanovsky
  2026-05-13 20:14   ` Uwe Kleine-König (The Capable Hub)
  1 sibling, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2026-05-13 18:51 UTC (permalink / raw)
  To: Chengchang Tang, Junxian Huang, Jason Gunthorpe,
	Uwe Kleine-König (The Capable Hub)
  Cc: Markus Schneider-Pargmann, linux-rdma, linux-kernel


On Thu, 07 May 2026 09:54:37 +0200, Uwe Kleine-König (The Capable Hub) wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] RDMS/hns: Use named initializer for pci_device_id array
      https://git.kernel.org/rdma/rdma/c/9dd3e17173bfb8

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMS/hns: Use named initializer for pci_device_id array
  2026-05-13 18:51 ` Leon Romanovsky
@ 2026-05-13 20:14   ` Uwe Kleine-König (The Capable Hub)
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-13 20:14 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Chengchang Tang, Junxian Huang, Jason Gunthorpe,
	Markus Schneider-Pargmann, linux-rdma, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

On Wed, May 13, 2026 at 02:51:20PM -0400, Leon Romanovsky wrote:
> 
> On Thu, 07 May 2026 09:54:37 +0200, Uwe Kleine-König (The Capable Hub) wrote:
> > 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.
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/1] RDMS/hns: Use named initializer for pci_device_id array
>       https://git.kernel.org/rdma/rdma/c/9dd3e17173bfb8

Thanks for picking the patch up and also for the typo fix!

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-13 20:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07  7:54 [PATCH] RDMS/hns: Use named initializer for pci_device_id array Uwe Kleine-König (The Capable Hub)
2026-05-11  1:53 ` Junxian Huang
2026-05-13 18:51 ` Leon Romanovsky
2026-05-13 20:14   ` Uwe Kleine-König (The Capable Hub)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox