virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] virtio-scsi: use pr_err() instead of printk()
@ 2013-03-07  3:29 Wanlong Gao
  2013-03-07  3:29 ` [PATCH 2/2] virtio-scsi: reorder the goto label in init() Wanlong Gao
  2013-03-08  9:48 ` [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Paolo Bonzini
  0 siblings, 2 replies; 7+ messages in thread
From: Wanlong Gao @ 2013-03-07  3:29 UTC (permalink / raw)
  To: rusty; +Cc: pbonzini, virtualization

Convert the virtio-scsi driver to use pr_err() instead of printk().

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 drivers/scsi/virtio_scsi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 612e320..f679b8c 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -13,6 +13,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/mempool.h>
@@ -771,8 +773,7 @@ static int __init init(void)
 
 	virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
 	if (!virtscsi_cmd_cache) {
-		printk(KERN_ERR "kmem_cache_create() for "
-				"virtscsi_cmd_cache failed\n");
+		pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
 		goto error;
 	}
 
@@ -781,8 +782,7 @@ static int __init init(void)
 		mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
 					 virtscsi_cmd_cache);
 	if (!virtscsi_cmd_pool) {
-		printk(KERN_ERR "mempool_create() for"
-				"virtscsi_cmd_pool failed\n");
+		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
 		goto error;
 	}
 	ret = register_virtio_driver(&virtio_scsi_driver);
-- 
1.8.2.rc2

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

* [PATCH 2/2] virtio-scsi: reorder the goto label in init()
  2013-03-07  3:29 [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Wanlong Gao
@ 2013-03-07  3:29 ` Wanlong Gao
  2013-03-08  0:06   ` Rusty Russell
  2013-03-08  9:48 ` [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Paolo Bonzini
  1 sibling, 1 reply; 7+ messages in thread
From: Wanlong Gao @ 2013-03-07  3:29 UTC (permalink / raw)
  To: rusty; +Cc: pbonzini, virtualization

Reorder the goto label in init() to make it more clearly, and remove
the useless NULL pointer reassignment.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 drivers/scsi/virtio_scsi.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index f679b8c..55dfb06 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -774,32 +774,27 @@ static int __init init(void)
 	virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
 	if (!virtscsi_cmd_cache) {
 		pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
-		goto error;
+		return ret;
 	}
 
-
-	virtscsi_cmd_pool =
-		mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
-					 virtscsi_cmd_cache);
+	virtscsi_cmd_pool = mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
+						     virtscsi_cmd_cache);
 	if (!virtscsi_cmd_pool) {
 		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
-		goto error;
+		goto out_destroy_cache;
 	}
+
 	ret = register_virtio_driver(&virtio_scsi_driver);
 	if (ret < 0)
-		goto error;
+		goto out_destroy_pool;
 
 	return 0;
 
-error:
-	if (virtscsi_cmd_pool) {
-		mempool_destroy(virtscsi_cmd_pool);
-		virtscsi_cmd_pool = NULL;
-	}
-	if (virtscsi_cmd_cache) {
-		kmem_cache_destroy(virtscsi_cmd_cache);
-		virtscsi_cmd_cache = NULL;
-	}
+out_destroy_pool:
+	mempool_destroy(virtscsi_cmd_pool);
+out_destroy_cache:
+	kmem_cache_destroy(virtscsi_cmd_cache);
+
 	return ret;
 }
 
-- 
1.8.2.rc2

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

* Re: [PATCH 2/2] virtio-scsi: reorder the goto label in init()
  2013-03-07  3:29 ` [PATCH 2/2] virtio-scsi: reorder the goto label in init() Wanlong Gao
@ 2013-03-08  0:06   ` Rusty Russell
  2013-03-08  1:11     ` [PATCH V2 " Wanlong Gao
  0 siblings, 1 reply; 7+ messages in thread
From: Rusty Russell @ 2013-03-08  0:06 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: pbonzini, virtualization

Wanlong Gao <gaowanlong@cn.fujitsu.com> writes:
> Reorder the goto label in init() to make it more clearly, and remove
> the useless NULL pointer reassignment.
>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

These both require Paulo's Ack...

> ---
>  drivers/scsi/virtio_scsi.c | 27 +++++++++++----------------
>  1 file changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index f679b8c..55dfb06 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -774,32 +774,27 @@ static int __init init(void)
>  	virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
>  	if (!virtscsi_cmd_cache) {
>  		pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
> -		goto error;
> +		return ret;

I mildly prefer the former (or perhaps renamed to "goto out" to match
the other labels.

>  	}
>  
> -
> -	virtscsi_cmd_pool =
> -		mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
> -					 virtscsi_cmd_cache);
> +	virtscsi_cmd_pool = mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
> +						     virtscsi_cmd_cache);
>  	if (!virtscsi_cmd_pool) {
>  		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
> -		goto error;
> +		goto out_destroy_cache;
>  	}
> +
>  	ret = register_virtio_driver(&virtio_scsi_driver);
>  	if (ret < 0)
> -		goto error;
> +		goto out_destroy_pool;
>  
>  	return 0;
>  
> -error:
> -	if (virtscsi_cmd_pool) {
> -		mempool_destroy(virtscsi_cmd_pool);
> -		virtscsi_cmd_pool = NULL;
> -	}
> -	if (virtscsi_cmd_cache) {
> -		kmem_cache_destroy(virtscsi_cmd_cache);
> -		virtscsi_cmd_cache = NULL;
> -	}
> +out_destroy_pool:
> +	mempool_destroy(virtscsi_cmd_pool);
> +out_destroy_cache:
> +	kmem_cache_destroy(virtscsi_cmd_cache);
> +
>  	return ret;
>  }
>  
> -- 
> 1.8.2.rc2

