public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio-mmio: read[wl]()/write[wl] are already little-endian
@ 2021-03-09 22:43 Laurent Vivier
  2021-03-10  3:08 ` kernel test robot
  2021-03-11 15:44 ` Michael S. Tsirkin
  0 siblings, 2 replies; 6+ messages in thread
From: Laurent Vivier @ 2021-03-09 22:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: virtualization, Michael S. Tsirkin, Jason Wang, Laurent Vivier

read[wl]()/write[wl] already access memory in little-endian mode.
No need to convert the value with cpu_to_leXX()/leXX_to_cpu()

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 drivers/virtio/virtio_mmio.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index a286d22b6551..3f6a5588f77d 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -168,17 +168,17 @@ static void vm_get(struct virtio_device *vdev, unsigned offset,
 		memcpy(buf, &b, sizeof b);
 		break;
 	case 2:
-		w = cpu_to_le16(readw(base + offset));
+		w = readw(base + offset);
 		memcpy(buf, &w, sizeof w);
 		break;
 	case 4:
-		l = cpu_to_le32(readl(base + offset));
+		l = readl(base + offset);
 		memcpy(buf, &l, sizeof l);
 		break;
 	case 8:
-		l = cpu_to_le32(readl(base + offset));
+		l = readl(base + offset);
 		memcpy(buf, &l, sizeof l);
-		l = cpu_to_le32(ioread32(base + offset + sizeof l));
+		l = ioread32(base + offset + sizeof l);
 		memcpy(buf + sizeof l, &l, sizeof l);
 		break;
 	default:
@@ -212,17 +212,17 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
 		break;
 	case 2:
 		memcpy(&w, buf, sizeof w);
-		writew(le16_to_cpu(w), base + offset);
+		writew(w, base + offset);
 		break;
 	case 4:
 		memcpy(&l, buf, sizeof l);
-		writel(le32_to_cpu(l), base + offset);
+		writel(l, base + offset);
 		break;
 	case 8:
 		memcpy(&l, buf, sizeof l);
-		writel(le32_to_cpu(l), base + offset);
+		writel(l, base + offset);
 		memcpy(&l, buf + sizeof l, sizeof l);
-		writel(le32_to_cpu(l), base + offset + sizeof l);
+		writel(l, base + offset + sizeof l);
 		break;
 	default:
 		BUG();
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-14  8:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-09 22:43 [PATCH] virtio-mmio: read[wl]()/write[wl] are already little-endian Laurent Vivier
2021-03-10  3:08 ` kernel test robot
2021-03-11 15:44 ` Michael S. Tsirkin
2021-03-11 15:55   ` Laurent Vivier
2021-03-13 17:10   ` Laurent Vivier
2021-03-14  8:26     ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox