virtio: console: make discard_port_data() use get_inbuf()
discard_port_data() used virtqueue_get_buf() directly instead of using get_inbuf(). Fix this, so that we get accounting for all received bytes. This also simplifies the code a lot. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ce072a0cee
commit
2d24cdaa6e
|
@ -386,28 +386,23 @@ static int add_inbuf(struct virtqueue *vq, struct port_buffer *buf)
|
||||||
static void discard_port_data(struct port *port)
|
static void discard_port_data(struct port *port)
|
||||||
{
|
{
|
||||||
struct port_buffer *buf;
|
struct port_buffer *buf;
|
||||||
struct virtqueue *vq;
|
unsigned int err;
|
||||||
unsigned int len, err;
|
|
||||||
|
|
||||||
if (!port->portdev) {
|
if (!port->portdev) {
|
||||||
/* Device has been unplugged. vqs are already gone. */
|
/* Device has been unplugged. vqs are already gone. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vq = port->in_vq;
|
buf = get_inbuf(port);
|
||||||
if (port->inbuf)
|
|
||||||
buf = port->inbuf;
|
|
||||||
else
|
|
||||||
buf = virtqueue_get_buf(vq, &len);
|
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
while (buf) {
|
while (buf) {
|
||||||
if (add_inbuf(vq, buf) < 0) {
|
if (add_inbuf(port->in_vq, buf) < 0) {
|
||||||
err++;
|
err++;
|
||||||
free_buf(buf);
|
free_buf(buf);
|
||||||
}
|
}
|
||||||
buf = virtqueue_get_buf(vq, &len);
|
port->inbuf = NULL;
|
||||||
|
buf = get_inbuf(port);
|
||||||
}
|
}
|
||||||
port->inbuf = NULL;
|
|
||||||
if (err)
|
if (err)
|
||||||
dev_warn(port->dev, "Errors adding %d buffers back to vq\n",
|
dev_warn(port->dev, "Errors adding %d buffers back to vq\n",
|
||||||
err);
|
err);
|
||||||
|
|
Loading…
Reference in New Issue