X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Ffbsd-device.c;h=2ea5e84402e690ddbbacb2687867792104bad1c3;hb=06f9ecf36e529695feea35038e15233dffe37bb7;hp=78067dcdbb497b40aa1411ea586359dbcbe45dd5;hpb=0f3d0ca73ecedaba180bf4607bb57fb8abe6d405;p=pciutils.git diff --git a/lib/fbsd-device.c b/lib/fbsd-device.c index 78067dc..2ea5e84 100644 --- a/lib/fbsd-device.c +++ b/lib/fbsd-device.c @@ -5,7 +5,9 @@ * Updated in 2003 by Samy Al Bahra * Updated in 2017 by Imre Vadász * - * 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 */ #include @@ -143,7 +145,7 @@ fbsd_scan(struct pci_access *a) t = pci_alloc_dev(a); t->bus = matches[i].pc_sel.pc_bus; t->dev = matches[i].pc_sel.pc_dev; - t->dev = matches[i].pc_sel.pc_dev; + t->func = matches[i].pc_sel.pc_func; t->domain = matches[i].pc_sel.pc_domain; t->domain_16 = matches[i].pc_sel.pc_domain; t->vendor_id = matches[i].pc_vendor; @@ -159,8 +161,8 @@ fbsd_scan(struct pci_access *a) free(matches); } -static int -fbsd_fill_info(struct pci_dev *d, int flags) +static void +fbsd_fill_info(struct pci_dev *d, unsigned int flags) { struct pci_conf_io conf; struct pci_bar_io bar; @@ -195,21 +197,19 @@ fbsd_fill_info(struct pci_dev *d, int flags) if (ioctl(d->access->fd, PCIOCGETCONF, &conf) < 0) { - if (errno == ENODEV) - return 0; - d->access->error("fbsd_fill_info: ioctl(PCIOCGETCONF) failed: %s", strerror(errno)); + if (errno != ENODEV) + d->access->error("fbsd_fill_info: ioctl(PCIOCGETCONF) failed: %s", strerror(errno)); + return; } - if (flags & PCI_FILL_IDENT) + if (want_fill(d, flags, PCI_FILL_IDENT)) { d->vendor_id = match.pc_vendor; d->device_id = match.pc_device; } - if (flags & PCI_FILL_CLASS) - { - d->device_class = match.pc_class | (match.pc_subclass << 8); - } - if (flags & (PCI_FILL_BASES | PCI_FILL_SIZES)) + if (want_fill(d, flags, PCI_FILL_CLASS)) + d->device_class = (match.pc_class << 8) | match.pc_subclass; + if (want_fill(d, flags, PCI_FILL_BASES | PCI_FILL_SIZES)) { d->rom_base_addr = 0; d->rom_size = 0; @@ -226,7 +226,7 @@ fbsd_fill_info(struct pci_dev *d, int flags) if (ioctl(d->access->fd, PCIOCGETBAR, &bar) < 0) { if (errno == ENODEV) - return 0; + return; if (errno == EINVAL) { d->base_addr[i] = 0; @@ -242,9 +242,6 @@ fbsd_fill_info(struct pci_dev *d, int flags) } } } - - return flags & (PCI_FILL_IDENT | PCI_FILL_CLASS | PCI_FILL_BASES | - PCI_FILL_SIZES); } static int @@ -254,7 +251,7 @@ fbsd_read(struct pci_dev *d, int pos, byte *buf, int len) if (d->access->fd_rw < 0) { - d->access->warn("fbsd_read: missing permissions"); + d->access->warning("fbsd_read: missing permissions"); return 0; } @@ -266,6 +263,9 @@ fbsd_read(struct pci_dev *d, int pos, byte *buf, int len) #if __FreeBSD_version >= 700053 || defined(__DragonFly__) pi.pi_sel.pc_domain = d->domain; +#else + if (d->domain) + return 0; #endif pi.pi_sel.pc_bus = d->bus; pi.pi_sel.pc_dev = d->dev; @@ -303,7 +303,7 @@ fbsd_write(struct pci_dev *d, int pos, byte *buf, int len) if (d->access->fd_rw < 0) { - d->access->warn("fbsd_write: missing permissions"); + d->access->warning("fbsd_write: missing permissions"); return 0; } @@ -315,6 +315,9 @@ fbsd_write(struct pci_dev *d, int pos, byte *buf, int len) #if __FreeBSD_version >= 700053 || defined(__DragonFly__) pi.pi_sel.pc_domain = d->domain; +#else + if (d->domain) + return 0; #endif pi.pi_sel.pc_bus = d->bus; pi.pi_sel.pc_dev = d->dev;