linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() helper macro
@ 2021-07-23  3:36 Cai Huoqing
  2021-07-23  3:36 ` [PATCH v3 1/2] PCI: Make use of PCI_DEVICE_SUB/_CLASS() " Cai Huoqing
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Cai Huoqing @ 2021-07-23  3:36 UTC (permalink / raw)
  To: kw, bhelgaas, jonathan.derrick, lorenzo.pieralisi, robh
  Cc: linux-pci, linux-kernel, Cai Huoqing

Could make use of PCI_DEVICE_XXX() helper macro

v1->v2: *fix extra indent for git-apply failure

v2->v3: *update the subject line from "function" to "macro"
	*add changelog to commit message

commit date: 7-23-2021 11:00

Cai Huoqing (2):
  PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper macro
  PCI: vmd: Make use of PCI_DEVICE_DATA() helper macro

 drivers/pci/controller/vmd.c      | 38 +++++++++++++++----------------
 drivers/pci/hotplug/cpqphp_core.c | 13 ++---------
 drivers/pci/search.c              | 14 ++----------
 include/linux/pci_ids.h           |  2 ++
 4 files changed, 25 insertions(+), 42 deletions(-)

-- 
2.25.1


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

* [PATCH v3 1/2] PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper macro
  2021-07-23  3:36 [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() helper macro Cai Huoqing
@ 2021-07-23  3:36 ` Cai Huoqing
  2021-07-23  3:36 ` [PATCH v3 2/2] PCI: vmd: Make use of PCI_DEVICE_DATA() " Cai Huoqing
  2021-07-26  1:39 ` [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() " Cai,Huoqing
  2 siblings, 0 replies; 4+ messages in thread
From: Cai Huoqing @ 2021-07-23  3:36 UTC (permalink / raw)
  To: kw, bhelgaas, jonathan.derrick, lorenzo.pieralisi, robh
  Cc: linux-pci, linux-kernel, Cai Huoqing

We could make use of PCI_DEVICE_SUB/CLASS() helper macro

v1->v2: *fix extra indent for git-apply failure

v2->v3: *update the subject line from "function" to "macro"
	*add changelog to commit message

commit date: 7-23-2021 11:00

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
 drivers/pci/hotplug/cpqphp_core.c | 13 ++-----------
 drivers/pci/search.c              | 14 ++------------
 2 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index f99a7927e5a8..407206a233c8 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -1357,18 +1357,9 @@ static void __exit unload_cpqphpd(void)
 }
 
 static const struct pci_device_id hpcd_pci_tbl[] = {
-	{
 	/* handle any PCI Hotplug controller */
-	.class =        ((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00),
-	.class_mask =   ~0,
-
-	/* no matter who makes it */
-	.vendor =       PCI_ANY_ID,
-	.device =       PCI_ANY_ID,
-	.subvendor =    PCI_ANY_ID,
-	.subdevice =    PCI_ANY_ID,
-
-	}, { /* end: all zeroes */ }
+	{ PCI_DEVICE_CLASS(((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00), ~0) },
+	{ /* end: all zeroes */ },
 };
 
 MODULE_DEVICE_TABLE(pci, hpcd_pci_tbl);
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index b4c138a6ec02..528c4fe33171 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -303,11 +303,7 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
 			       struct pci_dev *from)
 {
 	struct pci_device_id id = {
-		.vendor = vendor,
-		.device = device,
-		.subvendor = ss_vendor,
-		.subdevice = ss_device,
-	};
+		PCI_DEVICE_SUB(vendor, device, ss_vendor, ss_device) };
 
 	return pci_get_dev_by_id(&id, from);
 }
@@ -351,13 +347,7 @@ EXPORT_SYMBOL(pci_get_device);
 struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
 {
 	struct pci_device_id id = {
-		.vendor = PCI_ANY_ID,
-		.device = PCI_ANY_ID,
-		.subvendor = PCI_ANY_ID,
-		.subdevice = PCI_ANY_ID,
-		.class_mask = PCI_ANY_ID,
-		.class = class,
-	};
+		PCI_DEVICE_CLASS(PCI_ANY_ID, class) };
 
 	return pci_get_dev_by_id(&id, from);
 }
-- 
2.25.1


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

