Skip to content

Commit 169294a

Browse files
Christoph Hellwigmstsirkin
authored andcommitted
vringh: use bvec_kmap_local
Use the bvec_kmap_local helper rather than digging into the bvec internals. Signed-off-by: Christoph Hellwig <hch@lst.de> Message-Id: <20250501142244.2888227-1-hch@lst.de> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
1 parent 8b3f996 commit 169294a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/vhost/vringh.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,11 +1290,10 @@ static inline int getu16_iotlb(const struct vringh *vrh,
12901290
if (ret)
12911291
return ret;
12921292
} else {
1293-
void *kaddr = kmap_local_page(ivec.iov.bvec[0].bv_page);
1294-
void *from = kaddr + ivec.iov.bvec[0].bv_offset;
1293+
__virtio16 *from = bvec_kmap_local(&ivec.iov.bvec[0]);
12951294

1296-
tmp = READ_ONCE(*(__virtio16 *)from);
1297-
kunmap_local(kaddr);
1295+
tmp = READ_ONCE(*from);
1296+
kunmap_local(from);
12981297
}
12991298

13001299
*val = vringh16_to_cpu(vrh, tmp);
@@ -1329,11 +1328,10 @@ static inline int putu16_iotlb(const struct vringh *vrh,
13291328
if (ret)
13301329
return ret;
13311330
} else {
1332-
void *kaddr = kmap_local_page(ivec.iov.bvec[0].bv_page);
1333-
void *to = kaddr + ivec.iov.bvec[0].bv_offset;
1331+
__virtio16 *to = bvec_kmap_local(&ivec.iov.bvec[0]);
13341332

1335-
WRITE_ONCE(*(__virtio16 *)to, tmp);
1336-
kunmap_local(kaddr);
1333+
WRITE_ONCE(*to, tmp);
1334+
kunmap_local(to);
13371335
}
13381336

13391337
return 0;

0 commit comments

Comments
 (0)