aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2012-10-09 10:50:16 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-24 18:35:03 -0400
commitebb108ef93605a68f6f38d5eb407e7d5138e8028 (patch)
tree0dbd844bc17310a4d0fb62529ee823e80cb57c1b /drivers/misc
parent7e6735c3578e76c270a2797225a4214176ba13ef (diff)
mei: rename mei_cl_cb.information to mei_cl_cb.buf_idx
rename 'information' member of the struct mei_cl_cb to more self-descriptive 'buf_idx' 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/interrupt.c43
-rw-r--r--drivers/misc/mei/iorw.c17
-rw-r--r--drivers/misc/mei/main.c33
-rw-r--r--drivers/misc/mei/mei_dev.h2
4 files changed, 45 insertions, 50 deletions
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 3533edde04a5..320ebd2f06ce 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -149,7 +149,7 @@ static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list,
149 return -ENODEV; 149 return -ENODEV;
150 150
151 dev->iamthif_stall_timer = 0; 151 dev->iamthif_stall_timer = 0;
152 cb->information = dev->iamthif_msg_buf_index; 152 cb->buf_idx = dev->iamthif_msg_buf_index;
153 cb->read_time = jiffies; 153 cb->read_time = jiffies;
154 if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) { 154 if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) {
155 /* found the iamthif cb */ 155 /* found the iamthif cb */
@@ -205,10 +205,10 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
205 cl = (struct mei_cl *)cb_pos->file_private; 205 cl = (struct mei_cl *)cb_pos->file_private;
206 if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) { 206 if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
207 cl->reading_state = MEI_READING; 207 cl->reading_state = MEI_READING;
208 buffer = cb_pos->response_buffer.data + cb_pos->information; 208 buffer = cb_pos->response_buffer.data + cb_pos->buf_idx;
209 209
210 if (cb_pos->response_buffer.size < 210 if (cb_pos->response_buffer.size <
211 mei_hdr->length + cb_pos->information) { 211 mei_hdr->length + cb_pos->buf_idx) {
212 dev_dbg(&dev->pdev->dev, "message overflow.\n"); 212 dev_dbg(&dev->pdev->dev, "message overflow.\n");
213 list_del(&cb_pos->cb_list); 213 list_del(&cb_pos->cb_list);
214 return -ENOMEM; 214 return -ENOMEM;
@@ -216,7 +216,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
216 if (buffer) 216 if (buffer)
217 mei_read_slots(dev, buffer, mei_hdr->length); 217 mei_read_slots(dev, buffer, mei_hdr->length);
218 218
219 cb_pos->information += mei_hdr->length; 219 cb_pos->buf_idx += mei_hdr->length;
220 if (mei_hdr->msg_complete) { 220 if (mei_hdr->msg_complete) {
221 cl->status = 0; 221 cl->status = 0;
222 list_del(&cb_pos->cb_list); 222 list_del(&cb_pos->cb_list);
@@ -224,7 +224,8 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
224 "completed read H cl = %d, ME cl = %d, length = %lu\n", 224 "completed read H cl = %d, ME cl = %d, length = %lu\n",
225 cl->host_client_id, 225 cl->host_client_id,
226 cl->me_client_id, 226 cl->me_client_id,
227 cb_pos->information); 227 cb_pos->buf_idx);
228
228 list_add_tail(&cb_pos->cb_list, 229 list_add_tail(&cb_pos->cb_list,
229 &complete_list->mei_cb.cb_list); 230 &complete_list->mei_cb.cb_list);
230 } 231 }
@@ -300,14 +301,14 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
300 301
301 if (mei_disconnect(dev, cl)) { 302 if (mei_disconnect(dev, cl)) {
302 cl->status = 0; 303 cl->status = 0;
303 cb_pos->information = 0; 304 cb_pos->buf_idx = 0;
304 list_move_tail(&cb_pos->cb_list, 305 list_move_tail(&cb_pos->cb_list,
305 &cmpl_list->mei_cb.cb_list); 306 &cmpl_list->mei_cb.cb_list);
306 return -EMSGSIZE; 307 return -EMSGSIZE;
307 } else { 308 } else {
308 cl->state = MEI_FILE_DISCONNECTING; 309 cl->state = MEI_FILE_DISCONNECTING;
309 cl->status = 0; 310 cl->status = 0;
310 cb_pos->information = 0; 311 cb_pos->buf_idx = 0;
311 list_move_tail(&cb_pos->cb_list, 312 list_move_tail(&cb_pos->cb_list,
312 &dev->ctrl_rd_list.mei_cb.cb_list); 313 &dev->ctrl_rd_list.mei_cb.cb_list);
313 cl->timer_count = MEI_CONNECT_TIMEOUT; 314 cl->timer_count = MEI_CONNECT_TIMEOUT;
@@ -834,7 +835,7 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
834 835
835 if (mei_send_flow_control(dev, cl)) { 836 if (mei_send_flow_control(dev, cl)) {
836 cl->status = -ENODEV; 837 cl->status = -ENODEV;
837 cb_pos->information = 0; 838 cb_pos->buf_idx = 0;
838 list_move_tail(&cb_pos->cb_list, &cmpl_list->mei_cb.cb_list); 839 list_move_tail(&cb_pos->cb_list, &cmpl_list->mei_cb.cb_list);
839 return -ENODEV; 840 return -ENODEV;
840 } 841 }
@@ -871,7 +872,7 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
871 *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request)); 872 *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
872 if (mei_connect(dev, cl)) { 873 if (mei_connect(dev, cl)) {
873 cl->status = -ENODEV; 874 cl->status = -ENODEV;
874 cb_pos->information = 0; 875 cb_pos->buf_idx = 0;
875 list_del(&cb_pos->cb_list); 876 list_del(&cb_pos->cb_list);
876 return -ENODEV; 877 return -ENODEV;
877 } else { 878 } else {
@@ -901,28 +902,26 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
901 struct mei_msg_hdr *mei_hdr; 902 struct mei_msg_hdr *mei_hdr;
902 903
903 if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) + 904 if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
904 (cb_pos->request_buffer.size - 905 (cb_pos->request_buffer.size - cb_pos->buf_idx))) {
905 cb_pos->information))) {
906 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; 906 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
907 mei_hdr->host_addr = cl->host_client_id; 907 mei_hdr->host_addr = cl->host_client_id;
908 mei_hdr->me_addr = cl->me_client_id; 908 mei_hdr->me_addr = cl->me_client_id;
909 mei_hdr->length = cb_pos->request_buffer.size - 909 mei_hdr->length = cb_pos->request_buffer.size - cb_pos->buf_idx;
910 cb_pos->information;
911 mei_hdr->msg_complete = 1; 910 mei_hdr->msg_complete = 1;
912 mei_hdr->reserved = 0; 911 mei_hdr->reserved = 0;
913 dev_dbg(&dev->pdev->dev, "cb_pos->request_buffer.size =%d" 912 dev_dbg(&dev->pdev->dev, "cb_pos->request_buffer.size =%d"
914 "mei_hdr->msg_complete = %d\n", 913 "mei_hdr->msg_complete = %d\n",
915 cb_pos->request_buffer.size, 914 cb_pos->request_buffer.size,
916 mei_hdr->msg_complete); 915 mei_hdr->msg_complete);
917 dev_dbg(&dev->pdev->dev, "cb_pos->information =%lu\n", 916 dev_dbg(&dev->pdev->dev, "cb_pos->buf_idx =%lu\n",
918 cb_pos->information); 917 cb_pos->buf_idx);
919 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", 918 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
920 mei_hdr->length); 919 mei_hdr->length);
921 *slots -= mei_data2slots(mei_hdr->length); 920 *slots -= mei_data2slots(mei_hdr->length);
922 if (mei_write_message(dev, mei_hdr, 921 if (mei_write_message(dev, mei_hdr,
923 (unsigned char *) 922 (unsigned char *)
924 (cb_pos->request_buffer.data + 923 (cb_pos->request_buffer.data +
925 cb_pos->information), 924 cb_pos->buf_idx),
926 mei_hdr->length)) { 925 mei_hdr->length)) {
927 cl->status = -ENODEV; 926 cl->status = -ENODEV;
928 list_move_tail(&cb_pos->cb_list, 927 list_move_tail(&cb_pos->cb_list,
@@ -932,7 +931,7 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
932 if (mei_flow_ctrl_reduce(dev, cl)) 931 if (mei_flow_ctrl_reduce(dev, cl))
933 return -ENODEV; 932 return -ENODEV;
934 cl->status = 0; 933 cl->status = 0;
935 cb_pos->information += mei_hdr->length; 934 cb_pos->buf_idx += mei_hdr->length;
936 list_move_tail(&cb_pos->cb_list, 935 list_move_tail(&cb_pos->cb_list,
937 &dev->write_waiting_list.mei_cb.cb_list); 936 &dev->write_waiting_list.mei_cb.cb_list);
938 } 937 }
@@ -949,21 +948,21 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
949 if (mei_write_message(dev, mei_hdr, 948 if (mei_write_message(dev, mei_hdr,
950 (unsigned char *) 949 (unsigned char *)
951 (cb_pos->request_buffer.data + 950 (cb_pos->request_buffer.data +
952 cb_pos->information), 951 cb_pos->buf_idx),
953 mei_hdr->length)) { 952 mei_hdr->length)) {
954 cl->status = -ENODEV; 953 cl->status = -ENODEV;
955 list_move_tail(&cb_pos->cb_list, 954 list_move_tail(&cb_pos->cb_list,
956 &cmpl_list->mei_cb.cb_list); 955 &cmpl_list->mei_cb.cb_list);
957 return -ENODEV; 956 return -ENODEV;
958 } else { 957 } else {
959 cb_pos->information += mei_hdr->length; 958 cb_pos->buf_idx += mei_hdr->length;
960 dev_dbg(&dev->pdev->dev, 959 dev_dbg(&dev->pdev->dev,
961 "cb_pos->request_buffer.size =%d" 960 "cb_pos->request_buffer.size =%d"
962 " mei_hdr->msg_complete = %d\n", 961 " mei_hdr->msg_complete = %d\n",
963 cb_pos->request_buffer.size, 962 cb_pos->request_buffer.size,
964 mei_hdr->msg_complete); 963 mei_hdr->msg_complete);
965 dev_dbg(&dev->pdev->dev, "cb_pos->information =%lu\n", 964 dev_dbg(&dev->pdev->dev, "cb_pos->buf_idx =%lu\n",
966 cb_pos->information); 965 cb_pos->buf_idx);
967 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", 966 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
968 mei_hdr->length); 967 mei_hdr->length);
969 } 968 }
@@ -1018,7 +1017,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
1018 if (mei_flow_ctrl_reduce(dev, cl)) 1017 if (mei_flow_ctrl_reduce(dev, cl))
1019 return -ENODEV; 1018 return -ENODEV;
1020 dev->iamthif_msg_buf_index += mei_hdr->length; 1019 dev->iamthif_msg_buf_index += mei_hdr->length;
1021 cb_pos->information = dev->iamthif_msg_buf_index; 1020 cb_pos->buf_idx = dev->iamthif_msg_buf_index;
1022 cl->status = 0; 1021 cl->status = 0;
1023 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL; 1022 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
1024 dev->iamthif_flow_control_pending = true; 1023 dev->iamthif_flow_control_pending = true;
diff --git a/drivers/misc/mei/iorw.c b/drivers/misc/mei/iorw.c
index fcba98eb892e..20652e140c43 100644
--- a/drivers/misc/mei/iorw.c
+++ b/drivers/misc/mei/iorw.c
@@ -346,9 +346,9 @@ int amthi_read(struct mei_device *dev, struct file *file,
346 } 346 }
347 } 347 }
348 /* if the whole message will fit remove it from the list */ 348 /* if the whole message will fit remove it from the list */
349 if (cb->information >= *offset && length >= (cb->information - *offset)) 349 if (cb->buf_idx >= *offset && length >= (cb->buf_idx - *offset))
350 list_del(&cb->cb_list); 350 list_del(&cb->cb_list);
351 else if (cb->information > 0 && cb->information <= *offset) { 351 else if (cb->buf_idx > 0 && cb->buf_idx <= *offset) {
352 /* end of the message has been reached */ 352 /* end of the message has been reached */
353 list_del(&cb->cb_list); 353 list_del(&cb->cb_list);
354 rets = 0; 354 rets = 0;
@@ -360,18 +360,17 @@ int amthi_read(struct mei_device *dev, struct file *file,
360 360
361 dev_dbg(&dev->pdev->dev, "amthi cb->response_buffer size - %d\n", 361 dev_dbg(&dev->pdev->dev, "amthi cb->response_buffer size - %d\n",
362 cb->response_buffer.size); 362 cb->response_buffer.size);
363 dev_dbg(&dev->pdev->dev, "amthi cb->information - %lu\n", 363 dev_dbg(&dev->pdev->dev, "amthi cb->buf_idx - %lu\n", cb->buf_idx);
364 cb->information);
365 364
366 /* length is being turncated to PAGE_SIZE, however, 365 /* length is being turncated to PAGE_SIZE, however,
367 * the information may be longer */ 366 * the buf_idx may point beyond */
368 length = min_t(size_t, length, (cb->information - *offset)); 367 length = min_t(size_t, length, (cb->buf_idx - *offset));
369 368
370 if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) 369 if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length))
371 rets = -EFAULT; 370 rets = -EFAULT;
372 else { 371 else {
373 rets = length; 372 rets = length;
374 if ((*offset + length) < cb->information) { 373 if ((*offset + length) < cb->buf_idx) {
375 *offset += length; 374 *offset += length;
376 goto out; 375 goto out;
377 } 376 }
@@ -432,8 +431,8 @@ int mei_start_read(struct mei_device *dev, struct mei_cl *cl)
432 } 431 }
433 dev_dbg(&dev->pdev->dev, "allocation call back data success.\n"); 432 dev_dbg(&dev->pdev->dev, "allocation call back data success.\n");
434 cb->major_file_operations = MEI_READ; 433 cb->major_file_operations = MEI_READ;
435 /* make sure information is zero before we start */ 434 /* make sure buffer index is zero before we start */
436 cb->information = 0; 435 cb->buf_idx = 0;
437 cb->file_private = (void *) cl; 436 cb->file_private = (void *) cl;
438 cl->read_cb = cb; 437 cl->read_cb = cb;
439 if (dev->mei_host_buffer_is_empty) { 438 if (dev->mei_host_buffer_is_empty) {
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index e8b0858132c1..3d4f6d17d74c 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -415,16 +415,15 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
415 goto out; 415 goto out;
416 } 416 }
417 417
418 if (cl->read_cb && cl->read_cb->information > *offset) { 418 if (cl->read_cb && cl->read_cb->buf_idx > *offset) {
419 cb = cl->read_cb; 419 cb = cl->read_cb;
420 goto copy_buffer; 420 goto copy_buffer;
421 } else if (cl->read_cb && cl->read_cb->information > 0 && 421 } else if (cl->read_cb && cl->read_cb->buf_idx > 0 &&
422 cl->read_cb->information <= *offset) { 422 cl->read_cb->buf_idx <= *offset) {
423 cb = cl->read_cb; 423 cb = cl->read_cb;
424 rets = 0; 424 rets = 0;
425 goto free; 425 goto free;
426 } else if ((!cl->read_cb || !cl->read_cb->information) && 426 } else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) {
427 *offset > 0) {
428 /*Offset needs to be cleaned for contiguous reads*/ 427 /*Offset needs to be cleaned for contiguous reads*/
429 *offset = 0; 428 *offset = 0;
430 rets = 0; 429 rets = 0;
@@ -481,16 +480,15 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
481copy_buffer: 480copy_buffer:
482 dev_dbg(&dev->pdev->dev, "cb->response_buffer size - %d\n", 481 dev_dbg(&dev->pdev->dev, "cb->response_buffer size - %d\n",
483 cb->response_buffer.size); 482 cb->response_buffer.size);
484 dev_dbg(&dev->pdev->dev, "cb->information - %lu\n", 483 dev_dbg(&dev->pdev->dev, "cb->buf_idx - %lu\n", cb->buf_idx);
485 cb->information); 484 if (length == 0 || ubuf == NULL || *offset > cb->buf_idx) {
486 if (length == 0 || ubuf == NULL || *offset > cb->information) {
487 rets = -EMSGSIZE; 485 rets = -EMSGSIZE;
488 goto free; 486 goto free;
489 } 487 }
490 488
491 /* length is being truncated to PAGE_SIZE, however, */ 489 /* length is being truncated to PAGE_SIZE,
492 /* information size may be longer */ 490 * however buf_idx may point beyond that */
493 length = min_t(size_t, length, (cb->information - *offset)); 491 length = min_t(size_t, length, cb->buf_idx - *offset);
494 492
495 if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) { 493 if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
496 rets = -EFAULT; 494 rets = -EFAULT;
@@ -499,7 +497,7 @@ copy_buffer:
499 497
500 rets = length; 498 rets = length;
501 *offset += length; 499 *offset += length;
502 if ((unsigned long)*offset < cb->information) 500 if ((unsigned long)*offset < cb->buf_idx)
503 goto out; 501 goto out;
504 502
505free: 503free:
@@ -637,7 +635,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
637 635
638 write_cb->response_buffer.size = dev->iamthif_mtu; 636 write_cb->response_buffer.size = dev->iamthif_mtu;
639 write_cb->major_file_operations = MEI_IOCTL; 637 write_cb->major_file_operations = MEI_IOCTL;
640 write_cb->information = 0; 638 write_cb->buf_idx = 0;
641 write_cb->request_buffer.size = length; 639 write_cb->request_buffer.size = length;
642 if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) { 640 if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) {
643 rets = -ENODEV; 641 rets = -ENODEV;
@@ -668,9 +666,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
668 } 666 }
669 667
670 write_cb->major_file_operations = MEI_WRITE; 668 write_cb->major_file_operations = MEI_WRITE;
671 /* make sure information is zero before we start */ 669 /* make sure buffer index is zero before we start */
672 670 write_cb->buf_idx = 0;
673 write_cb->information = 0;
674 write_cb->request_buffer.size = length; 671 write_cb->request_buffer.size = length;
675 672
676 dev_dbg(&dev->pdev->dev, "host client = %d, ME client = %d\n", 673 dev_dbg(&dev->pdev->dev, "host client = %d, ME client = %d\n",
@@ -719,7 +716,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
719 goto unlock_dev; 716 goto unlock_dev;
720 } 717 }
721 cl->writing_state = MEI_WRITING; 718 cl->writing_state = MEI_WRITING;
722 write_cb->information = mei_hdr.length; 719 write_cb->buf_idx = mei_hdr.length;
723 if (mei_hdr.msg_complete) { 720 if (mei_hdr.msg_complete) {
724 if (mei_flow_ctrl_reduce(dev, cl)) { 721 if (mei_flow_ctrl_reduce(dev, cl)) {
725 rets = -ENODEV; 722 rets = -ENODEV;
@@ -734,7 +731,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
734 731
735 } else { 732 } else {
736 733
737 write_cb->information = 0; 734 write_cb->buf_idx = 0;
738 cl->writing_state = MEI_WRITING; 735 cl->writing_state = MEI_WRITING;
739 list_add_tail(&write_cb->cb_list, 736 list_add_tail(&write_cb->cb_list,
740 &dev->write_list.mei_cb.cb_list); 737 &dev->write_list.mei_cb.cb_list);
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index adb35fb9281c..c58b6fa06c07 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -149,7 +149,7 @@ struct mei_cl_cb {
149 void *file_private; 149 void *file_private;
150 struct mei_message_data request_buffer; 150 struct mei_message_data request_buffer;
151 struct mei_message_data response_buffer; 151 struct mei_message_data response_buffer;
152 unsigned long information; 152 unsigned long buf_idx;
153 unsigned long read_time; 153 unsigned long read_time;
154 struct file *file_object; 154 struct file *file_object;
155}; 155};