[alsa-devel] [PATCH 2/3] ASoC: da7218: Use common error handling code in da7218_of_to_pdata()

Adam Thomson Adam.Thomson.Opensource at diasemi.com
Fri Nov 24 13:03:32 CET 2017


On 23 November 2017 20:06, SF Markus Elfring wrote:

> From: Markus Elfring <elfring at users.sourceforge.net>
> Date: Thu, 23 Nov 2017 20:48:05 +0100
> 
> Add a jump target so that a bit of exception handling can be better reused
> in an if branch of this function.
> 
> Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>

Hmm. Doesn't really gain an awful lot this. Would understand if there were
multiple return paths, but in that case I'd have implemented something like
this anyway. Also your patch description isn't really correct. You're re-using
code from the sunny day scenario to handle an exception.

> ---
>  sound/soc/codecs/da7218.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/soc/codecs/da7218.c b/sound/soc/codecs/da7218.c
> index 25ab7443d803..93a0cb741751 100644
> --- a/sound/soc/codecs/da7218.c
> +++ b/sound/soc/codecs/da7218.c
> @@ -2524,10 +2524,9 @@ static struct da7218_pdata *da7218_of_to_pdata(struct
> snd_soc_codec *codec)
> 
>  		hpldet_pdata = devm_kzalloc(codec->dev, sizeof(*hpldet_pdata),
>  					    GFP_KERNEL);
> -		if (!hpldet_pdata) {
> -			of_node_put(hpldet_np);
> -			return pdata;
> -		}
> +		if (!hpldet_pdata)
> +			goto put_node;
> +
>  		pdata->hpldet_pdata = hpldet_pdata;
> 
>  		if (of_property_read_u32(hpldet_np, "dlg,jack-rate-us",
> @@ -2561,6 +2560,7 @@ static struct da7218_pdata *da7218_of_to_pdata(struct
> snd_soc_codec *codec)
>  		if (of_property_read_bool(hpldet_np, "dlg,discharge"))
>  			hpldet_pdata->discharge = true;
> 
> +put_node:
>  		of_node_put(hpldet_np);
>  	}
> 
> --
> 2.15.0



More information about the Alsa-devel mailing list