This source file includes following definitions.
- as10x_cmd_get_context
- as10x_cmd_set_context
- as10x_cmd_eLNA_change_mode
- as10x_context_rsp_parse
1
2
3
4
5
6
7 #include <linux/kernel.h>
8 #include "as102_drv.h"
9 #include "as10x_cmd.h"
10
11
12
13
14
15
16
17
18
19
20
21
22
23 int as10x_cmd_get_context(struct as10x_bus_adapter_t *adap, uint16_t tag,
24 uint32_t *pvalue)
25 {
26 int error;
27 struct as10x_cmd_t *pcmd, *prsp;
28
29 pcmd = adap->cmd;
30 prsp = adap->rsp;
31
32
33 as10x_cmd_build(pcmd, (++adap->cmd_xid),
34 sizeof(pcmd->body.context.req));
35
36
37 pcmd->body.context.req.proc_id = cpu_to_le16(CONTROL_PROC_CONTEXT);
38 pcmd->body.context.req.tag = cpu_to_le16(tag);
39 pcmd->body.context.req.type = cpu_to_le16(GET_CONTEXT_DATA);
40
41
42 if (adap->ops->xfer_cmd) {
43 error = adap->ops->xfer_cmd(adap,
44 (uint8_t *) pcmd,
45 sizeof(pcmd->body.context.req)
46 + HEADER_SIZE,
47 (uint8_t *) prsp,
48 sizeof(prsp->body.context.rsp)
49 + HEADER_SIZE);
50 } else {
51 error = AS10X_CMD_ERROR;
52 }
53
54 if (error < 0)
55 goto out;
56
57
58
59 error = as10x_context_rsp_parse(prsp, CONTROL_PROC_CONTEXT_RSP);
60
61 if (error == 0) {
62
63 *pvalue = le32_to_cpu((__force __le32)prsp->body.context.rsp.reg_val.u.value32);
64
65 }
66
67 out:
68 return error;
69 }
70
71
72
73
74
75
76
77
78
79 int as10x_cmd_set_context(struct as10x_bus_adapter_t *adap, uint16_t tag,
80 uint32_t value)
81 {
82 int error;
83 struct as10x_cmd_t *pcmd, *prsp;
84
85 pcmd = adap->cmd;
86 prsp = adap->rsp;
87
88
89 as10x_cmd_build(pcmd, (++adap->cmd_xid),
90 sizeof(pcmd->body.context.req));
91
92
93 pcmd->body.context.req.proc_id = cpu_to_le16(CONTROL_PROC_CONTEXT);
94
95 pcmd->body.context.req.reg_val.u.value32 = (__force u32)cpu_to_le32(value);
96 pcmd->body.context.req.tag = cpu_to_le16(tag);
97 pcmd->body.context.req.type = cpu_to_le16(SET_CONTEXT_DATA);
98
99
100 if (adap->ops->xfer_cmd) {
101 error = adap->ops->xfer_cmd(adap,
102 (uint8_t *) pcmd,
103 sizeof(pcmd->body.context.req)
104 + HEADER_SIZE,
105 (uint8_t *) prsp,
106 sizeof(prsp->body.context.rsp)
107 + HEADER_SIZE);
108 } else {
109 error = AS10X_CMD_ERROR;
110 }
111
112 if (error < 0)
113 goto out;
114
115
116
117 error = as10x_context_rsp_parse(prsp, CONTROL_PROC_CONTEXT_RSP);
118
119 out:
120 return error;
121 }
122
123
124
125
126
127
128
129
130
131
132
133
134 int as10x_cmd_eLNA_change_mode(struct as10x_bus_adapter_t *adap, uint8_t mode)
135 {
136 int error;
137 struct as10x_cmd_t *pcmd, *prsp;
138
139 pcmd = adap->cmd;
140 prsp = adap->rsp;
141
142
143 as10x_cmd_build(pcmd, (++adap->cmd_xid),
144 sizeof(pcmd->body.cfg_change_mode.req));
145
146
147 pcmd->body.cfg_change_mode.req.proc_id =
148 cpu_to_le16(CONTROL_PROC_ELNA_CHANGE_MODE);
149 pcmd->body.cfg_change_mode.req.mode = mode;
150
151
152 if (adap->ops->xfer_cmd) {
153 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
154 sizeof(pcmd->body.cfg_change_mode.req)
155 + HEADER_SIZE, (uint8_t *) prsp,
156 sizeof(prsp->body.cfg_change_mode.rsp)
157 + HEADER_SIZE);
158 } else {
159 error = AS10X_CMD_ERROR;
160 }
161
162 if (error < 0)
163 goto out;
164
165
166 error = as10x_rsp_parse(prsp, CONTROL_PROC_ELNA_CHANGE_MODE_RSP);
167
168 out:
169 return error;
170 }
171
172
173
174
175
176
177
178
179
180
181 int as10x_context_rsp_parse(struct as10x_cmd_t *prsp, uint16_t proc_id)
182 {
183 int err;
184
185 err = prsp->body.context.rsp.error;
186
187 if ((err == 0) &&
188 (le16_to_cpu(prsp->body.context.rsp.proc_id) == proc_id)) {
189 return 0;
190 }
191 return AS10X_CMD_ERROR;
192 }