From 1d586c3beee3e703f35a36f8be7c065cb47363da Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 21 Mar 2024 02:49:07 +0800 Subject: [PATCH] pci: Add driver_data to pci_device_id_s so driver writer could save the private data here and get it back in the probe function. Signed-off-by: Xiang Xiao --- drivers/pci/pci.c | 2 ++ include/nuttx/pci/pci.h | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index dfd39a8b9e..b57af3278a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1839,6 +1839,7 @@ int pci_register_driver(FAR struct pci_driver_s *drv) { if (pci_match_one_device(id, dev)) { + dev->id = id; if (drv->probe(dev) >= 0) { dev->drv = drv; @@ -1927,6 +1928,7 @@ int pci_register_device(FAR struct pci_device_s *dev) { if (pci_match_one_device(id, dev)) { + dev->id = id; if (drv->probe(dev) >= 0) { dev->drv = drv; diff --git a/include/nuttx/pci/pci.h b/include/nuttx/pci/pci.h index 5635aa8f03..142cc29b73 100644 --- a/include/nuttx/pci/pci.h +++ b/include/nuttx/pci/pci.h @@ -219,6 +219,17 @@ enum /* The pci_device_s structure is used to describe PCI devices. */ +struct pci_device_id_s +{ + uint16_t vendor; /* Vendor id */ + uint16_t device; /* Device id */ + uint32_t subvendor; /* Sub vendor id */ + uint32_t subdevice; /* Sub device id */ + uint32_t class; /* (Class, subclass, prog-if) triplet */ + uint32_t class_mask; + uintptr_t driver_data; +}; + struct pci_device_s { struct list_node node; @@ -239,6 +250,7 @@ struct pci_device_s struct pci_resource_s resource[PCI_NUM_RESOURCES]; + FAR const struct pci_device_id_s *id; FAR struct pci_driver_s *drv; FAR void *priv; /* Used by pci driver */ }; @@ -306,16 +318,6 @@ struct pci_controller_s uint8_t busno; }; -struct pci_device_id_s -{ - uint16_t vendor; /* Vendor id */ - uint16_t device; /* Device id */ - uint32_t subvendor; /* Sub vendor id */ - uint32_t subdevice; /* Sub device id */ - uint32_t class; /* (Class, subclass, prog-if) triplet */ - uint32_t class_mask; -}; - struct pci_driver_s { FAR const struct pci_device_id_s *id_table;