-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdma_op.c
More file actions
127 lines (99 loc) · 1.99 KB
/
dma_op.c
File metadata and controls
127 lines (99 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* Copyright (C) 2016 University of Granada
* Miguel Jimenez Lopez <klyone@ugr.es>
*
* DMA Operation functions (implementation).
*
* This source code is licensed under the GNU General Public License,
* Version 2. See the file COPYING for more details.
*/
#include <linux/slab.h>
#include "dma_op.h"
struct dma_op * dma_op_create(gfp_t gfp)
{
struct dma_op * op = NULL;
op = kzalloc(sizeof(*op),gfp);
if(op != NULL)
INIT_LIST_HEAD(&op->list_dma_xfer);
return op;
}
int dma_op_add_xfer(struct dma_op * op, \
struct dma_xfer * xfer)
{
int r = 0;
if(op != NULL && xfer != NULL)
list_add_tail(&xfer->node,&op->list_dma_xfer);
else
r = -1;
return r;
}
int dma_op_del_xfer(struct dma_op * op, \
struct dma_xfer * xfer)
{
int r = 0;
if(op != NULL && xfer != NULL)
list_del(&xfer->node);
else
r = -1;
return r;
}
int dma_op_clear_xfer(struct dma_op * op)
{
int r = 0;
struct list_head * p;
struct list_head * aux;
struct dma_xfer * xfer;
list_for_each_safe(p,aux,&op->list_dma_xfer) {
xfer = list_entry(p,struct dma_xfer,node);
r = dma_op_del_xfer(op,xfer);
if(r < 0)
break;
}
return r;
}
int dma_op_start(struct dma_op * op)
{
struct list_head *p;
struct dma_xfer *xfer;
int r = 0;
list_for_each(p,&op->list_dma_xfer) {
xfer = list_entry(p,struct dma_xfer,node);
r = dma_xfer_start(xfer);
if(r != 0)
break;
}
return r;
}
int dma_op_all_xfers_completed(struct dma_op * op)
{
struct list_head *p;
struct dma_xfer *xfer;
int r = 1;
list_for_each(p,&op->list_dma_xfer) {
xfer = list_entry(p,struct dma_xfer,node);
if(dma_xfer_status(xfer) != DMA_COMPLETE) {
r = 0;
break;
}
}
return r;
}
int dma_op_xfer_error(struct dma_op * op)
{
struct list_head *p;
struct dma_xfer *xfer;
int r = 0;
list_for_each(p,&op->list_dma_xfer) {
xfer = list_entry(p,struct dma_xfer,node);
if(dma_xfer_status(xfer) == DMA_ERROR) {
r = 1;
break;
}
}
return r;
}
void dma_op_free(struct dma_op * op)
{
if(op != NULL)
kfree(op);
}