aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2012-10-15 06:06:48 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-24 18:36:39 -0400
commitfb601adb350f82738210c0a1dc6af928a15391db (patch)
treebc230173aa912c64ca8aed863b5213a196e82ad3 /drivers/misc
parent75f0ee1559c5d51948e029041a9b722b3e3f0b83 (diff)
mei: kill usless struct mei_io_list
kill useless mei_io_list list wrapper and use directly struct mei_cl_cb mei_cb which was its only member for managing io queues Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/init.c31
-rw-r--r--drivers/misc/mei/interrupt.c134
-rw-r--r--drivers/misc/mei/iorw.c34
-rw-r--r--drivers/misc/mei/main.c43
-rw-r--r--drivers/misc/mei/mei_dev.h32
5 files changed, 118 insertions, 156 deletions
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 98f1430e3e14..2275cf03badd 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -48,34 +48,22 @@ const uuid_le mei_amthi_guid = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac,
48 0x81, 0x4c); 48 0x81, 0x4c);
49 49
50/** 50/**
51 * mei_io_list_init - Sets up a queue list.
52 *
53 * @list: An instance io list structure
54 * @dev: the device structure
55 */
56void mei_io_list_init(struct mei_io_list *list)
57{
58 /* initialize our queue list */
59 INIT_LIST_HEAD(&list->mei_cb.cb_list);
60}
61
62/**
63 * mei_io_list_flush - removes list entry belonging to cl. 51 * mei_io_list_flush - removes list entry belonging to cl.
64 * 52 *
65 * @list: An instance of our list structure 53 * @list: An instance of our list structure
66 * @cl: private data of the file object 54 * @cl: private data of the file object
67 */ 55 */
68void mei_io_list_flush(struct mei_io_list *list, struct mei_cl *cl) 56void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl)
69{ 57{
70 struct mei_cl_cb *pos; 58 struct mei_cl_cb *pos;
71 struct mei_cl_cb *next; 59 struct mei_cl_cb *next;
72 60
73 list_for_each_entry_safe(pos, next, &list->mei_cb.cb_list, cb_list) { 61 list_for_each_entry_safe(pos, next, &list->list, list) {
74 if (pos->file_private) { 62 if (pos->file_private) {
75 struct mei_cl *cl_tmp; 63 struct mei_cl *cl_tmp;
76 cl_tmp = (struct mei_cl *)pos->file_private; 64 cl_tmp = (struct mei_cl *)pos->file_private;
77 if (mei_cl_cmp_id(cl, cl_tmp)) 65 if (mei_cl_cmp_id(cl, cl_tmp))
78 list_del(&pos->cb_list); 66 list_del(&pos->list);
79 } 67 }
80 } 68 }
81} 69}
@@ -351,9 +339,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
351 } 339 }
352 } 340 }
353 /* remove all waiting requests */ 341 /* remove all waiting requests */
354 list_for_each_entry_safe(cb_pos, cb_next, 342 list_for_each_entry_safe(cb_pos, cb_next, &dev->write_list.list, list) {
355 &dev->write_list.mei_cb.cb_list, cb_list) { 343 list_del(&cb_pos->list);
356 list_del(&cb_pos->cb_list);
357 mei_free_cb_private(cb_pos); 344 mei_free_cb_private(cb_pos);
358 } 345 }
359} 346}
@@ -685,7 +672,7 @@ int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)
685 if (!cb) 672 if (!cb)
686 return -ENOMEM; 673 return -ENOMEM;
687 674
688 INIT_LIST_HEAD(&cb->cb_list); 675 mei_io_list_init(cb);
689 cb->file_private = cl; 676 cb->file_private = cl;
690 cb->major_file_operations = MEI_CLOSE; 677 cb->major_file_operations = MEI_CLOSE;
691 if (dev->mei_host_buffer_is_empty) { 678 if (dev->mei_host_buffer_is_empty) {
@@ -696,11 +683,11 @@ int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)
696 goto free; 683 goto free;
697 } 684 }
698 mdelay(10); /* Wait for hardware disconnection ready */ 685 mdelay(10); /* Wait for hardware disconnection ready */
699 list_add_tail(&cb->cb_list, &dev->ctrl_rd_list.mei_cb.cb_list); 686 list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
700 } else { 687 } else {
701 dev_dbg(&dev->pdev->dev, "add disconnect cb to control write list\n"); 688 dev_dbg(&dev->pdev->dev, "add disconnect cb to control write list\n");
702 list_add_tail(&cb->cb_list, 689 list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
703 &dev->ctrl_wr_list.mei_cb.cb_list); 690
704 } 691 }
705 mutex_unlock(&dev->device_lock); 692 mutex_unlock(&dev->device_lock);
706 693
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 320ebd2f06ce..54d6f1a1dbc9 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -87,9 +87,8 @@ static void _mei_cmpl_iamthif(struct mei_device *dev, struct mei_cl_cb *cb_pos)
87 memcpy(cb_pos->response_buffer.data, 87 memcpy(cb_pos->response_buffer.data,
88 dev->iamthif_msg_buf, 88 dev->iamthif_msg_buf,
89 dev->iamthif_msg_buf_index); 89 dev->iamthif_msg_buf_index);
90 list_add_tail(&cb_pos->cb_list, 90 list_add_tail(&cb_pos->list, &dev->amthi_read_complete_list.list);
91 &dev->amthi_read_complete_list.mei_cb.cb_list); 91 dev_dbg(&dev->pdev->dev, "amthi read completed\n");
92 dev_dbg(&dev->pdev->dev, "amthi read completed.\n");
93 dev->iamthif_timer = jiffies; 92 dev->iamthif_timer = jiffies;
94 dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n", 93 dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
95 dev->iamthif_timer); 94 dev->iamthif_timer);
@@ -112,7 +111,7 @@ static void _mei_cmpl_iamthif(struct mei_device *dev, struct mei_cl_cb *cb_pos)
112 * 111 *
113 * returns 0 on success, <0 on failure. 112 * returns 0 on success, <0 on failure.
114 */ 113 */
115static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list, 114static int mei_irq_thread_read_amthi_message(struct mei_cl_cb *complete_list,
116 struct mei_device *dev, 115 struct mei_device *dev,
117 struct mei_msg_hdr *mei_hdr) 116 struct mei_msg_hdr *mei_hdr)
118{ 117{
@@ -155,8 +154,7 @@ static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list,
155 /* found the iamthif cb */ 154 /* found the iamthif cb */
156 dev_dbg(&dev->pdev->dev, "complete the amthi read cb.\n "); 155 dev_dbg(&dev->pdev->dev, "complete the amthi read cb.\n ");
157 dev_dbg(&dev->pdev->dev, "add the amthi read cb to complete.\n "); 156 dev_dbg(&dev->pdev->dev, "add the amthi read cb to complete.\n ");
158 list_add_tail(&cb->cb_list, 157 list_add_tail(&cb->list, &complete_list->list);
159 &complete_list->mei_cb.cb_list);
160 } 158 }
161 return 0; 159 return 0;
162} 160}
@@ -188,7 +186,7 @@ static int _mei_irq_thread_state_ok(struct mei_cl *cl,
188 * 186 *
189 * returns 0 on success, <0 on failure. 187 * returns 0 on success, <0 on failure.
190 */ 188 */
191static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list, 189static int mei_irq_thread_read_client_message(struct mei_cl_cb *complete_list,
192 struct mei_device *dev, 190 struct mei_device *dev,
193 struct mei_msg_hdr *mei_hdr) 191 struct mei_msg_hdr *mei_hdr)
194{ 192{
@@ -197,11 +195,10 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
197 unsigned char *buffer = NULL; 195 unsigned char *buffer = NULL;
198 196
199 dev_dbg(&dev->pdev->dev, "start client msg\n"); 197 dev_dbg(&dev->pdev->dev, "start client msg\n");
200 if (list_empty(&dev->read_list.mei_cb.cb_list)) 198 if (list_empty(&dev->read_list.list))
201 goto quit; 199 goto quit;
202 200
203 list_for_each_entry_safe(cb_pos, cb_next, 201 list_for_each_entry_safe(cb_pos, cb_next, &dev->read_list.list, list) {
204 &dev->read_list.mei_cb.cb_list, cb_list) {
205 cl = (struct mei_cl *)cb_pos->file_private; 202 cl = (struct mei_cl *)cb_pos->file_private;
206 if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) { 203 if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
207 cl->reading_state = MEI_READING; 204 cl->reading_state = MEI_READING;
@@ -210,7 +207,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
210 if (cb_pos->response_buffer.size < 207 if (cb_pos->response_buffer.size <
211 mei_hdr->length + cb_pos->buf_idx) { 208 mei_hdr->length + cb_pos->buf_idx) {
212 dev_dbg(&dev->pdev->dev, "message overflow.\n"); 209 dev_dbg(&dev->pdev->dev, "message overflow.\n");
213 list_del(&cb_pos->cb_list); 210 list_del(&cb_pos->list);
214 return -ENOMEM; 211 return -ENOMEM;
215 } 212 }
216 if (buffer) 213 if (buffer)
@@ -219,15 +216,15 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
219 cb_pos->buf_idx += mei_hdr->length; 216 cb_pos->buf_idx += mei_hdr->length;
220 if (mei_hdr->msg_complete) { 217 if (mei_hdr->msg_complete) {
221 cl->status = 0; 218 cl->status = 0;
222 list_del(&cb_pos->cb_list); 219 list_del(&cb_pos->list);
223 dev_dbg(&dev->pdev->dev, 220 dev_dbg(&dev->pdev->dev,
224 "completed read H cl = %d, ME cl = %d, length = %lu\n", 221 "completed read H cl = %d, ME cl = %d, length = %lu\n",
225 cl->host_client_id, 222 cl->host_client_id,
226 cl->me_client_id, 223 cl->me_client_id,
227 cb_pos->buf_idx); 224 cb_pos->buf_idx);
228 225
229 list_add_tail(&cb_pos->cb_list, 226 list_add_tail(&cb_pos->list,
230 &complete_list->mei_cb.cb_list); 227 &complete_list->list);
231 } 228 }
232 229
233 break; 230 break;
@@ -291,7 +288,7 @@ static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
291static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots, 288static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
292 struct mei_cl_cb *cb_pos, 289 struct mei_cl_cb *cb_pos,
293 struct mei_cl *cl, 290 struct mei_cl *cl,
294 struct mei_io_list *cmpl_list) 291 struct mei_cl_cb *cmpl_list)
295{ 292{
296 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) + 293 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
297 sizeof(struct hbm_client_disconnect_request))) 294 sizeof(struct hbm_client_disconnect_request)))
@@ -302,15 +299,13 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
302 if (mei_disconnect(dev, cl)) { 299 if (mei_disconnect(dev, cl)) {
303 cl->status = 0; 300 cl->status = 0;
304 cb_pos->buf_idx = 0; 301 cb_pos->buf_idx = 0;
305 list_move_tail(&cb_pos->cb_list, 302 list_move_tail(&cb_pos->list, &cmpl_list->list);
306 &cmpl_list->mei_cb.cb_list);
307 return -EMSGSIZE; 303 return -EMSGSIZE;
308 } else { 304 } else {
309 cl->state = MEI_FILE_DISCONNECTING; 305 cl->state = MEI_FILE_DISCONNECTING;
310 cl->status = 0; 306 cl->status = 0;
311 cb_pos->buf_idx = 0; 307 cb_pos->buf_idx = 0;
312 list_move_tail(&cb_pos->cb_list, 308 list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
313 &dev->ctrl_rd_list.mei_cb.cb_list);
314 cl->timer_count = MEI_CONNECT_TIMEOUT; 309 cl->timer_count = MEI_CONNECT_TIMEOUT;
315 } 310 }
316 311
@@ -357,7 +352,7 @@ static void mei_client_connect_response(struct mei_device *dev,
357{ 352{
358 353
359 struct mei_cl *cl; 354 struct mei_cl *cl;
360 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL; 355 struct mei_cl_cb *pos = NULL, *next = NULL;
361 356
362 dev_dbg(&dev->pdev->dev, 357 dev_dbg(&dev->pdev->dev,
363 "connect_response:\n" 358 "connect_response:\n"
@@ -383,17 +378,16 @@ static void mei_client_connect_response(struct mei_device *dev,
383 dev->iamthif_state = MEI_IAMTHIF_IDLE; 378 dev->iamthif_state = MEI_IAMTHIF_IDLE;
384 return; 379 return;
385 } 380 }
386 list_for_each_entry_safe(cb_pos, cb_next, 381 list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
387 &dev->ctrl_rd_list.mei_cb.cb_list, cb_list) {
388 382
389 cl = (struct mei_cl *)cb_pos->file_private; 383 cl = (struct mei_cl *)pos->file_private;
390 if (!cl) { 384 if (!cl) {
391 list_del(&cb_pos->cb_list); 385 list_del(&pos->list);
392 return; 386 return;
393 } 387 }
394 if (MEI_IOCTL == cb_pos->major_file_operations) { 388 if (MEI_IOCTL == pos->major_file_operations) {
395 if (is_treat_specially_client(cl, rs)) { 389 if (is_treat_specially_client(cl, rs)) {
396 list_del(&cb_pos->cb_list); 390 list_del(&pos->list);
397 cl->status = 0; 391 cl->status = 0;
398 cl->timer_count = 0; 392 cl->timer_count = 0;
399 break; 393 break;
@@ -412,7 +406,7 @@ static void mei_client_disconnect_response(struct mei_device *dev,
412 struct hbm_client_connect_response *rs) 406 struct hbm_client_connect_response *rs)
413{ 407{
414 struct mei_cl *cl; 408 struct mei_cl *cl;
415 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL; 409 struct mei_cl_cb *pos = NULL, *next = NULL;
416 410
417 dev_dbg(&dev->pdev->dev, 411 dev_dbg(&dev->pdev->dev,
418 "disconnect_response:\n" 412 "disconnect_response:\n"
@@ -423,12 +417,11 @@ static void mei_client_disconnect_response(struct mei_device *dev,
423 rs->host_addr, 417 rs->host_addr,
424 rs->status); 418 rs->status);
425 419
426 list_for_each_entry_safe(cb_pos, cb_next, 420 list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) {
427 &dev->ctrl_rd_list.mei_cb.cb_list, cb_list) { 421 cl = (struct mei_cl *)pos->file_private;
428 cl = (struct mei_cl *)cb_pos->file_private;
429 422
430 if (!cl) { 423 if (!cl) {
431 list_del(&cb_pos->cb_list); 424 list_del(&pos->list);
432 return; 425 return;
433 } 426 }
434 427
@@ -436,7 +429,7 @@ static void mei_client_disconnect_response(struct mei_device *dev,
436 if (cl->host_client_id == rs->host_addr && 429 if (cl->host_client_id == rs->host_addr &&
437 cl->me_client_id == rs->me_addr) { 430 cl->me_client_id == rs->me_addr) {
438 431
439 list_del(&cb_pos->cb_list); 432 list_del(&pos->list);
440 if (!rs->status) 433 if (!rs->status)
441 cl->state = MEI_FILE_DISCONNECTED; 434 cl->state = MEI_FILE_DISCONNECTED;
442 435
@@ -822,12 +815,12 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
822static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots, 815static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
823 struct mei_cl_cb *cb_pos, 816 struct mei_cl_cb *cb_pos,
824 struct mei_cl *cl, 817 struct mei_cl *cl,
825 struct mei_io_list *cmpl_list) 818 struct mei_cl_cb *cmpl_list)
826{ 819{
827 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) + 820 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
828 sizeof(struct hbm_flow_control))) { 821 sizeof(struct hbm_flow_control))) {
829 /* return the cancel routine */ 822 /* return the cancel routine */
830 list_del(&cb_pos->cb_list); 823 list_del(&cb_pos->list);
831 return -EBADMSG; 824 return -EBADMSG;
832 } 825 }
833 826
@@ -836,10 +829,10 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
836 if (mei_send_flow_control(dev, cl)) { 829 if (mei_send_flow_control(dev, cl)) {
837 cl->status = -ENODEV; 830 cl->status = -ENODEV;
838 cb_pos->buf_idx = 0; 831 cb_pos->buf_idx = 0;
839 list_move_tail(&cb_pos->cb_list, &cmpl_list->mei_cb.cb_list); 832 list_move_tail(&cb_pos->list, &cmpl_list->list);
840 return -ENODEV; 833 return -ENODEV;
841 } 834 }
842 list_move_tail(&cb_pos->cb_list, &dev->read_list.mei_cb.cb_list); 835 list_move_tail(&cb_pos->list, &dev->read_list.list);
843 836
844 return 0; 837 return 0;
845} 838}
@@ -859,12 +852,12 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
859static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots, 852static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
860 struct mei_cl_cb *cb_pos, 853 struct mei_cl_cb *cb_pos,
861 struct mei_cl *cl, 854 struct mei_cl *cl,
862 struct mei_io_list *cmpl_list) 855 struct mei_cl_cb *cmpl_list)
863{ 856{
864 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) + 857 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) +
865 sizeof(struct hbm_client_connect_request))) { 858 sizeof(struct hbm_client_connect_request))) {
866 /* return the cancel routine */ 859 /* return the cancel routine */
867 list_del(&cb_pos->cb_list); 860 list_del(&cb_pos->list);
868 return -EBADMSG; 861 return -EBADMSG;
869 } 862 }
870 863
@@ -873,11 +866,10 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
873 if (mei_connect(dev, cl)) { 866 if (mei_connect(dev, cl)) {
874 cl->status = -ENODEV; 867 cl->status = -ENODEV;
875 cb_pos->buf_idx = 0; 868 cb_pos->buf_idx = 0;
876 list_del(&cb_pos->cb_list); 869 list_del(&cb_pos->list);
877 return -ENODEV; 870 return -ENODEV;
878 } else { 871 } else {
879 list_move_tail(&cb_pos->cb_list, 872 list_move_tail(&cb_pos->list, &dev->ctrl_rd_list.list);
880 &dev->ctrl_rd_list.mei_cb.cb_list);
881 cl->timer_count = MEI_CONNECT_TIMEOUT; 873 cl->timer_count = MEI_CONNECT_TIMEOUT;
882 } 874 }
883 return 0; 875 return 0;
@@ -897,7 +889,7 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
897static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots, 889static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
898 struct mei_cl_cb *cb_pos, 890 struct mei_cl_cb *cb_pos,
899 struct mei_cl *cl, 891 struct mei_cl *cl,
900 struct mei_io_list *cmpl_list) 892 struct mei_cl_cb *cmpl_list)
901{ 893{
902 struct mei_msg_hdr *mei_hdr; 894 struct mei_msg_hdr *mei_hdr;
903 895
@@ -924,16 +916,14 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
924 cb_pos->buf_idx), 916 cb_pos->buf_idx),
925 mei_hdr->length)) { 917 mei_hdr->length)) {
926 cl->status = -ENODEV; 918 cl->status = -ENODEV;
927 list_move_tail(&cb_pos->cb_list, 919 list_move_tail(&cb_pos->list, &cmpl_list->list);
928 &cmpl_list->mei_cb.cb_list);
929 return -ENODEV; 920 return -ENODEV;
930 } else { 921 } else {
931 if (mei_flow_ctrl_reduce(dev, cl)) 922 if (mei_flow_ctrl_reduce(dev, cl))
932 return -ENODEV; 923 return -ENODEV;
933 cl->status = 0; 924 cl->status = 0;
934 cb_pos->buf_idx += mei_hdr->length; 925 cb_pos->buf_idx += mei_hdr->length;
935 list_move_tail(&cb_pos->cb_list, 926 list_move_tail(&cb_pos->list, &dev->write_waiting_list.list);
936 &dev->write_waiting_list.mei_cb.cb_list);
937 } 927 }
938 } else if (*slots == dev->hbuf_depth) { 928 } else if (*slots == dev->hbuf_depth) {
939 /* buffer is still empty */ 929 /* buffer is still empty */
@@ -951,8 +941,7 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
951 cb_pos->buf_idx), 941 cb_pos->buf_idx),
952 mei_hdr->length)) { 942 mei_hdr->length)) {
953 cl->status = -ENODEV; 943 cl->status = -ENODEV;
954 list_move_tail(&cb_pos->cb_list, 944 list_move_tail(&cb_pos->list, &cmpl_list->list);
955 &cmpl_list->mei_cb.cb_list);
956 return -ENODEV; 945 return -ENODEV;
957 } else { 946 } else {
958 cb_pos->buf_idx += mei_hdr->length; 947 cb_pos->buf_idx += mei_hdr->length;
@@ -988,7 +977,7 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
988static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots, 977static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
989 struct mei_cl_cb *cb_pos, 978 struct mei_cl_cb *cb_pos,
990 struct mei_cl *cl, 979 struct mei_cl *cl,
991 struct mei_io_list *cmpl_list) 980 struct mei_cl_cb *cmpl_list)
992{ 981{
993 struct mei_msg_hdr *mei_hdr; 982 struct mei_msg_hdr *mei_hdr;
994 983
@@ -1011,7 +1000,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
1011 mei_hdr->length)) { 1000 mei_hdr->length)) {
1012 dev->iamthif_state = MEI_IAMTHIF_IDLE; 1001 dev->iamthif_state = MEI_IAMTHIF_IDLE;
1013 cl->status = -ENODEV; 1002 cl->status = -ENODEV;
1014 list_del(&cb_pos->cb_list); 1003 list_del(&cb_pos->list);
1015 return -ENODEV; 1004 return -ENODEV;
1016 } else { 1005 } else {
1017 if (mei_flow_ctrl_reduce(dev, cl)) 1006 if (mei_flow_ctrl_reduce(dev, cl))
@@ -1023,8 +1012,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
1023 dev->iamthif_flow_control_pending = true; 1012 dev->iamthif_flow_control_pending = true;
1024 /* save iamthif cb sent to amthi client */ 1013 /* save iamthif cb sent to amthi client */
1025 dev->iamthif_current_cb = cb_pos; 1014 dev->iamthif_current_cb = cb_pos;
1026 list_move_tail(&cb_pos->cb_list, 1015 list_move_tail(&cb_pos->list, &dev->write_waiting_list.list);
1027 &dev->write_waiting_list.mei_cb.cb_list);
1028 1016
1029 } 1017 }
1030 } else if (*slots == dev->hbuf_depth) { 1018 } else if (*slots == dev->hbuf_depth) {
@@ -1044,7 +1032,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
1044 dev->iamthif_msg_buf_index), 1032 dev->iamthif_msg_buf_index),
1045 mei_hdr->length)) { 1033 mei_hdr->length)) {
1046 cl->status = -ENODEV; 1034 cl->status = -ENODEV;
1047 list_del(&cb_pos->cb_list); 1035 list_del(&cb_pos->list);
1048 } else { 1036 } else {
1049 dev->iamthif_msg_buf_index += mei_hdr->length; 1037 dev->iamthif_msg_buf_index += mei_hdr->length;
1050 } 1038 }
@@ -1066,7 +1054,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
1066 * 1054 *
1067 * returns 0 on success, <0 on failure. 1055 * returns 0 on success, <0 on failure.
1068 */ 1056 */
1069static int mei_irq_thread_read_handler(struct mei_io_list *cmpl_list, 1057static int mei_irq_thread_read_handler(struct mei_cl_cb *cmpl_list,
1070 struct mei_device *dev, 1058 struct mei_device *dev,
1071 s32 *slots) 1059 s32 *slots)
1072{ 1060{
@@ -1169,14 +1157,13 @@ end:
1169 * 1157 *
1170 * returns 0 on success, <0 on failure. 1158 * returns 0 on success, <0 on failure.
1171 */ 1159 */
1172static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, 1160static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list,
1173 struct mei_device *dev, 1161 struct mei_device *dev, s32 *slots)
1174 s32 *slots)
1175{ 1162{
1176 1163
1177 struct mei_cl *cl; 1164 struct mei_cl *cl;
1178 struct mei_cl_cb *pos = NULL, *next = NULL; 1165 struct mei_cl_cb *pos = NULL, *next = NULL;
1179 struct mei_io_list *list; 1166 struct mei_cl_cb *list;
1180 int ret; 1167 int ret;
1181 1168
1182 if (!mei_hbuf_is_empty(dev)) { 1169 if (!mei_hbuf_is_empty(dev)) {
@@ -1191,20 +1178,19 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
1191 dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n"); 1178 dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
1192 1179
1193 list = &dev->write_waiting_list; 1180 list = &dev->write_waiting_list;
1194 list_for_each_entry_safe(pos, next, &list->mei_cb.cb_list, cb_list) { 1181 list_for_each_entry_safe(pos, next, &list->list, list) {
1195 cl = (struct mei_cl *)pos->file_private; 1182 cl = (struct mei_cl *)pos->file_private;
1196 if (cl == NULL) 1183 if (cl == NULL)
1197 continue; 1184 continue;
1198 1185
1199 cl->status = 0; 1186 cl->status = 0;
1200 list_del(&pos->cb_list); 1187 list_del(&pos->list);
1201 if (MEI_WRITING == cl->writing_state && 1188 if (MEI_WRITING == cl->writing_state &&
1202 (pos->major_file_operations == MEI_WRITE) && 1189 (pos->major_file_operations == MEI_WRITE) &&
1203 (cl != &dev->iamthif_cl)) { 1190 (cl != &dev->iamthif_cl)) {
1204 dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n"); 1191 dev_dbg(&dev->pdev->dev, "MEI WRITE COMPLETE\n");
1205 cl->writing_state = MEI_WRITE_COMPLETE; 1192 cl->writing_state = MEI_WRITE_COMPLETE;
1206 list_add_tail(&pos->cb_list, 1193 list_add_tail(&pos->list, &cmpl_list->list);
1207 &cmpl_list->mei_cb.cb_list);
1208 } 1194 }
1209 if (cl == &dev->iamthif_cl) { 1195 if (cl == &dev->iamthif_cl) {
1210 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n"); 1196 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
@@ -1250,11 +1236,10 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
1250 1236
1251 /* complete control write list CB */ 1237 /* complete control write list CB */
1252 dev_dbg(&dev->pdev->dev, "complete control write list cb.\n"); 1238 dev_dbg(&dev->pdev->dev, "complete control write list cb.\n");
1253 list_for_each_entry_safe(pos, next, 1239 list_for_each_entry_safe(pos, next, &dev->ctrl_wr_list.list, list) {
1254 &dev->ctrl_wr_list.mei_cb.cb_list, cb_list) {
1255 cl = (struct mei_cl *) pos->file_private; 1240 cl = (struct mei_cl *) pos->file_private;
1256 if (!cl) { 1241 if (!cl) {
1257 list_del(&pos->cb_list); 1242 list_del(&pos->list);
1258 return -ENODEV; 1243 return -ENODEV;
1259 } 1244 }
1260 switch (pos->major_file_operations) { 1245 switch (pos->major_file_operations) {
@@ -1289,8 +1274,7 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
1289 } 1274 }
1290 /* complete write list CB */ 1275 /* complete write list CB */
1291 dev_dbg(&dev->pdev->dev, "complete write list cb.\n"); 1276 dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
1292 list_for_each_entry_safe(pos, next, 1277 list_for_each_entry_safe(pos, next, &dev->write_list.list, list) {
1293 &dev->write_list.mei_cb.cb_list, cb_list) {
1294 cl = (struct mei_cl *)pos->file_private; 1278 cl = (struct mei_cl *)pos->file_private;
1295 if (cl == NULL) 1279 if (cl == NULL)
1296 continue; 1280 continue;
@@ -1410,16 +1394,15 @@ void mei_timer(struct work_struct *work)
1410 1394
1411 dev_dbg(&dev->pdev->dev, "freeing AMTHI for other requests\n"); 1395 dev_dbg(&dev->pdev->dev, "freeing AMTHI for other requests\n");
1412 1396
1413 amthi_complete_list = &dev->amthi_read_complete_list. 1397 amthi_complete_list = &dev->amthi_read_complete_list.list;
1414 mei_cb.cb_list;
1415 1398
1416 list_for_each_entry_safe(cb_pos, cb_next, amthi_complete_list, cb_list) { 1399 list_for_each_entry_safe(cb_pos, cb_next, amthi_complete_list, list) {
1417 1400
1418 cl_pos = cb_pos->file_object->private_data; 1401 cl_pos = cb_pos->file_object->private_data;
1419 1402
1420 /* Finding the AMTHI entry. */ 1403 /* Finding the AMTHI entry. */
1421 if (cl_pos == &dev->iamthif_cl) 1404 if (cl_pos == &dev->iamthif_cl)
1422 list_del(&cb_pos->cb_list); 1405 list_del(&cb_pos->list);
1423 } 1406 }
1424 if (dev->iamthif_current_cb) 1407 if (dev->iamthif_current_cb)
1425 mei_free_cb_private(dev->iamthif_current_cb); 1408 mei_free_cb_private(dev->iamthif_current_cb);
@@ -1450,7 +1433,7 @@ out:
1450irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) 1433irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
1451{ 1434{
1452 struct mei_device *dev = (struct mei_device *) dev_id; 1435 struct mei_device *dev = (struct mei_device *) dev_id;
1453 struct mei_io_list complete_list; 1436 struct mei_cl_cb complete_list;
1454 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL; 1437 struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
1455 struct mei_cl *cl; 1438 struct mei_cl *cl;
1456 s32 slots; 1439 s32 slots;
@@ -1530,14 +1513,13 @@ end:
1530 wake_up_interruptible(&dev->wait_recvd_msg); 1513 wake_up_interruptible(&dev->wait_recvd_msg);
1531 bus_message_received = false; 1514 bus_message_received = false;
1532 } 1515 }
1533 if (list_empty(&complete_list.mei_cb.cb_list)) 1516 if (list_empty(&complete_list.list))
1534 return IRQ_HANDLED; 1517 return IRQ_HANDLED;
1535 1518
1536 1519
1537 list_for_each_entry_safe(cb_pos, cb_next, 1520 list_for_each_entry_safe(cb_pos, cb_next, &complete_list.list, list) {
1538 &complete_list.mei_cb.cb_list, cb_list) {
1539 cl = (struct mei_cl *)cb_pos->file_private; 1521 cl = (struct mei_cl *)cb_pos->file_private;
1540 list_del(&cb_pos->cb_list); 1522 list_del(&cb_pos->list);
1541 if (cl) { 1523 if (cl) {
1542 if (cl != &dev->iamthif_cl) { 1524 if (cl != &dev->iamthif_cl) {
1543 dev_dbg(&dev->pdev->dev, "completing call back.\n"); 1525 dev_dbg(&dev->pdev->dev, "completing call back.\n");
diff --git a/drivers/misc/mei/iorw.c b/drivers/misc/mei/iorw.c
index 20652e140c43..4ff9eaf2add9 100644
--- a/drivers/misc/mei/iorw.c
+++ b/drivers/misc/mei/iorw.c
@@ -104,7 +104,7 @@ int mei_ioctl_connect_client(struct file *file,
104 rets = -ENOMEM; 104 rets = -ENOMEM;
105 goto end; 105 goto end;
106 } 106 }
107 INIT_LIST_HEAD(&cb->cb_list); 107 mei_io_list_init(cb);
108 108
109 cb->major_file_operations = MEI_IOCTL; 109 cb->major_file_operations = MEI_IOCTL;
110 110
@@ -193,9 +193,7 @@ int mei_ioctl_connect_client(struct file *file,
193 dev_dbg(&dev->pdev->dev, "Sending connect message - succeeded\n"); 193 dev_dbg(&dev->pdev->dev, "Sending connect message - succeeded\n");
194 cl->timer_count = MEI_CONNECT_TIMEOUT; 194 cl->timer_count = MEI_CONNECT_TIMEOUT;
195 cb->file_private = cl; 195 cb->file_private = cl;
196 list_add_tail(&cb->cb_list, 196 list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
197 &dev->ctrl_rd_list.mei_cb.
198 cb_list);
199 } 197 }
200 198
201 199
@@ -203,8 +201,7 @@ int mei_ioctl_connect_client(struct file *file,
203 dev_dbg(&dev->pdev->dev, "Queuing the connect request due to device busy\n"); 201 dev_dbg(&dev->pdev->dev, "Queuing the connect request due to device busy\n");
204 cb->file_private = cl; 202 cb->file_private = cl;
205 dev_dbg(&dev->pdev->dev, "add connect cb to control write list.\n"); 203 dev_dbg(&dev->pdev->dev, "add connect cb to control write list.\n");
206 list_add_tail(&cb->cb_list, 204 list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
207 &dev->ctrl_wr_list.mei_cb.cb_list);
208 } 205 }
209 mutex_unlock(&dev->device_lock); 206 mutex_unlock(&dev->device_lock);
210 err = wait_event_timeout(dev->wait_recvd_msg, 207 err = wait_event_timeout(dev->wait_recvd_msg,
@@ -255,7 +252,7 @@ struct mei_cl_cb *find_amthi_read_list_entry(
255 struct mei_cl_cb *next = NULL; 252 struct mei_cl_cb *next = NULL;
256 253
257 list_for_each_entry_safe(pos, next, 254 list_for_each_entry_safe(pos, next,
258 &dev->amthi_read_complete_list.mei_cb.cb_list, cb_list) { 255 &dev->amthi_read_complete_list.list, list) {
259 cl_temp = (struct mei_cl *)pos->file_private; 256 cl_temp = (struct mei_cl *)pos->file_private;
260 if (cl_temp && cl_temp == &dev->iamthif_cl && 257 if (cl_temp && cl_temp == &dev->iamthif_cl &&
261 pos->file_object == file) 258 pos->file_object == file)
@@ -340,17 +337,17 @@ int amthi_read(struct mei_device *dev, struct file *file,
340 if (time_after(jiffies, timeout)) { 337 if (time_after(jiffies, timeout)) {
341 dev_dbg(&dev->pdev->dev, "amthi Time out\n"); 338 dev_dbg(&dev->pdev->dev, "amthi Time out\n");
342 /* 15 sec for the message has expired */ 339 /* 15 sec for the message has expired */
343 list_del(&cb->cb_list); 340 list_del(&cb->list);
344 rets = -ETIMEDOUT; 341 rets = -ETIMEDOUT;
345 goto free; 342 goto free;
346 } 343 }
347 } 344 }
348 /* if the whole message will fit remove it from the list */ 345 /* if the whole message will fit remove it from the list */
349 if (cb->buf_idx >= *offset && length >= (cb->buf_idx - *offset)) 346 if (cb->buf_idx >= *offset && length >= (cb->buf_idx - *offset))
350 list_del(&cb->cb_list); 347 list_del(&cb->list);
351 else if (cb->buf_idx > 0 && cb->buf_idx <= *offset) { 348 else if (cb->buf_idx > 0 && cb->buf_idx <= *offset) {
352 /* end of the message has been reached */ 349 /* end of the message has been reached */
353 list_del(&cb->cb_list); 350 list_del(&cb->list);
354 rets = 0; 351 rets = 0;
355 goto free; 352 goto free;
356 } 353 }
@@ -441,9 +438,9 @@ int mei_start_read(struct mei_device *dev, struct mei_cl *cl)
441 rets = -ENODEV; 438 rets = -ENODEV;
442 goto unlock; 439 goto unlock;
443 } 440 }
444 list_add_tail(&cb->cb_list, &dev->read_list.mei_cb.cb_list); 441 list_add_tail(&cb->list, &dev->read_list.list);
445 } else { 442 } else {
446 list_add_tail(&cb->cb_list, &dev->ctrl_wr_list.mei_cb.cb_list); 443 list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
447 } 444 }
448 return rets; 445 return rets;
449unlock: 446unlock:
@@ -510,13 +507,11 @@ int amthi_write(struct mei_device *dev, struct mei_cl_cb *cb)
510 dev_dbg(&dev->pdev->dev, "add amthi cb to write waiting list\n"); 507 dev_dbg(&dev->pdev->dev, "add amthi cb to write waiting list\n");
511 dev->iamthif_current_cb = cb; 508 dev->iamthif_current_cb = cb;
512 dev->iamthif_file_object = cb->file_object; 509 dev->iamthif_file_object = cb->file_object;
513 list_add_tail(&cb->cb_list, 510 list_add_tail(&cb->list, &dev->write_waiting_list.list);
514 &dev->write_waiting_list.mei_cb.cb_list);
515 } else { 511 } else {
516 dev_dbg(&dev->pdev->dev, "message does not complete, " 512 dev_dbg(&dev->pdev->dev, "message does not complete, "
517 "so add amthi cb to write list.\n"); 513 "so add amthi cb to write list.\n");
518 list_add_tail(&cb->cb_list, 514 list_add_tail(&cb->list, &dev->write_list.list);
519 &dev->write_list.mei_cb.cb_list);
520 } 515 }
521 } else { 516 } else {
522 if (!(dev->mei_host_buffer_is_empty)) 517 if (!(dev->mei_host_buffer_is_empty))
@@ -524,7 +519,7 @@ int amthi_write(struct mei_device *dev, struct mei_cl_cb *cb)
524 519
525 dev_dbg(&dev->pdev->dev, "No flow control credentials, " 520 dev_dbg(&dev->pdev->dev, "No flow control credentials, "
526 "so add iamthif cb to write list.\n"); 521 "so add iamthif cb to write list.\n");
527 list_add_tail(&cb->cb_list, &dev->write_list.mei_cb.cb_list); 522 list_add_tail(&cb->list, &dev->write_list.list);
528 } 523 }
529 return 0; 524 return 0;
530} 525}
@@ -556,9 +551,8 @@ void mei_run_next_iamthif_cmd(struct mei_device *dev)
556 551
557 dev_dbg(&dev->pdev->dev, "complete amthi cmd_list cb.\n"); 552 dev_dbg(&dev->pdev->dev, "complete amthi cmd_list cb.\n");
558 553
559 list_for_each_entry_safe(pos, next, 554 list_for_each_entry_safe(pos, next, &dev->amthi_cmd_list.list, list) {
560 &dev->amthi_cmd_list.mei_cb.cb_list, cb_list) { 555 list_del(&pos->list);
561 list_del(&pos->cb_list);
562 cl_tmp = (struct mei_cl *)pos->file_private; 556 cl_tmp = (struct mei_cl *)pos->file_private;
563 557
564 if (cl_tmp && cl_tmp == &dev->iamthif_cl) { 558 if (cl_tmp && cl_tmp == &dev->iamthif_cl) {
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 8dcf59d43b0d..2e46291b8b71 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -111,12 +111,12 @@ static bool mei_clear_list(struct mei_device *dev,
111 bool removed = false; 111 bool removed = false;
112 112
113 /* list all list member */ 113 /* list all list member */
114 list_for_each_entry_safe(cb_pos, cb_next, mei_cb_list, cb_list) { 114 list_for_each_entry_safe(cb_pos, cb_next, mei_cb_list, list) {
115 file_temp = (struct file *)cb_pos->file_object; 115 file_temp = (struct file *)cb_pos->file_object;
116 /* check if list member associated with a file */ 116 /* check if list member associated with a file */
117 if (file_temp == file) { 117 if (file_temp == file) {
118 /* remove member from the list */ 118 /* remove member from the list */
119 list_del(&cb_pos->cb_list); 119 list_del(&cb_pos->list);
120 /* check if cb equal to current iamthif cb */ 120 /* check if cb equal to current iamthif cb */
121 if (dev->iamthif_current_cb == cb_pos) { 121 if (dev->iamthif_current_cb == cb_pos) {
122 dev->iamthif_current_cb = NULL; 122 dev->iamthif_current_cb = NULL;
@@ -148,20 +148,20 @@ static bool mei_clear_lists(struct mei_device *dev, struct file *file)
148 bool removed = false; 148 bool removed = false;
149 149
150 /* remove callbacks associated with a file */ 150 /* remove callbacks associated with a file */
151 mei_clear_list(dev, file, &dev->amthi_cmd_list.mei_cb.cb_list); 151 mei_clear_list(dev, file, &dev->amthi_cmd_list.list);
152 if (mei_clear_list(dev, file, 152 if (mei_clear_list(dev, file,
153 &dev->amthi_read_complete_list.mei_cb.cb_list)) 153 &dev->amthi_read_complete_list.list))
154 removed = true; 154 removed = true;
155 155
156 mei_clear_list(dev, file, &dev->ctrl_rd_list.mei_cb.cb_list); 156 mei_clear_list(dev, file, &dev->ctrl_rd_list.list);
157 157
158 if (mei_clear_list(dev, file, &dev->ctrl_wr_list.mei_cb.cb_list)) 158 if (mei_clear_list(dev, file, &dev->ctrl_wr_list.list))
159 removed = true; 159 removed = true;
160 160
161 if (mei_clear_list(dev, file, &dev->write_waiting_list.mei_cb.cb_list)) 161 if (mei_clear_list(dev, file, &dev->write_waiting_list.list))
162 removed = true; 162 removed = true;
163 163
164 if (mei_clear_list(dev, file, &dev->write_list.mei_cb.cb_list)) 164 if (mei_clear_list(dev, file, &dev->write_list.list))
165 removed = true; 165 removed = true;
166 166
167 /* check if iamthif_current_cb not NULL */ 167 /* check if iamthif_current_cb not NULL */
@@ -192,8 +192,7 @@ static struct mei_cl_cb *find_read_list_entry(
192 struct mei_cl_cb *next = NULL; 192 struct mei_cl_cb *next = NULL;
193 193
194 dev_dbg(&dev->pdev->dev, "remove read_list CB\n"); 194 dev_dbg(&dev->pdev->dev, "remove read_list CB\n");
195 list_for_each_entry_safe(pos, next, 195 list_for_each_entry_safe(pos, next, &dev->read_list.list, list) {
196 &dev->read_list.mei_cb.cb_list, cb_list) {
197 struct mei_cl *cl_temp; 196 struct mei_cl *cl_temp;
198 cl_temp = (struct mei_cl *)pos->file_private; 197 cl_temp = (struct mei_cl *)pos->file_private;
199 198
@@ -324,7 +323,7 @@ static int mei_release(struct inode *inode, struct file *file)
324 cb = find_read_list_entry(dev, cl); 323 cb = find_read_list_entry(dev, cl);
325 /* Remove entry from read list */ 324 /* Remove entry from read list */
326 if (cb) 325 if (cb)
327 list_del(&cb->cb_list); 326 list_del(&cb->list);
328 327
329 cb = cl->read_cb; 328 cb = cl->read_cb;
330 cl->read_cb = NULL; 329 cl->read_cb = NULL;
@@ -504,7 +503,7 @@ free:
504 cb_pos = find_read_list_entry(dev, cl); 503 cb_pos = find_read_list_entry(dev, cl);
505 /* Remove entry from read list */ 504 /* Remove entry from read list */
506 if (cb_pos) 505 if (cb_pos)
507 list_del(&cb_pos->cb_list); 506 list_del(&cb_pos->list);
508 mei_free_cb_private(cb); 507 mei_free_cb_private(cb);
509 cl->reading_state = MEI_IDLE; 508 cl->reading_state = MEI_IDLE;
510 cl->read_cb = NULL; 509 cl->read_cb = NULL;
@@ -534,7 +533,7 @@ static struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, struct file *fp)
534 if (!cb) 533 if (!cb)
535 return NULL; 534 return NULL;
536 535
537 INIT_LIST_HEAD(&cb->cb_list); 536 mei_io_list_init(cb);
538 537
539 cb->file_object = fp; 538 cb->file_object = fp;
540 cb->file_private = cl; 539 cb->file_private = cl;
@@ -651,7 +650,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
651 if (time_after(jiffies, timeout) || 650 if (time_after(jiffies, timeout) ||
652 cl->reading_state == MEI_READ_COMPLETE) { 651 cl->reading_state == MEI_READ_COMPLETE) {
653 *offset = 0; 652 *offset = 0;
654 list_del(&write_cb->cb_list); 653 list_del(&write_cb->list);
655 mei_free_cb_private(write_cb); 654 mei_free_cb_private(write_cb);
656 write_cb = NULL; 655 write_cb = NULL;
657 } 656 }
@@ -663,7 +662,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
663 *offset = 0; 662 *offset = 0;
664 write_cb = find_read_list_entry(dev, cl); 663 write_cb = find_read_list_entry(dev, cl);
665 if (write_cb) { 664 if (write_cb) {
666 list_del(&write_cb->cb_list); 665 list_del(&write_cb->list);
667 mei_free_cb_private(write_cb); 666 mei_free_cb_private(write_cb);
668 write_cb = NULL; 667 write_cb = NULL;
669 cl->reading_state = MEI_IDLE; 668 cl->reading_state = MEI_IDLE;
@@ -707,13 +706,12 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
707 706
708 write_cb->major_file_operations = MEI_IOCTL; 707 write_cb->major_file_operations = MEI_IOCTL;
709 708
710 if (!list_empty(&dev->amthi_cmd_list.mei_cb.cb_list) || 709 if (!list_empty(&dev->amthi_cmd_list.list) ||
711 dev->iamthif_state != MEI_IAMTHIF_IDLE) { 710 dev->iamthif_state != MEI_IAMTHIF_IDLE) {
712 dev_dbg(&dev->pdev->dev, "amthi_state = %d\n", 711 dev_dbg(&dev->pdev->dev, "amthi_state = %d\n",
713 (int) dev->iamthif_state); 712 (int) dev->iamthif_state);
714 dev_dbg(&dev->pdev->dev, "add amthi cb to amthi cmd waiting list\n"); 713 dev_dbg(&dev->pdev->dev, "add amthi cb to amthi cmd waiting list\n");
715 list_add_tail(&write_cb->cb_list, 714 list_add_tail(&write_cb->list, &dev->amthi_cmd_list.list);
716 &dev->amthi_cmd_list.mei_cb.cb_list);
717 } else { 715 } else {
718 dev_dbg(&dev->pdev->dev, "call amthi write\n"); 716 dev_dbg(&dev->pdev->dev, "call amthi write\n");
719 rets = amthi_write(dev, write_cb); 717 rets = amthi_write(dev, write_cb);
@@ -764,19 +762,16 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
764 rets = -ENODEV; 762 rets = -ENODEV;
765 goto unlock_dev; 763 goto unlock_dev;
766 } 764 }
767 list_add_tail(&write_cb->cb_list, 765 list_add_tail(&write_cb->list, &dev->write_waiting_list.list);
768 &dev->write_waiting_list.mei_cb.cb_list);
769 } else { 766 } else {
770 list_add_tail(&write_cb->cb_list, 767 list_add_tail(&write_cb->list, &dev->write_list.list);
771 &dev->write_list.mei_cb.cb_list);
772 } 768 }
773 769
774 } else { 770 } else {
775 771
776 write_cb->buf_idx = 0; 772 write_cb->buf_idx = 0;
777 cl->writing_state = MEI_WRITING; 773 cl->writing_state = MEI_WRITING;
778 list_add_tail(&write_cb->cb_list, 774 list_add_tail(&write_cb->list, &dev->write_list.list);
779 &dev->write_list.mei_cb.cb_list);
780 } 775 }
781 mutex_unlock(&dev->device_lock); 776 mutex_unlock(&dev->device_lock);
782 return length; 777 return length;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index c58b6fa06c07..de5babc5c8ee 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -144,7 +144,7 @@ struct mei_message_data {
144 144
145 145
146struct mei_cl_cb { 146struct mei_cl_cb {
147 struct list_head cb_list; 147 struct list_head list;
148 enum mei_cb_major_types major_file_operations; 148 enum mei_cb_major_types major_file_operations;
149 void *file_private; 149 void *file_private;
150 struct mei_message_data request_buffer; 150 struct mei_message_data request_buffer;
@@ -175,10 +175,6 @@ struct mei_cl {
175 struct mei_cl_cb *read_cb; 175 struct mei_cl_cb *read_cb;
176}; 176};
177 177
178struct mei_io_list {
179 struct mei_cl_cb mei_cb;
180};
181
182/** 178/**
183 * struct mei_deive - MEI private device struct 179 * struct mei_deive - MEI private device struct
184 * @hbuf_depth - depth of host(write) buffer 180 * @hbuf_depth - depth of host(write) buffer
@@ -189,15 +185,15 @@ struct mei_device {
189 * lists of queues 185 * lists of queues
190 */ 186 */
191 /* array of pointers to aio lists */ 187 /* array of pointers to aio lists */
192 struct mei_io_list read_list; /* driver read queue */ 188 struct mei_cl_cb read_list; /* driver read queue */
193 struct mei_io_list write_list; /* driver write queue */ 189 struct mei_cl_cb write_list; /* driver write queue */
194 struct mei_io_list write_waiting_list; /* write waiting queue */ 190 struct mei_cl_cb write_waiting_list; /* write waiting queue */
195 struct mei_io_list ctrl_wr_list; /* managed write IOCTL list */ 191 struct mei_cl_cb ctrl_wr_list; /* managed write IOCTL list */
196 struct mei_io_list ctrl_rd_list; /* managed read IOCTL list */ 192 struct mei_cl_cb ctrl_rd_list; /* managed read IOCTL list */
197 struct mei_io_list amthi_cmd_list; /* amthi list for cmd waiting */ 193 struct mei_cl_cb amthi_cmd_list; /* amthi list for cmd waiting */
198 194
199 /* driver managed amthi list for reading completed amthi cmd data */ 195 /* driver managed amthi list for reading completed amthi cmd data */
200 struct mei_io_list amthi_read_complete_list; 196 struct mei_cl_cb amthi_read_complete_list;
201 /* 197 /*
202 * list of files 198 * list of files
203 */ 199 */
@@ -297,8 +293,16 @@ int mei_me_cl_by_id(struct mei_device *dev, u8 client_id);
297/* 293/*
298 * MEI IO List Functions 294 * MEI IO List Functions
299 */ 295 */
300void mei_io_list_init(struct mei_io_list *list); 296/**
301void mei_io_list_flush(struct mei_io_list *list, struct mei_cl *cl); 297 * mei_io_list_init - Sets up a queue list.
298 *
299 * @list: An instance cl callback structure
300 */
301static inline void mei_io_list_init(struct mei_cl_cb *list)
302{
303 INIT_LIST_HEAD(&list->list);
304}
305void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl);
302 306
303/* 307/*
304 * MEI ME Client Functions 308 * MEI ME Client Functions