• Kuninori Morimoto's avatar
    ASoC: soc-dapm.c: tidyup error handling on snd_soc_dapm_add_route() · f19a2ec7
    Kuninori Morimoto authored
    Current error handling on snd_soc_dapm_add_route() has some wastes.
    It indicates *own* error message *only* for sink or source,
    and return error directly at (A). OTOH, it has similar error message at
    (B) which indicates *both* sink/source.
    
    And more, (A) is using dev_err(), (B) is using dev_warn().
    (B) is caring prefix, but (A) is not.
    
    (X)	int snd_soc_dapm_add_route(...)
    	{
    		...
    		if (wsource == NULL) {
    (A)			dev_err(...);
    			return -ENODEV;
    		}
    		if (wsink == NULL) {
    (A)			dev_err(...);
    			return -ENODEV;
    		}
    
    		...
    
    		ret = snd_soc_dapm_add_path(...);
    		if (ret)
    (B)			goto err;
    
    		return 0;
    	err:
    (B)		dev_warn(...);
    		return ret;
    	}
    
    Above snd_soc_dapm_add_route() (= X) is called from
    snd_soc_dapm_add_routes() (= Y).
    (X) will indicate error message by itself, but (Y) will indicate
    own error message at (C). (C) is duplicated.
    
    (Y)	int snd_soc_dapm_add_routes(...)
    	{
    		...
    		for (...) {
    (X)			int r = snd_soc_dapm_add_route(...);
    			if (r < 0) {
    (C)				dev_err(...);
    				ret = r;
    			}
    			...
    		}
    		...
    	}
    
    This patch (1) merges these error message (= A,B) into one,
    (2) use dev_err(), (3) remove duplicate error message (= C) from
    snd_soc_dapm_add_routes().
    
    By this patch, it will indicate error message like this.
    
    	- error message with prefix
    	- not found widget will have "(*)" mark
    	- it indicates [control] if exists.
    
    ex)
    [if no sink with control]
    
    	ASoC: Failed to add route SOURCE -> [CTRL] -> SINK(*)
    
    [if no source without control]
    
    	ASoC: Failed to add route SOURCE(*) -> SINK
    Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
    Reviewed-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
    Link: https://lore.kernel.org/r/878rlctzt5.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    f19a2ec7
soc-dapm.c 122 KB