Skip to content

Commit 8d7de07

Browse files
Peter UjfalusiLee Jones
authored andcommitted
mfd: stm32-timers: Use dma_request_chan() instead dma_request_slave_channel()
dma_request_slave_channel() is a wrapper on top of dma_request_chan() eating up the error code. By using dma_request_chan() directly the driver can support deferred probing against DMA. Signed-off-by: Peter Ujfalusi <[email protected]> Acked-by: Fabrice Gasnier <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent c085c66 commit 8d7de07

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

drivers/mfd/stm32-timers.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ static void stm32_timers_get_arr_size(struct stm32_timers *ddata)
167167
regmap_write(ddata->regmap, TIM_ARR, 0x0);
168168
}
169169

170-
static void stm32_timers_dma_probe(struct device *dev,
170+
static int stm32_timers_dma_probe(struct device *dev,
171171
struct stm32_timers *ddata)
172172
{
173173
int i;
174+
int ret = 0;
174175
char name[4];
175176

176177
init_completion(&ddata->dma.completion);
@@ -179,14 +180,23 @@ static void stm32_timers_dma_probe(struct device *dev,
179180
/* Optional DMA support: get valid DMA channel(s) or NULL */
180181
for (i = STM32_TIMERS_DMA_CH1; i <= STM32_TIMERS_DMA_CH4; i++) {
181182
snprintf(name, ARRAY_SIZE(name), "ch%1d", i + 1);
182-
ddata->dma.chans[i] = dma_request_slave_channel(dev, name);
183+
ddata->dma.chans[i] = dma_request_chan(dev, name);
183184
}
184-
ddata->dma.chans[STM32_TIMERS_DMA_UP] =
185-
dma_request_slave_channel(dev, "up");
186-
ddata->dma.chans[STM32_TIMERS_DMA_TRIG] =
187-
dma_request_slave_channel(dev, "trig");
188-
ddata->dma.chans[STM32_TIMERS_DMA_COM] =
189-
dma_request_slave_channel(dev, "com");
185+
ddata->dma.chans[STM32_TIMERS_DMA_UP] = dma_request_chan(dev, "up");
186+
ddata->dma.chans[STM32_TIMERS_DMA_TRIG] = dma_request_chan(dev, "trig");
187+
ddata->dma.chans[STM32_TIMERS_DMA_COM] = dma_request_chan(dev, "com");
188+
189+
for (i = STM32_TIMERS_DMA_CH1; i < STM32_TIMERS_MAX_DMAS; i++) {
190+
if (IS_ERR(ddata->dma.chans[i])) {
191+
/* Save the first error code to return */
192+
if (PTR_ERR(ddata->dma.chans[i]) != -ENODEV && !ret)
193+
ret = PTR_ERR(ddata->dma.chans[i]);
194+
195+
ddata->dma.chans[i] = NULL;
196+
}
197+
}
198+
199+
return ret;
190200
}
191201

192202
static void stm32_timers_dma_remove(struct device *dev,
@@ -230,7 +240,11 @@ static int stm32_timers_probe(struct platform_device *pdev)
230240

231241
stm32_timers_get_arr_size(ddata);
232242

233-
stm32_timers_dma_probe(dev, ddata);
243+
ret = stm32_timers_dma_probe(dev, ddata);
244+
if (ret) {
245+
stm32_timers_dma_remove(dev, ddata);
246+
return ret;
247+
}
234248

235249
platform_set_drvdata(pdev, ddata);
236250

0 commit comments

Comments
 (0)