Commit 839896ef authored by Alex Smith's avatar Alex Smith Committed by Vinod Koul

dmaengine: jz4780: Fix error handling/signedness issues

There are a some signedness bugs such as testing for < 0 on unsigned
return values. Additionally there are some cases where functions which
should return NULL on error actually return a PTR_ERR value which can
result in oopses on error. Fix these issues.
Signed-off-by: default avatarAlex Smith <alex.smith@imgtec.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
Cc: dmaengine@vger.kernel.org
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent dc578f31
...@@ -250,7 +250,7 @@ static uint32_t jz4780_dma_transfer_size(unsigned long val, uint32_t *shift) ...@@ -250,7 +250,7 @@ static uint32_t jz4780_dma_transfer_size(unsigned long val, uint32_t *shift)
} }
} }
static uint32_t jz4780_dma_setup_hwdesc(struct jz4780_dma_chan *jzchan, static int jz4780_dma_setup_hwdesc(struct jz4780_dma_chan *jzchan,
struct jz4780_dma_hwdesc *desc, dma_addr_t addr, size_t len, struct jz4780_dma_hwdesc *desc, dma_addr_t addr, size_t len,
enum dma_transfer_direction direction) enum dma_transfer_direction direction)
{ {
...@@ -301,6 +301,7 @@ static uint32_t jz4780_dma_setup_hwdesc(struct jz4780_dma_chan *jzchan, ...@@ -301,6 +301,7 @@ static uint32_t jz4780_dma_setup_hwdesc(struct jz4780_dma_chan *jzchan,
desc->dcm |= width << JZ_DMA_DCM_DP_SHIFT; desc->dcm |= width << JZ_DMA_DCM_DP_SHIFT;
desc->dtc = len >> jzchan->transfer_shift; desc->dtc = len >> jzchan->transfer_shift;
return 0;
} }
static struct dma_async_tx_descriptor *jz4780_dma_prep_slave_sg( static struct dma_async_tx_descriptor *jz4780_dma_prep_slave_sg(
...@@ -323,8 +324,7 @@ static struct dma_async_tx_descriptor *jz4780_dma_prep_slave_sg( ...@@ -323,8 +324,7 @@ static struct dma_async_tx_descriptor *jz4780_dma_prep_slave_sg(
sg_dma_len(&sgl[i]), sg_dma_len(&sgl[i]),
direction); direction);
if (err < 0) if (err < 0)
return ERR_PTR(err); return NULL;
desc->desc[i].dcm |= JZ_DMA_DCM_TIE; desc->desc[i].dcm |= JZ_DMA_DCM_TIE;
...@@ -368,7 +368,7 @@ static struct dma_async_tx_descriptor *jz4780_dma_prep_dma_cyclic( ...@@ -368,7 +368,7 @@ static struct dma_async_tx_descriptor *jz4780_dma_prep_dma_cyclic(
err = jz4780_dma_setup_hwdesc(jzchan, &desc->desc[i], buf_addr, err = jz4780_dma_setup_hwdesc(jzchan, &desc->desc[i], buf_addr,
period_len, direction); period_len, direction);
if (err < 0) if (err < 0)
return ERR_PTR(err); return NULL;
buf_addr += period_len; buf_addr += period_len;
...@@ -417,7 +417,7 @@ struct dma_async_tx_descriptor *jz4780_dma_prep_dma_memcpy( ...@@ -417,7 +417,7 @@ struct dma_async_tx_descriptor *jz4780_dma_prep_dma_memcpy(
tsz << JZ_DMA_DCM_TSZ_SHIFT | tsz << JZ_DMA_DCM_TSZ_SHIFT |
JZ_DMA_WIDTH_32_BIT << JZ_DMA_DCM_SP_SHIFT | JZ_DMA_WIDTH_32_BIT << JZ_DMA_DCM_SP_SHIFT |
JZ_DMA_WIDTH_32_BIT << JZ_DMA_DCM_DP_SHIFT; JZ_DMA_WIDTH_32_BIT << JZ_DMA_DCM_DP_SHIFT;
desc->desc[0].dtc = len >> ord; desc->desc[0].dtc = len >> jzchan->transfer_shift;
return vchan_tx_prep(&jzchan->vchan, &desc->vdesc, flags); return vchan_tx_prep(&jzchan->vchan, &desc->vdesc, flags);
} }
...@@ -756,17 +756,19 @@ static int jz4780_dma_probe(struct platform_device *pdev) ...@@ -756,17 +756,19 @@ static int jz4780_dma_probe(struct platform_device *pdev)
if (IS_ERR(jzdma->base)) if (IS_ERR(jzdma->base))
return PTR_ERR(jzdma->base); return PTR_ERR(jzdma->base);
jzdma->irq = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (jzdma->irq < 0) { if (ret < 0) {
dev_err(dev, "failed to get IRQ: %d\n", ret); dev_err(dev, "failed to get IRQ: %d\n", ret);
return jzdma->irq; return ret;
} }
jzdma->irq = ret;
ret = devm_request_irq(dev, jzdma->irq, jz4780_dma_irq_handler, 0, ret = devm_request_irq(dev, jzdma->irq, jz4780_dma_irq_handler, 0,
dev_name(dev), jzdma); dev_name(dev), jzdma);
if (ret) { if (ret) {
dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq); dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq);
return -EINVAL; return ret;
} }
jzdma->clk = devm_clk_get(dev, NULL); jzdma->clk = devm_clk_get(dev, NULL);
...@@ -803,7 +805,6 @@ static int jz4780_dma_probe(struct platform_device *pdev) ...@@ -803,7 +805,6 @@ static int jz4780_dma_probe(struct platform_device *pdev)
dd->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); dd->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
dd->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; dd->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
/* /*
* Enable DMA controller, mark all channels as not programmable. * Enable DMA controller, mark all channels as not programmable.
* Also set the FMSC bit - it increases MSC performance, so it makes * Also set the FMSC bit - it increases MSC performance, so it makes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment