.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * ISHTP bus layer messages handling |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2003-2016, Intel Corporation. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify it |
---|
7 | | - * under the terms and conditions of the GNU General Public License, |
---|
8 | | - * version 2, as published by the Free Software Foundation. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
---|
11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
13 | | - * more details. |
---|
14 | | - * |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #include <linux/export.h> |
---|
.. | .. |
---|
136 | 127 | int ishtp_hbm_start_req(struct ishtp_device *dev) |
---|
137 | 128 | { |
---|
138 | 129 | struct ishtp_msg_hdr hdr; |
---|
139 | | - unsigned char data[128]; |
---|
140 | | - struct ishtp_msg_hdr *ishtp_hdr = &hdr; |
---|
141 | | - struct hbm_host_version_request *start_req; |
---|
142 | | - const size_t len = sizeof(struct hbm_host_version_request); |
---|
| 130 | + struct hbm_host_version_request start_req = { 0 }; |
---|
143 | 131 | |
---|
144 | | - ishtp_hbm_hdr(ishtp_hdr, len); |
---|
| 132 | + ishtp_hbm_hdr(&hdr, sizeof(start_req)); |
---|
145 | 133 | |
---|
146 | 134 | /* host start message */ |
---|
147 | | - start_req = (struct hbm_host_version_request *)data; |
---|
148 | | - memset(start_req, 0, len); |
---|
149 | | - start_req->hbm_cmd = HOST_START_REQ_CMD; |
---|
150 | | - start_req->host_version.major_version = HBM_MAJOR_VERSION; |
---|
151 | | - start_req->host_version.minor_version = HBM_MINOR_VERSION; |
---|
| 135 | + start_req.hbm_cmd = HOST_START_REQ_CMD; |
---|
| 136 | + start_req.host_version.major_version = HBM_MAJOR_VERSION; |
---|
| 137 | + start_req.host_version.minor_version = HBM_MINOR_VERSION; |
---|
152 | 138 | |
---|
153 | 139 | /* |
---|
154 | 140 | * (!) Response to HBM start may be so quick that this thread would get |
---|
.. | .. |
---|
156 | 142 | * So set it at first, change back to ISHTP_HBM_IDLE upon failure |
---|
157 | 143 | */ |
---|
158 | 144 | dev->hbm_state = ISHTP_HBM_START; |
---|
159 | | - if (ishtp_write_message(dev, ishtp_hdr, data)) { |
---|
| 145 | + if (ishtp_write_message(dev, &hdr, &start_req)) { |
---|
160 | 146 | dev_err(dev->devc, "version message send failed\n"); |
---|
161 | 147 | dev->dev_state = ISHTP_DEV_RESETTING; |
---|
162 | 148 | dev->hbm_state = ISHTP_HBM_IDLE; |
---|
.. | .. |
---|
178 | 164 | void ishtp_hbm_enum_clients_req(struct ishtp_device *dev) |
---|
179 | 165 | { |
---|
180 | 166 | struct ishtp_msg_hdr hdr; |
---|
181 | | - unsigned char data[128]; |
---|
182 | | - struct ishtp_msg_hdr *ishtp_hdr = &hdr; |
---|
183 | | - struct hbm_host_enum_request *enum_req; |
---|
184 | | - const size_t len = sizeof(struct hbm_host_enum_request); |
---|
| 167 | + struct hbm_host_enum_request enum_req = { 0 }; |
---|
185 | 168 | |
---|
186 | 169 | /* enumerate clients */ |
---|
187 | | - ishtp_hbm_hdr(ishtp_hdr, len); |
---|
| 170 | + ishtp_hbm_hdr(&hdr, sizeof(enum_req)); |
---|
| 171 | + enum_req.hbm_cmd = HOST_ENUM_REQ_CMD; |
---|
188 | 172 | |
---|
189 | | - enum_req = (struct hbm_host_enum_request *)data; |
---|
190 | | - memset(enum_req, 0, len); |
---|
191 | | - enum_req->hbm_cmd = HOST_ENUM_REQ_CMD; |
---|
192 | | - |
---|
193 | | - if (ishtp_write_message(dev, ishtp_hdr, data)) { |
---|
| 173 | + if (ishtp_write_message(dev, &hdr, &enum_req)) { |
---|
194 | 174 | dev->dev_state = ISHTP_DEV_RESETTING; |
---|
195 | 175 | dev_err(dev->devc, "enumeration request send failed\n"); |
---|
196 | 176 | ish_hw_reset(dev); |
---|
.. | .. |
---|
208 | 188 | */ |
---|
209 | 189 | static int ishtp_hbm_prop_req(struct ishtp_device *dev) |
---|
210 | 190 | { |
---|
211 | | - |
---|
212 | 191 | struct ishtp_msg_hdr hdr; |
---|
213 | | - unsigned char data[128]; |
---|
214 | | - struct ishtp_msg_hdr *ishtp_hdr = &hdr; |
---|
215 | | - struct hbm_props_request *prop_req; |
---|
216 | | - const size_t len = sizeof(struct hbm_props_request); |
---|
| 192 | + struct hbm_props_request prop_req = { 0 }; |
---|
217 | 193 | unsigned long next_client_index; |
---|
218 | 194 | uint8_t client_num; |
---|
219 | 195 | |
---|
.. | .. |
---|
237 | 213 | |
---|
238 | 214 | dev->fw_clients[client_num].client_id = next_client_index; |
---|
239 | 215 | |
---|
240 | | - ishtp_hbm_hdr(ishtp_hdr, len); |
---|
241 | | - prop_req = (struct hbm_props_request *)data; |
---|
| 216 | + ishtp_hbm_hdr(&hdr, sizeof(prop_req)); |
---|
242 | 217 | |
---|
243 | | - memset(prop_req, 0, sizeof(struct hbm_props_request)); |
---|
| 218 | + prop_req.hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD; |
---|
| 219 | + prop_req.address = next_client_index; |
---|
244 | 220 | |
---|
245 | | - prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD; |
---|
246 | | - prop_req->address = next_client_index; |
---|
247 | | - |
---|
248 | | - if (ishtp_write_message(dev, ishtp_hdr, data)) { |
---|
| 221 | + if (ishtp_write_message(dev, &hdr, &prop_req)) { |
---|
249 | 222 | dev->dev_state = ISHTP_DEV_RESETTING; |
---|
250 | 223 | dev_err(dev->devc, "properties request send failed\n"); |
---|
251 | 224 | ish_hw_reset(dev); |
---|
.. | .. |
---|
266 | 239 | static void ishtp_hbm_stop_req(struct ishtp_device *dev) |
---|
267 | 240 | { |
---|
268 | 241 | struct ishtp_msg_hdr hdr; |
---|
269 | | - unsigned char data[128]; |
---|
270 | | - struct ishtp_msg_hdr *ishtp_hdr = &hdr; |
---|
271 | | - struct hbm_host_stop_request *req; |
---|
272 | | - const size_t len = sizeof(struct hbm_host_stop_request); |
---|
| 242 | + struct hbm_host_stop_request stop_req = { 0 } ; |
---|
273 | 243 | |
---|
274 | | - ishtp_hbm_hdr(ishtp_hdr, len); |
---|
275 | | - req = (struct hbm_host_stop_request *)data; |
---|
| 244 | + ishtp_hbm_hdr(&hdr, sizeof(stop_req)); |
---|
276 | 245 | |
---|
277 | | - memset(req, 0, sizeof(struct hbm_host_stop_request)); |
---|
278 | | - req->hbm_cmd = HOST_STOP_REQ_CMD; |
---|
279 | | - req->reason = DRIVER_STOP_REQUEST; |
---|
| 246 | + stop_req.hbm_cmd = HOST_STOP_REQ_CMD; |
---|
| 247 | + stop_req.reason = DRIVER_STOP_REQUEST; |
---|
280 | 248 | |
---|
281 | | - ishtp_write_message(dev, ishtp_hdr, data); |
---|
| 249 | + ishtp_write_message(dev, &hdr, &stop_req); |
---|
282 | 250 | } |
---|
283 | 251 | |
---|
284 | 252 | /** |
---|
.. | .. |
---|
294 | 262 | struct ishtp_cl *cl) |
---|
295 | 263 | { |
---|
296 | 264 | struct ishtp_msg_hdr hdr; |
---|
297 | | - unsigned char data[128]; |
---|
298 | | - struct ishtp_msg_hdr *ishtp_hdr = &hdr; |
---|
299 | | - const size_t len = sizeof(struct hbm_flow_control); |
---|
| 265 | + struct hbm_flow_control flow_ctrl; |
---|
| 266 | + const size_t len = sizeof(flow_ctrl); |
---|
300 | 267 | int rv; |
---|
301 | 268 | unsigned long flags; |
---|
302 | 269 | |
---|
303 | 270 | spin_lock_irqsave(&cl->fc_spinlock, flags); |
---|
304 | | - ishtp_hbm_hdr(ishtp_hdr, len); |
---|
305 | | - ishtp_hbm_cl_hdr(cl, ISHTP_FLOW_CONTROL_CMD, data, len); |
---|
| 271 | + |
---|
| 272 | + ishtp_hbm_hdr(&hdr, len); |
---|
| 273 | + ishtp_hbm_cl_hdr(cl, ISHTP_FLOW_CONTROL_CMD, &flow_ctrl, len); |
---|
306 | 274 | |
---|
307 | 275 | /* |
---|
308 | 276 | * Sync possible race when RB recycle and packet receive paths |
---|
.. | .. |
---|
315 | 283 | |
---|
316 | 284 | cl->recv_msg_num_frags = 0; |
---|
317 | 285 | |
---|
318 | | - rv = ishtp_write_message(dev, ishtp_hdr, data); |
---|
| 286 | + rv = ishtp_write_message(dev, &hdr, &flow_ctrl); |
---|
319 | 287 | if (!rv) { |
---|
320 | 288 | ++cl->out_flow_ctrl_creds; |
---|
321 | 289 | ++cl->out_flow_ctrl_cnt; |
---|
.. | .. |
---|
345 | 313 | int ishtp_hbm_cl_disconnect_req(struct ishtp_device *dev, struct ishtp_cl *cl) |
---|
346 | 314 | { |
---|
347 | 315 | struct ishtp_msg_hdr hdr; |
---|
348 | | - unsigned char data[128]; |
---|
349 | | - struct ishtp_msg_hdr *ishtp_hdr = &hdr; |
---|
350 | | - const size_t len = sizeof(struct hbm_client_connect_request); |
---|
| 316 | + struct hbm_client_connect_request disconn_req; |
---|
| 317 | + const size_t len = sizeof(disconn_req); |
---|
351 | 318 | |
---|
352 | | - ishtp_hbm_hdr(ishtp_hdr, len); |
---|
353 | | - ishtp_hbm_cl_hdr(cl, CLIENT_DISCONNECT_REQ_CMD, data, len); |
---|
| 319 | + ishtp_hbm_hdr(&hdr, len); |
---|
| 320 | + ishtp_hbm_cl_hdr(cl, CLIENT_DISCONNECT_REQ_CMD, &disconn_req, len); |
---|
354 | 321 | |
---|
355 | | - return ishtp_write_message(dev, ishtp_hdr, data); |
---|
| 322 | + return ishtp_write_message(dev, &hdr, &disconn_req); |
---|
356 | 323 | } |
---|
357 | 324 | |
---|
358 | 325 | /** |
---|
.. | .. |
---|
391 | 358 | int ishtp_hbm_cl_connect_req(struct ishtp_device *dev, struct ishtp_cl *cl) |
---|
392 | 359 | { |
---|
393 | 360 | struct ishtp_msg_hdr hdr; |
---|
394 | | - unsigned char data[128]; |
---|
395 | | - struct ishtp_msg_hdr *ishtp_hdr = &hdr; |
---|
396 | | - const size_t len = sizeof(struct hbm_client_connect_request); |
---|
| 361 | + struct hbm_client_connect_request conn_req; |
---|
| 362 | + const size_t len = sizeof(conn_req); |
---|
397 | 363 | |
---|
398 | | - ishtp_hbm_hdr(ishtp_hdr, len); |
---|
399 | | - ishtp_hbm_cl_hdr(cl, CLIENT_CONNECT_REQ_CMD, data, len); |
---|
| 364 | + ishtp_hbm_hdr(&hdr, len); |
---|
| 365 | + ishtp_hbm_cl_hdr(cl, CLIENT_CONNECT_REQ_CMD, &conn_req, len); |
---|
400 | 366 | |
---|
401 | | - return ishtp_write_message(dev, ishtp_hdr, data); |
---|
| 367 | + return ishtp_write_message(dev, &hdr, &conn_req); |
---|
402 | 368 | } |
---|
403 | 369 | |
---|
404 | 370 | /** |
---|
.. | .. |
---|
436 | 402 | * @dev: ISHTP device instance |
---|
437 | 403 | * @disconnect_req: disconnect request structure |
---|
438 | 404 | * |
---|
439 | | - * Disconnect request bus message from the fw. Send diconnect response. |
---|
| 405 | + * Disconnect request bus message from the fw. Send disconnect response. |
---|
440 | 406 | */ |
---|
441 | 407 | static void ishtp_hbm_fw_disconnect_req(struct ishtp_device *dev, |
---|
442 | 408 | struct hbm_client_connect_request *disconnect_req) |
---|