提交 ddb146da 编写于 作者: T Takashi Iwai 提交者: Mark Brown

ASoC: blackfin: Use WARN_ON() instead of BUG_ON()

Use WARN_ON() and handle the error cases accordingly.
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 5e01dc7b
...@@ -179,8 +179,9 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) ...@@ -179,8 +179,9 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport)
struct dmasg *desc, temp_desc; struct dmasg *desc, temp_desc;
unsigned long flags; unsigned long flags;
BUG_ON(sport->dummy_rx_desc == NULL); if (WARN_ON(!sport->dummy_rx_desc) ||
BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); WARN_ON(sport->curr_rx_desc == sport->dummy_rx_desc))
return -EINVAL;
/* Maybe the dummy buffer descriptor ring is damaged */ /* Maybe the dummy buffer descriptor ring is damaged */
sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1; sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1;
...@@ -250,8 +251,9 @@ int sport_rx_start(struct sport_device *sport) ...@@ -250,8 +251,9 @@ int sport_rx_start(struct sport_device *sport)
return -EBUSY; return -EBUSY;
if (sport->tx_run) { if (sport->tx_run) {
/* tx is running, rx is not running */ /* tx is running, rx is not running */
BUG_ON(sport->dma_rx_desc == NULL); if (WARN_ON(!sport->dma_rx_desc) ||
BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); WARN_ON(sport->curr_rx_desc != sport->dummy_rx_desc))
return -EINVAL;
local_irq_save(flags); local_irq_save(flags);
while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) -
sizeof(struct dmasg)) != sport->dummy_rx_desc) sizeof(struct dmasg)) != sport->dummy_rx_desc)
...@@ -298,8 +300,9 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport) ...@@ -298,8 +300,9 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport)
struct dmasg *desc, temp_desc; struct dmasg *desc, temp_desc;
unsigned long flags; unsigned long flags;
BUG_ON(sport->dummy_tx_desc == NULL); if (WARN_ON(!sport->dummy_tx_desc) ||
BUG_ON(sport->curr_tx_desc == 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; sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1;
...@@ -331,8 +334,9 @@ int sport_tx_start(struct sport_device *sport) ...@@ -331,8 +334,9 @@ int sport_tx_start(struct sport_device *sport)
if (sport->tx_run) if (sport->tx_run)
return -EBUSY; return -EBUSY;
if (sport->rx_run) { if (sport->rx_run) {
BUG_ON(sport->dma_tx_desc == NULL); if (WARN_ON(!sport->dma_tx_desc) ||
BUG_ON(sport->curr_tx_desc != sport->dummy_tx_desc); WARN_ON(sport->curr_tx_desc != sport->dummy_tx_desc))
return -EINVAL;
/* Hook the normal buffer descriptor */ /* Hook the normal buffer descriptor */
local_irq_save(flags); local_irq_save(flags);
while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) -
...@@ -767,7 +771,8 @@ static irqreturn_t err_handler(int irq, void *dev_id) ...@@ -767,7 +771,8 @@ static irqreturn_t err_handler(int irq, void *dev_id)
int sport_set_rx_callback(struct sport_device *sport, int sport_set_rx_callback(struct sport_device *sport,
void (*rx_callback)(void *), void *rx_data) 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_callback = rx_callback;
sport->rx_data = rx_data; sport->rx_data = rx_data;
...@@ -778,7 +783,8 @@ EXPORT_SYMBOL(sport_set_rx_callback); ...@@ -778,7 +783,8 @@ EXPORT_SYMBOL(sport_set_rx_callback);
int sport_set_tx_callback(struct sport_device *sport, int sport_set_tx_callback(struct sport_device *sport,
void (*tx_callback)(void *), void *tx_data) 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_callback = tx_callback;
sport->tx_data = tx_data; sport->tx_data = tx_data;
...@@ -789,7 +795,8 @@ EXPORT_SYMBOL(sport_set_tx_callback); ...@@ -789,7 +795,8 @@ EXPORT_SYMBOL(sport_set_tx_callback);
int sport_set_err_callback(struct sport_device *sport, int sport_set_err_callback(struct sport_device *sport,
void (*err_callback)(void *), void *err_data) 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_callback = err_callback;
sport->err_data = err_data; sport->err_data = err_data;
...@@ -856,7 +863,8 @@ struct sport_device *sport_init(struct platform_device *pdev, ...@@ -856,7 +863,8 @@ struct sport_device *sport_init(struct platform_device *pdev,
param.wdsize = wdsize; param.wdsize = wdsize;
param.dummy_count = dummy_count; 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); ret = sport_config_pdev(pdev, &param);
if (ret) if (ret)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册