Skip to contentSkip to conversation

MISC: Convert to DEFINE_PCI_DEVICE_TABLE

PATCH In review Axel Lin 5 participants 7 messages Dec 2, 2011 – Dec 3, 2011

Subsystems (4)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 MISC: Convert to DEFINE_PCI_DEVICE_TABLE

Convert static struct pci_device_id *[] to static DEFINE_PCI_DEVICE_TABLE tables. Also convert to the PCI_DEVICE/PCI_VDEVICE macros for better readablity.

Cc Arnd Bergmann <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc David Altobelli <[email protected]>
Cc Brent Casavant <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc J Freyensee <[email protected]>
Cc Alex Dubov <[email protected]>
---
 drivers/misc/hpilo.c     |    2 +-
 drivers/misc/ioc4.c      |    6 +++---
 drivers/misc/pch_phub.c  |    2 +-
 drivers/misc/phantom.c   |    2 +-
 drivers/misc/pti.c       |    2 +-
 drivers/misc/tifm_7xx1.c |   11 ++++-------
 6 files changed, 11 insertions(+), 14 deletions(-)
drivers/misc/hpilo.c +1 -1
index fffc227..f705cbb 100644
@@ -828,7 +828,7 @@ out:
 	return error;
 }
 
-static struct pci_device_id ilo_devices[] = {
+static DEFINE_PCI_DEVICE_TABLE(ilo_devices) = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB204) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3307) },
 	{ }
drivers/misc/ioc4.c +3 -3
index df03dd3..46adc36 100644
@@ -456,9 +456,9 @@ ioc4_remove(struct pci_dev *pdev)
 	kfree(idd);
 }
 
-static struct pci_device_id ioc4_id_table[] = {
-	{PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4, PCI_ANY_ID,
-	 PCI_ANY_ID, 0x0b4000, 0xFFFFFF},
+static DEFINE_PCI_DEVICE_TABLE(ioc4_id_table) = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4),
+	  .class = 0x0b4000, .class_mask = 0xFFFFFF },
 	{0}
 };
 
drivers/misc/pch_phub.c +1 -1
index 10fc478..daa19c2 100644
@@ -878,7 +878,7 @@ static int pch_phub_resume(struct pci_dev *pdev)
 #define pch_phub_resume NULL
 #endif /* CONFIG_PM */
 
-static struct pci_device_id pch_phub_pcidev_id[] = {
+static DEFINE_PCI_DEVICE_TABLE(pch_phub_pcidev_id) = {
 	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH1_PHUB),       1,  },
 	{ PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7213_PHUB), 2,  },
 	{ PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7223_mPHUB), 3,  },
drivers/misc/phantom.c +1 -1
index 21b28fc..7f12ee6 100644
@@ -487,7 +487,7 @@ static int phantom_resume(struct pci_dev *pdev)
 #define phantom_resume	NULL
 #endif
 
