diff mbox

[2/2] ASoC: fsl_dma: Do not use 'full_name' node reference

Message ID 1420651312-21671-2-git-send-email-festevam@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fabio Estevam Jan. 7, 2015, 5:21 p.m. UTC
From: Fabio Estevam <fabio.estevam@freescale.com>

The only usage of 'full_name' is inside an error message, which provides a 
rather verbose node path.

A more concise error message can be obtained by using 'pdev->name' instead. It 
also makes the kzalloc calculation simpler, as we don't need to take the length
of full_name into account.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Buit tested only.

 sound/soc/fsl/fsl_dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Timur Tabi Jan. 7, 2015, 5:26 p.m. UTC | #1
Fabio Estevam wrote:
> -			ssi_np->full_name);
> +			pdev->name);
>   		of_node_put(ssi_np);
>   		return ret;
>   	}
>
> -	dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL);
> +	dma = kzalloc(sizeof(*dma), GFP_KERNEL);

Something is missing here.  Since we're no longer allocating space in 
the 'dma' object for the name, then you should probably delete the code 
that copies the string to the 'dma' object.
Lars-Peter Clausen Jan. 7, 2015, 5:26 p.m. UTC | #2
On 01/07/2015 06:21 PM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> The only usage of 'full_name' is inside an error message, which provides a
> rather verbose node path.
>
> A more concise error message can be obtained by using 'pdev->name' instead.

It's probably best to drop it altogether in that case. dev_err() already 
prints the name of the device.

  It
> also makes the kzalloc calculation simpler, as we don't need to take the length
> of full_name into account.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Buit tested only.
>
>   sound/soc/fsl/fsl_dma.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
> index 026da0a..770de20 100644
> --- a/sound/soc/fsl/fsl_dma.c
> +++ b/sound/soc/fsl/fsl_dma.c
> @@ -897,12 +897,12 @@ static int fsl_soc_dma_probe(struct platform_device *pdev)
>   	ret = of_address_to_resource(ssi_np, 0, &res);
>   	if (ret) {
>   		dev_err(&pdev->dev, "could not determine resources for %s\n",
> -			ssi_np->full_name);
> +			pdev->name);
>   		of_node_put(ssi_np);
>   		return ret;
>   	}
>
> -	dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL);
> +	dma = kzalloc(sizeof(*dma), GFP_KERNEL);

This should probably be part of patch 1.

>   	if (!dma) {
>   		dev_err(&pdev->dev, "could not allocate dma object\n");
>   		of_node_put(ssi_np);
>
Timur Tabi Jan. 7, 2015, 5:27 p.m. UTC | #3
Lars-Peter Clausen wrote:
>>
>> -    dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL);
>> +    dma = kzalloc(sizeof(*dma), GFP_KERNEL);
>
> This should probably be part of patch 1.

I think you're right.
diff mbox

Patch

diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index 026da0a..770de20 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -897,12 +897,12 @@  static int fsl_soc_dma_probe(struct platform_device *pdev)
 	ret = of_address_to_resource(ssi_np, 0, &res);
 	if (ret) {
 		dev_err(&pdev->dev, "could not determine resources for %s\n",
-			ssi_np->full_name);
+			pdev->name);
 		of_node_put(ssi_np);
 		return ret;
 	}
 
-	dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL);
+	dma = kzalloc(sizeof(*dma), GFP_KERNEL);
 	if (!dma) {
 		dev_err(&pdev->dev, "could not allocate dma object\n");
 		of_node_put(ssi_np);