git: b7a47939e250 - stable/13 - virtio: make the write_config buffer argument const
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 07 May 2022 15:57:16 UTC
The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=b7a47939e25000049b55f5fdc4c439e8b3323096 commit b7a47939e25000049b55f5fdc4c439e8b3323096 Author: Alex Richardson <arichardson@FreeBSD.org> AuthorDate: 2021-10-11 10:52:17 +0000 Commit: Alex Richardson <arichardson@FreeBSD.org> CommitDate: 2022-05-07 12:09:09 +0000 virtio: make the write_config buffer argument const No functional change intended, but noticed that we could add const here while adding linuxkpi support for virtio. Reviewed By: bryanv, imp Differential Revision: https://reviews.freebsd.org/D32370 (cherry picked from commit 6c4f95161d6e38ba3fd50ca1cceee3110cbfa02e) --- sys/dev/virtio/mmio/virtio_mmio.c | 14 +++++++------- sys/dev/virtio/pci/virtio_pci_legacy.c | 6 +++--- sys/dev/virtio/pci/virtio_pci_modern.c | 12 ++++++------ sys/dev/virtio/virtio.c | 2 +- sys/dev/virtio/virtio.h | 2 +- sys/dev/virtio/virtio_bus_if.m | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sys/dev/virtio/mmio/virtio_mmio.c b/sys/dev/virtio/mmio/virtio_mmio.c index 5672a6f0f69c..72c68400cb28 100644 --- a/sys/dev/virtio/mmio/virtio_mmio.c +++ b/sys/dev/virtio/mmio/virtio_mmio.c @@ -88,7 +88,7 @@ static void vtmmio_notify_virtqueue(device_t, uint16_t, bus_size_t); static uint8_t vtmmio_get_status(device_t); static void vtmmio_set_status(device_t, uint8_t); static void vtmmio_read_dev_config(device_t, bus_size_t, void *, int); -static void vtmmio_write_dev_config(device_t, bus_size_t, void *, int); +static void vtmmio_write_dev_config(device_t, bus_size_t, const void *, int); static void vtmmio_describe_features(struct vtmmio_softc *, const char *, uint64_t); static void vtmmio_probe_and_attach_child(struct vtmmio_softc *); @@ -737,7 +737,7 @@ vtmmio_read_dev_config(device_t dev, bus_size_t offset, static void vtmmio_write_dev_config(device_t dev, bus_size_t offset, - void *src, int length) + const void *src, int length) { struct vtmmio_softc *sc; bus_size_t off; @@ -755,21 +755,21 @@ vtmmio_write_dev_config(device_t dev, bus_size_t offset, if (sc->vtmmio_version > 1) { switch (length) { case 1: - vtmmio_write_config_1(sc, off, *(uint8_t *)src); + vtmmio_write_config_1(sc, off, *(const uint8_t *)src); break; case 2: vtmmio_write_config_2(sc, off, - htole16(*(uint16_t *)src)); + htole16(*(const uint16_t *)src)); break; case 4: vtmmio_write_config_4(sc, off, - htole32(*(uint32_t *)src)); + htole32(*(const uint32_t *)src)); break; case 8: vtmmio_write_config_4(sc, off, - htole32(*(uint64_t *)src)); + htole32(*(const uint64_t *)src)); vtmmio_write_config_4(sc, off + 4, - htole32((*(uint64_t *)src) >> 32)); + htole32((*(const uint64_t *)src) >> 32)); break; default: panic("%s: invalid length %d\n", __func__, length); diff --git a/sys/dev/virtio/pci/virtio_pci_legacy.c b/sys/dev/virtio/pci/virtio_pci_legacy.c index 2cebee720975..e5882295e9dd 100644 --- a/sys/dev/virtio/pci/virtio_pci_legacy.c +++ b/sys/dev/virtio/pci/virtio_pci_legacy.c @@ -97,7 +97,7 @@ static int vtpci_legacy_reinit(device_t, uint64_t); static void vtpci_legacy_reinit_complete(device_t); static void vtpci_legacy_notify_vq(device_t, uint16_t, bus_size_t); static void vtpci_legacy_read_dev_config(device_t, bus_size_t, void *, int); -static void vtpci_legacy_write_dev_config(device_t, bus_size_t, void *, int); +static void vtpci_legacy_write_dev_config(device_t, bus_size_t, const void *, int); static bool vtpci_legacy_setup_msix(struct vtpci_legacy_softc *sc); static void vtpci_legacy_teardown_msix(struct vtpci_legacy_softc *sc); @@ -519,11 +519,11 @@ vtpci_legacy_read_dev_config(device_t dev, bus_size_t offset, static void vtpci_legacy_write_dev_config(device_t dev, bus_size_t offset, - void *src, int length) + const void *src, int length) { struct vtpci_legacy_softc *sc; bus_size_t off; - uint8_t *s; + const uint8_t *s; int i; sc = device_get_softc(dev); diff --git a/sys/dev/virtio/pci/virtio_pci_modern.c b/sys/dev/virtio/pci/virtio_pci_modern.c index 33fdebf19402..30dcebe320b1 100644 --- a/sys/dev/virtio/pci/virtio_pci_modern.c +++ b/sys/dev/virtio/pci/virtio_pci_modern.c @@ -123,7 +123,7 @@ static void vtpci_modern_reinit_complete(device_t); static void vtpci_modern_notify_vq(device_t, uint16_t, bus_size_t); static int vtpci_modern_config_generation(device_t); static void vtpci_modern_read_dev_config(device_t, bus_size_t, void *, int); -static void vtpci_modern_write_dev_config(device_t, bus_size_t, void *, int); +static void vtpci_modern_write_dev_config(device_t, bus_size_t, const void *, int); static int vtpci_modern_probe_configs(device_t); static int vtpci_modern_find_cap(device_t, uint8_t, int *); @@ -686,7 +686,7 @@ vtpci_modern_read_dev_config(device_t dev, bus_size_t offset, void *dst, } static void -vtpci_modern_write_dev_config(device_t dev, bus_size_t offset, void *src, +vtpci_modern_write_dev_config(device_t dev, bus_size_t offset, const void *src, int length) { struct vtpci_modern_softc *sc; @@ -700,20 +700,20 @@ vtpci_modern_write_dev_config(device_t dev, bus_size_t offset, void *src, switch (length) { case 1: - vtpci_modern_write_device_1(sc, offset, *(uint8_t *) src); + vtpci_modern_write_device_1(sc, offset, *(const uint8_t *) src); break; case 2: { - uint16_t val = virtio_gtoh16(true, *(uint16_t *) src); + uint16_t val = virtio_gtoh16(true, *(const uint16_t *) src); vtpci_modern_write_device_2(sc, offset, val); break; } case 4: { - uint32_t val = virtio_gtoh32(true, *(uint32_t *) src); + uint32_t val = virtio_gtoh32(true, *(const uint32_t *) src); vtpci_modern_write_device_4(sc, offset, val); break; } case 8: { - uint64_t val = virtio_gtoh64(true, *(uint64_t *) src); + uint64_t val = virtio_gtoh64(true, *(const uint64_t *) src); vtpci_modern_write_device_8(sc, offset, val); break; } diff --git a/sys/dev/virtio/virtio.c b/sys/dev/virtio/virtio.c index 53b47004610e..050e29c37dda 100644 --- a/sys/dev/virtio/virtio.c +++ b/sys/dev/virtio/virtio.c @@ -321,7 +321,7 @@ virtio_read_device_config(device_t dev, bus_size_t offset, void *dst, int len) } void -virtio_write_device_config(device_t dev, bus_size_t offset, void *dst, int len) +virtio_write_device_config(device_t dev, bus_size_t offset, const void *dst, int len) { VIRTIO_BUS_WRITE_DEVICE_CONFIG(device_get_parent(dev), diff --git a/sys/dev/virtio/virtio.h b/sys/dev/virtio/virtio.h index 8d32d5a8742f..8c6fdc4638d0 100644 --- a/sys/dev/virtio/virtio.h +++ b/sys/dev/virtio/virtio.h @@ -124,7 +124,7 @@ int virtio_child_pnpinfo_str(device_t busdev, device_t child, char *buf, void virtio_read_device_config(device_t dev, bus_size_t offset, void *dst, int length); void virtio_write_device_config(device_t dev, bus_size_t offset, - void *src, int length); + const void *src, int length); /* Inlined device specific read/write functions for common lengths. */ #define VIRTIO_RDWR_DEVICE_CONFIG(size, type) \ diff --git a/sys/dev/virtio/virtio_bus_if.m b/sys/dev/virtio/virtio_bus_if.m index 2c3424204842..80a99f2afedd 100644 --- a/sys/dev/virtio/virtio_bus_if.m +++ b/sys/dev/virtio/virtio_bus_if.m @@ -107,7 +107,7 @@ METHOD void read_device_config { METHOD void write_device_config { device_t dev; bus_size_t offset; - void *src; + const void *src; int len; };