@@ -282,7 +282,7 @@ static void control_out(VirtIODevice *vdev, VirtQueue *vq)
VirtQueueElement elem;
VirtIOSerial *vser;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = container_of(vdev, VirtIOSerial, vdev);
while (virtqueue_pop(vq, &elem)) {
handle_control_message(vser, elem.out_sg[0].iov_base);
@@ -297,7 +297,7 @@ static void handle_output(VirtIODevice *vdev, VirtQueue *vq)
VirtIOSerial *vser;
VirtQueueElement elem;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = container_of(vdev, VirtIOSerial, vdev);
while (virtqueue_pop(vq, &elem)) {
VirtIOSerialPort *port;
@@ -335,7 +335,7 @@ static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
{
- VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ VirtIOSerial *vser = container_of(vdev, VirtIOSerial, vdev);
if (vser->bus->max_nr_ports > 1) {
features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
}
@@ -347,7 +347,7 @@ static void get_config(VirtIODevice *vdev, uint8_t *config_data)
{
VirtIOSerial *vser;
- vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+ vser = container_of(vdev, VirtIOSerial, vdev);
memcpy(config_data, &vser->config, sizeof(struct virtio_console_config));
}
Use container_of and remove assumption that vdev is 1st member of structure. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- hw/virtio-serial-bus.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)