virtio: console: Use better variable names for fill_queue operation
We want to keep track of the number of buffers added to a vq. Use nr_added_bufs instead of 'ret'. Also, the users of fill_queue() overloaded a local 'err' variable to check the numbers of buffers allocated. Use nr_added_bufs instead of err. Signed-off-by: Amit Shah <amit.shah@redhat.com> Reported-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
Родитель
604b2ad7cc
Коммит
335a64a5c2
|
@ -1071,27 +1071,27 @@ static void config_intr(struct virtio_device *vdev)
|
||||||
static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
|
static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
|
||||||
{
|
{
|
||||||
struct port_buffer *buf;
|
struct port_buffer *buf;
|
||||||
unsigned int ret;
|
unsigned int nr_added_bufs;
|
||||||
int err;
|
int ret;
|
||||||
|
|
||||||
ret = 0;
|
nr_added_bufs = 0;
|
||||||
do {
|
do {
|
||||||
buf = alloc_buf(PAGE_SIZE);
|
buf = alloc_buf(PAGE_SIZE);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
spin_lock_irq(lock);
|
spin_lock_irq(lock);
|
||||||
err = add_inbuf(vq, buf);
|
ret = add_inbuf(vq, buf);
|
||||||
if (err < 0) {
|
if (ret < 0) {
|
||||||
spin_unlock_irq(lock);
|
spin_unlock_irq(lock);
|
||||||
free_buf(buf);
|
free_buf(buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret++;
|
nr_added_bufs++;
|
||||||
spin_unlock_irq(lock);
|
spin_unlock_irq(lock);
|
||||||
} while (err > 0);
|
} while (ret > 0);
|
||||||
|
|
||||||
return ret;
|
return nr_added_bufs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_port(struct ports_device *portdev, u32 id)
|
static int add_port(struct ports_device *portdev, u32 id)
|
||||||
|
@ -1100,6 +1100,7 @@ static int add_port(struct ports_device *portdev, u32 id)
|
||||||
struct port *port;
|
struct port *port;
|
||||||
struct port_buffer *buf;
|
struct port_buffer *buf;
|
||||||
dev_t devt;
|
dev_t devt;
|
||||||
|
unsigned int nr_added_bufs;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
port = kmalloc(sizeof(*port), GFP_KERNEL);
|
port = kmalloc(sizeof(*port), GFP_KERNEL);
|
||||||
|
@ -1144,8 +1145,8 @@ static int add_port(struct ports_device *portdev, u32 id)
|
||||||
init_waitqueue_head(&port->waitqueue);
|
init_waitqueue_head(&port->waitqueue);
|
||||||
|
|
||||||
/* Fill the in_vq with buffers so the host can send us data. */
|
/* Fill the in_vq with buffers so the host can send us data. */
|
||||||
err = fill_queue(port->in_vq, &port->inbuf_lock);
|
nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock);
|
||||||
if (!err) {
|
if (!nr_added_bufs) {
|
||||||
dev_err(port->dev, "Error allocating inbufs\n");
|
dev_err(port->dev, "Error allocating inbufs\n");
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto free_device;
|
goto free_device;
|
||||||
|
@ -1442,12 +1443,14 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
|
||||||
INIT_LIST_HEAD(&portdev->ports);
|
INIT_LIST_HEAD(&portdev->ports);
|
||||||
|
|
||||||
if (multiport) {
|
if (multiport) {
|
||||||
|
unsigned int nr_added_bufs;
|
||||||
|
|
||||||
spin_lock_init(&portdev->cvq_lock);
|
spin_lock_init(&portdev->cvq_lock);
|
||||||
INIT_WORK(&portdev->control_work, &control_work_handler);
|
INIT_WORK(&portdev->control_work, &control_work_handler);
|
||||||
INIT_WORK(&portdev->config_work, &config_work_handler);
|
INIT_WORK(&portdev->config_work, &config_work_handler);
|
||||||
|
|
||||||
err = fill_queue(portdev->c_ivq, &portdev->cvq_lock);
|
nr_added_bufs = fill_queue(portdev->c_ivq, &portdev->cvq_lock);
|
||||||
if (!err) {
|
if (!nr_added_bufs) {
|
||||||
dev_err(&vdev->dev,
|
dev_err(&vdev->dev,
|
||||||
"Error allocating buffers for control queue\n");
|
"Error allocating buffers for control queue\n");
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче