]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Sylixos: Coding style cleanup
authorMartin Mares <mj@ucw.cz>
Sun, 18 Mar 2018 17:47:42 +0000 (18:47 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 18 Mar 2018 17:47:42 +0000 (18:47 +0100)
lib/sylixos-device.c

index 6bb9958f25964458e7341b13e2e004a5171d347a..4bc207427a69a1509dab88a3e1eb44b90201a99a 100644 (file)
@@ -18,9 +18,9 @@
 #define PCI_VENDOR_ID_IS_INVALID(vendor) (((vendor) == 0xffff) || ((vendor) == 0x0000))
 
 typedef struct {
-    struct pci_access *a;
-    byte *busmap;
-    int bus;
+  struct pci_access *a;
+  byte *busmap;
+  int bus;
 } pci_dev_scan;
 
 static int
@@ -31,9 +31,7 @@ sylixos_pci_traversal (int (*function)(), void *arg, int min_bus, int max_bus)
   u16 vendor;
 
   if (!function || (min_bus < 0) || (max_bus < 0))
-    {
-      return  (PX_ERROR);
-    }
+    return PX_ERROR;
 
   min_bus = (min_bus > (PCI_MAX_BUS - 1)) ? (PCI_MAX_BUS - 1) : min_bus;
   max_bus = (max_bus > (PCI_MAX_BUS - 1)) ? (PCI_MAX_BUS - 1) : max_bus;
@@ -41,38 +39,32 @@ sylixos_pci_traversal (int (*function)(), void *arg, int min_bus, int max_bus)
   for (bus = min_bus; bus <= max_bus; bus++)
     {
       for (dev = 0; dev < PCI_MAX_SLOTS; dev++)
-    {
-      for (func = 0; func < PCI_MAX_FUNCTIONS; func++)
-    {
-      pciConfigInWord(bus, dev, func, PCI_VENDOR_ID, &vendor);
-      if (PCI_VENDOR_ID_IS_INVALID(vendor))
-        {
-          if (func == 0)
-            {
-              break;
-            }
-          continue;
-        }
-
-      if (function(bus, dev, func, arg) != ERROR_NONE)
-        {
-          goto  __out;
-        }
-
-      if (func == 0)
-        {
-          pciConfigInByte(bus, dev, func, PCI_HEADER_TYPE, &header);
-          if ((header & PCI_HEADER_MULTI_FUNC) != PCI_HEADER_MULTI_FUNC)
-            {
-              break;
-            }
-        }
-    }
-    }
+       {
+         for (func = 0; func < PCI_MAX_FUNCTIONS; func++)
+           {
+             pciConfigInWord(bus, dev, func, PCI_VENDOR_ID, &vendor);
+             if (PCI_VENDOR_ID_IS_INVALID(vendor))
+               {
+                 if (func == 0)
+                   break;
+                 continue;
+               }
+
+             if (function(bus, dev, func, arg) != ERROR_NONE)
+               goto  __out;
+
+             if (func == 0)
+               {
+                 pciConfigInByte(bus, dev, func, PCI_HEADER_TYPE, &header);
+                 if ((header & PCI_HEADER_MULTI_FUNC) != PCI_HEADER_MULTI_FUNC)
+                   break;
+               }
+           }
+       }
     }
 
 __out:
-  return  (ERROR_NONE);
+  return ERROR_NONE;
 }
 
 static int
@@ -95,13 +87,13 @@ pci_dev_list_create (int  bus, int  dev, int  func, void *arg)
   d->hdrtype = pci_read_byte(d, PCI_HEADER_TYPE) & 0x7f;
   pci_link_dev(f->a, d);
 
-  return  (ERROR_NONE);
+  return ERROR_NONE;
 }
 
 static void
 pci_generic_scan_bus_tbl(struct pci_access *a, byte *busmap, int bus)
 {
-  pci_dev_scan    f;
+  pci_dev_scan f;
 
   f.a = a;
   f.busmap = busmap;
@@ -128,13 +120,9 @@ sylixos_scan(struct pci_access *a)
 
   se = atoi(env);
   if (se)
-    {
-      pci_generic_scan_bus_tbl(a, busmap, 0);
-    }
+    pci_generic_scan_bus_tbl(a, busmap, 0);
   else
-    {
-      pci_generic_scan_bus(a, busmap, 0);
-    }
+    pci_generic_scan_bus(a, busmap, 0);
 }
 
 static void
