]> 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 a10bea5333220ae5f18d6919f8b86be64b4aaca1..028d92ae312503582d37efb72d486b225e2cb16e 100644 (file)
@@ -3,7 +3,9 @@
  *
  *     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
-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)
     {
@@ -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)
-        {
-          a->error("aix_open_bus: %s open failed", devbuf);
-        }
+       a->error("aix_open_bus: %s open failed", devbuf);
     }
 
   return bp->bus_fd;
@@ -207,7 +208,7 @@ aix_scan(struct pci_access *a)
       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);
         }
     }
 }
@@ -218,10 +219,10 @@ aix_read(struct pci_dev *d, int pos, byte *buf, int len)
   struct mdio mdio;
   int fd;
 
-  if (pos + len > 256)
+  if (d->domain || pos + len > 256)
     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;
@@ -240,10 +241,10 @@ aix_write(struct pci_dev *d, int pos, byte *buf, int len)
   struct mdio mdio;
   int fd;
 
-  if (pos + len > 256)
+  if (d->domain || pos + len > 256)
     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;