X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fobsd-device.c;h=dc68422abf1ef02385c0b25145509ee6a1feeed3;hb=refs%2Ftags%2Fv3.1.5;hp=e3e36303379158bfbef31f915b4907ba9b4471c2;hpb=b6359063c32299c3d09de4cbdbb66d5b3468887a;p=pciutils.git diff --git a/lib/obsd-device.c b/lib/obsd-device.c index e3e3630..dc68422 100644 --- a/lib/obsd-device.c +++ b/lib/obsd-device.c @@ -19,13 +19,13 @@ 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)) { @@ -39,13 +39,11 @@ obsd_detect(struct pci_access *a) 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) - { - a->error("obsd_init: %s open failed", name); - } + a->error("obsd_init: %s open failed", name); } static void @@ -65,9 +63,7 @@ obsd_read(struct pci_dev *d, int pos, byte *buf, int len) } u; if (!(len == 1 || len == 2 || len == 4)) - { - return pci_generic_block_read(d, pos, buf, len); - } + return pci_generic_block_read(d, pos, buf, len); if (pos >= 256) return 0; @@ -78,13 +74,12 @@ obsd_read(struct pci_dev *d, int pos, byte *buf, int len) pi.pi_reg = pos - (pos % 4); pi.pi_width = 4; - + if (ioctl(d->access->fd, PCIOCREAD, &pi) < 0) { - if (errno == ENXIO) { + if (errno == ENXIO) pi.pi_data = 0xffffffff; - } else { + else d->access->error("obsd_read: ioctl(PCIOCREAD) failed"); - } } u.u32 = pi.pi_data; @@ -109,9 +104,7 @@ obsd_write(struct pci_dev *d, int pos, byte *buf, int len) struct pci_io pi; if (!(len == 1 || len == 2 || len == 4)) - { - return pci_generic_block_write(d, pos, buf, len); - } + return pci_generic_block_write(d, pos, buf, len); if (pos >= 256) return 0; @@ -122,7 +115,7 @@ obsd_write(struct pci_dev *d, int pos, byte *buf, int len) pi.pi_reg = pos; pi.pi_width = len; - + switch (len) { case 1: @@ -135,17 +128,16 @@ obsd_write(struct pci_dev *d, int pos, byte *buf, int len) pi.pi_data = ((u32 *) buf)[0]; break; } - + if (ioctl(d->access->fd, PCIOCWRITE, &pi) < 0) - { - d->access->error("obsd_write: ioctl(PCIOCWRITE) failed"); - } + d->access->error("obsd_write: ioctl(PCIOCWRITE) failed"); return 1; } struct pci_methods pm_obsd_device = { - "OpenBSD-device", + "obsd-device", + "/dev/pci on OpenBSD", obsd_config, obsd_detect, obsd_init, @@ -154,6 +146,7 @@ struct pci_methods pm_obsd_device = { pci_generic_fill_info, obsd_read, obsd_write, + NULL, /* read_vpd */ NULL, /* dev_init */ NULL /* dev_cleanup */ };