-static struct pci_device_id phantom_pci_tbl[] __devinitdata = {
+static DEFINE_PCI_DEVICE_TABLE(phantom_pci_tbl) = {
 	{ .vendor = PCI_VENDOR_ID_PLX, .device = PCI_DEVICE_ID_PLX_9050,
 	  .subvendor = PCI_VENDOR_ID_PLX, .subdevice = PCI_DEVICE_ID_PLX_9050,
 	  .class = PCI_CLASS_BRIDGE_OTHER << 8, .class_mask = 0xffff00 },
drivers/misc/pti.c +1 -1
index 0b56e3f..03843e3 100644
@@ -76,7 +76,7 @@ struct pti_dev {
  */
 static DEFINE_MUTEX(alloclock);
 
-static struct pci_device_id pci_ids[] __devinitconst = {
+static DEFINE_PCI_DEVICE_TABLE(pci_ids) = {
 		{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x82B)},
 		{0}
 };
drivers/misc/tifm_7xx1.c +4 -7
index ba24790..a93adcca 100644
@@ -415,13 +415,10 @@ static void tifm_7xx1_remove(struct pci_dev *dev)
 	tifm_free_adapter(fm);
 }
 
-static struct pci_device_id tifm_7xx1_pci_tbl [] = {
-	{ PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11_FM, PCI_ANY_ID,
-	  PCI_ANY_ID, 0, 0, 0 }, /* xx21 - the one I have */
-        { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX12_FM, PCI_ANY_ID,
-	  PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX20_FM, PCI_ANY_ID,
-	  PCI_ANY_ID, 0, 0, 0 },
+static DEFINE_PCI_DEVICE_TABLE(tifm_7xx1_pci_tbl) = {
+	{ PCI_VDEVICE(TI, PCI_DEVICE_ID_TI_XX21_XX11_FM) },
+	{ PCI_VDEVICE(TI, PCI_DEVICE_ID_TI_XX12_FM) },
+	{ PCI_VDEVICE(TI, PCI_DEVICE_ID_TI_XX20_FM) },
 	{ }
 };
 
Signature · 1 line
1.7.5.4
Acked-by on v1 1/1
#1 lore raw
Quoted 117 lines · Axel Lin

Convert static struct pci_device_id *[] to static DEFINE_PCI_DEVICE_TABLE tables. Also convert to the PCI_DEVICE/PCI_VDEVICE macros for better readablity.

Cc Arnd Bergmann <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc David Altobelli <[email protected]>
Cc Brent Casavant <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc J Freyensee <[email protected]>
Cc Alex Dubov <[email protected]>
---
 drivers/misc/hpilo.c     |    2 +-
 drivers/misc/ioc4.c      |    6 +++---
 drivers/misc/pch_phub.c  |    2 +-
 drivers/misc/phantom.c   |    2 +-
 drivers/misc/pti.c       |    2 +-
 drivers/misc/tifm_7xx1.c |   11 ++++-------
 6 files changed, 11 insertions(+), 14 deletions(-)
drivers/misc/hpilo.c +1 -1
index fffc227..f705cbb 100644
@@ -828,7 +828,7 @@ out:
 	return error;
 }
 
-static struct pci_device_id ilo_devices[] = {
+static DEFINE_PCI_DEVICE_TABLE(ilo_devices) = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB204) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3307) },
 	{ }
drivers/misc/ioc4.c +3 -3
index df03dd3..46adc36 100644
@@ -456,9 +456,9 @@ ioc4_remove(struct pci_dev *pdev)
 	kfree(idd);
 }
 
-static struct pci_device_id ioc4_id_table[] = {
-	{PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4, PCI_ANY_ID,
-	 PCI_ANY_ID, 0x0b4000, 0xFFFFFF},
+static DEFINE_PCI_DEVICE_TABLE(ioc4_id_table) = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4),
+	  .class = 0x0b4000, .class_mask = 0xFFFFFF },
 	{0}
 };
 
drivers/misc/pch_phub.c +1 -1
index 10fc478..daa19c2 100644
@@ -878,7 +878,7 @@ static int pch_phub_resume(struct pci_dev *pdev)
 #define pch_phub_resume NULL
 #endif /* CONFIG_PM */
 
-static struct pci_device_id pch_phub_pcidev_id[] = {
+static DEFINE_PCI_DEVICE_TABLE(pch_phub_pcidev_id) = {
 	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH1_PHUB),       1,  },
 	{ PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7213_PHUB), 2,  },
 	{ PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7223_mPHUB), 3,  },
drivers/misc/phantom.c +1 -1
index 21b28fc..7f12ee6 100644
@@ -487,7 +487,7 @@ static int phantom_resume(struct pci_dev *pdev)
 #define phantom_resume	NULL
 #endif
 
