linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390/dasd: Use kzalloc instead of kmalloc/memset
@ 2022-04-19  1:43 Haowen Bai
  2022-04-19  5:43 ` Sven Schnelle
  0 siblings, 1 reply; 5+ messages in thread
From: Haowen Bai @ 2022-04-19  1:43 UTC (permalink / raw)
  To: Stefan Haberland, Jan Hoeppner, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle
  Cc: Haowen Bai, linux-s390, linux-kernel

Use kzalloc rather than duplicating its implementation, which
makes code simple and easy to understand.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 drivers/s390/block/dasd_eckd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 8410a25a65c1..74a035c56c3e 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1480,7 +1480,7 @@ static int dasd_eckd_pe_handler(struct dasd_device *device,
 {
 	struct pe_handler_work_data *data;
 
-	data = kmalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
+	data = kzalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
 	if (!data) {
 		if (mutex_trylock(&dasd_pe_handler_mutex)) {
 			data = pe_handler_worker;
@@ -1489,7 +1489,6 @@ static int dasd_eckd_pe_handler(struct dasd_device *device,
 			return -ENOMEM;
 		}
 	} else {
-		memset(data, 0, sizeof(*data));
 		data->isglobal = 0;
 	}
 	INIT_WORK(&data->worker, do_pe_handler_work);
-- 
2.7.4


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

* Re: [PATCH] s390/dasd: Use kzalloc instead of kmalloc/memset
  2022-04-19  1:43 [PATCH] s390/dasd: Use kzalloc instead of kmalloc/memset Haowen Bai
@ 2022-04-19  5:43 ` Sven Schnelle
  2022-04-19  6:05   ` [PATCH V2] " Haowen Bai
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Schnelle @ 2022-04-19  5:43 UTC (permalink / raw)
  To: Haowen Bai
  Cc: Stefan Haberland, Jan Hoeppner, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, linux-s390,
	linux-kernel

Hi,

Haowen Bai <baihaowen@meizu.com> writes:

> Use kzalloc rather than duplicating its implementation, which
> makes code simple and easy to understand.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
>  drivers/s390/block/dasd_eckd.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
> index 8410a25a65c1..74a035c56c3e 100644
> --- a/drivers/s390/block/dasd_eckd.c
> +++ b/drivers/s390/block/dasd_eckd.c
> @@ -1480,7 +1480,7 @@ static int dasd_eckd_pe_handler(struct dasd_device *device,
>  {
>  	struct pe_handler_work_data *data;
>  
> -	data = kmalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
> +	data = kzalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
>  	if (!data) {
>  		if (mutex_trylock(&dasd_pe_handler_mutex)) {
>  			data = pe_handler_worker;
> @@ -1489,7 +1489,6 @@ static int dasd_eckd_pe_handler(struct dasd_device *device,
>  			return -ENOMEM;
>  		}
>  	} else {
> -		memset(data, 0, sizeof(*data));
>  		data->isglobal = 0;

Maybe also remove the isglobal assigment above, so the whole else block
could go away?

>  	}
>  	INIT_WORK(&data->worker, do_pe_handler_work);

Thanks,
Sven

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

* [PATCH V2] s390/dasd: Use kzalloc instead of kmalloc/memset
  2022-04-19  5:43 ` Sven Schnelle
