This is an automated email from the ASF dual-hosted git repository.

raiden00 pushed a commit to branch pci
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit ce21b77cf0be6d05cadf9fb48fec5eaeb5a76029
Author: raiden00pl <[email protected]>
AuthorDate: Sat Jan 20 13:40:51 2024 +0100

    drivers/qemu_pci_test: cosmetics
---
 drivers/virt/qemu_pci_test.c  | 85 +++++++++++++++++++++++++------------------
 include/nuttx/virt/qemu_pci.h |  2 +-
 2 files changed, 50 insertions(+), 37 deletions(-)

diff --git a/drivers/virt/qemu_pci_test.c b/drivers/virt/qemu_pci_test.c
index d0df753121..23e2f52aab 100644
--- a/drivers/virt/qemu_pci_test.c
+++ b/drivers/virt/qemu_pci_test.c
@@ -46,42 +46,69 @@
 
 struct pci_test_dev_hdr_s
 {
-    volatile uint8_t test;       /* write-only, starts a given test number */
-    volatile uint8_t width_type; /* read-only, type and width of access for a 
given test.
-                                  * 1,2,4 for byte,word or long write.
-                                  * any other value if test not supported on 
this BAR */
-    volatile uint8_t pad0[2];
-    volatile uint32_t offset;    /* read-only, offset in this BAR for a given 
test */
-    volatile uint32_t data;      /* read-only, data to use for a given test */
-    volatile uint32_t count;     /* for debugging. number of writes detected. 
*/
-    volatile uint8_t name[];     /* for debugging. 0-terminated ASCII string. 
*/
+  volatile uint8_t  test;       /* write-only, starts a given test number */
+  volatile uint8_t  width_type; /* read-only, type and width of access for a 
given test.
+                                 * 1,2,4 for byte,word or long write.
+                                 * any other value if test not supported on 
this BAR */
+  volatile uint8_t  pad0[2];
+  volatile uint32_t offset;     /* read-only, offset in this BAR for a given 
test */
+  volatile uint32_t data;       /* read-only, data to use for a given test */
+  volatile uint32_t count;      /* for debugging. number of writes detected. */
+  volatile uint8_t  name[];     /* for debugging. 0-terminated ASCII string. */
 };
 
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int qemu_pci_test_probe(FAR struct pcie_bus_s *bus,
+                               FAR struct pcie_dev_type_s *type,
+                               uint16_t bdf);
+
 /*****************************************************************************
- * Public Functions
+ * Public Data
  *****************************************************************************/
 
+struct pcie_dev_type_s g_pcie_type_qemu_pci_test =
+{
+  0x1b36,                 /* vendor */
+  0x0005,                 /* device */
+  PCI_ID_ANY,             /* class_rev */
+  "Qemu PCI test device", /* name */
+  qemu_pci_test_probe     /* probe */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
 /*****************************************************************************
  * Name: qemu_pci_test_probe
  *
  * Description:
  *   Initialize device
+ *
  *****************************************************************************/
 
-int qemu_pci_test_probe(FAR struct pcie_bus_s *bus,
-                        FAR struct pcie_dev_type_s *type, uint16_t bdf)
+static int qemu_pci_test_probe(FAR struct pcie_bus_s *bus,
+                               FAR struct pcie_dev_type_s *type,
+                               uint16_t bdf)
 {
-  uint32_t bar[2];
-  struct pcie_dev_s dev =
-    {
-      .bus = bus,
-      .type = type,
-      .bdf = bdf,
-    };
+  FAR struct pci_test_dev_hdr_s *ptr;
+  struct pcie_dev_s              dev;
+  uint32_t                       bar[2];
+  int                            ii;
+  int                            i;
+
+  /* Get dev */
+
+  dev.bus = bus;
+  dev.type = type;
+  dev.bdf = bdf;
 
   pci_enable_device(&dev);
 
-  for (int ii = 0; ii < 2; ii++)
+  for (ii = 0; ii < 2; ii++)
     {
       pci_get_bar(&dev, ii, bar + ii);
 
@@ -91,10 +118,9 @@ int qemu_pci_test_probe(FAR struct pcie_bus_s *bus,
 
           pci_map_bar(&dev, ii, 0x1000, NULL);
 
-          struct pci_test_dev_hdr_s *ptr =
-            (struct pci_test_dev_hdr_s *)(uintptr_t)bar[ii];
+          ptr = (struct pci_test_dev_hdr_s *)(uintptr_t)bar[ii];
 
-          int i = 0;
+          i = 0;
           while (1)
             {
               ptr->test = i;
@@ -115,16 +141,3 @@ int qemu_pci_test_probe(FAR struct pcie_bus_s *bus,
 
   return OK;
 }
-
-/*****************************************************************************
- * Public Data
- *****************************************************************************/
-
-struct pcie_dev_type_s pcie_type_qemu_pci_test =
-{
-    .vendor = 0x1b36,
-    .device = 0x0005,
-    .class_rev = PCI_ID_ANY,
-    .name = "Qemu PCI test device",
-    .probe = qemu_pci_test_probe
-};
diff --git a/include/nuttx/virt/qemu_pci.h b/include/nuttx/virt/qemu_pci.h
index f8e38f9241..855a4a5e88 100644
--- a/include/nuttx/virt/qemu_pci.h
+++ b/include/nuttx/virt/qemu_pci.h
@@ -42,7 +42,7 @@ extern "C"
 #endif
 
 #ifdef CONFIG_VIRT_QEMU_PCI_TEST
-extern struct pcie_dev_type_s pcie_type_qemu_pci_test;
+extern struct pcie_dev_type_s g_pcie_type_qemu_pci_test;
 #endif /* CONFIG_VIRT_QEMU_PCI_TEST */
 
 #undef EXTERN

Reply via email to