-static struct pci_device_id phantom_pci_tbl[] __devinitdata = {
+static DEFINE_PCI_DEVICE_TABLE(phantom_pci_tbl) = {
 	{ .vendor = PCI_VENDOR_ID_PLX, .device = PCI_DEVICE_ID_PLX_9050,
 	  .subvendor = PCI_VENDOR_ID_PLX, .subdevice = PCI_DEVICE_ID_PLX_9050,
 	  .class = PCI_CLASS_BRIDGE_OTHER << 8, .class_mask = 0xffff00 },
drivers/misc/pti.c +1 -1
index 0b56e3f..03843e3 100644
@@ -76,7 +76,7 @@ struct pti_dev {
  */
 static DEFINE_MUTEX(alloclock);
 
-static struct pci_device_id pci_ids[] __devinitconst = {
+static DEFINE_PCI_DEVICE_TABLE(pci_ids) = {
 		{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x82B)},
 		{0}
 };
drivers/misc/tifm_7xx1.c +4 -7
index ba24790..a93adcca 100644
@@ -415,13 +415,10 @@ static void tifm_7xx1_remove(struct pci_dev *dev)
 	tifm_free_adapter(fm);
 }
 
-static struct pci_device_id tifm_7xx1_pci_tbl [] = {
-	{ PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11_FM, PCI_ANY_ID,
-	  PCI_ANY_ID, 0, 0, 0 }, /* xx21 - the one I have */
-        { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX12_FM, PCI_ANY_ID,
-	  PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX20_FM, PCI_ANY_ID,
-	  PCI_ANY_ID, 0, 0, 0 },
+static DEFINE_PCI_DEVICE_TABLE(tifm_7xx1_pci_tbl) = {
+	{ PCI_VDEVICE(TI, PCI_DEVICE_ID_TI_XX21_XX11_FM) },
+	{ PCI_VDEVICE(TI, PCI_DEVICE_ID_TI_XX12_FM) },
+	{ PCI_VDEVICE(TI, PCI_DEVICE_ID_TI_XX20_FM) },
 	{ }
 };
 
Signature · 1 line
1.7.5.4
Signature · 2 lines
Brent Casavant                      Silicon Graphics International, Inc.
System software BIOS engineering    http://www.sgi.com/products/server/uv
Acked-by on v1 1/1
#2 lore raw
In reply to Axel Lin

-----Original Message-----

Quoted 14 lines

From: Axel Lin
Subject: [PATCH] MISC: Convert to DEFINE_PCI_DEVICE_TABLE

Convert static struct pci_device_id *[] to static DEFINE_PCI_DEVICE_TABLE tables. Also convert to the PCI_DEVICE/PCI_VDEVICE macros for better readablity.

drivers/misc/hpilo.c | 2 +-

drivers/misc/hpilo.c +0 -0
index fffc227..f705cbb 100644

drivers/misc/hpilo.c out: · line 834

Quoted 8 lines
drivers/misc/hpilo.c +1 -1
@@ -828,7 +828,7 @@ out:
 	return error;
 }
 
-static struct pci_device_id ilo_devices[] = {
+static DEFINE_PCI_DEVICE_TABLE(ilo_devices) = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB204) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3307) },
 	{ }

Thanks ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#3 lore raw
In reply to Axel Lin
Quoted 26 lines · Axel Lin

Convert static struct pci_device_id *[] to static DEFINE_PCI_DEVICE_TABLE tables. Also convert to the PCI_DEVICE/PCI_VDEVICE macros for better readablity.

Cc Arnd Bergmann <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc David Altobelli <[email protected]>
Cc Brent Casavant <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc J Freyensee <[email protected]>
Cc Alex Dubov <[email protected]>
---
 drivers/misc/hpilo.c     |    2 +-
 drivers/misc/ioc4.c      |    6 +++---
 drivers/misc/pch_phub.c  |    2 +-
 drivers/misc/phantom.c   |    2 +-
 drivers/misc/pti.c       |    2 +-
 drivers/misc/tifm_7xx1.c |   11 ++++-------
 6 files changed, 11 insertions(+), 14 deletions(-)
drivers/misc/hpilo.c +0 -0
index fffc227..f705cbb 100644

drivers/misc/hpilo.c out: · line 831

Quoted 5 lines
drivers/misc/hpilo.c +1 -1
@@ -828,7 +828,7 @@ out:
 	return error;
 }
 
