blob: 20652e140c430c63317ae9642fbdb778f8a7b381 [file] [log] [blame]
Oren Weilab841162011-05-15 13:43:41 +03001/*
2 *
3 * Intel Management Engine Interface (Intel MEI) Linux driver
Tomas Winkler733ba912012-02-09 19:25:53 +02004 * Copyright (c) 2003-2012, Intel Corporation.
Oren Weilab841162011-05-15 13:43:41 +03005 *
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 */
16
17
18#include <linux/kernel.h>
19#include <linux/fs.h>
20#include <linux/errno.h>
21#include <linux/types.h>
22#include <linux/fcntl.h>
23#include <linux/aio.h>
24#include <linux/pci.h>
25#include <linux/init.h>
26#include <linux/ioctl.h>
27#include <linux/cdev.h>
28#include <linux/list.h>
29#include <linux/delay.h>
30#include <linux/sched.h>
31#include <linux/uuid.h>
32#include <linux/jiffies.h>
33#include <linux/uaccess.h>
34
35
36#include "mei_dev.h"
37#include "hw.h"
Tomas Winkler4f3afe12012-05-09 16:38:59 +030038#include <linux/mei.h>
Oren Weilab841162011-05-15 13:43:41 +030039#include "interface.h"
Oren Weilab841162011-05-15 13:43:41 +030040
Tomas Winkler07b509b2012-07-23 14:05:39 +030041/**
42 * mei_me_cl_by_id return index to me_clients for client_id
43 *
44 * @dev: the device structure
45 * @client_id: me client id
46 *
47 * Locking: called under "dev->device_lock" lock
48 *
49 * returns index on success, -ENOENT on failure.
50 */
Oren Weilab841162011-05-15 13:43:41 +030051
Tomas Winkler07b509b2012-07-23 14:05:39 +030052int mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
53{
54 int i;
55 for (i = 0; i < dev->me_clients_num; i++)
56 if (dev->me_clients[i].client_id == client_id)
57 break;
58 if (WARN_ON(dev->me_clients[i].client_id != client_id))
59 return -ENOENT;
60
61 if (i == dev->me_clients_num)
62 return -ENOENT;
63
64 return i;
65}
Oren Weilab841162011-05-15 13:43:41 +030066
67/**
68 * mei_ioctl_connect_client - the connect to fw client IOCTL function
69 *
70 * @dev: the device structure
71 * @data: IOCTL connect data, input and output parameters
72 * @file: private data of the file object
73 *
74 * Locking: called under "dev->device_lock" lock
75 *
76 * returns 0 on success, <0 on failure.
77 */
78int mei_ioctl_connect_client(struct file *file,
79 struct mei_connect_client_data *data)
80{
81 struct mei_device *dev;
82 struct mei_cl_cb *cb;
83 struct mei_client *client;
84 struct mei_cl *cl;
85 struct mei_cl *cl_pos = NULL;
86 struct mei_cl *cl_next = NULL;
87 long timeout = CONNECT_TIMEOUT;
88 int i;
89 int err;
90 int rets;
91
92 cl = file->private_data;
93 if (WARN_ON(!cl || !cl->dev))
94 return -ENODEV;
95
96 dev = cl->dev;
97
98 dev_dbg(&dev->pdev->dev, "mei_ioctl_connect_client() Entry\n");
99
100
101 /* buffered ioctl cb */
102 cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
103 if (!cb) {
104 rets = -ENOMEM;
105 goto end;
106 }
107 INIT_LIST_HEAD(&cb->cb_list);
108
109 cb->major_file_operations = MEI_IOCTL;
110
Tomas Winklerb210d752012-08-07 00:03:56 +0300111 if (dev->dev_state != MEI_DEV_ENABLED) {
Oren Weilab841162011-05-15 13:43:41 +0300112 rets = -ENODEV;
113 goto end;
114 }
115 if (cl->state != MEI_FILE_INITIALIZING &&
116 cl->state != MEI_FILE_DISCONNECTED) {
117 rets = -EBUSY;
118 goto end;
119 }
120
121 /* find ME client we're trying to connect to */
Tomas Winkler07b509b2012-07-23 14:05:39 +0300122 i = mei_me_cl_by_uuid(dev, &data->in_client_uuid);
Oren Weilab841162011-05-15 13:43:41 +0300123 if (i >= 0 && !dev->me_clients[i].props.fixed_address) {
124 cl->me_client_id = dev->me_clients[i].client_id;
125 cl->state = MEI_FILE_CONNECTING;
126 }
127
128 dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n",
129 cl->me_client_id);
130 dev_dbg(&dev->pdev->dev, "FW Client - Protocol Version = %d\n",
131 dev->me_clients[i].props.protocol_version);
132 dev_dbg(&dev->pdev->dev, "FW Client - Max Msg Len = %d\n",
133 dev->me_clients[i].props.max_msg_length);
134
Justin P. Mattock5f9092f2012-03-12 07:18:09 -0700135 /* if we're connecting to amthi client then we will use the
136 * existing connection
Oren Weilab841162011-05-15 13:43:41 +0300137 */
138 if (uuid_le_cmp(data->in_client_uuid, mei_amthi_guid) == 0) {
139 dev_dbg(&dev->pdev->dev, "FW Client is amthi\n");
140 if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) {
141 rets = -ENODEV;
142 goto end;
143 }
144 clear_bit(cl->host_client_id, dev->host_clients_map);
145 list_for_each_entry_safe(cl_pos, cl_next,
146 &dev->file_list, link) {
Tomas Winkler0288c7c2011-06-06 10:44:34 +0300147 if (mei_cl_cmp_id(cl, cl_pos)) {
Oren Weilab841162011-05-15 13:43:41 +0300148 dev_dbg(&dev->pdev->dev,
149 "remove file private data node host"
150 " client = %d, ME client = %d.\n",
151 cl_pos->host_client_id,
152 cl_pos->me_client_id);
153 list_del(&cl_pos->link);
154 }
155
156 }
157 dev_dbg(&dev->pdev->dev, "free file private data memory.\n");
158 kfree(cl);
159
160 cl = NULL;
161 file->private_data = &dev->iamthif_cl;
162
163 client = &data->out_client_properties;
164 client->max_msg_length =
165 dev->me_clients[i].props.max_msg_length;
166 client->protocol_version =
167 dev->me_clients[i].props.protocol_version;
168 rets = dev->iamthif_cl.status;
169
170 goto end;
171 }
172
173 if (cl->state != MEI_FILE_CONNECTING) {
174 rets = -ENODEV;
175 goto end;
176 }
177
178
179 /* prepare the output buffer */
180 client = &data->out_client_properties;
181 client->max_msg_length = dev->me_clients[i].props.max_msg_length;
182 client->protocol_version = dev->me_clients[i].props.protocol_version;
183 dev_dbg(&dev->pdev->dev, "Can connect?\n");
184 if (dev->mei_host_buffer_is_empty
185 && !mei_other_client_is_connecting(dev, cl)) {
186 dev_dbg(&dev->pdev->dev, "Sending Connect Message\n");
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300187 dev->mei_host_buffer_is_empty = false;
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200188 if (mei_connect(dev, cl)) {
Oren Weilab841162011-05-15 13:43:41 +0300189 dev_dbg(&dev->pdev->dev, "Sending connect message - failed\n");
190 rets = -ENODEV;
191 goto end;
192 } else {
193 dev_dbg(&dev->pdev->dev, "Sending connect message - succeeded\n");
194 cl->timer_count = MEI_CONNECT_TIMEOUT;
195 cb->file_private = cl;
196 list_add_tail(&cb->cb_list,
197 &dev->ctrl_rd_list.mei_cb.
198 cb_list);
199 }
200
201
202 } else {
203 dev_dbg(&dev->pdev->dev, "Queuing the connect request due to device busy\n");
204 cb->file_private = cl;
205 dev_dbg(&dev->pdev->dev, "add connect cb to control write list.\n");
206 list_add_tail(&cb->cb_list,
207 &dev->ctrl_wr_list.mei_cb.cb_list);
208 }
209 mutex_unlock(&dev->device_lock);
210 err = wait_event_timeout(dev->wait_recvd_msg,
211 (MEI_FILE_CONNECTED == cl->state ||
212 MEI_FILE_DISCONNECTED == cl->state),
213 timeout * HZ);
214
215 mutex_lock(&dev->device_lock);
216 if (MEI_FILE_CONNECTED == cl->state) {
217 dev_dbg(&dev->pdev->dev, "successfully connected to FW client.\n");
218 rets = cl->status;
219 goto end;
220 } else {
221 dev_dbg(&dev->pdev->dev, "failed to connect to FW client.cl->state = %d.\n",
222 cl->state);
223 if (!err) {
224 dev_dbg(&dev->pdev->dev,
225 "wait_event_interruptible_timeout failed on client"
226 " connect message fw response message.\n");
227 }
228 rets = -EFAULT;
229
Tomas Winkler0288c7c2011-06-06 10:44:34 +0300230 mei_io_list_flush(&dev->ctrl_rd_list, cl);
231 mei_io_list_flush(&dev->ctrl_wr_list, cl);
Oren Weilab841162011-05-15 13:43:41 +0300232 goto end;
233 }
234 rets = 0;
235end:
236 dev_dbg(&dev->pdev->dev, "free connect cb memory.");
237 kfree(cb);
238 return rets;
239}
240
241/**
242 * find_amthi_read_list_entry - finds a amthilist entry for current file
243 *
244 * @dev: the device structure
245 * @file: pointer to file object
246 *
247 * returns returned a list entry on success, NULL on failure.
248 */
249struct mei_cl_cb *find_amthi_read_list_entry(
250 struct mei_device *dev,
251 struct file *file)
252{
253 struct mei_cl *cl_temp;
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200254 struct mei_cl_cb *pos = NULL;
255 struct mei_cl_cb *next = NULL;
Oren Weilab841162011-05-15 13:43:41 +0300256
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200257 list_for_each_entry_safe(pos, next,
258 &dev->amthi_read_complete_list.mei_cb.cb_list, cb_list) {
259 cl_temp = (struct mei_cl *)pos->file_private;
260 if (cl_temp && cl_temp == &dev->iamthif_cl &&
261 pos->file_object == file)
262 return pos;
Oren Weilab841162011-05-15 13:43:41 +0300263 }
264 return NULL;
265}
266
267/**
268 * amthi_read - read data from AMTHI client
269 *
270 * @dev: the device structure
271 * @if_num: minor number
272 * @file: pointer to file object
273 * @*ubuf: pointer to user data in user space
274 * @length: data length to read
275 * @offset: data read offset
276 *
277 * Locking: called under "dev->device_lock" lock
278 *
279 * returns
280 * returned data length on success,
281 * zero if no data to read,
282 * negative on failure.
283 */
284int amthi_read(struct mei_device *dev, struct file *file,
Tomas Winkler441ab502011-12-13 23:39:34 +0200285 char __user *ubuf, size_t length, loff_t *offset)
Oren Weilab841162011-05-15 13:43:41 +0300286{
287 int rets;
288 int wait_ret;
289 struct mei_cl_cb *cb = NULL;
290 struct mei_cl *cl = file->private_data;
291 unsigned long timeout;
292 int i;
293
294 /* Only Posible if we are in timeout */
295 if (!cl || cl != &dev->iamthif_cl) {
296 dev_dbg(&dev->pdev->dev, "bad file ext.\n");
297 return -ETIMEDOUT;
298 }
299
Tomas Winkler07b509b2012-07-23 14:05:39 +0300300 i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id);
Oren Weilab841162011-05-15 13:43:41 +0300301
Tomas Winkler07b509b2012-07-23 14:05:39 +0300302 if (i < 0) {
Oren Weilab841162011-05-15 13:43:41 +0300303 dev_dbg(&dev->pdev->dev, "amthi client not found.\n");
304 return -ENODEV;
305 }
Oren Weilab841162011-05-15 13:43:41 +0300306 dev_dbg(&dev->pdev->dev, "checking amthi data\n");
307 cb = find_amthi_read_list_entry(dev, file);
308
309 /* Check for if we can block or not*/
310 if (cb == NULL && file->f_flags & O_NONBLOCK)
311 return -EAGAIN;
312
313
314 dev_dbg(&dev->pdev->dev, "waiting for amthi data\n");
315 while (cb == NULL) {
316 /* unlock the Mutex */
317 mutex_unlock(&dev->device_lock);
318
319 wait_ret = wait_event_interruptible(dev->iamthif_cl.wait,
320 (cb = find_amthi_read_list_entry(dev, file)));
321
322 if (wait_ret)
323 return -ERESTARTSYS;
324
325 dev_dbg(&dev->pdev->dev, "woke up from sleep\n");
326
327 /* Locking again the Mutex */
328 mutex_lock(&dev->device_lock);
329 }
330
331
332 dev_dbg(&dev->pdev->dev, "Got amthi data\n");
333 dev->iamthif_timer = 0;
334
335 if (cb) {
Tomas Winkler07b509b2012-07-23 14:05:39 +0300336 timeout = cb->read_time + msecs_to_jiffies(IAMTHIF_READ_TIMER);
Oren Weilab841162011-05-15 13:43:41 +0300337 dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n",
338 timeout);
339
340 if (time_after(jiffies, timeout)) {
341 dev_dbg(&dev->pdev->dev, "amthi Time out\n");
342 /* 15 sec for the message has expired */
343 list_del(&cb->cb_list);
344 rets = -ETIMEDOUT;
345 goto free;
346 }
347 }
348 /* if the whole message will fit remove it from the list */
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200349 if (cb->buf_idx >= *offset && length >= (cb->buf_idx - *offset))
Oren Weilab841162011-05-15 13:43:41 +0300350 list_del(&cb->cb_list);
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200351 else if (cb->buf_idx > 0 && cb->buf_idx <= *offset) {
Oren Weilab841162011-05-15 13:43:41 +0300352 /* end of the message has been reached */
353 list_del(&cb->cb_list);
354 rets = 0;
355 goto free;
356 }
357 /* else means that not full buffer will be read and do not
358 * remove message from deletion list
359 */
360
361 dev_dbg(&dev->pdev->dev, "amthi cb->response_buffer size - %d\n",
362 cb->response_buffer.size);
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200363 dev_dbg(&dev->pdev->dev, "amthi cb->buf_idx - %lu\n", cb->buf_idx);
Oren Weilab841162011-05-15 13:43:41 +0300364
365 /* length is being turncated to PAGE_SIZE, however,
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200366 * the buf_idx may point beyond */
367 length = min_t(size_t, length, (cb->buf_idx - *offset));
Oren Weilab841162011-05-15 13:43:41 +0300368
Tomas Winkler441ab502011-12-13 23:39:34 +0200369 if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length))
Oren Weilab841162011-05-15 13:43:41 +0300370 rets = -EFAULT;
371 else {
372 rets = length;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200373 if ((*offset + length) < cb->buf_idx) {
Oren Weilab841162011-05-15 13:43:41 +0300374 *offset += length;
375 goto out;
376 }
377 }
378free:
379 dev_dbg(&dev->pdev->dev, "free amthi cb memory.\n");
380 *offset = 0;
381 mei_free_cb_private(cb);
382out:
383 return rets;
384}
385
386/**
387 * mei_start_read - the start read client message function.
388 *
389 * @dev: the device structure
390 * @if_num: minor number
391 * @cl: private data of the file object
392 *
393 * returns 0 on success, <0 on failure.
394 */
395int mei_start_read(struct mei_device *dev, struct mei_cl *cl)
396{
397 struct mei_cl_cb *cb;
398 int rets = 0;
399 int i;
400
401 if (cl->state != MEI_FILE_CONNECTED)
402 return -ENODEV;
403
Tomas Winklerb210d752012-08-07 00:03:56 +0300404 if (dev->dev_state != MEI_DEV_ENABLED)
Oren Weilab841162011-05-15 13:43:41 +0300405 return -ENODEV;
406
407 dev_dbg(&dev->pdev->dev, "check if read is pending.\n");
408 if (cl->read_pending || cl->read_cb) {
409 dev_dbg(&dev->pdev->dev, "read is pending.\n");
410 return -EBUSY;
411 }
412
413 cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
414 if (!cb)
415 return -ENOMEM;
416
417 dev_dbg(&dev->pdev->dev, "allocation call back successful. host client = %d, ME client = %d\n",
418 cl->host_client_id, cl->me_client_id);
Tomas Winkler07b509b2012-07-23 14:05:39 +0300419 i = mei_me_cl_by_id(dev, cl->me_client_id);
420 if (i < 0) {
Oren Weilab841162011-05-15 13:43:41 +0300421 rets = -ENODEV;
422 goto unlock;
423 }
424
425 cb->response_buffer.size = dev->me_clients[i].props.max_msg_length;
426 cb->response_buffer.data =
Tomas Winkler441ab502011-12-13 23:39:34 +0200427 kmalloc(cb->response_buffer.size, GFP_KERNEL);
Oren Weilab841162011-05-15 13:43:41 +0300428 if (!cb->response_buffer.data) {
429 rets = -ENOMEM;
430 goto unlock;
431 }
432 dev_dbg(&dev->pdev->dev, "allocation call back data success.\n");
433 cb->major_file_operations = MEI_READ;
Tomas Winklerebb108ef2012-10-09 16:50:16 +0200434 /* make sure buffer index is zero before we start */
435 cb->buf_idx = 0;
Oren Weilab841162011-05-15 13:43:41 +0300436 cb->file_private = (void *) cl;
437 cl->read_cb = cb;
438 if (dev->mei_host_buffer_is_empty) {
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300439 dev->mei_host_buffer_is_empty = false;
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200440 if (mei_send_flow_control(dev, cl)) {
Oren Weilab841162011-05-15 13:43:41 +0300441 rets = -ENODEV;
442 goto unlock;
Oren Weilab841162011-05-15 13:43:41 +0300443 }
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200444 list_add_tail(&cb->cb_list, &dev->read_list.mei_cb.cb_list);
Oren Weilab841162011-05-15 13:43:41 +0300445 } else {
Tomas Winkler441ab502011-12-13 23:39:34 +0200446 list_add_tail(&cb->cb_list, &dev->ctrl_wr_list.mei_cb.cb_list);
Oren Weilab841162011-05-15 13:43:41 +0300447 }
448 return rets;
449unlock:
450 mei_free_cb_private(cb);
451 return rets;
452}
453
454/**
455 * amthi_write - write iamthif data to amthi client
456 *
457 * @dev: the device structure
458 * @cb: mei call back struct
459 *
460 * returns 0 on success, <0 on failure.
461 */
462int amthi_write(struct mei_device *dev, struct mei_cl_cb *cb)
463{
464 struct mei_msg_hdr mei_hdr;
465 int ret;
466
467 if (!dev || !cb)
468 return -ENODEV;
469
470 dev_dbg(&dev->pdev->dev, "write data to amthi client.\n");
471
472 dev->iamthif_state = MEI_IAMTHIF_WRITING;
473 dev->iamthif_current_cb = cb;
474 dev->iamthif_file_object = cb->file_object;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300475 dev->iamthif_canceled = false;
476 dev->iamthif_ioctl = true;
Oren Weilab841162011-05-15 13:43:41 +0300477 dev->iamthif_msg_buf_size = cb->request_buffer.size;
478 memcpy(dev->iamthif_msg_buf, cb->request_buffer.data,
Tomas Winkler441ab502011-12-13 23:39:34 +0200479 cb->request_buffer.size);
Oren Weilab841162011-05-15 13:43:41 +0300480
481 ret = mei_flow_ctrl_creds(dev, &dev->iamthif_cl);
482 if (ret < 0)
483 return ret;
484
485 if (ret && dev->mei_host_buffer_is_empty) {
486 ret = 0;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300487 dev->mei_host_buffer_is_empty = false;
Tomas Winkler24aadc82012-06-25 23:46:27 +0300488 if (cb->request_buffer.size > mei_hbuf_max_data(dev)) {
489 mei_hdr.length = mei_hbuf_max_data(dev);
Oren Weilab841162011-05-15 13:43:41 +0300490 mei_hdr.msg_complete = 0;
491 } else {
492 mei_hdr.length = cb->request_buffer.size;
493 mei_hdr.msg_complete = 1;
494 }
495
496 mei_hdr.host_addr = dev->iamthif_cl.host_client_id;
497 mei_hdr.me_addr = dev->iamthif_cl.me_client_id;
498 mei_hdr.reserved = 0;
499 dev->iamthif_msg_buf_index += mei_hdr.length;
Tomas Winkler1ccb7b62012-03-14 14:39:42 +0200500 if (mei_write_message(dev, &mei_hdr,
Oren Weilab841162011-05-15 13:43:41 +0300501 (unsigned char *)(dev->iamthif_msg_buf),
502 mei_hdr.length))
503 return -ENODEV;
504
505 if (mei_hdr.msg_complete) {
506 if (mei_flow_ctrl_reduce(dev, &dev->iamthif_cl))
507 return -ENODEV;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300508 dev->iamthif_flow_control_pending = true;
Oren Weilab841162011-05-15 13:43:41 +0300509 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
510 dev_dbg(&dev->pdev->dev, "add amthi cb to write waiting list\n");
511 dev->iamthif_current_cb = cb;
512 dev->iamthif_file_object = cb->file_object;
513 list_add_tail(&cb->cb_list,
514 &dev->write_waiting_list.mei_cb.cb_list);
515 } else {
516 dev_dbg(&dev->pdev->dev, "message does not complete, "
517 "so add amthi cb to write list.\n");
518 list_add_tail(&cb->cb_list,
519 &dev->write_list.mei_cb.cb_list);
520 }
521 } else {
522 if (!(dev->mei_host_buffer_is_empty))
523 dev_dbg(&dev->pdev->dev, "host buffer is not empty");
524
525 dev_dbg(&dev->pdev->dev, "No flow control credentials, "
526 "so add iamthif cb to write list.\n");
Tomas Winkler441ab502011-12-13 23:39:34 +0200527 list_add_tail(&cb->cb_list, &dev->write_list.mei_cb.cb_list);
Oren Weilab841162011-05-15 13:43:41 +0300528 }
529 return 0;
530}
531
532/**
533 * iamthif_ioctl_send_msg - send cmd data to amthi client
534 *
535 * @dev: the device structure
536 *
537 * returns 0 on success, <0 on failure.
538 */
Tomas Winklerc95efb72011-05-25 17:28:21 +0300539void mei_run_next_iamthif_cmd(struct mei_device *dev)
Oren Weilab841162011-05-15 13:43:41 +0300540{
541 struct mei_cl *cl_tmp;
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200542 struct mei_cl_cb *pos = NULL;
543 struct mei_cl_cb *next = NULL;
Oren Weilab841162011-05-15 13:43:41 +0300544 int status;
545
546 if (!dev)
547 return;
548
549 dev->iamthif_msg_buf_size = 0;
550 dev->iamthif_msg_buf_index = 0;
Tomas Winklereb9af0a2011-05-25 17:28:22 +0300551 dev->iamthif_canceled = false;
552 dev->iamthif_ioctl = true;
Oren Weilab841162011-05-15 13:43:41 +0300553 dev->iamthif_state = MEI_IAMTHIF_IDLE;
554 dev->iamthif_timer = 0;
555 dev->iamthif_file_object = NULL;
556
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200557 dev_dbg(&dev->pdev->dev, "complete amthi cmd_list cb.\n");
Oren Weilab841162011-05-15 13:43:41 +0300558
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200559 list_for_each_entry_safe(pos, next,
560 &dev->amthi_cmd_list.mei_cb.cb_list, cb_list) {
561 list_del(&pos->cb_list);
562 cl_tmp = (struct mei_cl *)pos->file_private;
Oren Weilab841162011-05-15 13:43:41 +0300563
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200564 if (cl_tmp && cl_tmp == &dev->iamthif_cl) {
565 status = amthi_write(dev, pos);
566 if (status) {
567 dev_dbg(&dev->pdev->dev,
568 "amthi write failed status = %d\n",
569 status);
570 return;
Oren Weilab841162011-05-15 13:43:41 +0300571 }
Tomas Winklerb7cd2d92011-11-27 21:43:34 +0200572 break;
Oren Weilab841162011-05-15 13:43:41 +0300573 }
574 }
575}
576
577/**
578 * mei_free_cb_private - free mei_cb_private related memory
579 *
580 * @cb: mei callback struct
581 */
582void mei_free_cb_private(struct mei_cl_cb *cb)
583{
584 if (cb == NULL)
585 return;
586
587 kfree(cb->request_buffer.data);
588 kfree(cb->response_buffer.data);
589 kfree(cb);
590}