All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register()
@ 2017-04-26  8:05 ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-04-26  8:05 UTC (permalink / raw)
  To: kernel, linux-arm-kernel, Patrice Chotard, Philipp Zabel,
	Srinivas Kandagatla, Stephen Gallimore
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 26 Apr 2017 09:50:34 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "devm_kcalloc".

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

* Delete the local variable "size" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/reset/sti/reset-syscfg.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/sti/reset-syscfg.c b/drivers/reset/sti/reset-syscfg.c
index 9bd57a5eee72..7e0f2aa55ba7 100644
--- a/drivers/reset/sti/reset-syscfg.c
+++ b/drivers/reset/sti/reset-syscfg.c
@@ -145,16 +145,14 @@ static int syscfg_reset_controller_register(struct device *dev,
 				const struct syscfg_reset_controller_data *data)
 {
 	struct syscfg_reset_controller *rc;
-	size_t size;
 	int i, err;
 
 	rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
 	if (!rc)
 		return -ENOMEM;
 
-	size = sizeof(struct syscfg_reset_channel) * data->nr_channels;
-
-	rc->channels = devm_kzalloc(dev, size, GFP_KERNEL);
+	rc->channels = devm_kcalloc(dev, data->nr_channels,
+				    sizeof(*rc->channels), GFP_KERNEL);
 	if (!rc->channels)
 		return -ENOMEM;
 
-- 
2.12.2

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

* [PATCH] reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register()
@ 2017-04-26  8:05 ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-04-26  8:05 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 26 Apr 2017 09:50:34 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "devm_kcalloc".

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

* Delete the local variable "size" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/reset/sti/reset-syscfg.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/sti/reset-syscfg.c b/drivers/reset/sti/reset-syscfg.c
index 9bd57a5eee72..7e0f2aa55ba7 100644
--- a/drivers/reset/sti/reset-syscfg.c
+++ b/drivers/reset/sti/reset-syscfg.c
@@ -145,16 +145,14 @@ static int syscfg_reset_controller_register(struct device *dev,
 				const struct syscfg_reset_controller_data *data)
 {
 	struct syscfg_reset_controller *rc;
-	size_t size;
 	int i, err;
 
 	rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
 	if (!rc)
 		return -ENOMEM;
 
-	size = sizeof(struct syscfg_reset_channel) * data->nr_channels;
-
-	rc->channels = devm_kzalloc(dev, size, GFP_KERNEL);
+	rc->channels = devm_kcalloc(dev, data->nr_channels,
+				    sizeof(*rc->channels), GFP_KERNEL);
 	if (!rc->channels)
 		return -ENOMEM;
 
-- 
2.12.2


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

* [PATCH] reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register()
@ 2017-04-26  8:05 ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-04-26  8:05 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 26 Apr 2017 09:50:34 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "devm_kcalloc".

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

* Delete the local variable "size" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/reset/sti/reset-syscfg.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/sti/reset-syscfg.c b/drivers/reset/sti/reset-syscfg.c
index 9bd57a5eee72..7e0f2aa55ba7 100644
--- a/drivers/reset/sti/reset-syscfg.c
+++ b/drivers/reset/sti/reset-syscfg.c
@@ -145,16 +145,14 @@ static int syscfg_reset_controller_register(struct device *dev,
 				const struct syscfg_reset_controller_data *data)
 {
 	struct syscfg_reset_controller *rc;
-	size_t size;
 	int i, err;
 
 	rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
 	if (!rc)
 		return -ENOMEM;
 
-	size = sizeof(struct syscfg_reset_channel) * data->nr_channels;
-
-	rc->channels = devm_kzalloc(dev, size, GFP_KERNEL);
+	rc->channels = devm_kcalloc(dev, data->nr_channels,
+				    sizeof(*rc->channels), GFP_KERNEL);
 	if (!rc->channels)
 		return -ENOMEM;
 
-- 
2.12.2

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

* Re: [PATCH] reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register()
  2017-04-26  8:05 ` SF Markus Elfring
  (?)
@ 2017-04-26  9:19   ` Philipp Zabel
  -1 siblings, 0 replies; 9+ messages in thread
From: Philipp Zabel @ 2017-04-26  9:19 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kernel, linux-arm-kernel, Patrice Chotard, Srinivas Kandagatla,
	Stephen Gallimore, LKML, kernel-janitors

On Wed, 2017-04-26 at 10:05 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 26 Apr 2017 09:50:34 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "devm_kcalloc".
> 
> * Replace the specification of a data structure by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> * Delete the local variable "size" which became unnecessary with
>   this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/reset/sti/reset-syscfg.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/reset/sti/reset-syscfg.c b/drivers/reset/sti/reset-syscfg.c
> index 9bd57a5eee72..7e0f2aa55ba7 100644
> --- a/drivers/reset/sti/reset-syscfg.c
> +++ b/drivers/reset/sti/reset-syscfg.c
> @@ -145,16 +145,14 @@ static int syscfg_reset_controller_register(struct device *dev,
>  				const struct syscfg_reset_controller_data *data)
>  {
>  	struct syscfg_reset_controller *rc;
> -	size_t size;
>  	int i, err;
>  
>  	rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
>  	if (!rc)
>  		return -ENOMEM;
>  
> -	size = sizeof(struct syscfg_reset_channel) * data->nr_channels;
> -
> -	rc->channels = devm_kzalloc(dev, size, GFP_KERNEL);
> +	rc->channels = devm_kcalloc(dev, data->nr_channels,
> +				    sizeof(*rc->channels), GFP_KERNEL);
>  	if (!rc->channels)
>  		return -ENOMEM;
>  

Thank you, I have applied this to the reset/next branch. The same change
could be made in the ti-syscon reset driver.

regards
Philipp

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

* Re: [PATCH] reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register()
@ 2017-04-26  9:19   ` Philipp Zabel
  0 siblings, 0 replies; 9+ messages in thread
From: Philipp Zabel @ 2017-04-26  9:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2017-04-26 at 10:05 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 26 Apr 2017 09:50:34 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "devm_kcalloc".
> 
> * Replace the specification of a data structure by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> * Delete the local variable "size" which became unnecessary with
>   this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/reset/sti/reset-syscfg.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/reset/sti/reset-syscfg.c b/drivers/reset/sti/reset-syscfg.c
> index 9bd57a5eee72..7e0f2aa55ba7 100644
> --- a/drivers/reset/sti/reset-syscfg.c
> +++ b/drivers/reset/sti/reset-syscfg.c
> @@ -145,16 +145,14 @@ static int syscfg_reset_controller_register(struct device *dev,
>  				const struct syscfg_reset_controller_data *data)
>  {
>  	struct syscfg_reset_controller *rc;
> -	size_t size;
>  	int i, err;
>  
>  	rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
>  	if (!rc)
>  		return -ENOMEM;
>  
> -	size = sizeof(struct syscfg_reset_channel) * data->nr_channels;
> -
> -	rc->channels = devm_kzalloc(dev, size, GFP_KERNEL);
> +	rc->channels = devm_kcalloc(dev, data->nr_channels,
> +				    sizeof(*rc->channels), GFP_KERNEL);
>  	if (!rc->channels)
>  		return -ENOMEM;
>  

Thank you, I have applied this to the reset/next branch. The same change
could be made in the ti-syscon reset driver.

regards
Philipp


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

* [PATCH] reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register()
@ 2017-04-26  9:19   ` Philipp Zabel
  0 siblings, 0 replies; 9+ messages in thread
From: Philipp Zabel @ 2017-04-26  9:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2017-04-26 at 10:05 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 26 Apr 2017 09:50:34 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "devm_kcalloc".
> 
> * Replace the specification of a data structure by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> * Delete the local variable "size" which became unnecessary with
>   this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/reset/sti/reset-syscfg.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/reset/sti/reset-syscfg.c b/drivers/reset/sti/reset-syscfg.c
> index 9bd57a5eee72..7e0f2aa55ba7 100644
> --- a/drivers/reset/sti/reset-syscfg.c
> +++ b/drivers/reset/sti/reset-syscfg.c
> @@ -145,16 +145,14 @@ static int syscfg_reset_controller_register(struct device *dev,
>  				const struct syscfg_reset_controller_data *data)
>  {
>  	struct syscfg_reset_controller *rc;
> -	size_t size;
>  	int i, err;
>  
>  	rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
>  	if (!rc)
>  		return -ENOMEM;
>  
> -	size = sizeof(struct syscfg_reset_channel) * data->nr_channels;
> -
> -	rc->channels = devm_kzalloc(dev, size, GFP_KERNEL);
> +	rc->channels = devm_kcalloc(dev, data->nr_channels,
> +				    sizeof(*rc->channels), GFP_KERNEL);
>  	if (!rc->channels)
>  		return -ENOMEM;
>  

Thank you, I have applied this to the reset/next branch. The same change
could be made in the ti-syscon reset driver.

regards
Philipp

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

* Re: reset: Use devm_kcalloc() in ti_syscon_reset_probe()?
  2017-04-26  9:19   ` Philipp Zabel
  (?)
@ 2017-04-26 11:00     ` SF Markus Elfring
  -1 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-04-26 11:00 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: kernel, linux-arm-kernel, Patrice Chotard, Srinivas Kandagatla,
	Stephen Gallimore, LKML, kernel-janitors

> Thank you, I have applied this to the reset/next branch.

Thanks for your acceptance.


> The same change could be made in the ti-syscon reset driver.

I was unsure if a similar source code adjustments would be worthwhile there.
If you would like to be more strict with consistent usage of Linux functions
for array allocations, there are various further update candidates to consider.

Regards,
Markus

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

* Re: reset: Use devm_kcalloc() in ti_syscon_reset_probe()?
@ 2017-04-26 11:00     ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-04-26 11:00 UTC (permalink / raw)
  To: linux-arm-kernel

> Thank you, I have applied this to the reset/next branch.

Thanks for your acceptance.


> The same change could be made in the ti-syscon reset driver.

I was unsure if a similar source code adjustments would be worthwhile there.
If you would like to be more strict with consistent usage of Linux functions
for array allocations, there are various further update candidates to consider.

Regards,
Markus

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

* reset: Use devm_kcalloc() in ti_syscon_reset_probe()?
@ 2017-04-26 11:00     ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-04-26 11:00 UTC (permalink / raw)
  To: linux-arm-kernel

> Thank you, I have applied this to the reset/next branch.

Thanks for your acceptance.


> The same change could be made in the ti-syscon reset driver.

I was unsure if a similar source code adjustments would be worthwhile there.
If you would like to be more strict with consistent usage of Linux functions
for array allocations, there are various further update candidates to consider.

Regards,
Markus

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

end of thread, other threads:[~2017-04-26 11:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  8:05 [PATCH] reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register() SF Markus Elfring
2017-04-26  8:05 ` SF Markus Elfring
2017-04-26  8:05 ` SF Markus Elfring
2017-04-26  9:19 ` Philipp Zabel
2017-04-26  9:19   ` Philipp Zabel
2017-04-26  9:19   ` Philipp Zabel
2017-04-26 11:00   ` reset: Use devm_kcalloc() in ti_syscon_reset_probe()? SF Markus Elfring
2017-04-26 11:00     ` SF Markus Elfring
2017-04-26 11:00     ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.