From 7bd1ac279f169522d70a1d9b84bdc22daa0c0391 Mon Sep 17 00:00:00 2001 From: dlg Date: Mon, 31 May 2021 04:48:35 +0000 Subject: [PATCH] make nvme_read8 and write8 less clever. hopefully big endian still works. --- sys/dev/ic/nvme.c | 25 ++++++------------------- 1 file 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 @@ -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 -- 2.20.1