]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/nbsd-libpci.c
i386-ports: Do not mark pci_access in conf12_cleanup() as unused
[pciutils.git] / lib / nbsd-libpci.c
index 00c6878249b9ed155a31944a11ada5fb90db18cd..2b2ca4166d2a762ef9b5648d1fd112ce34cd1505 100644 (file)
 static void
 nbsd_config(struct pci_access *a)
 {
-  a->method_params[PCI_ACCESS_NBSD_LIBPCI] = PCI_PATH_NBSD_DEVICE;
+  pci_define_param(a, "nbsd.path", PCI_PATH_NBSD_DEVICE, "Path to the NetBSD PCI device");
 }
 
 static int
 nbsd_detect(struct pci_access *a)
 {
-  char *name = a->method_params[PCI_ACCESS_NBSD_LIBPCI];
+  char *name = pci_get_param(a, "nbsd.path");
 
   if (access(name, R_OK))
     {
@@ -40,9 +40,7 @@ nbsd_detect(struct pci_access *a)
     }
 
   if (!access(name, W_OK))
-    {
-      a->writeable = O_RDWR;
-    }
+    a->writeable = O_RDWR;
   a->debug("...using %s", name);
   return 1;
 }
@@ -50,7 +48,7 @@ nbsd_detect(struct pci_access *a)
 static void
 nbsd_init(struct pci_access *a)
 {
-  char *name = a->method_params[PCI_ACCESS_NBSD_LIBPCI];
+  char *name = pci_get_param(a, "nbsd.path");
   int mode = a->writeable ? O_RDWR : O_RDONLY;
 
   a->fd = open(name, mode, 0);
@@ -73,12 +71,12 @@ nbsd_read(struct pci_dev *d, int pos, byte *buf, int len)
   if (!(len == 1 || len == 2 || len == 4))
     return pci_generic_block_read(d, pos, buf, len);
 
-  if (pos >= 256)
+  if (d->domain || pos >= 4096)
     return 0;
 
   shift = 8*(pos % 4);
   pos &= ~3;
-       
+
   if (pcibus_conf_read(d->access->fd, d->bus, d->dev, d->func, pos, &val) < 0)
     d->access->error("nbsd_read: pci_bus_conf_read() failed");
 
@@ -106,7 +104,7 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
   if (!(len == 1 || len == 2 || len == 4))
     return pci_generic_block_write(d, pos, buf, len);
 
-  if (pos >= 256)
+  if (d->domain || pos >= 256)
     return 0;
 
   /*
@@ -135,7 +133,7 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
       val = le32_to_cpu(*(u32*)buf);
       break;
     }
-  
+
   if (pcibus_conf_write(d->access->fd, d->bus, d->dev, d->func, pos, val) < 0)
     d->access->error("nbsd_write: pci_bus_conf_write() failed");
 
@@ -143,7 +141,8 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
 }
 
 struct pci_methods pm_nbsd_libpci = {
-  "NetBSD-libpci",
+  "nbsd-libpci",
+  "NetBSD libpci",
   nbsd_config,
   nbsd_detect,
   nbsd_init,
@@ -152,6 +151,7 @@ struct pci_methods pm_nbsd_libpci = {
   pci_generic_fill_info,
   nbsd_read,
   nbsd_write,
+  NULL,                                 /* read_vpd */
   NULL,                                 /* dev_init */
   NULL                                  /* dev_cleanup */
 };