-static struct pci_device_id ilo_devices[] = {
+static DEFINE_PCI_DEVICE_TABLE(ilo_devices) = {

No, I hate this macro, see, it's actually taking you more characters to use it than to just properly define the structure yourself. It's pointless and stupid.

So no, I'm not going to accept this patch, sorry.

I would love to see a patch removing this macro from the kernel, but I'm not the PCI maintainer anymore, so I can't directly accept it :(

Quoted 8 lines
drivers/misc/hpilo.c +0 -0
 	{ PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB204) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3307) },
 	{ }
drivers/misc/ioc4.c +0 -0
index df03dd3..46adc36 100644

drivers/misc/ioc4.c ioc4_remove(struct pci_dev *pdev) · line 461

Quoted 9 lines
drivers/misc/ioc4.c +3 -3
@@ -456,9 +456,9 @@ ioc4_remove(struct pci_dev *pdev)
 	kfree(idd);
 }
 
-static struct pci_device_id ioc4_id_table[] = {
-	{PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4, PCI_ANY_ID,
-	 PCI_ANY_ID, 0x0b4000, 0xFFFFFF},
+static DEFINE_PCI_DEVICE_TABLE(ioc4_id_table) = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4),
+	  .class = 0x0b4000, .class_mask = 0xFFFFFF },

But the PCI_DEVICE() changes, yes, those are good as they make things much more obvious as to what is going on. Care to send me a patch for just that instead?

thanks,

greg k-h

#4 lore raw
Quoted 4 lines · Greg KH
Quoted 3 lines · Axel Lin

Convert static struct pci_device_id *[] to static DEFINE_PCI_DEVICE_TABLE tables. Also convert to the PCI_DEVICE/PCI_VDEVICE macros for better readablity.

[]

Quoted 1 line

drivers/misc/hpilo.c

Quoted 1 line
drivers/misc/hpilo.c +0 -0

[]

Quoted 10 lines

drivers/misc/hpilo.c out: · line 831

Quoted 6 lines
drivers/misc/hpilo.c +1 -1
@@ -828,7 +828,7 @@ out:
 	return error;
 }
 
