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

Configure Feed

Select the types of activity you want to include in your feed.

dmaengine: at_xdmac: get the number of DMA channels from device tree

In case of kernel runs in non-secure mode, the number of DMA channels can
be got from device tree since the value read from GTYPE register is "0" as
it's always secured.

As the number of channels can never be negative, update them to the type
"unsigned".

This is required for LAN969x.

Signed-off-by: Tony Han <tony.han@microchip.com>
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Link: https://patch.msgid.link/20251203121208.1269487-1-robert.marko@sartura.hr
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Tony Han and committed by
Vinod Koul
d3824968 c47422f4

+23 -3
+23 -3
drivers/dma/at_xdmac.c
··· 2247 2247 return clk_enable(atxdmac->clk); 2248 2248 } 2249 2249 2250 + static inline int at_xdmac_get_channel_number(struct platform_device *pdev, 2251 + u32 reg, u32 *pchannels) 2252 + { 2253 + int ret; 2254 + 2255 + if (reg) { 2256 + *pchannels = AT_XDMAC_NB_CH(reg); 2257 + return 0; 2258 + } 2259 + 2260 + ret = of_property_read_u32(pdev->dev.of_node, "dma-channels", pchannels); 2261 + if (ret) 2262 + dev_err(&pdev->dev, "can't get number of channels\n"); 2263 + 2264 + return ret; 2265 + } 2266 + 2250 2267 static int at_xdmac_probe(struct platform_device *pdev) 2251 2268 { 2252 2269 struct at_xdmac *atxdmac; 2253 - int irq, nr_channels, i, ret; 2270 + int irq, ret; 2254 2271 void __iomem *base; 2255 - u32 reg; 2272 + u32 nr_channels, i, reg; 2256 2273 2257 2274 irq = platform_get_irq(pdev, 0); 2258 2275 if (irq < 0) ··· 2285 2268 * of channels to do the allocation. 2286 2269 */ 2287 2270 reg = readl_relaxed(base + AT_XDMAC_GTYPE); 2288 - nr_channels = AT_XDMAC_NB_CH(reg); 2271 + ret = at_xdmac_get_channel_number(pdev, reg, &nr_channels); 2272 + if (ret) 2273 + return ret; 2274 + 2289 2275 if (nr_channels > AT_XDMAC_MAX_CHAN) { 2290 2276 dev_err(&pdev->dev, "invalid number of channels (%u)\n", 2291 2277 nr_channels);