Cheers,
Rusty.

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

* [PATCH V2 2/2] virtio-scsi: reorder the goto label in init()
  2013-03-08  0:06   ` Rusty Russell
@ 2013-03-08  1:11     ` Wanlong Gao
  0 siblings, 0 replies; 7+ messages in thread
From: Wanlong Gao @ 2013-03-08  1:11 UTC (permalink / raw)
  To: rusty; +Cc: pbonzini, virtualization

Reorder the goto label in init() to make it more clearly, and remove
the useless NULL pointer reassignment.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 drivers/scsi/virtio_scsi.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index f679b8c..6307099 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -774,32 +774,27 @@ static int __init init(void)
 	virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
 	if (!virtscsi_cmd_cache) {
 		pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
-		goto error;
+		goto out;
 	}
 
-
-	virtscsi_cmd_pool =
-		mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
-					 virtscsi_cmd_cache);
+	virtscsi_cmd_pool = mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
+						     virtscsi_cmd_cache);
 	if (!virtscsi_cmd_pool) {
 		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
-		goto error;
+		goto out_destroy_cache;
 	}
+
 	ret = register_virtio_driver(&virtio_scsi_driver);
 	if (ret < 0)
-		goto error;
+		goto out_destroy_pool;
 
 	return 0;
 
-error:
-	if (virtscsi_cmd_pool) {
-		mempool_destroy(virtscsi_cmd_pool);
-		virtscsi_cmd_pool = NULL;
-	}
-	if (virtscsi_cmd_cache) {
-		kmem_cache_destroy(virtscsi_cmd_cache);
-		virtscsi_cmd_cache = NULL;
-	}
+out_destroy_pool:
+	mempool_destroy(virtscsi_cmd_pool);
+out_destroy_cache:
+	kmem_cache_destroy(virtscsi_cmd_cache);
+out:
 	return ret;
 }
 
-- 
1.8.2.rc2

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

* Re: [PATCH 1/2] virtio-scsi: use pr_err() instead of printk()
  2013-03-07  3:29 [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Wanlong Gao
  2013-03-07  3:29 ` [PATCH 2/2] virtio-scsi: reorder the goto label in init() Wanlong Gao
@ 2013-03-08  9:48 ` Paolo Bonzini
  2013-03-08 10:00   ` Wanlong Gao
  2013-03-12  3:43   ` Rusty Russell
  1 sibling, 2 replies; 7+ messages in thread
From: Paolo Bonzini @ 2013-03-08  9:48 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: virtualization

Il 07/03/2013 04:29, Wanlong Gao ha scritto:
> Convert the virtio-scsi driver to use pr_err() instead of printk().
> 
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

to this patch only.  For the other it's a matter of taste, and since
this is not a fast path it's easier to have a single label to bail out
out.  If you want to change it to "out", that's fine.

Paolo

> ---
>  drivers/scsi/virtio_scsi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 612e320..f679b8c 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -13,6 +13,8 @@
>   *
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/module.h>
>  #include <linux/slab.h>
>  #include <linux/mempool.h>
> @@ -771,8 +773,7 @@ static int __init init(void)
>  
>  	virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
>  	if (!virtscsi_cmd_cache) {
> -		printk(KERN_ERR "kmem_cache_create() for "
> -				"virtscsi_cmd_cache failed\n");
> +		pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
>  		goto error;
>  	}
>  
> @@ -781,8 +782,7 @@ static int __init init(void)
>  		mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
>  					 virtscsi_cmd_cache);
>  	if (!virtscsi_cmd_pool) {
> -		printk(KERN_ERR "mempool_create() for"
> -				"virtscsi_cmd_pool failed\n");
> +		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
>  		goto error;
>  	}
>  	ret = register_virtio_driver(&virtio_scsi_driver);
> 

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

