aboutsummaryrefslogtreecommitdiffstats
path: root/samples/kfifo
diff options
context:
space:
mode:
Diffstat (limited to 'samples/kfifo')
-rw-r--r--samples/kfifo/dma-example.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/samples/kfifo/dma-example.c b/samples/kfifo/dma-example.c
index ee03a4f0b64f..06473791c08a 100644
--- a/samples/kfifo/dma-example.c
+++ b/samples/kfifo/dma-example.c
@@ -24,6 +24,7 @@ static int __init example_init(void)
24{ 24{
25 int i; 25 int i;
26 unsigned int ret; 26 unsigned int ret;
27 unsigned int nents;
27 struct scatterlist sg[10]; 28 struct scatterlist sg[10];
28 29
29 printk(KERN_INFO "DMA fifo test start\n"); 30 printk(KERN_INFO "DMA fifo test start\n");
@@ -61,9 +62,9 @@ static int __init example_init(void)
61 * byte at the beginning, after the kfifo_skip(). 62 * byte at the beginning, after the kfifo_skip().
62 */ 63 */
63 sg_init_table(sg, ARRAY_SIZE(sg)); 64 sg_init_table(sg, ARRAY_SIZE(sg));
64 ret = kfifo_dma_in_prepare(&fifo, sg, ARRAY_SIZE(sg), FIFO_SIZE); 65 nents = kfifo_dma_in_prepare(&fifo, sg, ARRAY_SIZE(sg), FIFO_SIZE);
65 printk(KERN_INFO "DMA sgl entries: %d\n", ret); 66 printk(KERN_INFO "DMA sgl entries: %d\n", nents);
66 if (!ret) { 67 if (!nents) {
67 /* fifo is full and no sgl was created */ 68 /* fifo is full and no sgl was created */
68 printk(KERN_WARNING "error kfifo_dma_in_prepare\n"); 69 printk(KERN_WARNING "error kfifo_dma_in_prepare\n");
69 return -EIO; 70 return -EIO;
@@ -71,7 +72,7 @@ static int __init example_init(void)
71 72
72 /* receive data */ 73 /* receive data */
73 printk(KERN_INFO "scatterlist for receive:\n"); 74 printk(KERN_INFO "scatterlist for receive:\n");
74 for (i = 0; i < ARRAY_SIZE(sg); i++) { 75 for (i = 0; i < nents; i++) {
75 printk(KERN_INFO 76 printk(KERN_INFO
76 "sg[%d] -> " 77 "sg[%d] -> "
77 "page_link 0x%.8lx offset 0x%.8x length 0x%.8x\n", 78 "page_link 0x%.8lx offset 0x%.8x length 0x%.8x\n",
@@ -91,16 +92,16 @@ static int __init example_init(void)
91 kfifo_dma_in_finish(&fifo, ret); 92 kfifo_dma_in_finish(&fifo, ret);
92 93
93 /* Prepare to transmit data, example: 8 bytes */ 94 /* Prepare to transmit data, example: 8 bytes */
94 ret = kfifo_dma_out_prepare(&fifo, sg, ARRAY_SIZE(sg), 8); 95 nents = kfifo_dma_out_prepare(&fifo, sg, ARRAY_SIZE(sg), 8);
95 printk(KERN_INFO "DMA sgl entries: %d\n", ret); 96 printk(KERN_INFO "DMA sgl entries: %d\n", nents);
96 if (!ret) { 97 if (!nents) {
97 /* no data was available and no sgl was created */ 98 /* no data was available and no sgl was created */
98 printk(KERN_WARNING "error kfifo_dma_out_prepare\n"); 99 printk(KERN_WARNING "error kfifo_dma_out_prepare\n");
99 return -EIO; 100 return -EIO;
100 } 101 }
101 102
102 printk(KERN_INFO "scatterlist for transmit:\n"); 103 printk(KERN_INFO "scatterlist for transmit:\n");
103 for (i = 0; i < ARRAY_SIZE(sg); i++) { 104 for (i = 0; i < nents; i++) {
104 printk(KERN_INFO 105 printk(KERN_INFO
105 "sg[%d] -> " 106 "sg[%d] -> "
106 "page_link 0x%.8lx offset 0x%.8x length 0x%.8x\n", 107 "page_link 0x%.8lx offset 0x%.8x length 0x%.8x\n",