@ 2022-04-19  6:05   ` Haowen Bai
  2022-04-20  6:44     ` Sven Schnelle
  2022-04-29 12:52     ` Stefan Haberland
  0 siblings, 2 replies; 5+ messages in thread
From: Haowen Bai @ 2022-04-19  6:05 UTC (permalink / raw)
  To: svens
  Cc: agordeev, baihaowen, borntraeger, gor, hca, hoeppner,
	linux-kernel, linux-s390, sth

Use kzalloc rather than duplicating its implementation, which
makes code simple and easy to understand.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
V1->V2: also remove the isglobal assigment above, so the whole else block
could go away

 drivers/s390/block/dasd_eckd.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 8410a25a65c1..6b70f9dfff02 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1480,7 +1480,7 @@ static int dasd_eckd_pe_handler(struct dasd_device *device,
 {
 	struct pe_handler_work_data *data;
 
-	data = kmalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
+	data = kzalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
 	if (!data) {
 		if (mutex_trylock(&dasd_pe_handler_mutex)) {
 			data = pe_handler_worker;
@@ -1488,9 +1488,6 @@ static int dasd_eckd_pe_handler(struct dasd_device *device,
 		} else {
 			return -ENOMEM;
 		}
-	} else {
-		memset(data, 0, sizeof(*data));
-		data->isglobal = 0;
 	}
 	INIT_WORK(&data->worker, do_pe_handler_work);
 	dasd_get_device(device);
-- 
2.7.4


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

* Re: [PATCH V2] s390/dasd: Use kzalloc instead of kmalloc/memset
  2022-04-19  6:05   ` [PATCH V2] " Haowen Bai
@ 2022-04-20  6:44     ` Sven Schnelle
  2022-04-29 12:52     ` Stefan Haberland
  1 sibling, 0 replies; 5+ messages in thread
From: Sven Schnelle @ 2022-04-20  6:44 UTC (permalink / raw)
  To: Haowen Bai
  Cc: agordeev, borntraeger, gor, hca, hoeppner, linux-kernel, linux-s390, sth

Haowen Bai <baihaowen@meizu.com> writes:

> Use kzalloc rather than duplicating its implementation, which
> makes code simple and easy to understand.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
> V1->V2: also remove the isglobal assigment above, so the whole else block
> could go away
>
>  drivers/s390/block/dasd_eckd.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
> index 8410a25a65c1..6b70f9dfff02 100644
> --- a/drivers/s390/block/dasd_eckd.c
> +++ b/drivers/s390/block/dasd_eckd.c
> @@ -1480,7 +1480,7 @@ static int dasd_eckd_pe_handler(struct dasd_device *device,
>  {
>  	struct pe_handler_work_data *data;
>  
> -	data = kmalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
> +	data = kzalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
>  	if (!data) {
>  		if (mutex_trylock(&dasd_pe_handler_mutex)) {
>  			data = pe_handler_worker;
> @@ -1488,9 +1488,6 @@ static int dasd_eckd_pe_handler(struct dasd_device *device,
>  		} else {
>  			return -ENOMEM;
>  		}
> -	} else {
> -		memset(data, 0, sizeof(*data));
> -		data->isglobal = 0;
>  	}
>  	INIT_WORK(&data->worker, do_pe_handler_work);
>  	dasd_get_device(device);

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>

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

* Re: [PATCH V2] s390/dasd: Use kzalloc instead of kmalloc/memset
  2022-04-19  6:05   ` [PATCH V2] " Haowen Bai
  2022-04-20  6:44     ` Sven Schnelle
@ 2022-04-29 12:52     ` Stefan Haberland
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Haberland @ 2022-04-29 12:52 UTC (permalink / raw)
  To: Haowen Bai, svens
  Cc: agordeev, borntraeger, gor, hca, hoeppner, linux-kernel, linux-s390

Am 19.04.22 um 08:05 schrieb Haowen Bai:
> Use kzalloc rather than duplicating its implementation, which
> makes code simple and easy to understand.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
> V1->V2: also remove the isglobal assigment above, so the whole else block
> could go away

thanks, applied!


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

end of thread, other threads:[~2022-04-29 12:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19  1:43 [PATCH] s390/dasd: Use kzalloc instead of kmalloc/memset Haowen Bai
2022-04-19  5:43 ` Sven Schnelle
2022-04-19  6:05   ` [PATCH V2] " Haowen Bai
2022-04-20  6:44     ` Sven Schnelle
2022-04-29 12:52     ` Stefan Haberland

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