@@ -379,7 +379,7 @@ static ssize_t send_control_msg(struct port *port, unsigned int event,
379379 struct scatterlist sg [1 ];
380380 struct virtio_console_control cpkt ;
381381 struct virtqueue * vq ;
382- int len ;
382+ unsigned int len ;
383383
384384 if (!use_multiport (port -> portdev ))
385385 return 0 ;
@@ -1071,27 +1071,27 @@ static void config_intr(struct virtio_device *vdev)
10711071static unsigned int fill_queue (struct virtqueue * vq , spinlock_t * lock )
10721072{
10731073 struct port_buffer * buf ;
1074- unsigned int ret ;
1075- int err ;
1074+ unsigned int nr_added_bufs ;
1075+ int ret ;
10761076
1077- ret = 0 ;
1077+ nr_added_bufs = 0 ;
10781078 do {
10791079 buf = alloc_buf (PAGE_SIZE );
10801080 if (!buf )
10811081 break ;
10821082
10831083 spin_lock_irq (lock );
1084- err = add_inbuf (vq , buf );
1085- if (err < 0 ) {
1084+ ret = add_inbuf (vq , buf );
1085+ if (ret < 0 ) {
10861086 spin_unlock_irq (lock );
10871087 free_buf (buf );
10881088 break ;
10891089 }
1090- ret ++ ;
1090+ nr_added_bufs ++ ;
10911091 spin_unlock_irq (lock );
1092- } while (err > 0 );
1092+ } while (ret > 0 );
10931093
1094- return ret ;
1094+ return nr_added_bufs ;
10951095}
10961096
10971097static int add_port (struct ports_device * portdev , u32 id )
@@ -1100,6 +1100,7 @@ static int add_port(struct ports_device *portdev, u32 id)
11001100 struct port * port ;
11011101 struct port_buffer * buf ;
11021102 dev_t devt ;
1103+ unsigned int nr_added_bufs ;
11031104 int err ;
11041105
11051106 port = kmalloc (sizeof (* port ), GFP_KERNEL );
@@ -1144,8 +1145,8 @@ static int add_port(struct ports_device *portdev, u32 id)
11441145 init_waitqueue_head (& port -> waitqueue );
11451146
11461147 /* Fill the in_vq with buffers so the host can send us data. */
1147- err = fill_queue (port -> in_vq , & port -> inbuf_lock );
1148- if (!err ) {
1148+ nr_added_bufs = fill_queue (port -> in_vq , & port -> inbuf_lock );
1149+ if (!nr_added_bufs ) {
11491150 dev_err (port -> dev , "Error allocating inbufs\n" );
11501151 err = - ENOMEM ;
11511152 goto free_device ;
@@ -1442,12 +1443,14 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
14421443 INIT_LIST_HEAD (& portdev -> ports );
14431444
14441445 if (multiport ) {
1446+ unsigned int nr_added_bufs ;
1447+
14451448 spin_lock_init (& portdev -> cvq_lock );
14461449 INIT_WORK (& portdev -> control_work , & control_work_handler );
14471450 INIT_WORK (& portdev -> config_work , & config_work_handler );
14481451
1449- err = fill_queue (portdev -> c_ivq , & portdev -> cvq_lock );
1450- if (!err ) {
1452+ nr_added_bufs = fill_queue (portdev -> c_ivq , & portdev -> cvq_lock );
1453+ if (!nr_added_bufs ) {
14511454 dev_err (& vdev -> dev ,
14521455 "Error allocating buffers for control queue\n" );
14531456 err = - ENOMEM ;
0 commit comments