ASoC: blackfin: Use WARN_ON() instead of BUG_ON()
authorTakashi Iwai <tiwai@suse.de>
Tue, 5 Nov 2013 17:39:48 +0000 (18:39 +0100)
committerMark Brown <broonie@linaro.org>
Wed, 6 Nov 2013 10:26:09 +0000 (10:26 +0000)
Use WARN_ON() and handle the error cases accordingly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/blackfin/bf5xx-sport.c

index 695351241db89cb1ab0f4ec0c1d114edbdb501e9..9dfa1241ea6661d75bc4eb77cb3b6b588a8abd1c 100644 (file)
@@ -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;
@@ -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)
@@ -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;
 
@@ -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) -
@@ -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;
 
@@ -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;
 
@@ -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;
 
@@ -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)