openbsd-ports/sysutils/pciutils/patches/patch-lib_obsd-device_c

38 lines
1.0 KiB
Plaintext

$OpenBSD: patch-lib_obsd-device_c,v 1.3 2006/12/30 14:55:25 matthieu Exp $
--- lib/obsd-device.c.orig Sat Sep 9 12:53:01 2006
+++ lib/obsd-device.c Sat Dec 16 16:13:26 2006
@@ -58,11 +58,6 @@ static int
obsd_read(struct pci_dev *d, int pos, byte *buf, int len)
{
struct pci_io pi;
- union {
- u_int32_t u32;
- u_int16_t u16[2];
- u_int8_t u8[4];
- } u;
if (!(len == 1 || len == 2 || len == 4))
{
@@ -86,18 +81,16 @@ obsd_read(struct pci_dev *d, int pos, by
d->access->error("obsd_read: ioctl(PCIOCREAD) failed");
}
}
- u.u32 = pi.pi_data;
-
switch (len)
{
case 1:
- buf[0] = (u8) u.u8[pos % 4];
+ buf[0] = (u8) (pi.pi_data >> ((pos % 4) * 8));
break;
case 2:
- ((u16 *) buf)[0] = letoh16(u.u16[(pos % 4) / 2]);
+ ((u16 *) buf)[0] = (u16) htole16(pi.pi_data >> ((pos % 4) * 8));
break;
case 4:
- ((u32 *) buf)[0] = (u32) letoh32(pi.pi_data);
+ ((u32 *) buf)[0] = (u32) htole32(pi.pi_data);
break;
}
return 1;