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

dma: of: Remove restriction that #dma-cells can't be 0

There is no sensible reason why #dma-cells shouldn't be allowed to be 0. It is
completely up to the DMA controller how many additional parameters, besides the
phandle, it needs to identify a channel. E.g. for DMA controller with only one
channel or for DMA controllers which don't have a restriction on which channel
can be used for which peripheral it completely legitimate to not require any
additional parameters.

Also fixes the following warning:
drivers/dma/of-dma.c: In function 'of_dma_controller_register':
drivers/dma/of-dma.c:67:7: warning: 'nbcells' may be used uninitialized in this function

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Lars-Peter Clausen and committed by
Vinod Koul
ff0e0f4f 317ddd25

+4 -7
+4 -7
drivers/dma/of-dma.c
··· 64 64 void *data) 65 65 { 66 66 struct of_dma *ofdma; 67 - int nbcells; 68 67 const __be32 *prop; 69 68 70 69 if (!np || !of_dma_xlate) { ··· 76 77 return -ENOMEM; 77 78 78 79 prop = of_get_property(np, "#dma-cells", NULL); 79 - if (prop) 80 - nbcells = be32_to_cpup(prop); 81 - 82 - if (!prop || !nbcells) { 83 - pr_err("%s: #dma-cells property is missing or invalid\n", 80 + if (!prop) { 81 + pr_err("%s: #dma-cells property is missing\n", 84 82 __func__); 85 83 kfree(ofdma); 86 84 return -EINVAL; 87 85 } 88 86 87 + 89 88 ofdma->of_node = np; 90 - ofdma->of_dma_nbcells = nbcells; 89 + ofdma->of_dma_nbcells = be32_to_cpup(prop); 91 90 ofdma->of_dma_xlate = of_dma_xlate; 92 91 ofdma->of_dma_data = data; 93 92