diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2021-05-31 04:48:36 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2021-05-31 04:48:36 +0000 |
commit | 3c51a512019c016be5d031051d91f882f0fd31a1 (patch) | |
tree | 07d15baaf4e74b84c60186683ed77ee66395f455 /sys/dev/ic | |
parent | ae73e1196feb81d6ae6bf98dd0d6ef5dc56cd9b7 (diff) |
make nvme_read8 and write8 less clever.
hopefully big endian still works.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/nvme.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index 4a29ea4151c..62b8e40c626 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nvme.c,v 1.98 2021/05/31 04:13:42 dlg Exp $ */ +/* $OpenBSD: nvme.c,v 1.99 2021/05/31 04:48:35 dlg Exp $ */ /* * Copyright (c) 2014 David Gwynne <dlg@openbsd.org> @@ -141,15 +141,9 @@ u_int64_t nvme_read8(struct nvme_softc *sc, bus_size_t r) { u_int64_t v; - u_int32_t *a = (u_int32_t *)&v; - -#if _BYTE_ORDER == _LITTLE_ENDIAN - a[0] = nvme_read4(sc, r); - a[1] = nvme_read4(sc, r + 4); -#else /* _BYTE_ORDER == _LITTLE_ENDIAN */ - a[1] = nvme_read4(sc, r); - a[0] = nvme_read4(sc, r + 4); -#endif + + v = (u_int64_t)nvme_read4(sc, r) | + (u_int64_t)nvme_read4(sc, r + 4) << 32; return (v); } @@ -157,15 +151,8 @@ nvme_read8(struct nvme_softc *sc, bus_size_t r) void nvme_write8(struct nvme_softc *sc, bus_size_t r, u_int64_t v) { - u_int32_t *a = (u_int32_t *)&v; - -#if _BYTE_ORDER == _LITTLE_ENDIAN - nvme_write4(sc, r, a[0]); - nvme_write4(sc, r + 4, a[1]); -#else /* _BYTE_ORDER == _LITTLE_ENDIAN */ - nvme_write4(sc, r, a[1]); - nvme_write4(sc, r + 4, a[0]); -#endif + nvme_write4(sc, r, v); + nvme_write4(sc, r + 4, v >> 32); } void |