]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/aix-device.c
libpci: Add separate file for bit manipulation functions
[pciutils.git] / lib / aix-device.c
index 2c6a2ccf676f8f89e0fdc2e4fd142bb65785f9a5..028d92ae312503582d37efb72d486b225e2cb16e 100644 (file)
@@ -3,7 +3,9 @@
  *
  *     Copyright (c) 1999 Jari Kirma <kirma@cs.hut.fi>
  *
  *
  *     Copyright (c) 1999 Jari Kirma <kirma@cs.hut.fi>
  *
- *     Can be freely distributed and used under the terms of the GNU GPL.
+ *     Can be freely distributed and used under the terms of the GNU GPL v2+.
+ *
+ *     SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 /*
  */
 
 /*
@@ -60,9 +62,10 @@ aix_find_bus(struct pci_access *a, int bus_number)
 }
 
 static int
 }
 
 static int
-aix_bus_open(struct pci_access *a, int bus_number)
+aix_bus_open(struct pci_dev *d)
 {
 {
-  aix_pci_bus *bp = aix_find_bus(a, bus_number);
+  struct pci_access *a = d->access;
+  aix_pci_bus *bp = aix_find_bus(a, d->bus);
 
   if (bp->bus_fd < 0)
     {
 
   if (bp->bus_fd < 0)
     {
@@ -72,9 +75,7 @@ aix_bus_open(struct pci_access *a, int bus_number)
       snprintf(devbuf, sizeof (devbuf), "/dev/%s", bp->bus_name);
       bp->bus_fd = open(devbuf, mode, 0);
       if (bp->bus_fd < 0)
       snprintf(devbuf, sizeof (devbuf), "/dev/%s", bp->bus_name);
       bp->bus_fd = open(devbuf, mode, 0);
       if (bp->bus_fd < 0)
-        {
-          a->error("aix_open_bus: %s open failed", devbuf);
-        }
+       a->error("aix_open_bus: %s open failed", devbuf);
     }
 
   return bp->bus_fd;
     }
 
   return bp->bus_fd;
@@ -122,12 +123,6 @@ aix_bus_number(char *name)
 
 /* Method entries */
 
 
 /* Method entries */
 
-static void
-aix_config(struct pci_access *a)
-{
-  a->method_params[PCI_ACCESS_AIX_DEVICE] = NULL;
-}
-
 static int
 aix_detect(struct pci_access *a)
 {
 static int
 aix_detect(struct pci_access *a)
 {
@@ -207,13 +202,13 @@ aix_scan(struct pci_access *a)
   int bus_number;
   byte busmap[256];
 
   int bus_number;
   byte busmap[256];
 
-  bzero(busmap, sizeof(busmap));
+  memset(busmap, 0, sizeof(busmap));
   for (i = 0; i < pci_bus_count; i++)
     {
       bus_number = pci_buses[i].bus_number;
       if (!busmap[bus_number])
         {
   for (i = 0; i < pci_bus_count; i++)
     {
       bus_number = pci_buses[i].bus_number;
       if (!busmap[bus_number])
         {
-          pci_generic_scan_bus(a, busmap, bus_number);
+          pci_generic_scan_bus(a, busmap, 0, bus_number);
         }
     }
 }
         }
     }
 }
@@ -224,10 +219,10 @@ aix_read(struct pci_dev *d, int pos, byte *buf, int len)
   struct mdio mdio;
   int fd;
 
   struct mdio mdio;
   int fd;
 
-  if (pos + len > 256)
+  if (d->domain || pos + len > 256)
     return 0;
 
     return 0;
 
-  fd = aix_bus_open(d->access, d->bus);
+  fd = aix_bus_open(d);
   mdio.md_addr = (ulong) pos;
   mdio.md_size = len;
   mdio.md_incr = MV_BYTE;
   mdio.md_addr = (ulong) pos;
   mdio.md_size = len;
   mdio.md_incr = MV_BYTE;
@@ -246,10 +241,10 @@ aix_write(struct pci_dev *d, int pos, byte *buf, int len)
   struct mdio mdio;
   int fd;
 
   struct mdio mdio;
   int fd;
 
-  if (pos + len > 256)
+  if (d->domain || pos + len > 256)
     return 0;
 
     return 0;
 
-  fd = aix_bus_open(d->access, d->bus);
+  fd = aix_bus_open(d);
   mdio.md_addr = (ulong) pos;
   mdio.md_size = len;
   mdio.md_incr = MV_BYTE;
   mdio.md_addr = (ulong) pos;
   mdio.md_size = len;
   mdio.md_incr = MV_BYTE;
@@ -265,8 +260,9 @@ aix_write(struct pci_dev *d, int pos, byte *buf, int len)
 }
 
 struct pci_methods pm_aix_device = {
 }
 
 struct pci_methods pm_aix_device = {
-  "AIX-device",
-  aix_config,
+  "aix-device",
+  "AIX /dev/pci[0-n]",
+  NULL,
   aix_detect,
   aix_init,
   aix_cleanup,
   aix_detect,
   aix_init,
   aix_cleanup,
@@ -274,6 +270,7 @@ struct pci_methods pm_aix_device = {
   pci_generic_fill_info,
   aix_read,
   aix_write,
   pci_generic_fill_info,
   aix_read,
   aix_write,
+  NULL,                                 /* read_vpd */
   NULL,                                 /* dev_init */
   NULL                                  /* dev_cleanup */
 };
   NULL,                                 /* dev_init */
   NULL                                  /* dev_cleanup */
 };