Commit f0fd9446 authored by Russell King - ARM Linux's avatar Russell King - ARM Linux Committed by Dan Williams

ARM: PL08x: allow dma_set_runtime_config() to return errors

There are cases in dma_set_runtime_config() where we fail to perform
the requested action - and we just issue a KERN_ERR message in that
case.  We have the facility to return an error to the caller, so that
is what we should do.

When we encounter an error due to invalid parameters, we should not
modify driver state.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Acked-by: default avatarLinus Walleij <linus.walleij@stericsson.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent c370e594
...@@ -1117,13 +1117,14 @@ static const struct burst_table burst_sizes[] = { ...@@ -1117,13 +1117,14 @@ static const struct burst_table burst_sizes[] = {
}, },
}; };
static void dma_set_runtime_config(struct dma_chan *chan, static int dma_set_runtime_config(struct dma_chan *chan,
struct dma_slave_config *config) struct dma_slave_config *config)
{ {
struct pl08x_dma_chan *plchan = to_pl08x_chan(chan); struct pl08x_dma_chan *plchan = to_pl08x_chan(chan);
struct pl08x_driver_data *pl08x = plchan->host; struct pl08x_driver_data *pl08x = plchan->host;
struct pl08x_channel_data *cd = plchan->cd; struct pl08x_channel_data *cd = plchan->cd;
enum dma_slave_buswidth addr_width; enum dma_slave_buswidth addr_width;
dma_addr_t addr;
u32 maxburst; u32 maxburst;
u32 cctl = 0; u32 cctl = 0;
int i; int i;
...@@ -1131,17 +1132,17 @@ static void dma_set_runtime_config(struct dma_chan *chan, ...@@ -1131,17 +1132,17 @@ static void dma_set_runtime_config(struct dma_chan *chan,
/* Transfer direction */ /* Transfer direction */
plchan->runtime_direction = config->direction; plchan->runtime_direction = config->direction;
if (config->direction == DMA_TO_DEVICE) { if (config->direction == DMA_TO_DEVICE) {
plchan->runtime_addr = config->dst_addr; addr = config->dst_addr;
addr_width = config->dst_addr_width; addr_width = config->dst_addr_width;
maxburst = config->dst_maxburst; maxburst = config->dst_maxburst;
} else if (config->direction == DMA_FROM_DEVICE) { } else if (config->direction == DMA_FROM_DEVICE) {
plchan->runtime_addr = config->src_addr; addr = config->src_addr;
addr_width = config->src_addr_width; addr_width = config->src_addr_width;
maxburst = config->src_maxburst; maxburst = config->src_maxburst;
} else { } else {
dev_err(&pl08x->adev->dev, dev_err(&pl08x->adev->dev,
"bad runtime_config: alien transfer direction\n"); "bad runtime_config: alien transfer direction\n");
return; return -EINVAL;
} }
switch (addr_width) { switch (addr_width) {
...@@ -1160,7 +1161,7 @@ static void dma_set_runtime_config(struct dma_chan *chan, ...@@ -1160,7 +1161,7 @@ static void dma_set_runtime_config(struct dma_chan *chan,
default: default:
dev_err(&pl08x->adev->dev, dev_err(&pl08x->adev->dev,
"bad runtime_config: alien address width\n"); "bad runtime_config: alien address width\n");
return; return -EINVAL;
} }
/* /*
...@@ -1179,6 +1180,8 @@ static void dma_set_runtime_config(struct dma_chan *chan, ...@@ -1179,6 +1180,8 @@ static void dma_set_runtime_config(struct dma_chan *chan,
cctl |= burst_sizes[i].reg; cctl |= burst_sizes[i].reg;
} }
plchan->runtime_addr = addr;
/* Modify the default channel data to fit PrimeCell request */ /* Modify the default channel data to fit PrimeCell request */
cd->cctl = cctl; cd->cctl = cctl;
...@@ -1190,6 +1193,8 @@ static void dma_set_runtime_config(struct dma_chan *chan, ...@@ -1190,6 +1193,8 @@ static void dma_set_runtime_config(struct dma_chan *chan,
addr_width, addr_width,
maxburst, maxburst,
cctl); cctl);
return 0;
} }
/* /*
...@@ -1452,10 +1457,8 @@ static int pl08x_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, ...@@ -1452,10 +1457,8 @@ static int pl08x_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
/* Controls applicable to inactive channels */ /* Controls applicable to inactive channels */
if (cmd == DMA_SLAVE_CONFIG) { if (cmd == DMA_SLAVE_CONFIG) {
dma_set_runtime_config(chan, return dma_set_runtime_config(chan,
(struct dma_slave_config *) (struct dma_slave_config *)arg);
arg);
return 0;
} }
/* /*
......
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