virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] virtio: console: Trivial fixes based on review comments
@ 2010-03-08  8:46 Amit Shah
  2010-03-08  8:46 ` [PATCH 1/2] virtio: console: Fix type of 'len' as unsigned int Amit Shah
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Amit Shah @ 2010-03-08  8:46 UTC (permalink / raw)
  To: mst; +Cc: Amit Shah, virtualization, quintela

Hello,

Here are a couple of small fixes for the virtio_console code, it's mostly
stylistic fixes.

Michael, can you push these to Linus? Thanks.

Amit Shah (2):
  virtio: console: Fix type of 'len' as unsigned int
  virtio: console: Use better variable names for fill_queue operation

 drivers/char/virtio_console.c |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] virtio: console: Fix type of 'len' as unsigned int
  2010-03-08  8:46 [PATCH 0/2] virtio: console: Trivial fixes based on review comments Amit Shah
@ 2010-03-08  8:46 ` Amit Shah
  2010-03-08  8:47   ` [PATCH 2/2] virtio: console: Use better variable names for fill_queue operation Amit Shah
  2010-03-08 10:34 ` [PATCH 0/2] virtio: console: Trivial fixes based on review comments Juan Quintela
  2010-03-08 21:23 ` Michael S. Tsirkin
  2 siblings, 1 reply; 8+ messages in thread
From: Amit Shah @ 2010-03-08  8:46 UTC (permalink / raw)
  To: mst; +Cc: Amit Shah, virtualization, quintela

We declare 'len' as int type but it should be 'unsigned int', as
get_buf() wants it to be.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reported-by: Juan Quintela <quintela@redhat.com>
---
 drivers/char/virtio_console.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 213373b..2bd6a9c 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -379,7 +379,7 @@ static ssize_t send_control_msg(struct port *port, unsigned int event,
 	struct scatterlist sg[1];
 	struct virtio_console_control cpkt;
 	struct virtqueue *vq;
-	int len;
+	unsigned int len;
 
 	if (!use_multiport(port->portdev))
 		return 0;
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] virtio: console: Use better variable names for fill_queue operation
  2010-03-08  8:46 ` [PATCH 1/2] virtio: console: Fix type of 'len' as unsigned int Amit Shah
@ 2010-03-08  8:47   ` Amit Shah
  0 siblings, 0 replies; 8+ messages in thread
From: Amit Shah @ 2010-03-08  8:47 UTC (permalink / raw)
  To: mst; +Cc: Amit Shah, virtualization, quintela

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>
---
 drivers/char/virtio_console.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 2bd6a9c..f404ccf 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1071,27 +1071,27 @@ static void config_intr(struct virtio_device *vdev)
 static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
 {
 	struct port_buffer *buf;
-	unsigned int ret;
-	int err;
+	unsigned int nr_added_bufs;
+	int ret;
 
-	ret = 0;
+	nr_added_bufs = 0;
 	do {
 		buf = alloc_buf(PAGE_SIZE);
 		if (!buf)
 			break;
 
 		spin_lock_irq(lock);
-		err = add_inbuf(vq, buf);
-		if (err < 0) {
+		ret = add_inbuf(vq, buf);
+		if (ret < 0) {
 			spin_unlock_irq(lock);
 			free_buf(buf);
 			break;
 		}
-		ret++;
+		nr_added_bufs++;
 		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)
@@ -1100,6 +1100,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 	struct port *port;
 	struct port_buffer *buf;
 	dev_t devt;
+	unsigned int nr_added_bufs;
 	int err;
 
 	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);
 
 	/* Fill the in_vq with buffers so the host can send us data. */
-	err = fill_queue(port->in_vq, &port->inbuf_lock);
-	if (!err) {
+	nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock);
+	if (!nr_added_bufs) {
 		dev_err(port->dev, "Error allocating inbufs\n");
 		err = -ENOMEM;
 		goto free_device;
@@ -1442,12 +1443,14 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
 	INIT_LIST_HEAD(&portdev->ports);
 
 	if (multiport) {
+		unsigned int nr_added_bufs;
+
 		spin_lock_init(&portdev->cvq_lock);
 		INIT_WORK(&portdev->control_work, &control_work_handler);
 		INIT_WORK(&portdev->config_work, &config_work_handler);
 
-		err = fill_queue(portdev->c_ivq, &portdev->cvq_lock);
-		if (!err) {
+		nr_added_bufs = fill_queue(portdev->c_ivq, &portdev->cvq_lock);
+		if (!nr_added_bufs) {
 			dev_err(&vdev->dev,
 				"Error allocating buffers for control queue\n");
 			err = -ENOMEM;
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] virtio: console: Trivial fixes based on review comments
  2010-03-08  8:46 [PATCH 0/2] virtio: console: Trivial fixes based on review comments Amit Shah
  2010-03-08  8:46 ` [PATCH 1/2] virtio: console: Fix type of 'len' as unsigned int Amit Shah
@ 2010-03-08 10:34 ` Juan Quintela
  2010-03-08 21:23 ` Michael S. Tsirkin
  2 siblings, 0 replies; 8+ messages in thread
From: Juan Quintela @ 2010-03-08 10:34 UTC (permalink / raw)
  To: Amit Shah; +Cc: virtualization, mst

Amit Shah <amit.shah@redhat.com> wrote:
> Hello,
>
> Here are a couple of small fixes for the virtio_console code, it's mostly
> stylistic fixes.
>
> Michael, can you push these to Linus? Thanks.
>
> Amit Shah (2):
>   virtio: console: Fix type of 'len' as unsigned int
>   virtio: console: Use better variable names for fill_queue operation
>
>  drivers/char/virtio_console.c |   29 ++++++++++++++++-------------
>  1 files changed, 16 insertions(+), 13 deletions(-)

Acked-by: Juan Quintela <quintela@redhat.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] virtio: console: Trivial fixes based on review comments
  2010-03-08  8:46 [PATCH 0/2] virtio: console: Trivial fixes based on review comments Amit Shah
  2010-03-08  8:46 ` [PATCH 1/2] virtio: console: Fix type of 'len' as unsigned int Amit Shah
  2010-03-08 10:34 ` [PATCH 0/2] virtio: console: Trivial fixes based on review comments Juan Quintela
@ 2010-03-08 21:23 ` Michael S. Tsirkin
  2010-03-09  3:55   ` Amit Shah
  2 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2010-03-08 21:23 UTC (permalink / raw)
  To: Amit Shah; +Cc: virtualization, quintela

On Mon, Mar 08, 2010 at 02:16:58PM +0530, Amit Shah wrote:
> Hello,
> 
> Here are a couple of small fixes for the virtio_console code, it's mostly
> stylistic fixes.
> 
> Michael, can you push these to Linus? Thanks.

We are in fixes only mode now. Does the first patch fix a bug,
or is it cosmetic only?

> Amit Shah (2):
>   virtio: console: Fix type of 'len' as unsigned int
>   virtio: console: Use better variable names for fill_queue operation
> 
>  drivers/char/virtio_console.c |   29 ++++++++++++++++-------------
>  1 files changed, 16 insertions(+), 13 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] virtio: console: Trivial fixes based on review comments
  2010-03-08 21:23 ` Michael S. Tsirkin
@ 2010-03-09  3:55   ` Amit Shah
  2010-03-09  6:28     ` Michael S. Tsirkin
  0 siblings, 1 reply; 8+ messages in thread
From: Amit Shah @ 2010-03-09  3:55 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: virtualization, quintela

On (Mon) Mar 08 2010 [23:23:20], Michael S. Tsirkin wrote:
> On Mon, Mar 08, 2010 at 02:16:58PM +0530, Amit Shah wrote:
> > Hello,
> > 
> > Here are a couple of small fixes for the virtio_console code, it's mostly
> > stylistic fixes.
> > 
> > Michael, can you push these to Linus? Thanks.
> 
> We are in fixes only mode now. Does the first patch fix a bug,
> or is it cosmetic only?

No, it's not a bug fix. The value written to 'len' is write-only, we
never read from it.

		Amit

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] virtio: console: Trivial fixes based on review comments
  2010-03-09  3:55   ` Amit Shah
@ 2010-03-09  6:28     ` Michael S. Tsirkin
  2010-03-09  6:36       ` Amit Shah
  0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2010-03-09  6:28 UTC (permalink / raw)
  To: Amit Shah; +Cc: virtualization, quintela

On Tue, Mar 09, 2010 at 09:25:56AM +0530, Amit Shah wrote:
> On (Mon) Mar 08 2010 [23:23:20], Michael S. Tsirkin wrote:
> > On Mon, Mar 08, 2010 at 02:16:58PM +0530, Amit Shah wrote:
> > > Hello,
> > > 
> > > Here are a couple of small fixes for the virtio_console code, it's mostly
> > > stylistic fixes.
> > > 
> > > Michael, can you push these to Linus? Thanks.
> > 
> > We are in fixes only mode now. Does the first patch fix a bug,
> > or is it cosmetic only?
> 
> No, it's not a bug fix. The value written to 'len' is write-only, we
> never read from it.
> 
> 		Amit


Then IMO we are better off queueing it up for 2.6.35,
no need to create unnecessary noise.

-- 
MST

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] virtio: console: Trivial fixes based on review comments
  2010-03-09  6:28     ` Michael S. Tsirkin
@ 2010-03-09  6:36       ` Amit Shah
  0 siblings, 0 replies; 8+ messages in thread
From: Amit Shah @ 2010-03-09  6:36 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: virtualization, quintela

On (Tue) Mar 09 2010 [08:28:50], Michael S. Tsirkin wrote:
> On Tue, Mar 09, 2010 at 09:25:56AM +0530, Amit Shah wrote:
> > On (Mon) Mar 08 2010 [23:23:20], Michael S. Tsirkin wrote:
> > > On Mon, Mar 08, 2010 at 02:16:58PM +0530, Amit Shah wrote:
> > > > Hello,
> > > > 
> > > > Here are a couple of small fixes for the virtio_console code, it's mostly
> > > > stylistic fixes.
> > > > 
> > > > Michael, can you push these to Linus? Thanks.
> > > 
> > > We are in fixes only mode now. Does the first patch fix a bug,
> > > or is it cosmetic only?
> > 
> > No, it's not a bug fix. The value written to 'len' is write-only, we
> > never read from it.
> 
> Then IMO we are better off queueing it up for 2.6.35,
> no need to create unnecessary noise.

I'm fine with that too.

		Amit

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-09  6:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-08  8:46 [PATCH 0/2] virtio: console: Trivial fixes based on review comments Amit Shah
2010-03-08  8:46 ` [PATCH 1/2] virtio: console: Fix type of 'len' as unsigned int Amit Shah
2010-03-08  8:47   ` [PATCH 2/2] virtio: console: Use better variable names for fill_queue operation Amit Shah
2010-03-08 10:34 ` [PATCH 0/2] virtio: console: Trivial fixes based on review comments Juan Quintela
2010-03-08 21:23 ` Michael S. Tsirkin
2010-03-09  3:55   ` Amit Shah
2010-03-09  6:28     ` Michael S. Tsirkin
2010-03-09  6:36       ` Amit Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).