* [PATCH v3 2/2] PCI: vmd: Make use of PCI_DEVICE_DATA() helper macro
  2021-07-23  3:36 [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() helper macro Cai Huoqing
  2021-07-23  3:36 ` [PATCH v3 1/2] PCI: Make use of PCI_DEVICE_SUB/_CLASS() " Cai Huoqing
@ 2021-07-23  3:36 ` Cai Huoqing
  2021-07-26  1:39 ` [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() " Cai,Huoqing
  2 siblings, 0 replies; 4+ messages in thread
From: Cai Huoqing @ 2021-07-23  3:36 UTC (permalink / raw)
  To: kw, bhelgaas, jonathan.derrick, lorenzo.pieralisi, robh
  Cc: linux-pci, linux-kernel, Cai Huoqing

We could make use of PCI_DEVICE_DATA() helper macro

v1->v2: *fix extra indent which for git-apply failure

v2->v3: *update the subject line from "function" to "macro"
	*add changelog to commit message

commit date: 7-23-2021 11:00

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
 drivers/pci/controller/vmd.c | 38 ++++++++++++++++++------------------
 include/linux/pci_ids.h      |  2 ++
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index e3fcdfec58b3..565681ed00a1 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -859,25 +859,25 @@ static int vmd_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(vmd_dev_pm_ops, vmd_suspend, vmd_resume);
 
 static const struct pci_device_id vmd_ids[] = {
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_201D),
-		.driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP,},
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_28C0),
-		.driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW |
-				VMD_FEAT_HAS_BUS_RESTRICTIONS |
-				VMD_FEAT_CAN_BYPASS_MSI_REMAP,},
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x467f),
-		.driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
-				VMD_FEAT_HAS_BUS_RESTRICTIONS |
-				VMD_FEAT_OFFSET_FIRST_VECTOR,},
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4c3d),
-		.driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
-				VMD_FEAT_HAS_BUS_RESTRICTIONS |
-				VMD_FEAT_OFFSET_FIRST_VECTOR,},
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_9A0B),
-		.driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
-				VMD_FEAT_HAS_BUS_RESTRICTIONS |
-				VMD_FEAT_OFFSET_FIRST_VECTOR,},
-	{0,}
+	{ PCI_DEVICE_DATA(INTEL, VMD_201D,
+			  VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP) },
+	{ PCI_DEVICE_DATA(INTEL, VMD_28C0,
+			  VMD_FEAT_HAS_MEMBAR_SHADOW |
+			  VMD_FEAT_HAS_BUS_RESTRICTIONS |
+			  VMD_FEAT_CAN_BYPASS_MSI_REMAP) },
+	{ PCI_DEVICE_DATA(INTEL, VMD_467F,
+			  VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
+			  VMD_FEAT_HAS_BUS_RESTRICTIONS |
+			  VMD_FEAT_OFFSET_FIRST_VECTOR) },
+	{ PCI_DEVICE_DATA(INTEL, VMD_4C3D,
+			  VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
+			  VMD_FEAT_HAS_BUS_RESTRICTIONS |
+			  VMD_FEAT_OFFSET_FIRST_VECTOR) },
+	{ PCI_DEVICE_DATA(INTEL, VMD_9A0B,
+			  VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP |
+			  VMD_FEAT_HAS_BUS_RESTRICTIONS |
+			  VMD_FEAT_OFFSET_FIRST_VECTOR) },
+	{ },
 };
 MODULE_DEVICE_TABLE(pci, vmd_ids);
 
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 4bac1831de80..d25552b5ae3e 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2954,6 +2954,8 @@
 #define PCI_DEVICE_ID_INTEL_SBRIDGE_BR		0x3cf5	/* 13.6 */
 #define PCI_DEVICE_ID_INTEL_SBRIDGE_SAD1	0x3cf6	/* 12.7 */
 #define PCI_DEVICE_ID_INTEL_IOAT_SNB	0x402f
+#define PCI_DEVICE_ID_INTEL_VMD_467F	0x467f
+#define PCI_DEVICE_ID_INTEL_VMD_4C3D	0x4c3d
 #define PCI_DEVICE_ID_INTEL_5100_16	0x65f0
 #define PCI_DEVICE_ID_INTEL_5100_19	0x65f3
 #define PCI_DEVICE_ID_INTEL_5100_21	0x65f5
-- 
2.25.1


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

* RE: [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() helper macro
  2021-07-23  3:36 [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() helper macro Cai Huoqing
  2021-07-23  3:36 ` [PATCH v3 1/2] PCI: Make use of PCI_DEVICE_SUB/_CLASS() " Cai Huoqing
  2021-07-23  3:36 ` [PATCH v3 2/2] PCI: vmd: Make use of PCI_DEVICE_DATA() " Cai Huoqing
@ 2021-07-26  1:39 ` Cai,Huoqing
  2 siblings, 0 replies; 4+ messages in thread
From: Cai,Huoqing @ 2021-07-26  1:39 UTC (permalink / raw)
  To: kw, bhelgaas, jonathan.derrick, lorenzo.pieralisi, robh
  Cc: linux-pci, linux-kernel

Hi
Do you think patch-v3 is OK,  that's my pleasure if you give me some comments about v3

Cai
thanks

-----Original Message-----
From: Cai,Huoqing <caihuoqing@baidu.com> 
Sent: 2021年7月23日 11:36
To: kw@linux.com; bhelgaas@google.com; jonathan.derrick@intel.com; lorenzo.pieralisi@arm.com; robh@kernel.org
Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org; Cai,Huoqing <caihuoqing@baidu.com>
Subject: [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() helper macro

Could make use of PCI_DEVICE_XXX() helper macro

v1->v2: *fix extra indent for git-apply failure

v2->v3: *update the subject line from "function" to "macro"
	*add changelog to commit message

commit date: 7-23-2021 11:00

Cai Huoqing (2):
  PCI: Make use of PCI_DEVICE_SUB/_CLASS() helper macro
  PCI: vmd: Make use of PCI_DEVICE_DATA() helper macro

 drivers/pci/controller/vmd.c      | 38 +++++++++++++++----------------
 drivers/pci/hotplug/cpqphp_core.c | 13 ++---------
 drivers/pci/search.c              | 14 ++----------
 include/linux/pci_ids.h           |  2 ++
 4 files changed, 25 insertions(+), 42 deletions(-)

-- 
2.25.1


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

end of thread, other threads:[~2021-07-26  1:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23  3:36 [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() helper macro Cai Huoqing
2021-07-23  3:36 ` [PATCH v3 1/2] PCI: Make use of PCI_DEVICE_SUB/_CLASS() " Cai Huoqing
2021-07-23  3:36 ` [PATCH v3 2/2] PCI: vmd: Make use of PCI_DEVICE_DATA() " Cai Huoqing
2021-07-26  1:39 ` [PATCH v3 0/2] PCI: Make use of PCI_DEVICE_XXX() " Cai,Huoqing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).