Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio_console: drop unused config fields

struct ports_device includes a config field including the whole
virtio_console_config, but only max_nr_ports in there is ever updated or
used. The rest is unused and in fact does not even mirror the
device config. Drop everything except max_nr_ports,
saving some memory.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>

+7 -7
+7 -7
drivers/char/virtio_console.c
··· 152 152 spinlock_t c_ivq_lock; 153 153 spinlock_t c_ovq_lock; 154 154 155 - /* The current config space is stored here */ 156 - struct virtio_console_config config; 155 + /* max. number of ports this device can hold */ 156 + u32 max_nr_ports; 157 157 158 158 /* The virtio device we're associated with */ 159 159 struct virtio_device *vdev; ··· 1649 1649 break; 1650 1650 } 1651 1651 if (virtio32_to_cpu(vdev, cpkt->id) >= 1652 - portdev->config.max_nr_ports) { 1652 + portdev->max_nr_ports) { 1653 1653 dev_warn(&portdev->vdev->dev, 1654 1654 "Request for adding port with " 1655 1655 "out-of-bound id %u, max. supported id: %u\n", 1656 - cpkt->id, portdev->config.max_nr_ports - 1); 1656 + cpkt->id, portdev->max_nr_ports - 1); 1657 1657 break; 1658 1658 } 1659 1659 add_port(portdev, virtio32_to_cpu(vdev, cpkt->id)); ··· 1894 1894 u32 i, j, nr_ports, nr_queues; 1895 1895 int err; 1896 1896 1897 - nr_ports = portdev->config.max_nr_ports; 1897 + nr_ports = portdev->max_nr_ports; 1898 1898 nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2; 1899 1899 1900 1900 vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL); ··· 2047 2047 } 2048 2048 2049 2049 multiport = false; 2050 - portdev->config.max_nr_ports = 1; 2050 + portdev->max_nr_ports = 1; 2051 2051 2052 2052 /* Don't test MULTIPORT at all if we're rproc: not a valid feature! */ 2053 2053 if (!is_rproc_serial(vdev) && 2054 2054 virtio_cread_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT, 2055 2055 struct virtio_console_config, max_nr_ports, 2056 - &portdev->config.max_nr_ports) == 0) { 2056 + &portdev->max_nr_ports) == 0) { 2057 2057 multiport = true; 2058 2058 } 2059 2059