Unverified Commit 943116ba authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown
Browse files

ASoC: add common snd_soc_ret() and use it



Each soc-xxx.c is using own snd_xxx_ret(), but we want to share it.
Let's add common snd_soc_ret() for it.

Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/87frkt2qlx.wl-kuninori.morimoto.gx@renesas.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent dabbd325
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -539,6 +539,7 @@ int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
int snd_soc_params_to_bclk(const struct snd_pcm_hw_params *parms);
int snd_soc_tdm_params_to_bclk(const struct snd_pcm_hw_params *params,
			       int tdm_width, int tdm_slots, int slot_multiple);
int snd_soc_ret(const struct device *dev, int ret, const char *fmt, ...);

/* set runtime hw params */
static inline int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
+2 −12
Original line number Diff line number Diff line
@@ -15,18 +15,8 @@
static inline int _soc_card_ret(struct snd_soc_card *card,
				const char *func, int ret)
{
	switch (ret) {
	case -EPROBE_DEFER:
	case -ENOTSUPP:
	case 0:
		break;
	default:
		dev_err(card->dev,
			"ASoC: error at %s on %s: %d\n",
			func, card->name, ret);
	}

	return ret;
	return snd_soc_ret(card->dev, ret,
			   "at %s() on %s\n", func, card->name);
}

struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
+13 −25
Original line number Diff line number Diff line
@@ -13,32 +13,20 @@
#include <sound/soc.h>
#include <linux/bitops.h>

#define soc_component_ret(dai, ret) _soc_component_ret(dai, __func__, ret, -1)
#define soc_component_ret_reg_rw(dai, ret, reg) _soc_component_ret(dai, __func__, ret, reg)
static inline int _soc_component_ret(struct snd_soc_component *component,
				     const char *func, int ret, int reg)
#define soc_component_ret(dai, ret) _soc_component_ret(dai, __func__, ret)
static inline int _soc_component_ret(struct snd_soc_component *component, const char *func, int ret)
{
	/* Positive/Zero values are not errors */
	if (ret >= 0)
		return ret;

	/* Negative values might be errors */
	switch (ret) {
	case -EPROBE_DEFER:
	case -ENOTSUPP:
		break;
	default:
		if (reg == -1)
			dev_err(component->dev,
				"ASoC: error at %s on %s: %d\n",
				func, component->name, ret);
		else
			dev_err(component->dev,
				"ASoC: error at %s on %s for register: [0x%08x] %d\n",
				func, component->name, reg, ret);
	return snd_soc_ret(component->dev, ret,
			   "at %s() on %s\n", func, component->name);
}

	return ret;
#define soc_component_ret_reg_rw(dai, ret, reg) _soc_component_ret_reg_rw(dai, __func__, ret, reg)
static inline int _soc_component_ret_reg_rw(struct snd_soc_component *component,
					    const char *func, int ret, int reg)
{
	return snd_soc_ret(component->dev, ret,
			   "at %s() on %s for register: [0x%08x]\n",
			   func, component->name, reg);
}

static inline int soc_component_field_shift(struct snd_soc_component *component,
+2 −16
Original line number Diff line number Diff line
@@ -14,22 +14,8 @@
static inline int _soc_dai_ret(const struct snd_soc_dai *dai,
			       const char *func, int ret)
{
	/* Positive, Zero values are not errors */
	if (ret >= 0)
		return ret;

	/* Negative values might be errors */
	switch (ret) {
	case -EPROBE_DEFER:
	case -ENOTSUPP:
		break;
	default:
		dev_err(dai->dev,
			"ASoC: error at %s on %s: %d\n",
			func, dai->name, ret);
	}

	return ret;
	return snd_soc_ret(dai->dev, ret,
			   "at %s() on %s\n", func, dai->name);
}

/*
+2 −16
Original line number Diff line number Diff line
@@ -12,22 +12,8 @@
static inline int _soc_link_ret(struct snd_soc_pcm_runtime *rtd,
				const char *func, int ret)
{
	/* Positive, Zero values are not errors */
	if (ret >= 0)
		return ret;

	/* Negative values might be errors */
	switch (ret) {
	case -EPROBE_DEFER:
	case -ENOTSUPP:
		break;
	default:
		dev_err(rtd->dev,
			"ASoC: error at %s on %s: %d\n",
			func, rtd->dai_link->name, ret);
	}

	return ret;
	return snd_soc_ret(rtd->dev, ret,
			   "at %s() on %s\n", func, rtd->dai_link->name);
}

/*
Loading