-static struct pci_device_id ilo_devices[] = {
+static DEFINE_PCI_DEVICE_TABLE(ilo_devices) = {

No, I hate this macro, see, it's actually taking you more characters to use it than to just properly define the structure yourself. It's pointless and stupid.

Not quite.

include/linux/pci.h:#define DEFINE_PCI_DEVICE_TABLE(_table) \
include/linux/pci.h- const struct pci_device_id _table[] __devinitconst

Using the macro does declare the struct const and use attribute __devinitconst to place the table into section .devinit.rodata.

The straight definition does not.

Quoted 1 line

So no, I'm not going to accept this patch, sorry.

Never in doubt, not always right...

cheers, Joe

author
#5 lore raw
In reply to Greg KH

2011/12/3 Greg KH <[email protected]>:

Quoted 30 lines · Axel Lin
Quoted 29 lines

Convert static struct pci_device_id *[] to static DEFINE_PCI_DEVICE_TABLE tables. Also convert to the PCI_DEVICE/PCI_VDEVICE macros for better readablity.

Cc Arnd Bergmann <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc David Altobelli <[email protected]>
Cc Brent Casavant <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc J Freyensee <[email protected]>
Cc Alex Dubov <[email protected]>

---
 drivers/misc/hpilo.c     |    2 +-
 drivers/misc/ioc4.c      |    6 +++---
 drivers/misc/pch_phub.c  |    2 +-
 drivers/misc/phantom.c   |    2 +-
 drivers/misc/pti.c       |    2 +-
 drivers/misc/tifm_7xx1.c |   11 ++++-------

 6 files changed, 11 insertions(+), 14 deletions(-)
drivers/misc/hpilo.c +0 -0
index fffc227..f705cbb 100644
@@ -828,7 +828,7 @@ out:
       return error;
  }
 
Quoted 7 lines

drivers/misc/hpilo.c out: · line 831

Quoted 2 lines
drivers/misc/hpilo.c +1 -1
-static struct pci_device_id ilo_devices[] = {
+static DEFINE_PCI_DEVICE_TABLE(ilo_devices) = {

No, I hate this macro, see, it's actually taking you more characters to use it than to just properly define the structure yourself.  It's pointless and stupid.

$ grep -r "^static .*pci_device_id" drivers/misc/*
drivers/misc/cb710/core.c:static const struct pci_device_id cb710_pci_tbl[] = {
drivers/misc/hpilo.c:static struct pci_device_id ilo_devices[] = {
drivers/misc/ibmasm/module.c:static int __devinit
ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
drivers/misc/ibmasm/module.c:static struct pci_device_id ibmasm_pci_table[] =
drivers/misc/ioc4.c:static struct pci_device_id ioc4_id_table[] = {
drivers/misc/pch_phub.c:static struct pci_device_id pch_phub_pcidev_id[] = {
drivers/misc/phantom.c:static struct pci_device_id phantom_pci_tbl[]
__devinitdata = {
drivers/misc/pti.c:static struct pci_device_id pci_ids[] __devinitconst = {
drivers/misc/tifm_7xx1.c:static struct pci_device_id tifm_7xx1_pci_tbl [] = {

Some drivers missed const and __devinitconst annotations, it would be easier to use
DEFINE_PCI_DEVICE_TABLE.

#6 lore raw
Quoted 51 lines · Axel Lin

2011/12/3 Greg KH <[email protected]>:

Quoted 30 lines · Axel Lin
Quoted 29 lines

Convert static struct pci_device_id *[] to static DEFINE_PCI_DEVICE_TABLE tables. Also convert to the PCI_DEVICE/PCI_VDEVICE macros for better readablity.

Cc Arnd Bergmann <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc David Altobelli <[email protected]>
Cc Brent Casavant <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc J Freyensee <[email protected]>
Cc Alex Dubov <[email protected]>

---
 drivers/misc/hpilo.c     |    2 +-
 drivers/misc/ioc4.c      |    6 +++---
 drivers/misc/pch_phub.c  |    2 +-
 drivers/misc/phantom.c   |    2 +-
 drivers/misc/pti.c       |    2 +-
 drivers/misc/tifm_7xx1.c |   11 ++++-------

 6 files changed, 11 insertions(+), 14 deletions(-)
drivers/misc/hpilo.c +0 -0
index fffc227..f705cbb 100644
@@ -828,7 +828,7 @@ out:
       return error;
  }
 
Quoted 7 lines

drivers/misc/hpilo.c out: · line 831

Quoted 2 lines
drivers/misc/hpilo.c +1 -1
-static struct pci_device_id ilo_devices[] = {
+static DEFINE_PCI_DEVICE_TABLE(ilo_devices) = {

No, I hate this macro, see, it's actually taking you more characters to use it than to just properly define the structure yourself.  It's pointless and stupid.

$ grep -r "^static .*pci_device_id" drivers/misc/*
drivers/misc/cb710/core.c:static const struct pci_device_id cb710_pci_tbl[] = {
drivers/misc/hpilo.c:static struct pci_device_id ilo_devices[] = {
drivers/misc/ibmasm/module.c:static int __devinit
ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
drivers/misc/ibmasm/module.c:static struct pci_device_id ibmasm_pci_table[] =
drivers/misc/ioc4.c:static struct pci_device_id ioc4_id_table[] = {
drivers/misc/pch_phub.c:static struct pci_device_id pch_phub_pcidev_id[] = {
drivers/misc/phantom.c:static struct pci_device_id phantom_pci_tbl[]
__devinitdata = {
drivers/misc/pti.c:static struct pci_device_id pci_ids[] __devinitconst = {
drivers/misc/tifm_7xx1.c:static struct pci_device_id tifm_7xx1_pci_tbl [] = {
Quoted 3 lines

Some drivers missed const and __devinitconst annotations, it would be easier to use
DEFINE_PCI_DEVICE_TABLE.

I still don't like it, sorry.

greg "stick in the mud" k-h