* Re: [PATCH 1/2] virtio-scsi: use pr_err() instead of printk()
  2013-03-08  9:48 ` [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Paolo Bonzini
@ 2013-03-08 10:00   ` Wanlong Gao
  2013-03-12  3:43   ` Rusty Russell
  1 sibling, 0 replies; 7+ messages in thread
From: Wanlong Gao @ 2013-03-08 10:00 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: virtualization

On 03/08/2013 05:48 PM, Paolo Bonzini wrote:
> Il 07/03/2013 04:29, Wanlong Gao ha scritto:
>> Convert the virtio-scsi driver to use pr_err() instead of printk().
>>
>> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> 
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Thank you.

> 
> to this patch only.  For the other it's a matter of taste, and since
> this is not a fast path it's easier to have a single label to bail out
> out.  If you want to change it to "out", that's fine.

OK, but I still think the original lines are untidy.

Thanks,
Wanlong Gao

> 
> Paolo
> 
>> ---
>>  drivers/scsi/virtio_scsi.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
>> index 612e320..f679b8c 100644
>> --- a/drivers/scsi/virtio_scsi.c
>> +++ b/drivers/scsi/virtio_scsi.c
>> @@ -13,6 +13,8 @@
>>   *
>>   */
>>  
>> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>> +
>>  #include <linux/module.h>
>>  #include <linux/slab.h>
>>  #include <linux/mempool.h>
>> @@ -771,8 +773,7 @@ static int __init init(void)
>>  
>>  	virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
>>  	if (!virtscsi_cmd_cache) {
>> -		printk(KERN_ERR "kmem_cache_create() for "
>> -				"virtscsi_cmd_cache failed\n");
>> +		pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
>>  		goto error;
>>  	}
>>  
>> @@ -781,8 +782,7 @@ static int __init init(void)
>>  		mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
>>  					 virtscsi_cmd_cache);
>>  	if (!virtscsi_cmd_pool) {
>> -		printk(KERN_ERR "mempool_create() for"
>> -				"virtscsi_cmd_pool failed\n");
>> +		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
>>  		goto error;
>>  	}
>>  	ret = register_virtio_driver(&virtio_scsi_driver);
>>
> 
> 

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

* Re: [PATCH 1/2] virtio-scsi: use pr_err() instead of printk()
  2013-03-08  9:48 ` [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Paolo Bonzini
  2013-03-08 10:00   ` Wanlong Gao
@ 2013-03-12  3:43   ` Rusty Russell
  1 sibling, 0 replies; 7+ messages in thread
From: Rusty Russell @ 2013-03-12  3:43 UTC (permalink / raw)
  To: Paolo Bonzini, Wanlong Gao; +Cc: virtualization

Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 07/03/2013 04:29, Wanlong Gao ha scritto:
>> Convert the virtio-scsi driver to use pr_err() instead of printk().
>> 
>> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks, applied.

Cheers,
Rusty.

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

end of thread, other threads:[~2013-03-12  3:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-07  3:29 [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Wanlong Gao
2013-03-07  3:29 ` [PATCH 2/2] virtio-scsi: reorder the goto label in init() Wanlong Gao
2013-03-08  0:06   ` Rusty Russell
2013-03-08  1:11     ` [PATCH V2 " Wanlong Gao
2013-03-08  9:48 ` [PATCH 1/2] virtio-scsi: use pr_err() instead of printk() Paolo Bonzini
2013-03-08 10:00   ` Wanlong Gao
2013-03-12  3:43   ` Rusty Russell

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).