@@ -155,7 +143,6 @@ sylixos_detect(struct pci_access *a)
     }
 
   a->debug("...using %s", name);
-
   return 1;
 }
 
@@ -180,41 +167,31 @@ sylixos_read(struct pci_dev *d, int pos, byte *buf, int len)
   u32 data_dword = -1;
 
   if (!(len == 1 || len == 2 || len == 4))
-    {
-      return pci_generic_block_read(d, pos, buf, len);
-    }
+    return pci_generic_block_read(d, pos, buf, len);
 
   if (pos >= 256)
-    {
-      return 0;
-    }
+    return 0;
 
   switch (len)
     {
     case 1:
       ret = pciConfigInByte(d->bus, d->dev, d->func, pos, &data_byte);
       if (ret != ERROR_NONE)
-        {
-          return  (0);
-        }
+       return 0;
       buf[0] = (u8)data_byte;
       break;
 
     case 2:
       ret = pciConfigInWord(d->bus, d->dev, d->func, pos, &data_word);
       if (ret != ERROR_NONE)
-        {
-          return  (0);
-        }
+       return 0;
       ((u16 *) buf)[0] = cpu_to_le16(data_word);
       break;
 
     case 4:
       ret = pciConfigInDword(d->bus, d->dev, d->func, pos, &data_dword);
       if (ret != ERROR_NONE)
-        {
-          return  (0);
-        }
+       return 0;
       ((u32 *) buf)[0] = cpu_to_le32(data_dword);
       break;
     }
@@ -231,14 +208,10 @@ sylixos_write(struct pci_dev *d, int pos, byte *buf, int len)
   u32 data_dword;
 
   if (!(len == 1 || len == 2 || len == 4))
-    {
-      return pci_generic_block_write(d, pos, buf, len);
-    }
+    return pci_generic_block_write(d, pos, buf, len);
 
   if (pos >= 256)
-    {
-      return 0;
-    }
+    return 0;
 
   switch (len)
     {
@@ -246,27 +219,21 @@ sylixos_write(struct pci_dev *d, int pos, byte *buf, int len)
       data_byte = buf[0];
       ret = pciConfigOutByte(d->bus, d->dev, d->func, pos, data_byte);
       if (ret != ERROR_NONE)
-        {
-          return  (0);
-        }
+       return 0;
       break;
 
     case 2:
       data_word = le16_to_cpu(((u16 *) buf)[0]);
       ret = pciConfigOutWord(d->bus, d->dev, d->func, pos, data_word);
       if (ret != ERROR_NONE)
-        {
-          return  (0);
-        }
+       return 0;
       break;
 
     case 4:
       data_dword = le32_to_cpu(((u32 *) buf)[0]);
       ret = pciConfigOutDword(d->bus, d->dev, d->func, pos, data_dword);
       if (ret != ERROR_NONE)
-        {
-          return  (0);
-        }
+       return 0;
       break;
     }
 
@@ -276,7 +243,7 @@ sylixos_write(struct pci_dev *d, int pos, byte *buf, int len)
 struct pci_methods pm_sylixos_device = {
   "sylixos-device",
   "SylixOS /proc/pci device",
-  sylixos_config,                                                                          /* config                       */
+  sylixos_config,
   sylixos_detect,
   sylixos_init,
   sylixos_cleanup,
@@ -284,7 +251,7 @@ struct pci_methods pm_sylixos_device = {
   pci_generic_fill_info,
   sylixos_read,
   sylixos_write,
-  NULL,                                                                                        /* read_vpd                     */
-  NULL,                                                                                        /* init_dev                     */
-  NULL                                                                                 /* cleanup_dev                  */
+  NULL,                        // no read_vpd
+  NULL,                        // no init_dev
+  NULL,                        // no cleanup_dev
 };