]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/fbsd-device.c
Split parsing of options in setpci to multiple functions.
[pciutils.git] / lib / fbsd-device.c
index d6f35bdf08ba50037010f270efaa70416912b18b..742c6419f54efa1dbdb1b64057c3402e40345624 100644 (file)
 static void
 fbsd_config(struct pci_access *a)
 {
-  a->method_params[PCI_ACCESS_FBSD_DEVICE] = PCI_PATH_FBSD_DEVICE;
+  pci_define_param(a, "fbsd.path", PCI_PATH_FBSD_DEVICE, "Path to the FreeBSD PCI device");
 }
 
 static int
 fbsd_detect(struct pci_access *a)
 {
-  char *name = a->method_params[PCI_ACCESS_FBSD_DEVICE];
+  char *name = pci_get_param(a, "fbsd.path");
 
   if (access(name, R_OK))
     {
@@ -53,13 +53,11 @@ fbsd_detect(struct pci_access *a)
 static void
 fbsd_init(struct pci_access *a)
 {
-  char *name = a->method_params[PCI_ACCESS_FBSD_DEVICE];
+  char *name = pci_get_param(a, "fbsd.path");
 
   a->fd = open(name, O_RDWR, 0);
   if (a->fd < 0)
-    {
-      a->error("fbsd_init: %s open failed", name);
-    }
+    a->error("fbsd_init: %s open failed", name);
 }
 
 static void
@@ -74,9 +72,7 @@ fbsd_read(struct pci_dev *d, int pos, byte *buf, int len)
   struct pci_io pi;
 
   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;
@@ -94,9 +90,7 @@ fbsd_read(struct pci_dev *d, int pos, byte *buf, int len)
   if (ioctl(d->access->fd, PCIOCREAD, &pi) < 0)
     {
       if (errno == ENODEV)
-        {
-          return 0;
-        }
+       return 0;
       d->access->error("fbsd_read: ioctl(PCIOCREAD) failed: %s", strerror(errno));
     }
 
@@ -121,9 +115,7 @@ fbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
   struct pci_io pi;
 
   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;
@@ -154,9 +146,7 @@ fbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
   if (ioctl(d->access->fd, PCIOCWRITE, &pi) < 0)
     {
       if (errno == ENODEV)
-        {
-          return 0;
-        }
+       return 0;
       d->access->error("fbsd_write: ioctl(PCIOCWRITE) failed: %s", strerror(errno));
     }
 
@@ -164,7 +154,8 @@ fbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
 }
 
 struct pci_methods pm_fbsd_device = {
-  "FreeBSD-device",
+  "fbsd-device",
+  "FreeBSD /dev/pci device",
   fbsd_config,
   fbsd_detect,
   fbsd_init,