client.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*
  2. *
  3. * Intel Management Engine Interface (Intel MEI) Linux driver
  4. * Copyright (c) 2003-2012, 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. */
  16. #include <linux/pci.h>
  17. #include <linux/sched.h>
  18. #include <linux/wait.h>
  19. #include <linux/delay.h>
  20. #include <linux/mei.h>
  21. #include "mei_dev.h"
  22. #include "hbm.h"
  23. #include "client.h"
  24. /**
  25. * mei_me_cl_by_uuid - locate index of me client
  26. *
  27. * @dev: mei device
  28. * returns me client index or -ENOENT if not found
  29. */
  30. int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid)
  31. {
  32. int i, res = -ENOENT;
  33. for (i = 0; i < dev->me_clients_num; ++i)
  34. if (uuid_le_cmp(*uuid,
  35. dev->me_clients[i].props.protocol_name) == 0) {
  36. res = i;
  37. break;
  38. }
  39. return res;
  40. }
  41. /**
  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. */
  51. int mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
  52. {
  53. int i;
  54. for (i = 0; i < dev->me_clients_num; i++)
  55. if (dev->me_clients[i].client_id == client_id)
  56. break;
  57. if (WARN_ON(dev->me_clients[i].client_id != client_id))
  58. return -ENOENT;
  59. if (i == dev->me_clients_num)
  60. return -ENOENT;
  61. return i;
  62. }
  63. /**
  64. * mei_io_list_flush - removes list entry belonging to cl.
  65. *
  66. * @list: An instance of our list structure
  67. * @cl: host client
  68. */
  69. void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl)
  70. {
  71. struct mei_cl_cb *cb;
  72. struct mei_cl_cb *next;
  73. list_for_each_entry_safe(cb, next, &list->list, list) {
  74. if (cb->cl && mei_cl_cmp_id(cl, cb->cl))
  75. list_del(&cb->list);
  76. }
  77. }
  78. /**
  79. * mei_io_cb_free - free mei_cb_private related memory
  80. *
  81. * @cb: mei callback struct
  82. */
  83. void mei_io_cb_free(struct mei_cl_cb *cb)
  84. {
  85. if (cb == NULL)
  86. return;
  87. kfree(cb->request_buffer.data);
  88. kfree(cb->response_buffer.data);
  89. kfree(cb);
  90. }
  91. /**
  92. * mei_io_cb_init - allocate and initialize io callback
  93. *
  94. * @cl - mei client
  95. * @file: pointer to file structure
  96. *
  97. * returns mei_cl_cb pointer or NULL;
  98. */
  99. struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, struct file *fp)
  100. {
  101. struct mei_cl_cb *cb;
  102. cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
  103. if (!cb)
  104. return NULL;
  105. mei_io_list_init(cb);
  106. cb->file_object = fp;
  107. cb->cl = cl;
  108. cb->buf_idx = 0;
  109. return cb;
  110. }
  111. /**
  112. * mei_io_cb_alloc_req_buf - allocate request buffer
  113. *
  114. * @cb - io callback structure
  115. * @size: size of the buffer
  116. *
  117. * returns 0 on success
  118. * -EINVAL if cb is NULL
  119. * -ENOMEM if allocation failed
  120. */
  121. int mei_io_cb_alloc_req_buf(struct mei_cl_cb *cb, size_t length)
  122. {
  123. if (!cb)
  124. return -EINVAL;
  125. if (length == 0)
  126. return 0;
  127. cb->request_buffer.data = kmalloc(length, GFP_KERNEL);
  128. if (!cb->request_buffer.data)
  129. return -ENOMEM;
  130. cb->request_buffer.size = length;
  131. return 0;
  132. }
  133. /**
  134. * mei_io_cb_alloc_req_buf - allocate respose buffer
  135. *
  136. * @cb - io callback structure
  137. * @size: size of the buffer
  138. *
  139. * returns 0 on success
  140. * -EINVAL if cb is NULL
  141. * -ENOMEM if allocation failed
  142. */
  143. int mei_io_cb_alloc_resp_buf(struct mei_cl_cb *cb, size_t length)
  144. {
  145. if (!cb)
  146. return -EINVAL;
  147. if (length == 0)
  148. return 0;
  149. cb->response_buffer.data = kmalloc(length, GFP_KERNEL);
  150. if (!cb->response_buffer.data)
  151. return -ENOMEM;
  152. cb->response_buffer.size = length;
  153. return 0;
  154. }
  155. /**
  156. * mei_cl_flush_queues - flushes queue lists belonging to cl.
  157. *
  158. * @dev: the device structure
  159. * @cl: host client
  160. */
  161. int mei_cl_flush_queues(struct mei_cl *cl)
  162. {
  163. if (WARN_ON(!cl || !cl->dev))
  164. return -EINVAL;
  165. dev_dbg(&cl->dev->pdev->dev, "remove list entry belonging to cl\n");
  166. mei_io_list_flush(&cl->dev->read_list, cl);
  167. mei_io_list_flush(&cl->dev->write_list, cl);
  168. mei_io_list_flush(&cl->dev->write_waiting_list, cl);
  169. mei_io_list_flush(&cl->dev->ctrl_wr_list, cl);
  170. mei_io_list_flush(&cl->dev->ctrl_rd_list, cl);
  171. mei_io_list_flush(&cl->dev->amthif_cmd_list, cl);
  172. mei_io_list_flush(&cl->dev->amthif_rd_complete_list, cl);
  173. return 0;
  174. }
  175. /**
  176. * mei_cl_init - initializes intialize cl.
  177. *
  178. * @cl: host client to be initialized
  179. * @dev: mei device
  180. */
  181. void mei_cl_init(struct mei_cl *cl, struct mei_device *dev)
  182. {
  183. memset(cl, 0, sizeof(struct mei_cl));
  184. init_waitqueue_head(&cl->wait);
  185. init_waitqueue_head(&cl->rx_wait);
  186. init_waitqueue_head(&cl->tx_wait);
  187. INIT_LIST_HEAD(&cl->link);
  188. cl->reading_state = MEI_IDLE;
  189. cl->writing_state = MEI_IDLE;
  190. cl->dev = dev;
  191. }
  192. /**
  193. * mei_cl_allocate - allocates cl structure and sets it up.
  194. *
  195. * @dev: mei device
  196. * returns The allocated file or NULL on failure
  197. */
  198. struct mei_cl *mei_cl_allocate(struct mei_device *dev)
  199. {
  200. struct mei_cl *cl;
  201. cl = kmalloc(sizeof(struct mei_cl), GFP_KERNEL);
  202. if (!cl)
  203. return NULL;
  204. mei_cl_init(cl, dev);
  205. return cl;
  206. }
  207. /**
  208. * mei_cl_find_read_cb - find this cl's callback in the read list
  209. *
  210. * @dev: device structure
  211. * returns cb on success, NULL on error
  212. */
  213. struct mei_cl_cb *mei_cl_find_read_cb(struct mei_cl *cl)
  214. {
  215. struct mei_device *dev = cl->dev;
  216. struct mei_cl_cb *cb = NULL;
  217. struct mei_cl_cb *next = NULL;
  218. list_for_each_entry_safe(cb, next, &dev->read_list.list, list)
  219. if (mei_cl_cmp_id(cl, cb->cl))
  220. return cb;
  221. return NULL;
  222. }
  223. /** mei_cl_link: allocte host id in the host map
  224. *
  225. * @cl - host client
  226. * @id - fixed host id or -1 for genereting one
  227. * returns 0 on success
  228. * -EINVAL on incorrect values
  229. * -ENONET if client not found
  230. */
  231. int mei_cl_link(struct mei_cl *cl, int id)
  232. {
  233. struct mei_device *dev;
  234. if (WARN_ON(!cl || !cl->dev))
  235. return -EINVAL;
  236. dev = cl->dev;
  237. /* If Id is not asigned get one*/
  238. if (id == MEI_HOST_CLIENT_ID_ANY)
  239. id = find_first_zero_bit(dev->host_clients_map,
  240. MEI_CLIENTS_MAX);
  241. if (id >= MEI_CLIENTS_MAX) {
  242. dev_err(&dev->pdev->dev, "id exceded %d", MEI_CLIENTS_MAX) ;
  243. return -ENOENT;
  244. }
  245. dev->open_handle_count++;
  246. cl->host_client_id = id;
  247. list_add_tail(&cl->link, &dev->file_list);
  248. set_bit(id, dev->host_clients_map);
  249. cl->state = MEI_FILE_INITIALIZING;
  250. dev_dbg(&dev->pdev->dev, "link cl host id = %d\n", cl->host_client_id);
  251. return 0;
  252. }
  253. /**
  254. * mei_cl_unlink - remove me_cl from the list
  255. *
  256. * @dev: the device structure
  257. */
  258. int mei_cl_unlink(struct mei_cl *cl)
  259. {
  260. struct mei_device *dev;
  261. struct mei_cl *pos, *next;
  262. /* don't shout on error exit path */
  263. if (!cl)
  264. return 0;
  265. /* wd and amthif might not be initialized */
  266. if (!cl->dev)
  267. return 0;
  268. dev = cl->dev;
  269. list_for_each_entry_safe(pos, next, &dev->file_list, link) {
  270. if (cl->host_client_id == pos->host_client_id) {
  271. dev_dbg(&dev->pdev->dev, "remove host client = %d, ME client = %d\n",
  272. pos->host_client_id, pos->me_client_id);
  273. list_del_init(&pos->link);
  274. break;
  275. }
  276. }
  277. return 0;
  278. }
  279. void mei_host_client_init(struct work_struct *work)
  280. {
  281. struct mei_device *dev = container_of(work,
  282. struct mei_device, init_work);
  283. struct mei_client_properties *client_props;
  284. int i;
  285. mutex_lock(&dev->device_lock);
  286. bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX);
  287. dev->open_handle_count = 0;
  288. /*
  289. * Reserving the first three client IDs
  290. * 0: Reserved for MEI Bus Message communications
  291. * 1: Reserved for Watchdog
  292. * 2: Reserved for AMTHI
  293. */
  294. bitmap_set(dev->host_clients_map, 0, 3);
  295. for (i = 0; i < dev->me_clients_num; i++) {
  296. client_props = &dev->me_clients[i].props;
  297. if (!uuid_le_cmp(client_props->protocol_name, mei_amthif_guid))
  298. mei_amthif_host_init(dev);
  299. else if (!uuid_le_cmp(client_props->protocol_name, mei_wd_guid))
  300. mei_wd_host_init(dev);
  301. }
  302. dev->dev_state = MEI_DEV_ENABLED;
  303. mutex_unlock(&dev->device_lock);
  304. }
  305. /**
  306. * mei_cl_disconnect - disconnect host clinet form the me one
  307. *
  308. * @cl: host client
  309. *
  310. * Locking: called under "dev->device_lock" lock
  311. *
  312. * returns 0 on success, <0 on failure.
  313. */
  314. int mei_cl_disconnect(struct mei_cl *cl)
  315. {
  316. struct mei_device *dev;
  317. struct mei_cl_cb *cb;
  318. int rets, err;
  319. if (WARN_ON(!cl || !cl->dev))
  320. return -ENODEV;
  321. dev = cl->dev;
  322. if (cl->state != MEI_FILE_DISCONNECTING)
  323. return 0;
  324. cb = mei_io_cb_init(cl, NULL);
  325. if (!cb)
  326. return -ENOMEM;
  327. cb->fop_type = MEI_FOP_CLOSE;
  328. if (dev->hbuf_is_ready) {
  329. dev->hbuf_is_ready = false;
  330. if (mei_hbm_cl_disconnect_req(dev, cl)) {
  331. rets = -ENODEV;
  332. dev_err(&dev->pdev->dev, "failed to disconnect.\n");
  333. goto free;
  334. }
  335. mdelay(10); /* Wait for hardware disconnection ready */
  336. list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
  337. } else {
  338. dev_dbg(&dev->pdev->dev, "add disconnect cb to control write list\n");
  339. list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
  340. }
  341. mutex_unlock(&dev->device_lock);
  342. err = wait_event_timeout(dev->wait_recvd_msg,
  343. MEI_FILE_DISCONNECTED == cl->state,
  344. mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT));
  345. mutex_lock(&dev->device_lock);
  346. if (MEI_FILE_DISCONNECTED == cl->state) {
  347. rets = 0;
  348. dev_dbg(&dev->pdev->dev, "successfully disconnected from FW client.\n");
  349. } else {
  350. rets = -ENODEV;
  351. if (MEI_FILE_DISCONNECTED != cl->state)
  352. dev_dbg(&dev->pdev->dev, "wrong status client disconnect.\n");
  353. if (err)
  354. dev_dbg(&dev->pdev->dev,
  355. "wait failed disconnect err=%08x\n",
  356. err);
  357. dev_dbg(&dev->pdev->dev, "failed to disconnect from FW client.\n");
  358. }
  359. mei_io_list_flush(&dev->ctrl_rd_list, cl);
  360. mei_io_list_flush(&dev->ctrl_wr_list, cl);
  361. free:
  362. mei_io_cb_free(cb);
  363. return rets;
  364. }
  365. /**
  366. * mei_cl_is_other_connecting - checks if other
  367. * client with the same me client id is connecting
  368. *
  369. * @cl: private data of the file object
  370. *
  371. * returns ture if other client is connected, 0 - otherwise.
  372. */
  373. bool mei_cl_is_other_connecting(struct mei_cl *cl)
  374. {
  375. struct mei_device *dev;
  376. struct mei_cl *pos;
  377. struct mei_cl *next;
  378. if (WARN_ON(!cl || !cl->dev))
  379. return false;
  380. dev = cl->dev;
  381. list_for_each_entry_safe(pos, next, &dev->file_list, link) {
  382. if ((pos->state == MEI_FILE_CONNECTING) &&
  383. (pos != cl) && cl->me_client_id == pos->me_client_id)
  384. return true;
  385. }
  386. return false;
  387. }
  388. /**
  389. * mei_cl_connect - connect host clinet to the me one
  390. *
  391. * @cl: host client
  392. *
  393. * Locking: called under "dev->device_lock" lock
  394. *
  395. * returns 0 on success, <0 on failure.
  396. */
  397. int mei_cl_connect(struct mei_cl *cl, struct file *file)
  398. {
  399. struct mei_device *dev;
  400. struct mei_cl_cb *cb;
  401. long timeout = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT);
  402. int rets;
  403. if (WARN_ON(!cl || !cl->dev))
  404. return -ENODEV;
  405. dev = cl->dev;
  406. cb = mei_io_cb_init(cl, file);
  407. if (!cb) {
  408. rets = -ENOMEM;
  409. goto out;
  410. }
  411. cb->fop_type = MEI_FOP_IOCTL;
  412. if (dev->hbuf_is_ready && !mei_cl_is_other_connecting(cl)) {
  413. dev->hbuf_is_ready = false;
  414. if (mei_hbm_cl_connect_req(dev, cl)) {
  415. rets = -ENODEV;
  416. goto out;
  417. }
  418. cl->timer_count = MEI_CONNECT_TIMEOUT;
  419. list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
  420. } else {
  421. list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
  422. }
  423. mutex_unlock(&dev->device_lock);
  424. rets = wait_event_timeout(dev->wait_recvd_msg,
  425. (cl->state == MEI_FILE_CONNECTED ||
  426. cl->state == MEI_FILE_DISCONNECTED),
  427. timeout * HZ);
  428. mutex_lock(&dev->device_lock);
  429. if (cl->state != MEI_FILE_CONNECTED) {
  430. rets = -EFAULT;
  431. mei_io_list_flush(&dev->ctrl_rd_list, cl);
  432. mei_io_list_flush(&dev->ctrl_wr_list, cl);
  433. goto out;
  434. }
  435. rets = cl->status;
  436. out:
  437. mei_io_cb_free(cb);
  438. return rets;
  439. }
  440. /**
  441. * mei_cl_flow_ctrl_creds - checks flow_control credits for cl.
  442. *
  443. * @dev: the device structure
  444. * @cl: private data of the file object
  445. *
  446. * returns 1 if mei_flow_ctrl_creds >0, 0 - otherwise.
  447. * -ENOENT if mei_cl is not present
  448. * -EINVAL if single_recv_buf == 0
  449. */
  450. int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
  451. {
  452. struct mei_device *dev;
  453. int i;
  454. if (WARN_ON(!cl || !cl->dev))
  455. return -EINVAL;
  456. dev = cl->dev;
  457. if (!dev->me_clients_num)
  458. return 0;
  459. if (cl->mei_flow_ctrl_creds > 0)
  460. return 1;
  461. for (i = 0; i < dev->me_clients_num; i++) {
  462. struct mei_me_client *me_cl = &dev->me_clients[i];
  463. if (me_cl->client_id == cl->me_client_id) {
  464. if (me_cl->mei_flow_ctrl_creds) {
  465. if (WARN_ON(me_cl->props.single_recv_buf == 0))
  466. return -EINVAL;
  467. return 1;
  468. } else {
  469. return 0;
  470. }
  471. }
  472. }
  473. return -ENOENT;
  474. }
  475. /**
  476. * mei_cl_flow_ctrl_reduce - reduces flow_control.
  477. *
  478. * @dev: the device structure
  479. * @cl: private data of the file object
  480. * @returns
  481. * 0 on success
  482. * -ENOENT when me client is not found
  483. * -EINVAL when ctrl credits are <= 0
  484. */
  485. int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
  486. {
  487. struct mei_device *dev;
  488. int i;
  489. if (WARN_ON(!cl || !cl->dev))
  490. return -EINVAL;
  491. dev = cl->dev;
  492. if (!dev->me_clients_num)
  493. return -ENOENT;
  494. for (i = 0; i < dev->me_clients_num; i++) {
  495. struct mei_me_client *me_cl = &dev->me_clients[i];
  496. if (me_cl->client_id == cl->me_client_id) {
  497. if (me_cl->props.single_recv_buf != 0) {
  498. if (WARN_ON(me_cl->mei_flow_ctrl_creds <= 0))
  499. return -EINVAL;
  500. dev->me_clients[i].mei_flow_ctrl_creds--;
  501. } else {
  502. if (WARN_ON(cl->mei_flow_ctrl_creds <= 0))
  503. return -EINVAL;
  504. cl->mei_flow_ctrl_creds--;
  505. }
  506. return 0;
  507. }
  508. }
  509. return -ENOENT;
  510. }
  511. /**
  512. * mei_cl_start_read - the start read client message function.
  513. *
  514. * @cl: host client
  515. *
  516. * returns 0 on success, <0 on failure.
  517. */
  518. int mei_cl_read_start(struct mei_cl *cl)
  519. {
  520. struct mei_device *dev;
  521. struct mei_cl_cb *cb;
  522. int rets;
  523. int i;
  524. if (WARN_ON(!cl || !cl->dev))
  525. return -ENODEV;
  526. dev = cl->dev;
  527. if (cl->state != MEI_FILE_CONNECTED)
  528. return -ENODEV;
  529. if (dev->dev_state != MEI_DEV_ENABLED)
  530. return -ENODEV;
  531. if (cl->read_cb) {
  532. dev_dbg(&dev->pdev->dev, "read is pending.\n");
  533. return -EBUSY;
  534. }
  535. i = mei_me_cl_by_id(dev, cl->me_client_id);
  536. if (i < 0) {
  537. dev_err(&dev->pdev->dev, "no such me client %d\n",
  538. cl->me_client_id);
  539. return -ENODEV;
  540. }
  541. cb = mei_io_cb_init(cl, NULL);
  542. if (!cb)
  543. return -ENOMEM;
  544. rets = mei_io_cb_alloc_resp_buf(cb,
  545. dev->me_clients[i].props.max_msg_length);
  546. if (rets)
  547. goto err;
  548. cb->fop_type = MEI_FOP_READ;
  549. cl->read_cb = cb;
  550. if (dev->hbuf_is_ready) {
  551. dev->hbuf_is_ready = false;
  552. if (mei_hbm_cl_flow_control_req(dev, cl)) {
  553. rets = -ENODEV;
  554. goto err;
  555. }
  556. list_add_tail(&cb->list, &dev->read_list.list);
  557. } else {
  558. list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
  559. }
  560. return rets;
  561. err:
  562. mei_io_cb_free(cb);
  563. return rets;
  564. }
  565. /**
  566. * mei_cl_all_disconnect - disconnect forcefully all connected clients
  567. *
  568. * @dev - mei device
  569. */
  570. void mei_cl_all_disconnect(struct mei_device *dev)
  571. {
  572. struct mei_cl *cl, *next;
  573. list_for_each_entry_safe(cl, next, &dev->file_list, link) {
  574. cl->state = MEI_FILE_DISCONNECTED;
  575. cl->mei_flow_ctrl_creds = 0;
  576. cl->read_cb = NULL;
  577. cl->timer_count = 0;
  578. }
  579. }
  580. /**
  581. * mei_cl_all_read_wakeup - wake up all readings so they can be interrupted
  582. *
  583. * @dev - mei device
  584. */
  585. void mei_cl_all_read_wakeup(struct mei_device *dev)
  586. {
  587. struct mei_cl *cl, *next;
  588. list_for_each_entry_safe(cl, next, &dev->file_list, link) {
  589. if (waitqueue_active(&cl->rx_wait)) {
  590. dev_dbg(&dev->pdev->dev, "Waking up client!\n");
  591. wake_up_interruptible(&cl->rx_wait);
  592. }
  593. }
  594. }
  595. /**
  596. * mei_cl_all_write_clear - clear all pending writes
  597. * @dev - mei device
  598. */
  599. void mei_cl_all_write_clear(struct mei_device *dev)
  600. {
  601. struct mei_cl_cb *cb, *next;
  602. list_for_each_entry_safe(cb, next, &dev->write_list.list, list) {
  603. list_del(&cb->list);
  604. mei_io_cb_free(cb);
  605. }
  606. }