Skip to content

Commit

Permalink
Merge remote-tracking branch 'asoc/topic/warn' into asoc-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Brown committed Nov 8, 2013
2 parents 022aa51 + bf4edea commit 108145a
Show file tree
Hide file tree
Showing 28 changed files with 138 additions and 92 deletions.
32 changes: 20 additions & 12 deletions sound/soc/blackfin/bf5xx-sport.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport)
struct dmasg *desc, temp_desc;
unsigned long flags;

BUG_ON(sport->dummy_rx_desc == NULL);
BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc);
if (WARN_ON(!sport->dummy_rx_desc) ||
WARN_ON(sport->curr_rx_desc == sport->dummy_rx_desc))
return -EINVAL;

/* Maybe the dummy buffer descriptor ring is damaged */
sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1;
Expand Down Expand Up @@ -250,8 +251,9 @@ int sport_rx_start(struct sport_device *sport)
return -EBUSY;
if (sport->tx_run) {
/* tx is running, rx is not running */
BUG_ON(sport->dma_rx_desc == NULL);
BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc);
if (WARN_ON(!sport->dma_rx_desc) ||
WARN_ON(sport->curr_rx_desc != sport->dummy_rx_desc))
return -EINVAL;
local_irq_save(flags);
while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) -
sizeof(struct dmasg)) != sport->dummy_rx_desc)
Expand Down Expand Up @@ -298,8 +300,9 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport)
struct dmasg *desc, temp_desc;
unsigned long flags;

BUG_ON(sport->dummy_tx_desc == NULL);
BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc);
if (WARN_ON(!sport->dummy_tx_desc) ||
WARN_ON(sport->curr_tx_desc == sport->dummy_tx_desc))
return -EINVAL;

sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1;

