提交 ebb108ef 编写于 作者: T Tomas Winkler 提交者: Greg Kroah-Hartman

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: NTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 7e6735c3
...@@ -149,7 +149,7 @@ static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list, ...@@ -149,7 +149,7 @@ static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list,
return -ENODEV; return -ENODEV;
dev->iamthif_stall_timer = 0; dev->iamthif_stall_timer = 0;
cb->information = dev->iamthif_msg_buf_index; cb->buf_idx = dev->iamthif_msg_buf_index;
cb->read_time = jiffies; cb->read_time = jiffies;
if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) { if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) {
/* found the iamthif cb */ /* found the iamthif cb */
...@@ -205,10 +205,10 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list, ...@@ -205,10 +205,10 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
cl = (struct mei_cl *)cb_pos->file_private; cl = (struct mei_cl *)cb_pos->file_private;
if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) { if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
cl->reading_state = MEI_READING; cl->reading_state = MEI_READING;
buffer = cb_pos->response_buffer.data + cb_pos->information; buffer = cb_pos->response_buffer.data + cb_pos->buf_idx;
if (cb_pos->response_buffer.size < if (cb_pos->response_buffer.size <
mei_hdr->length + cb_pos->information) { mei_hdr->length + cb_pos->buf_idx) {
dev_dbg(&dev->pdev->dev, "message overflow.\n"); dev_dbg(&dev->pdev->dev, "message overflow.\n");
list_del(&cb_pos->cb_list); list_del(&cb_pos->cb_list);
return -ENOMEM; return -ENOMEM;
...@@ -216,7 +216,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list, ...@@ -216,7 +216,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
if (buffer) if (buffer)
mei_read_slots(dev, buffer, mei_hdr->length); mei_read_slots(dev, buffer, mei_hdr->length);
cb_pos->information += mei_hdr->length; cb_pos->buf_idx += mei_hdr->length;
if (mei_hdr->msg_complete) { if (mei_hdr->msg_complete) {
cl->status = 0; cl->status = 0;
list_del(&cb_pos->cb_list); 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,7 +224,8 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
"completed read H cl = %d, ME cl = %d, length = %lu\n", "completed read H cl = %d, ME cl = %d, length = %lu\n",
cl->host_client_id, cl->host_client_id,
cl->me_client_id, cl->me_client_id,
cb_pos->information); cb_pos->buf_idx);
list_add_tail(&cb_pos->cb_list, list_add_tail(&cb_pos->cb_list,
&complete_list->mei_cb.cb_list); &complete_list->mei_cb.cb_list);
} }
...@@ -300,14 +301,14 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots, ...@@ -300,14 +301,14 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
if (mei_disconnect(dev, cl)) { if (mei_disconnect(dev, cl)) {
cl->status = 0; cl->status = 0;
cb_pos->information = 0; cb_pos->buf_idx = 0;
list_move_tail(&cb_pos->cb_list, list_move_tail(&cb_pos->cb_list,
&cmpl_list->mei_cb.cb_list); &cmpl_list->mei_cb.cb_list);
return -EMSGSIZE; return -EMSGSIZE;
} else { } else {
cl->state = MEI_FILE_DISCONNECTING; cl->state = MEI_FILE_DISCONNECTING;
cl->status = 0; cl->status = 0;
cb_pos->information = 0; cb_pos->buf_idx = 0;
list_move_tail(&cb_pos->cb_list, list_move_tail(&cb_pos->cb_list,
&dev->ctrl_rd_list.mei_cb.cb_list); &dev->ctrl_rd_list.mei_cb.cb_list);
cl->timer_count = MEI_CONNECT_TIMEOUT; cl->timer_count = MEI_CONNECT_TIMEOUT;
...@@ -834,7 +835,7 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots, ...@@ -834,7 +835,7 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
if (mei_send_flow_control(dev, cl)) { if (mei_send_flow_control(dev, cl)) {
cl->status = -ENODEV; cl->status = -ENODEV;
cb_pos->information = 0; cb_pos->buf_idx = 0;
list_move_tail(&cb_pos->cb_list, &cmpl_list->mei_cb.cb_list); list_move_tail(&cb_pos->cb_list, &cmpl_list->mei_cb.cb_list);
return -ENODEV; return -ENODEV;
} }
...@@ -871,7 +872,7 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots, ...@@ -871,7 +872,7 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
*slots -= mei_data2slots(sizeof(struct hbm_client_connect_request)); *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request));
if (mei_connect(dev, cl)) { if (mei_connect(dev, cl)) {
cl->status = -ENODEV; cl->status = -ENODEV;
cb_pos->information = 0; cb_pos->buf_idx = 0;
list_del(&cb_pos->cb_list); list_del(&cb_pos->cb_list);
return -ENODEV; return -ENODEV;
} else { } else {
...@@ -901,28 +902,26 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots, ...@@ -901,28 +902,26 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
struct mei_msg_hdr *mei_hdr; struct mei_msg_hdr *mei_hdr;
if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) + if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
(cb_pos->request_buffer.size - (cb_pos->request_buffer.size - cb_pos->buf_idx))) {
cb_pos->information))) {
mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
mei_hdr->host_addr = cl->host_client_id; mei_hdr->host_addr = cl->host_client_id;
mei_hdr->me_addr = cl->me_client_id; mei_hdr->me_addr = cl->me_client_id;
mei_hdr->length = cb_pos->request_buffer.size - mei_hdr->length = cb_pos->request_buffer.size - cb_pos->buf_idx;
cb_pos->information;
mei_hdr->msg_complete = 1; mei_hdr->msg_complete = 1;
mei_hdr->reserved = 0; mei_hdr->reserved = 0;
dev_dbg(&dev->pdev->dev, "cb_pos->request_buffer.size =%d" dev_dbg(&dev->pdev->dev, "cb_pos->request_buffer.size =%d"
"mei_hdr->msg_complete = %d\n", "mei_hdr->msg_complete = %d\n",
cb_pos->request_buffer.size, cb_pos->request_buffer.size,
mei_hdr->msg_complete); mei_hdr->msg_complete);
dev_dbg(&dev->pdev->dev, "cb_pos->information =%lu\n", dev_dbg(&dev->pdev->dev, "cb_pos->buf_idx =%lu\n",
cb_pos->information); cb_pos->buf_idx);
dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
mei_hdr->length); mei_hdr->length);
*slots -= mei_data2slots(mei_hdr->length); *slots -= mei_data2slots(mei_hdr->length);
if (mei_write_message(dev, mei_hdr, if (mei_write_message(dev, mei_hdr,
(unsigned char *) (unsigned char *)
(cb_pos->request_buffer.data + (cb_pos->request_buffer.data +
cb_pos->information), cb_pos->buf_idx),
mei_hdr->length)) { mei_hdr->length)) {
cl->status = -ENODEV; cl->status = -ENODEV;
list_move_tail(&cb_pos->cb_list, list_move_tail(&cb_pos->cb_list,
...@@ -932,7 +931,7 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots, ...@@ -932,7 +931,7 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
if (mei_flow_ctrl_reduce(dev, cl)) if (mei_flow_ctrl_reduce(dev, cl))
return -ENODEV; return -ENODEV;
cl->status = 0; cl->status = 0;
cb_pos->information += mei_hdr->length; cb_pos->buf_idx += mei_hdr->length;
list_move_tail(&cb_pos->cb_list, list_move_tail(&cb_pos->cb_list,
&dev->write_waiting_list.mei_cb.cb_list); &dev->write_waiting_list.mei_cb.cb_list);
} }
...@@ -949,21 +948,21 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots, ...@@ -949,21 +948,21 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
if (mei_write_message(dev, mei_hdr, if (mei_write_message(dev, mei_hdr,
(unsigned char *) (unsigned char *)
(cb_pos->request_buffer.data + (cb_pos->request_buffer.data +
cb_pos->information), cb_pos->buf_idx),
mei_hdr->length)) { mei_hdr->length)) {
cl->status = -ENODEV; cl->status = -ENODEV;
list_move_tail(&cb_pos->cb_list, list_move_tail(&cb_pos->cb_list,
&cmpl_list->mei_cb.cb_list); &cmpl_list->mei_cb.cb_list);
return -ENODEV; return -ENODEV;
} else { } else {
cb_pos->information += mei_hdr->length; cb_pos->buf_idx += mei_hdr->length;
dev_dbg(&dev->pdev->dev, dev_dbg(&dev->pdev->dev,
"cb_pos->request_buffer.size =%d" "cb_pos->request_buffer.size =%d"
" mei_hdr->msg_complete = %d\n", " mei_hdr->msg_complete = %d\n",
cb_pos->request_buffer.size, cb_pos->request_buffer.size,
mei_hdr->msg_complete); mei_hdr->msg_complete);
dev_dbg(&dev->pdev->dev, "cb_pos->information =%lu\n", dev_dbg(&dev->pdev->dev, "cb_pos->buf_idx =%lu\n",
cb_pos->information); cb_pos->buf_idx);
dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
mei_hdr->length); mei_hdr->length);
} }
...@@ -1018,7 +1017,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots, ...@@ -1018,7 +1017,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
if (mei_flow_ctrl_reduce(dev, cl)) if (mei_flow_ctrl_reduce(dev, cl))
return -ENODEV; return -ENODEV;
dev->iamthif_msg_buf_index += mei_hdr->length; dev->iamthif_msg_buf_index += mei_hdr->length;
cb_pos->information = dev->iamthif_msg_buf_index; cb_pos->buf_idx = dev->iamthif_msg_buf_index;
cl->status = 0; cl->status = 0;
dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL; dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
dev->iamthif_flow_control_pending = true; dev->iamthif_flow_control_pending = true;
......
...@@ -346,9 +346,9 @@ int amthi_read(struct mei_device *dev, struct file *file, ...@@ -346,9 +346,9 @@ int amthi_read(struct mei_device *dev, struct file *file,
} }
} }
/* if the whole message will fit remove it from the list */ /* if the whole message will fit remove it from the list */
if (cb->information >= *offset && length >= (cb->information - *offset)) if (cb->buf_idx >= *offset && length >= (cb->buf_idx - *offset))
list_del(&cb->cb_list); list_del(&cb->cb_list);
else if (cb->information > 0 && cb->information <= *offset) { else if (cb->buf_idx > 0 && cb->buf_idx <= *offset) {
/* end of the message has been reached */ /* end of the message has been reached */
list_del(&cb->cb_list); list_del(&cb->cb_list);
rets = 0; rets = 0;
...@@ -360,18 +360,17 @@ int amthi_read(struct mei_device *dev, struct file *file, ...@@ -360,18 +360,17 @@ int amthi_read(struct mei_device *dev, struct file *file,
dev_dbg(&dev->pdev->dev, "amthi cb->response_buffer size - %d\n", dev_dbg(&dev->pdev->dev, "amthi cb->response_buffer size - %d\n",
cb->response_buffer.size); cb->response_buffer.size);
dev_dbg(&dev->pdev->dev, "amthi cb->information - %lu\n", dev_dbg(&dev->pdev->dev, "amthi cb->buf_idx - %lu\n", cb->buf_idx);
cb->information);
/* length is being turncated to PAGE_SIZE, however, /* length is being turncated to PAGE_SIZE, however,
* the information may be longer */ * the buf_idx may point beyond */
length = min_t(size_t, length, (cb->information - *offset)); length = min_t(size_t, length, (cb->buf_idx - *offset));
if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length))
rets = -EFAULT; rets = -EFAULT;
else { else {
rets = length; rets = length;
if ((*offset + length) < cb->information) { if ((*offset + length) < cb->buf_idx) {
*offset += length; *offset += length;
goto out; goto out;
} }
...@@ -432,8 +431,8 @@ int mei_start_read(struct mei_device *dev, struct mei_cl *cl) ...@@ -432,8 +431,8 @@ int mei_start_read(struct mei_device *dev, struct mei_cl *cl)
} }
dev_dbg(&dev->pdev->dev, "allocation call back data success.\n"); dev_dbg(&dev->pdev->dev, "allocation call back data success.\n");
cb->major_file_operations = MEI_READ; cb->major_file_operations = MEI_READ;
/* make sure information is zero before we start */ /* make sure buffer index is zero before we start */
cb->information = 0; cb->buf_idx = 0;
cb->file_private = (void *) cl; cb->file_private = (void *) cl;
cl->read_cb = cb; cl->read_cb = cb;
if (dev->mei_host_buffer_is_empty) { if (dev->mei_host_buffer_is_empty) {
......
...@@ -415,16 +415,15 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, ...@@ -415,16 +415,15 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
goto out; goto out;
} }
if (cl->read_cb && cl->read_cb->information > *offset) { if (cl->read_cb && cl->read_cb->buf_idx > *offset) {
cb = cl->read_cb; cb = cl->read_cb;
goto copy_buffer; goto copy_buffer;
} else if (cl->read_cb && cl->read_cb->information > 0 && } else if (cl->read_cb && cl->read_cb->buf_idx > 0 &&
cl->read_cb->information <= *offset) { cl->read_cb->buf_idx <= *offset) {
cb = cl->read_cb; cb = cl->read_cb;
rets = 0; rets = 0;
goto free; goto free;
} else if ((!cl->read_cb || !cl->read_cb->information) && } else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) {
*offset > 0) {
/*Offset needs to be cleaned for contiguous reads*/ /*Offset needs to be cleaned for contiguous reads*/
*offset = 0; *offset = 0;
rets = 0; rets = 0;
...@@ -481,16 +480,15 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, ...@@ -481,16 +480,15 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
copy_buffer: copy_buffer:
dev_dbg(&dev->pdev->dev, "cb->response_buffer size - %d\n", dev_dbg(&dev->pdev->dev, "cb->response_buffer size - %d\n",
cb->response_buffer.size); cb->response_buffer.size);
dev_dbg(&dev->pdev->dev, "cb->information - %lu\n", dev_dbg(&dev->pdev->dev, "cb->buf_idx - %lu\n", cb->buf_idx);
cb->information); if (length == 0 || ubuf == NULL || *offset > cb->buf_idx) {
if (length == 0 || ubuf == NULL || *offset > cb->information) {
rets = -EMSGSIZE; rets = -EMSGSIZE;
goto free; goto free;
} }
/* length is being truncated to PAGE_SIZE, however, */ /* length is being truncated to PAGE_SIZE,
/* information size may be longer */ * however buf_idx may point beyond that */
length = min_t(size_t, length, (cb->information - *offset)); length = min_t(size_t, length, cb->buf_idx - *offset);
if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) { if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
rets = -EFAULT; rets = -EFAULT;
...@@ -499,7 +497,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, ...@@ -499,7 +497,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
rets = length; rets = length;
*offset += length; *offset += length;
if ((unsigned long)*offset < cb->information) if ((unsigned long)*offset < cb->buf_idx)
goto out; goto out;
free: free:
...@@ -637,7 +635,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, ...@@ -637,7 +635,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
write_cb->response_buffer.size = dev->iamthif_mtu; write_cb->response_buffer.size = dev->iamthif_mtu;
write_cb->major_file_operations = MEI_IOCTL; write_cb->major_file_operations = MEI_IOCTL;
write_cb->information = 0; write_cb->buf_idx = 0;
write_cb->request_buffer.size = length; write_cb->request_buffer.size = length;
if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) { if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) {
rets = -ENODEV; rets = -ENODEV;
...@@ -668,9 +666,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, ...@@ -668,9 +666,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
} }
write_cb->major_file_operations = MEI_WRITE; write_cb->major_file_operations = MEI_WRITE;
/* make sure information is zero before we start */ /* make sure buffer index is zero before we start */
write_cb->buf_idx = 0;
write_cb->information = 0;
write_cb->request_buffer.size = length; write_cb->request_buffer.size = length;
dev_dbg(&dev->pdev->dev, "host client = %d, ME client = %d\n", 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,7 +716,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
goto unlock_dev; goto unlock_dev;
} }
cl->writing_state = MEI_WRITING; cl->writing_state = MEI_WRITING;
write_cb->information = mei_hdr.length; write_cb->buf_idx = mei_hdr.length;
if (mei_hdr.msg_complete) { if (mei_hdr.msg_complete) {
if (mei_flow_ctrl_reduce(dev, cl)) { if (mei_flow_ctrl_reduce(dev, cl)) {
rets = -ENODEV; rets = -ENODEV;
...@@ -734,7 +731,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, ...@@ -734,7 +731,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
} else { } else {
write_cb->information = 0; write_cb->buf_idx = 0;
cl->writing_state = MEI_WRITING; cl->writing_state = MEI_WRITING;
list_add_tail(&write_cb->cb_list, list_add_tail(&write_cb->cb_list,
&dev->write_list.mei_cb.cb_list); &dev->write_list.mei_cb.cb_list);
......
...@@ -149,7 +149,7 @@ struct mei_cl_cb { ...@@ -149,7 +149,7 @@ struct mei_cl_cb {
void *file_private; void *file_private;
struct mei_message_data request_buffer; struct mei_message_data request_buffer;
struct mei_message_data response_buffer; struct mei_message_data response_buffer;
unsigned long information; unsigned long buf_idx;
unsigned long read_time; unsigned long read_time;
struct file *file_object; struct file *file_object;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册