.. | .. |
---|
172 | 172 | regmap_write(ddata->regmap, TIM_ARR, arr); |
---|
173 | 173 | } |
---|
174 | 174 | |
---|
175 | | -static void stm32_timers_dma_probe(struct device *dev, |
---|
| 175 | +static int stm32_timers_dma_probe(struct device *dev, |
---|
176 | 176 | struct stm32_timers *ddata) |
---|
177 | 177 | { |
---|
178 | 178 | int i; |
---|
| 179 | + int ret = 0; |
---|
179 | 180 | char name[4]; |
---|
180 | 181 | |
---|
181 | 182 | init_completion(&ddata->dma.completion); |
---|
.. | .. |
---|
184 | 185 | /* Optional DMA support: get valid DMA channel(s) or NULL */ |
---|
185 | 186 | for (i = STM32_TIMERS_DMA_CH1; i <= STM32_TIMERS_DMA_CH4; i++) { |
---|
186 | 187 | snprintf(name, ARRAY_SIZE(name), "ch%1d", i + 1); |
---|
187 | | - ddata->dma.chans[i] = dma_request_slave_channel(dev, name); |
---|
| 188 | + ddata->dma.chans[i] = dma_request_chan(dev, name); |
---|
188 | 189 | } |
---|
189 | | - ddata->dma.chans[STM32_TIMERS_DMA_UP] = |
---|
190 | | - dma_request_slave_channel(dev, "up"); |
---|
191 | | - ddata->dma.chans[STM32_TIMERS_DMA_TRIG] = |
---|
192 | | - dma_request_slave_channel(dev, "trig"); |
---|
193 | | - ddata->dma.chans[STM32_TIMERS_DMA_COM] = |
---|
194 | | - dma_request_slave_channel(dev, "com"); |
---|
| 190 | + ddata->dma.chans[STM32_TIMERS_DMA_UP] = dma_request_chan(dev, "up"); |
---|
| 191 | + ddata->dma.chans[STM32_TIMERS_DMA_TRIG] = dma_request_chan(dev, "trig"); |
---|
| 192 | + ddata->dma.chans[STM32_TIMERS_DMA_COM] = dma_request_chan(dev, "com"); |
---|
| 193 | + |
---|
| 194 | + for (i = STM32_TIMERS_DMA_CH1; i < STM32_TIMERS_MAX_DMAS; i++) { |
---|
| 195 | + if (IS_ERR(ddata->dma.chans[i])) { |
---|
| 196 | + /* Save the first error code to return */ |
---|
| 197 | + if (PTR_ERR(ddata->dma.chans[i]) != -ENODEV && !ret) |
---|
| 198 | + ret = PTR_ERR(ddata->dma.chans[i]); |
---|
| 199 | + |
---|
| 200 | + ddata->dma.chans[i] = NULL; |
---|
| 201 | + } |
---|
| 202 | + } |
---|
| 203 | + |
---|
| 204 | + return ret; |
---|
195 | 205 | } |
---|
196 | 206 | |
---|
197 | 207 | static void stm32_timers_dma_remove(struct device *dev, |
---|
.. | .. |
---|
235 | 245 | |
---|
236 | 246 | stm32_timers_get_arr_size(ddata); |
---|
237 | 247 | |
---|
238 | | - stm32_timers_dma_probe(dev, ddata); |
---|
| 248 | + ret = stm32_timers_dma_probe(dev, ddata); |
---|
| 249 | + if (ret) { |
---|
| 250 | + stm32_timers_dma_remove(dev, ddata); |
---|
| 251 | + return ret; |
---|
| 252 | + } |
---|
239 | 253 | |
---|
240 | 254 | platform_set_drvdata(pdev, ddata); |
---|
241 | 255 | |
---|