Expand Down Expand Up @@ -331,8 +334,9 @@ int sport_tx_start(struct sport_device *sport)
if (sport->tx_run)
return -EBUSY;
if (sport->rx_run) {
BUG_ON(sport->dma_tx_desc == NULL);
BUG_ON(sport->curr_tx_desc != sport->dummy_tx_desc);
if (WARN_ON(!sport->dma_tx_desc) ||
WARN_ON(sport->curr_tx_desc != sport->dummy_tx_desc))
return -EINVAL;
/* Hook the normal buffer descriptor */
local_irq_save(flags);
while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) -
Expand Down Expand Up @@ -767,7 +771,8 @@ static irqreturn_t err_handler(int irq, void *dev_id)
int sport_set_rx_callback(struct sport_device *sport,
void (*rx_callback)(void *), void *rx_data)
{
BUG_ON(rx_callback == NULL);
if (WARN_ON(!rx_callback))
return -EINVAL;
sport->rx_callback = rx_callback;
sport->rx_data = rx_data;

Expand All @@ -778,7 +783,8 @@ EXPORT_SYMBOL(sport_set_rx_callback);
int sport_set_tx_callback(struct sport_device *sport,
void (*tx_callback)(void *), void *tx_data)
{
BUG_ON(tx_callback == NULL);
if (WARN_ON(!tx_callback))
return -EINVAL;
sport->tx_callback = tx_callback;
sport->tx_data = tx_data;

Expand All @@ -789,7 +795,8 @@ EXPORT_SYMBOL(sport_set_tx_callback);
int sport_set_err_callback(struct sport_device *sport,
void (*err_callback)(void *), void *err_data)
{
BUG_ON(err_callback == NULL);
if (WARN_ON(!err_callback))
return -EINVAL;
sport->err_callback = err_callback;
sport->err_data = err_data;

Expand Down Expand Up @@ -856,7 +863,8 @@ struct sport_device *sport_init(struct platform_device *pdev,

param.wdsize = wdsize;
param.dummy_count = dummy_count;
BUG_ON(param.wdsize == 0 || param.dummy_count == 0);
if (WARN_ON(param.wdsize == 0 || param.dummy_count == 0))
return NULL;

ret = sport_config_pdev(pdev, &param);
if (ret)
Expand Down
8 changes: 5 additions & 3 deletions sound/soc/codecs/max98088.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,9 @@ static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai,
unsigned int eq_reg;
unsigned int i;

BUG_ON(band > 4);
BUG_ON(dai > 1);
if (WARN_ON(band > 4) ||
WARN_ON(dai > 1))
return;

/* Load the base register address */
eq_reg = dai ? M98088_REG_84_DAI2_EQ_BASE : M98088_REG_52_DAI1_EQ_BASE;
Expand Down Expand Up @@ -909,7 +910,8 @@ static int max98088_line_pga(struct snd_soc_dapm_widget *w,
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
u8 *state;

BUG_ON(!((channel == 1) || (channel == 2)));
if (WARN_ON(!(channel == 1 || channel == 2)))
return -EINVAL;

switch (line) {
case LINE_INA:
Expand Down
16 changes: 10 additions & 6 deletions sound/soc/codecs/max98095.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ static void m98095_eq_band(struct snd_soc_codec *codec, unsigned int dai,
unsigned int eq_reg;
unsigned int i;

BUG_ON(band > 4);
BUG_ON(dai > 1);
if (WARN_ON(band > 4) ||
WARN_ON(dai > 1))
return;

/* Load the base register address */
eq_reg = dai ? M98095_142_DAI2_EQ_BASE : M98095_110_DAI1_EQ_BASE;
Expand All @@ -541,8 +542,9 @@ static void m98095_biquad_band(struct snd_soc_codec *codec, unsigned int dai,
unsigned int bq_reg;
unsigned int i;

BUG_ON(band > 1);
BUG_ON(dai > 1);
if (WARN_ON(band > 1) ||
WARN_ON(dai > 1))
return;

/* Load the base register address */
bq_reg = dai ? M98095_17E_DAI2_BQ_BASE : M98095_174_DAI1_BQ_BASE;
Expand Down Expand Up @@ -890,7 +892,8 @@ static int max98095_line_pga(struct snd_soc_dapm_widget *w,
struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
u8 *state;

BUG_ON(!((channel == 1) || (channel == 2)));
if (WARN_ON(!(channel == 1 || channel == 2)))
return -EINVAL;

state = &max98095->lin_state;

Expand Down Expand Up @@ -1740,7 +1743,8 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
int fs, best, best_val, i;
int regmask, regsave;

BUG_ON(channel > 1);
if (WARN_ON(channel > 1))
return -EINVAL;

if (!pdata || !max98095->eq_textcnt)
return 0;
Expand Down
21 changes: 14 additions & 7 deletions sound/soc/codecs/tpa6130a2.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ static int tpa6130a2_i2c_read(int reg)
struct tpa6130a2_data *data;
int val;

BUG_ON(tpa6130a2_client == NULL);
if (WARN_ON(!tpa6130a2_client))
return -EINVAL;
data = i2c_get_clientdata(tpa6130a2_client);

/* If powered off, return the cached value */
Expand All @@ -78,7 +79,8 @@ static int tpa6130a2_i2c_write(int reg, u8 value)
struct tpa6130a2_data *data;
int val = 0;

BUG_ON(tpa6130a2_client == NULL);
if (WARN_ON(!tpa6130a2_client))
return -EINVAL;
data = i2c_get_clientdata(tpa6130a2_client);

if (data->power_state) {
Expand All @@ -99,7 +101,8 @@ static u8 tpa6130a2_read(int reg)
{
struct tpa6130a2_data *data;

BUG_ON(tpa6130a2_client == NULL);
if (WARN_ON(!tpa6130a2_client))
return 0;
data = i2c_get_clientdata(tpa6130a2_client);

return data->regs[reg];
Expand All @@ -110,7 +113,8 @@ static int tpa6130a2_initialize(void)
struct tpa6130a2_data *data;
int i, ret = 0;

BUG_ON(tpa6130a2_client == NULL);
if (WARN_ON(!tpa6130a2_client))
return -EINVAL;
data = i2c_get_clientdata(tpa6130a2_client);

for (i = 1; i < TPA6130A2_REG_VERSION; i++) {
Expand All @@ -128,7 +132,8 @@ static int tpa6130a2_power(u8 power)
u8 val;
int ret = 0;

BUG_ON(tpa6130a2_client == NULL);
if (WARN_ON(!tpa6130a2_client))
return -EINVAL;
data = i2c_get_clientdata(tpa6130a2_client);

mutex_lock(&data->mutex);
Expand Down Expand Up @@ -194,7 +199,8 @@ static int tpa6130a2_get_volsw(struct snd_kcontrol *kcontrol,
unsigned int mask = (1 << fls(max)) - 1;
unsigned int invert = mc->invert;

BUG_ON(tpa6130a2_client == NULL);
if (WARN_ON(!tpa6130a2_client))
return -EINVAL;
data = i2c_get_clientdata(tpa6130a2_client);

mutex_lock(&data->mutex);
Expand Down Expand Up @@ -224,7 +230,8 @@ static int tpa6130a2_put_volsw(struct snd_kcontrol *kcontrol,
unsigned int val = (ucontrol->value.integer.value[0] & mask);
unsigned int val_reg;

BUG_ON(tpa6130a2_client == NULL);
if (WARN_ON(!tpa6130a2_client))
return -EINVAL;
data = i2c_get_clientdata(tpa6130a2_client);

if (invert)
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/wm0010.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
offset = 0;
dsp = inforec->dsp_target;
wm0010->boot_failed = false;
BUG_ON(!list_empty(&xfer_list));
if (WARN_ON(!list_empty(&xfer_list)))
return -EINVAL;
init_completion(&done);

/* First record should be INFO */
Expand Down
15 changes: 10 additions & 5 deletions sound/soc/codecs/wm2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue)
unsigned long rate;
int ret;

BUG_ON(wm2000->anc_mode != ANC_OFF);
if (WARN_ON(wm2000->anc_mode != ANC_OFF))
return -EINVAL;

dev_dbg(&i2c->dev, "Beginning power up\n");

Expand Down Expand Up @@ -277,7 +278,8 @@ static int wm2000_enter_bypass(struct i2c_client *i2c, int analogue)
{
struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev);

BUG_ON(wm2000->anc_mode != ANC_ACTIVE);
if (WARN_ON(wm2000->anc_mode != ANC_ACTIVE))
return -EINVAL;

if (analogue) {
wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL,
Expand Down Expand Up @@ -315,7 +317,8 @@ static int wm2000_exit_bypass(struct i2c_client *i2c, int analogue)
{
struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev);

BUG_ON(wm2000->anc_mode != ANC_BYPASS);
if (WARN_ON(wm2000->anc_mode != ANC_BYPASS))
return -EINVAL;

wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0);

Expand Down Expand Up @@ -349,7 +352,8 @@ static int wm2000_enter_standby(struct i2c_client *i2c, int analogue)
{
struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev);

BUG_ON(wm2000->anc_mode != ANC_ACTIVE);
if (WARN_ON(wm2000->anc_mode != ANC_ACTIVE))
return -EINVAL;

if (analogue) {
wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, 248 / 4);
Expand Down Expand Up @@ -392,7 +396,8 @@ static int wm2000_exit_standby(struct i2c_client *i2c, int analogue)
{
struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev);

BUG_ON(wm2000->anc_mode != ANC_STANDBY);
if (WARN_ON(wm2000->anc_mode != ANC_STANDBY))
return -EINVAL;

wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0);

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/wm5100.c
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,8 @@ static void wm5100_set_detect_mode(struct wm5100_priv *wm5100, int the_mode)
{
struct wm5100_jack_mode *mode = &wm5100->pdata.jack_modes[the_mode];

BUG_ON(the_mode >= ARRAY_SIZE(wm5100->pdata.jack_modes));
if (WARN_ON(the_mode >= ARRAY_SIZE(wm5100->pdata.jack_modes)))
return;

gpio_set_value_cansleep(wm5100->pdata.hp_pol, mode->hp_pol);
regmap_update_bits(wm5100->regmap, WM5100_ACCESSORY_DETECT_MODE_1,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/codecs/wm8350.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static int pga_event(struct snd_soc_dapm_widget *w,
break;

default:
BUG();
WARN(1, "Invalid shift %d\n", w->shift);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion sound/soc/codecs/wm8580.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id,
break;

default:
BUG_ON("Unknown DAI driver ID\n");
WARN(1, "Unknown DAI driver ID\n");
return -EINVAL;
}

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/wm8776.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ static int wm8776_set_sysclk(struct snd_soc_dai *dai,
struct snd_soc_codec *codec = dai->codec;
struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec);

BUG_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk));
if (WARN_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk)))
return -EINVAL;

wm8776->sysclk[dai->driver->id] = freq;

Expand Down
11 changes: 7 additions & 4 deletions sound/soc/codecs/wm8900.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ static int wm8900_hp_event(struct snd_soc_dapm_widget *w,
break;

default:
BUG();
WARN(1, "Invalid event %d\n", event);
break;
}

return 0;
Expand Down Expand Up @@ -691,7 +692,8 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
unsigned int K, Ndiv, Nmod, target;
unsigned int div;

BUG_ON(!Fout);
if (WARN_ON(!Fout))
return -EINVAL;

/* The FLL must run at 90-100MHz which is then scaled down to
* the output value by FLLCLK_DIV. */
Expand Down Expand Up @@ -742,8 +744,9 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
/* Move down to proper range now rounding is done */
fll_div->k = K / 10;

BUG_ON(target != Fout * (fll_div->fllclk_div << 2));
BUG_ON(!K && target != Fref * fll_div->fll_ratio * fll_div->n);
if (WARN_ON(target != Fout * (fll_div->fllclk_div << 2)) ||
WARN_ON(!K && target != Fref * fll_div->fll_ratio * fll_div->n))
return -EINVAL;

return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions sound/soc/codecs/wm8904.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ SOC_SINGLE_TLV("EQ5 Volume", WM8904_EQ6, 0, 24, 0, eq_tlv),
static int cp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
BUG_ON(event != SND_SOC_DAPM_POST_PMU);
if (WARN_ON(event != SND_SOC_DAPM_POST_PMU))
return -EINVAL;

/* Maximum startup time */
udelay(500);
Expand Down Expand Up @@ -740,7 +741,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
dcs_r = 3;
break;
default:
BUG();
WARN(1, "Invalid reg %d\n", reg);
return -EINVAL;
}

Expand Down
2 changes: 1 addition & 1 deletion sound/soc/codecs/wm8958-dsp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start)
aif = 1;
break;
default:
BUG();
WARN(1, "Invalid path %d\n", path);
return;
}

Expand Down
Loading

0 comments on commit 108145a

Please sign in to comment.