Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: pl022: handle EPROBE_DEFER for dma

Handle EPROBE_DEFER explicitly so that we ensure that we get the DMA
channel specified in the device tree, instead of depending on the DMA
controller getting probed before us.

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Rabin Vincent and committed by
Mark Brown
f3d4bb33 8005c49d

+22 -6
+22 -6
drivers/spi/spi-pl022.c
··· 1171 1171 static int pl022_dma_autoprobe(struct pl022 *pl022) 1172 1172 { 1173 1173 struct device *dev = &pl022->adev->dev; 1174 + struct dma_chan *chan; 1175 + int err; 1174 1176 1175 1177 /* automatically configure DMA channels from platform, normally using DT */ 1176 - pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx"); 1177 - if (!pl022->dma_rx_channel) 1178 + chan = dma_request_slave_channel_reason(dev, "rx"); 1179 + if (IS_ERR(chan)) { 1180 + err = PTR_ERR(chan); 1178 1181 goto err_no_rxchan; 1182 + } 1179 1183 1180 - pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx"); 1181 - if (!pl022->dma_tx_channel) 1184 + pl022->dma_rx_channel = chan; 1185 + 1186 + chan = dma_request_slave_channel_reason(dev, "tx"); 1187 + if (IS_ERR(chan)) { 1188 + err = PTR_ERR(chan); 1182 1189 goto err_no_txchan; 1190 + } 1191 + 1192 + pl022->dma_tx_channel = chan; 1183 1193 1184 1194 pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); 1185 - if (!pl022->dummypage) 1195 + if (!pl022->dummypage) { 1196 + err = -ENOMEM; 1186 1197 goto err_no_dummypage; 1198 + } 1187 1199 1188 1200 return 0; 1189 1201 ··· 1206 1194 dma_release_channel(pl022->dma_rx_channel); 1207 1195 pl022->dma_rx_channel = NULL; 1208 1196 err_no_rxchan: 1209 - return -ENODEV; 1197 + return err; 1210 1198 } 1211 1199 1212 1200 static void terminate_dma(struct pl022 *pl022) ··· 2248 2236 2249 2237 /* Get DMA channels, try autoconfiguration first */ 2250 2238 status = pl022_dma_autoprobe(pl022); 2239 + if (status == -EPROBE_DEFER) { 2240 + dev_dbg(dev, "deferring probe to get DMA channel\n"); 2241 + goto err_no_irq; 2242 + } 2251 2243 2252 2244 /* If that failed, use channels from platform_info */ 2253 2245 if (status == 0)