*
* Adapted from fbsd-device.c by Matthieu Herrb <matthieu.herrb@laas.fr>, 2006
*
- * 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 <fcntl.h>
static void
obsd_config(struct pci_access *a)
{
- a->method_params[PCI_ACCESS_OBSD_DEVICE] = PCI_PATH_OBSD_DEVICE;
+ pci_define_param(a, "obsd.path", PCI_PATH_OBSD_DEVICE, "Path to the OpenBSD PCI device");
}
static int
obsd_detect(struct pci_access *a)
{
- char *name = a->method_params[PCI_ACCESS_OBSD_DEVICE];
+ char *name = pci_get_param(a, "obsd.path");
if (access(name, R_OK))
{
static void
obsd_init(struct pci_access *a)
{
- char *name = a->method_params[PCI_ACCESS_OBSD_DEVICE];
+ char *name = pci_get_param(a, "obsd.path");
a->fd = open(name, O_RDWR, 0);
if (a->fd < 0)
if (!(len == 1 || len == 2 || len == 4))
return pci_generic_block_read(d, pos, buf, len);
- if (pos >= 256)
+ if (d->domain || pos >= 256)
return 0;
pi.pi_sel.pc_bus = d->bus;
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;
pi.pi_sel.pc_bus = d->bus;
}
struct pci_methods pm_obsd_device = {
- "OpenBSD-device",
+ "obsd-device",
+ "/dev/pci on OpenBSD",
obsd_config,
obsd_detect,
obsd_init,
pci_generic_fill_info,
obsd_read,
obsd_write,
+ NULL, /* read_vpd */
NULL, /* dev_init */
NULL /* dev_cleanup */
};