public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ufs: Rework pci_device_id initialization
@ 2026-05-05  8:25 Uwe Kleine-König (The Capable Hub)
  2026-05-05  8:28 ` [PATCH 1/2] ufs: tc-dwc-g210-pci: Simplify initialization of pci_device_id array Uwe Kleine-König (The Capable Hub)
  2026-05-05  8:28 ` [PATCH 2/2] ufs: ufshcd-pci: Use PCI_VDEVICE and named initializers for pci array Uwe Kleine-König (The Capable Hub)
  0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-05  8:25 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Bart Van Assche, Adrian Hunter, Peter Wang, Bean Huo, Can Guo,
	Archana Patni, Markus Schneider-Pargmann, linux-scsi,
	linux-kernel

Hello,

the patches in this series adapt the pci_device_id arrays of two ufs
drivers. These are preparing a change for making struct
pci_device_id::driver_data an anonymous union (similar to
https://lore.kernel.org/all/cover.1776579304.git.u.kleine-koenig@baylibre.com/).
This requires named initializers for .driver_data. But even without that
this is a nice cleanup making the array better readable and consistent.

The benefit for the union is that it allows to do:

-	{ PCI_VDEVICE(REDHAT, 0x0013), .driver_data = (kernel_ulong_t)&ufs_qemu_hba_vops },
+	{ PCI_VDEVICE(REDHAT, 0x0013), .driver_data_ptr = &ufs_qemu_hba_vops },

and

-	hba->vops = (struct ufs_hba_variant_ops *)id->driver_data;
+	hba->vops = id->driver_data_ptr;

. This involves less casting and thus makes usage of driver_data a bit
more type safe. And this will make it obvious that the ufshcd-pci driver
lacks a few consts.

Best regards
Uwe

Uwe Kleine-König (The Capable Hub) (2):
  ufs: tc-dwc-g210-pci: Simplify initialization of pci_device_id array
  ufs: ufshcd-pci: Use PCI_VDEVICE and named initializers for pci array

 drivers/ufs/host/tc-dwc-g210-pci.c |  4 ++--
 drivers/ufs/host/ufshcd-pci.c      | 29 ++++++++++++++---------------
 2 files changed, 16 insertions(+), 17 deletions(-)


base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
-- 
2.47.3


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

* [PATCH 1/2] ufs: tc-dwc-g210-pci: Simplify initialization of pci_device_id array
  2026-05-05  8:25 [PATCH 0/2] ufs: Rework pci_device_id initialization Uwe Kleine-König (The Capable Hub)
@ 2026-05-05  8:28 ` Uwe Kleine-König (The Capable Hub)
  2026-05-05  8:28 ` [PATCH 2/2] ufs: ufshcd-pci: Use PCI_VDEVICE and named initializers for pci array Uwe Kleine-König (The Capable Hub)
  1 sibling, 0 replies; 4+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-05  8:28 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Bart Van Assche, Adrian Hunter, Peter Wang, Bean Huo, Can Guo,
	Archana Patni, Markus Schneider-Pargmann, linux-scsi,
	linux-kernel

A list initializer is hard to parse for a human if they don't see or know
the order of the members of struct pci_devcie_id. So use the PCI_VDEVICE
macro which is much more ideomatic and skip assigning explicit zeros.

There are no changes to the compiled result of the array; verified with
builds for x86 and arm64.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
 drivers/ufs/host/tc-dwc-g210-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ufs/host/tc-dwc-g210-pci.c b/drivers/ufs/host/tc-dwc-g210-pci.c
index 0167d8bef71a..c6d89f9c44ae 100644
--- a/drivers/ufs/host/tc-dwc-g210-pci.c
+++ b/drivers/ufs/host/tc-dwc-g210-pci.c
@@ -114,8 +114,8 @@ static const struct dev_pm_ops tc_dwc_g210_pci_pm_ops = {
 };
 
 static const struct pci_device_id tc_dwc_g210_pci_tbl[] = {
-	{ PCI_VENDOR_ID_SYNOPSYS, 0xB101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_SYNOPSYS, 0xB102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VDEVICE(SYNOPSYS, 0xB101) },
+	{ PCI_VDEVICE(SYNOPSYS, 0xB102) },
 	{ }	/* terminate list */
 };
 
-- 
2.47.3


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

* [PATCH 2/2] ufs: ufshcd-pci: Use PCI_VDEVICE and named initializers for pci array
  2026-05-05  8:25 [PATCH 0/2] ufs: Rework pci_device_id initialization Uwe Kleine-König (The Capable Hub)
  2026-05-05  8:28 ` [PATCH 1/2] ufs: tc-dwc-g210-pci: Simplify initialization of pci_device_id array Uwe Kleine-König (The Capable Hub)
@ 2026-05-05  8:28 ` Uwe Kleine-König (The Capable Hub)
  2026-05-05  9:25   ` Adrian Hunter
  1 sibling, 1 reply; 4+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-05  8:28 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Bart Van Assche, Adrian Hunter, Peter Wang, Bean Huo, Can Guo,
	Archana Patni, Markus Schneider-Pargmann, linux-scsi,
	linux-kernel

The pci_device_id array uses a mixture of ways to initialize
ufshcd_pci_tbl[]. List initializers are hard to read unless you memoized
the order of the struct members. Use the PCI_VDEVICE for all entries and
a named initializer for .driver_data.

This allows to idiomatically assign the members without using zeros to
fill the fields before .driver_data (either explicitly or hidding in
PCI_VDEVICE()).

There are no changes to the compiled result of the array; verified with
builds for x86 and arm64.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
 drivers/ufs/host/ufshcd-pci.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/ufs/host/ufshcd-pci.c b/drivers/ufs/host/ufshcd-pci.c
index effa3c7a01c5..13293e83064c 100644
--- a/drivers/ufs/host/ufshcd-pci.c
+++ b/drivers/ufs/host/ufshcd-pci.c
@@ -680,21 +680,20 @@ static const struct dev_pm_ops ufshcd_pci_pm_ops = {
 };
 
 static const struct pci_device_id ufshcd_pci_tbl[] = {
-	{ PCI_VENDOR_ID_REDHAT, 0x0013, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-		(kernel_ulong_t)&ufs_qemu_hba_vops },
-	{ PCI_VENDOR_ID_SAMSUNG, 0xC00C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VDEVICE(INTEL, 0x9DFA), (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0x4B41), (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0x4B43), (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0x98FA), (kernel_ulong_t)&ufs_intel_lkf_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0x51FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0x54FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0x7E47), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0xA847), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0x7747), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0xE447), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0x4D47), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
-	{ PCI_VDEVICE(INTEL, 0xD335), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
+	{ PCI_VDEVICE(REDHAT, 0x0013), .driver_data = (kernel_ulong_t)&ufs_qemu_hba_vops },
+	{ PCI_VDEVICE(SAMSUNG, 0xC00C), .driver_data = 0 },
+	{ PCI_VDEVICE(INTEL, 0x9DFA), .driver_data = (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0x4B41), .driver_data = (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0x4B43), .driver_data = (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0x98FA), .driver_data = (kernel_ulong_t)&ufs_intel_lkf_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0x51FF), .driver_data = (kernel_ulong_t)&ufs_intel_adl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0x54FF), .driver_data = (kernel_ulong_t)&ufs_intel_adl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0x7E47), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0xA847), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0x7747), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0xE447), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0x4D47), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
+	{ PCI_VDEVICE(INTEL, 0xD335), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
 	{ }	/* terminate list */
 };
 
-- 
2.47.3


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

* Re: [PATCH 2/2] ufs: ufshcd-pci: Use PCI_VDEVICE and named initializers for pci array
  2026-05-05  8:28 ` [PATCH 2/2] ufs: ufshcd-pci: Use PCI_VDEVICE and named initializers for pci array Uwe Kleine-König (The Capable Hub)
@ 2026-05-05  9:25   ` Adrian Hunter
  0 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2026-05-05  9:25 UTC (permalink / raw)
  To: Uwe Kleine-König (The Capable Hub), James E.J. Bottomley,
	Martin K. Petersen
  Cc: Bart Van Assche, Peter Wang, Bean Huo, Can Guo, Archana Patni,
	Markus Schneider-Pargmann, linux-scsi, linux-kernel

On 05/05/2026 11:28, Uwe Kleine-König (The Capable Hub) wrote:
> The pci_device_id array uses a mixture of ways to initialize
> ufshcd_pci_tbl[]. List initializers are hard to read unless you memoized
> the order of the struct members. Use the PCI_VDEVICE for all entries and
> a named initializer for .driver_data.
> 
> This allows to idiomatically assign the members without using zeros to
> fill the fields before .driver_data (either explicitly or hidding in
> PCI_VDEVICE()).
> 
> There are no changes to the compiled result of the array; verified with
> builds for x86 and arm64.
> 
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/ufs/host/ufshcd-pci.c | 29 ++++++++++++++---------------
>  1 file changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/ufs/host/ufshcd-pci.c b/drivers/ufs/host/ufshcd-pci.c
> index effa3c7a01c5..13293e83064c 100644
> --- a/drivers/ufs/host/ufshcd-pci.c
> +++ b/drivers/ufs/host/ufshcd-pci.c
> @@ -680,21 +680,20 @@ static const struct dev_pm_ops ufshcd_pci_pm_ops = {
>  };
>  
>  static const struct pci_device_id ufshcd_pci_tbl[] = {
> -	{ PCI_VENDOR_ID_REDHAT, 0x0013, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
> -		(kernel_ulong_t)&ufs_qemu_hba_vops },
> -	{ PCI_VENDOR_ID_SAMSUNG, 0xC00C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
> -	{ PCI_VDEVICE(INTEL, 0x9DFA), (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0x4B41), (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0x4B43), (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0x98FA), (kernel_ulong_t)&ufs_intel_lkf_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0x51FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0x54FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0x7E47), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0xA847), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0x7747), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0xE447), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0x4D47), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> -	{ PCI_VDEVICE(INTEL, 0xD335), (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> +	{ PCI_VDEVICE(REDHAT, 0x0013), .driver_data = (kernel_ulong_t)&ufs_qemu_hba_vops },
> +	{ PCI_VDEVICE(SAMSUNG, 0xC00C), .driver_data = 0 },
> +	{ PCI_VDEVICE(INTEL, 0x9DFA), .driver_data = (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0x4B41), .driver_data = (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0x4B43), .driver_data = (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0x98FA), .driver_data = (kernel_ulong_t)&ufs_intel_lkf_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0x51FF), .driver_data = (kernel_ulong_t)&ufs_intel_adl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0x54FF), .driver_data = (kernel_ulong_t)&ufs_intel_adl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0x7E47), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0xA847), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0x7747), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0xE447), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0x4D47), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
> +	{ PCI_VDEVICE(INTEL, 0xD335), .driver_data = (kernel_ulong_t)&ufs_intel_mtl_hba_vops },
>  	{ }	/* terminate list */
>  };
>  


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

end of thread, other threads:[~2026-05-05  9:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05  8:25 [PATCH 0/2] ufs: Rework pci_device_id initialization Uwe Kleine-König (The Capable Hub)
2026-05-05  8:28 ` [PATCH 1/2] ufs: tc-dwc-g210-pci: Simplify initialization of pci_device_id array Uwe Kleine-König (The Capable Hub)
2026-05-05  8:28 ` [PATCH 2/2] ufs: ufshcd-pci: Use PCI_VDEVICE and named initializers for pci array Uwe Kleine-König (The Capable Hub)
2026-05-05  9:25   ` Adrian Hunter

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