[alsa-devel] [PATCH 6/6] ASoC: omap-dmic: Cleanup the probe function

Lars-Peter Clausen lars at metafoo.de
Thu Jul 11 13:10:02 CEST 2013


On 07/11/2013 12:18 PM, Peter Ujfalusi wrote:
> Move the clk_get later in the function. In this way we do not need to use
> goto in other error cases.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi at ti.com>

How about using devm_clk_get?

> ---
>  sound/soc/omap/omap-dmic.c | 24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
> index f66b033..1b6c507 100644
> --- a/sound/soc/omap/omap-dmic.c
> +++ b/sound/soc/omap/omap-dmic.c
> @@ -463,17 +463,10 @@ static int asoc_dmic_probe(struct platform_device *pdev)
>  
>  	mutex_init(&dmic->mutex);
>  
> -	dmic->fclk = clk_get(dmic->dev, "fck");
> -	if (IS_ERR(dmic->fclk)) {
> -		dev_err(dmic->dev, "cant get fck\n");
> -		return -ENODEV;
> -	}
> -
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma");
>  	if (!res) {
>  		dev_err(dmic->dev, "invalid dma memory resource\n");
> -		ret = -ENODEV;
> -		goto err_put_clk;
> +		return -ENODEV;
>  	}
>  	dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG;
>  
> @@ -482,23 +475,24 @@ static int asoc_dmic_probe(struct platform_device *pdev)
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
>  	if (!res) {
>  		dev_err(dmic->dev, "invalid memory resource\n");
> -		ret = -ENODEV;
> -		goto err_put_clk;
> +		return -ENODEV;
>  	}
>  
>  	dmic->io_base = devm_ioremap_resource(&pdev->dev, res);
>  	if (IS_ERR(dmic->io_base))
>  		return PTR_ERR(dmic->io_base);
>  
> +	dmic->fclk = clk_get(dmic->dev, "fck");
> +	if (IS_ERR(dmic->fclk)) {
> +		dev_err(dmic->dev, "cant get fck\n");
> +		return -ENODEV;
> +	}
> +
>  	ret = snd_soc_register_component(&pdev->dev, &omap_dmic_component,
>  					 &omap_dmic_dai, 1);
>  	if (ret)
> -		goto err_put_clk;
> -
> -	return 0;
> +		clk_put(dmic->fclk);
>  
> -err_put_clk:
> -	clk_put(dmic->fclk);
>  	return ret;
>  }
>  



More information about the Alsa-devel mailing list