PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry
Subsystems (2)
PATCH 1/1 PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry
There are a lot of examples in the kernel where PCI_VDEVICE() is used and still looks not so convenient due to additional driver_data field attached.
Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in shortest possible form. For example,
before:
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
(kernel_ulong_t) &dwc3_pci_mrfld_properties, },
after:
{ PCI_VDEVICE(INTEL, INTEL_MRFLD, &dwc3_pci_mrfld_properties },
Drivers can be converted later on in independent way.
While here, remove the unused macro with the same name from Ralink wireless driver.
--- drivers/net/wireless/ralink/rt2x00/rt2x00pci.h | 6 ------ include/linux/pci.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00pci.h +0 -6
@@ -27,12 +27,6 @@#include <linux/io.h> #include <linux/pci.h> -/* -* This variable should be used with the -* pci_driver structure initialization. -*/ -#define PCI_DEVICE_DATA (__ops) .driver_data = (kernel_ulong_t)(__ops) -/* * PCI driver handlers. */
include/linux/pci.h +15 -0
@@ -825,6 +825,21 @@ struct pci_driver { .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 +/** +* PCI_DEVICE_DATA - macro used to describe a specific PCI device in very short form +* @vend: the vendor name +* @dev: the device name (without PCI_DEVICE_ID_ prefix) +* @data: the driver data to be filled +* +* This macro is used to create a struct pci_device_id that matches a +* specific PCI device. The subvendor, and subdevice fields will be set +* to PCI_ANY_ID. +*/ +#define PCI_DEVICE_DATA (vend, dev, data) \ + .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##dev, \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 \ + .driver_data = (kernel_ulong_t)(data) +enum {PCI_REASSIGN_ALL_RSRC =0x00000001 ,/* Ignore firmware setup */ PCI_REASSIGN_ALL_BUS =0x00000002 ,/* Reassign all bus numbers */
Signature · 1 line
2.18.0
Quoted 13 lines · Andy Shevchenko
There are a lot of examples in the kernel where
PCI_VDEVICE()is used and still
looks not so convenient due to additionaldriver_datafield attached.Introduce
PCI_DEVICE_DATA()macro to fully describe device ID entry in shortest
possible form. For example,before:
{
PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
(kernel_ulong_t)&dwc3_pci_mrfld_properties, },
Quoted 8 lines
after:
{ PCI_VDEVICE(INTEL,
INTEL_MRFLD,&dwc3_pci_mrfld_properties},Drivers can be converted later on in independent way.
While here, remove the unused macro with the same name from Ralink wireless driver.
Skip this, it missed one comma.
Will send v2 soon.
Quoted 57 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/net/wireless/ralink/rt2x00/rt2x00pci.h | 6 ------ include/linux/pci.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-)drivers/net/wireless/ralink/rt2x00/rt2x00pci.h +0
-6@@ -27,12 +27,6 @@#include <linux/io.h> #include <linux/pci.h> -/* -* This variable should be used with the -* pci_driver structure initialization. -*/ -#define PCI_DEVICE_DATA (__ops) .driver_data = (kernel_ulong_t)(__ops) -/* * PCI driver handlers. */
include/linux/pci.h +2
-0@@ -825,6 +825,21 @@ struct pci_driver { .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 +/** +* PCI_DEVICE_DATA - macro used to describe a specific PCI device in very short form
+ * @vend: the vendor name
+ * @dev: the device name (withoutPCI_DEVICE_ID_prefix)
+ * @data: the driver data to be filled
+ *
+ * This macro is used to create a structpci_device_idthat matches a
+ * specific PCI device. The subvendor, and subdevice fields will be set
+ * toPCI_ANY_ID.
+ */include/linux/pci.h +2
-0+#define PCI_DEVICE_DATA (vend, dev, data) \ + .vendor = PCI_VENDOR_ID_##vend, .device =PCI_DEVICE_ID_##dev, \
include/linux/pci.h +3
-0+ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 \ + .driver_data = (kernel_ulong_t )(data ) + enum {PCI_REASSIGN_ALL_RSRC =0x00000001 ,/* Ignore firmware setup */
PCI_REASSIGN_ALL_BUS=0x00000002, /* Reassign
all bus numbers */
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
There are a lot of examples in the kernel where
PCI_VDEVICE()is used and still
looks not so convenient due to additionaldriver_datafield attached.Introduce
PCI_DEVICE_DATA()macro to fully describe device ID entry in shortest
possible form. For example,before:
{
PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
(kernel_ulong_t)&dwc3_pci_mrfld_properties, },after:
Quoted 8 lines
Quoted 6 lines
{ PCI_VDEVICE(INTEL,
INTEL_MRFLD,&dwc3_pci_mrfld_properties},Drivers can be converted later on in independent way.
While here, remove the unused macro with the same name from Ralink wireless driver.
Skip this, it missed one comma.
s/comma/right paren/ ??
Quoted 8 lines
Will send v2 soon.
Quoted 6 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/net/wireless/ralink/rt2x00/rt2x00pci.h | 6 ------ include/linux/pci.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-)
Signature · 1 line
~Randy
Quoted 23 lines · Randy Dunlap
Quoted 22 lines · Andy Shevchenko
Quoted 21 lines · Andy Shevchenko
There are a lot of examples in the kernel where
PCI_VDEVICE()is used
and still
looks not so convenient due to additionaldriver_datafield attached.Introduce
PCI_DEVICE_DATA()macro to fully describe device ID entry in
shortest
possible form. For example,before:
{
PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
(kernel_ulong_t)&dwc3_pci_mrfld_properties, },after:
{ PCI_VDEVICE(INTEL,
INTEL_MRFLD,&dwc3_pci_mrfld_properties
},
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Drivers can be converted later on in independent way.
While here, remove the unused macro with the same name from Ralink wireless driver.
Skip this, it missed one comma.
s/comma/right paren/ ??
comma in the code and you are right about commit message. Btw, it missed rename as well there.
Thanks for spotting this!
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 6 lines · Andy Shevchenko
There are a lot of examples in the kernel where
PCI_VDEVICE()is used and still looks not so convenient due to additionaldriver_datafield attached.Introduce
PCI_DEVICE_DATA()macro to fully describe device ID entry in shortest possible form. For example,
Quoted 8 lines
before:
{
PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
(kernel_ulong_t)&dwc3_pci_mrfld_properties, },after:
{ PCI_VDEVICE(INTEL,
INTEL_MRFLD,&dwc3_pci_mrfld_properties},
PCI_DEVICE_DATA(...)
Quoted 9 lines · Joe Perches
Quoted 8 lines · Andy Shevchenko
There are a lot of examples in the kernel where
PCI_VDEVICE()is used and still looks not so convenient due to additionaldriver_datafield attached.Introduce
PCI_DEVICE_DATA()macro to fully describe device ID entry in shortest possible form. For example,before:
Quoted 9 lines
Quoted 6 lines
{
PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
(kernel_ulong_t)&dwc3_pci_mrfld_properties, },after:
{ PCI_VDEVICE(INTEL,
INTEL_MRFLD,&dwc3_pci_mrfld_properties},
PCI_DEVICE_DATA(...)
see v2 and v3 :)
Signature · 1 line
~Randy