mei: amthif: prefix cb list with amthif
Subsystems (2)
PATCH 1/7 mei: amthif: prefix cb list with amthif
amthif cb list were prefixed with amthi_ instead
if amthif.
--- drivers/misc/mei/amthif.c | 10 +++++----- drivers/misc/mei/init.c | 8 ++++---- drivers/misc/mei/interrupt.c | 6 ++---- drivers/misc/mei/main.c | 5 ++--- drivers/misc/mei/mei_dev.h | 9 +++++---- 5 files changed, 18 insertions(+), 20 deletions(-)
drivers/misc/mei/amthif.c +5 -5
@@ -124,7 +124,7 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,struct mei_cl_cb *next =NULL ;list_for_each_entry_safe (pos, next, - &dev->amthi_read_complete_list.list, list) { + &dev->amthif_rd_complete_list.list, list) { cl_temp = (struct mei_cl *)pos->file_private;if (cl_temp && cl_temp == &dev->iamthif_cl && pos->file_object == file)
@@ -351,12 +351,12 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb) cb->major_file_operations =MEI_IOCTL ; -if (!list_empty (&dev->amthi_cmd_list.list) || +if (!list_empty (&dev->amthif_cmd_list.list) || dev->iamthif_state !=MEI_IAMTHIF_IDLE ) {dev_dbg (&dev->pdev->dev,"amthif state = %d\n" , dev->iamthif_state);dev_dbg (&dev->pdev->dev,"AMTHIF: add cb to the wait list\n" ); -list_add_tail (&cb->list, &dev->amthi_cmd_list.list); +list_add_tail (&cb->list, &dev->amthif_cmd_list.list);return 0 ; }return mei_amthif_send_cmd (dev, cb);
@@ -388,7 +388,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)dev_dbg (&dev->pdev->dev,"complete amthi cmd_list cb.\n" ); -list_for_each_entry_safe (pos, next, &dev->amthi_cmd_list.list, list) { +list_for_each_entry_safe (pos, next, &dev->amthif_cmd_list.list, list) {list_del (&pos->list); cl_tmp = (struct mei_cl *)pos->file_private;
@@ -589,7 +589,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)memcpy (cb->response_buffer.data, dev->iamthif_msg_buf, dev->iamthif_msg_buf_index); -list_add_tail (&cb->list, &dev->amthi_read_complete_list.list); +list_add_tail (&cb->list, &dev->amthif_rd_complete_list.list);dev_dbg (&dev->pdev->dev,"amthi read completed\n" ); dev->iamthif_timer = jiffies; dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
drivers/misc/mei/init.c +4 -4
@@ -80,8 +80,8 @@ int mei_cl_flush_queues(struct mei_cl *cl)mei_io_list_flush (&cl->dev->write_waiting_list, cl);mei_io_list_flush (&cl->dev->ctrl_wr_list, cl);mei_io_list_flush (&cl->dev->ctrl_rd_list, cl); -mei_io_list_flush (&cl->dev->amthi_cmd_list, cl); -mei_io_list_flush (&cl->dev->amthi_read_complete_list, cl); +mei_io_list_flush (&cl->dev->amthif_cmd_list, cl); +mei_io_list_flush (&cl->dev->amthif_rd_complete_list, cl);return 0 ; }
@@ -117,8 +117,8 @@ struct mei_device *mei_device_init(struct pci_dev *pdev)mei_io_list_init (&dev->write_waiting_list);mei_io_list_init (&dev->ctrl_wr_list);mei_io_list_init (&dev->ctrl_rd_list); -mei_io_list_init (&dev->amthi_cmd_list); -mei_io_list_init (&dev->amthi_read_complete_list); +mei_io_list_init (&dev->amthif_cmd_list); +mei_io_list_init (&dev->amthif_rd_complete_list); dev->pdev = pdev;return dev; }
drivers/misc/mei/interrupt.c +2 -4
@@ -1127,7 +1127,6 @@ void mei_timer(struct work_struct *work)unsigned long timeout;struct mei_cl *cl_pos =NULL ;struct mei_cl *cl_next =NULL ; -struct list_head *amthi_complete_list =NULL ;struct mei_cl_cb *cb_pos =NULL ;struct mei_cl_cb *cb_next =NULL ;
@@ -1195,9 +1194,8 @@ void mei_timer(struct work_struct *work)dev_dbg (&dev->pdev->dev,"freeing AMTHI for other requests\n" ); - amthi_complete_list = &dev->amthi_read_complete_list.list; - -list_for_each_entry_safe (cb_pos, cb_next, amthi_complete_list, list) { +list_for_each_entry_safe (cb_pos, cb_next, + &dev->amthif_rd_complete_list.list, list) { cl_pos = cb_pos->file_object->private_data;
drivers/misc/mei/main.c +2 -3
@@ -146,9 +146,8 @@ static bool mei_clear_lists(struct mei_device *dev, struct file *file)bool removed = false;/* remove callbacks associated with a file */ -mei_clear_list (dev, file, &dev->amthi_cmd_list.list); -if (mei_clear_list (dev, file, - &dev->amthi_read_complete_list.list)) +mei_clear_list (dev, file, &dev->amthif_cmd_list.list); +if (mei_clear_list (dev, file, &dev->amthif_rd_complete_list.list)) removed = true;mei_clear_list (dev, file, &dev->ctrl_rd_list.list);
drivers/misc/mei/mei_dev.h +5 -4
@@ -184,16 +184,13 @@ struct mei_device {/* * lists of queues */ -/* array of pointers to aio lists */ +/* array of pointers to aio lists */ struct mei_cl_cb read_list;/* driver read queue */ struct mei_cl_cb write_list;/* driver write queue */ struct mei_cl_cb write_waiting_list;/* write waiting queue */ struct mei_cl_cb ctrl_wr_list;/* managed write IOCTL list */ struct mei_cl_cb ctrl_rd_list;/* managed read IOCTL list */ -struct mei_cl_cb amthi_cmd_list;/* amthi list for cmd waiting */ -/* driver managed amthi list for reading completed amthi cmd data */ -struct mei_cl_cb amthi_read_complete_list;/* * list of files */
@@ -254,6 +251,10 @@ struct mei_device {unsigned char wd_data[MEI_WD_START_MSG_SIZE ]; +/* amthif list for cmd waiting */ +struct mei_cl_cb amthif_cmd_list; +/* driver managed amthif list for reading completed amthif cmd data */ +struct mei_cl_cb amthif_rd_complete_list;struct file *iamthif_file_object;struct mei_cl iamthif_cl;struct mei_cl_cb *iamthif_current_cb;
Signature · 1 line
1.7.4.4
PATCH 2/7 mei: use type struct mei_cl *cl instead of void in struct mei_cb
We can use correct type 'struct mei_cl' instead of 'void *' for file_private in the struct mei_cb
as there is no other type assigned to this member of the structure
We rename the member from file_private to cl
Remove about 10 lines of declarations of temporary variables used for type casting
--- drivers/misc/mei/amthif.c | 14 ++++---------- drivers/misc/mei/init.c | 6 ++---- drivers/misc/mei/interrupt.c | 14 +++++++------- drivers/misc/mei/iorw.c | 2 +- drivers/misc/mei/main.c | 8 ++------ drivers/misc/mei/mei_dev.h | 9 ++++++++- 6 files changed, 24 insertions(+), 29 deletions(-)
drivers/misc/mei/amthif.c +4 -10
@@ -119,14 +119,12 @@ void mei_amthif_host_init(struct mei_device *dev)struct mei_cl_cb *mei_amthif_find_read_list_entry (struct mei_device *dev,struct file *file) { -struct mei_cl *cl_temp;struct mei_cl_cb *pos =NULL ;struct mei_cl_cb *next =NULL ;list_for_each_entry_safe (pos, next, &dev->amthif_rd_complete_list.list, list) { - cl_temp = (struct mei_cl *)pos->file_private; -if (cl_temp && cl_temp == &dev->iamthif_cl && +if (pos->cl && pos->cl == &dev->iamthif_cl && pos->file_object == file)return pos; }
@@ -370,7 +368,6 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)*/ void mei_amthif_run_next_cmd (struct mei_device *dev) { -struct mei_cl *cl_tmp;struct mei_cl_cb *pos =NULL ;struct mei_cl_cb *next =NULL ;int status;
@@ -390,9 +387,8 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)list_for_each_entry_safe (pos, next, &dev->amthif_cmd_list.list, list) {list_del (&pos->list); - cl_tmp = (struct mei_cl *)pos->file_private; -if (cl_tmp && cl_tmp == &dev->iamthif_cl) { +if (pos->cl && pos->cl == &dev->iamthif_cl) { status =mei_amthif_send_cmd (dev, pos);if (status) { dev_dbg(&dev->pdev->dev,
@@ -500,7 +496,6 @@ int mei_amthif_irq_process_completed(struct mei_device *dev, s32 *slots,int mei_amthif_irq_read_message (struct mei_cl_cb *complete_list,struct mei_device *dev,struct mei_msg_hdr *mei_hdr) { -struct mei_cl *cl;struct mei_cl_cb *cb;unsigned char *buffer;
@@ -528,14 +523,13 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list, cb = dev->iamthif_current_cb; dev->iamthif_current_cb =NULL ; - cl = (struct mei_cl *)cb->file_private; -if (!cl) +if (!cb->cl)return -ENODEV ; dev->iamthif_stall_timer =0 ; cb->buf_idx = dev->iamthif_msg_buf_index; cb->read_time = jiffies; -if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) { +if (dev->iamthif_ioctl && cb->cl == &dev->iamthif_cl) {/* found the iamthif cb */ dev_dbg (&dev->pdev->dev,"complete the amthi read cb.\n " );dev_dbg (&dev->pdev->dev,"add the amthi read cb to complete.\n " );
drivers/misc/mei/init.c +2 -4
@@ -55,10 +55,8 @@ void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl)struct mei_cl_cb *next;list_for_each_entry_safe (pos, next, &list->list, list) { -if (pos->file_private) { -struct mei_cl *cl_tmp; - cl_tmp = (struct mei_cl *)pos->file_private; -if (mei_cl_cmp_id (cl, cl_tmp)) +if (pos->cl) { +if (mei_cl_cmp_id (cl, pos->cl))list_del (&pos->list); } }
drivers/misc/mei/interrupt.c +7 -7
@@ -113,7 +113,7 @@ static int mei_irq_thread_read_client_message(struct mei_cl_cb *complete_list, goto quit;list_for_each_entry_safe (cb_pos, cb_next, &dev->read_list.list, list) { - cl = (struct mei_cl *)cb_pos->file_private; + cl = cb_pos->cl;if (cl &&_mei_irq_thread_state_ok (cl, mei_hdr)) { cl->reading_state =MEI_READING ; buffer = cb_pos->response_buffer.data + cb_pos->buf_idx;
@@ -263,7 +263,7 @@ static void mei_client_connect_response(struct mei_device *dev, }list_for_each_entry_safe (pos, next, &dev->ctrl_rd_list.list, list) { - cl = (struct mei_cl *)pos->file_private; + cl = pos->cl;if (!cl) {list_del (&pos->list);return ;
@@ -301,7 +301,7 @@ static void mei_client_disconnect_response(struct mei_device *dev, rs->status);list_for_each_entry_safe (pos, next, &dev->ctrl_rd_list.list, list) { - cl = (struct mei_cl *)pos->file_private; + cl = pos->cl;if (!cl) {list_del (&pos->list);
@@ -981,7 +981,7 @@ static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list, list = &dev->write_waiting_list;list_for_each_entry_safe (pos, next, &list->list, list) { - cl = (struct mei_cl *)pos->file_private; + cl = pos->cl;if (cl ==NULL )continue ;
@@ -1039,7 +1039,7 @@ static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list,/* complete control write list CB */ dev_dbg (&dev->pdev->dev,"complete control write list cb.\n" );list_for_each_entry_safe (pos, next, &dev->ctrl_wr_list.list, list) { - cl = (struct mei_cl *) pos->file_private; + cl = pos->cl;if (!cl) {list_del (&pos->list);return -ENODEV ;
@@ -1077,7 +1077,7 @@ static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list,/* complete write list CB */ dev_dbg (&dev->pdev->dev,"complete write list cb.\n" );list_for_each_entry_safe (pos, next, &dev->write_list.list, list) { - cl = (struct mei_cl *)pos->file_private; + cl = pos->cl;if (cl ==NULL )continue ;
@@ -1316,7 +1316,7 @@ end:list_for_each_entry_safe (cb_pos, cb_next, &complete_list.list, list) { - cl = (struct mei_cl *)cb_pos->file_private; + cl = cb_pos->cl;list_del (&cb_pos->list);if (cl) {if (cl != &dev->iamthif_cl) {
drivers/misc/mei/iorw.c +1 -1
@@ -71,7 +71,7 @@ struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, struct file *fp)mei_io_list_init (cb); cb->file_object = fp; - cb->file_private = cl; + cb->cl = cl; cb->buf_idx =0 ;return cb; }
drivers/misc/mei/main.c +2 -6
@@ -189,13 +189,9 @@ static struct mei_cl_cb *find_read_list_entry(struct mei_cl_cb *next =NULL ;dev_dbg (&dev->pdev->dev,"remove read_list CB\n" ); -list_for_each_entry_safe (pos, next, &dev->read_list.list, list) { -struct mei_cl *cl_temp; - cl_temp = (struct mei_cl *)pos->file_private; - -if (mei_cl_cmp_id (cl, cl_temp)) +list_for_each_entry_safe (pos, next, &dev->read_list.list, list) +if (mei_cl_cmp_id (cl, pos->cl))return pos; - }return NULL ; }
drivers/misc/mei/mei_dev.h +8 -1
@@ -143,10 +143,17 @@ struct mei_message_data { }; +struct mei_cl ; + +/* +* struct mei_cl_cb - file operation callback structure +* +* @cl - file client who is running this operation +*/ struct mei_cl_cb {struct list_head list; +struct mei_cl *cl;enum mei_cb_major_types major_file_operations; -void *file_private;struct mei_message_data request_buffer;struct mei_message_data response_buffer;unsigned long buf_idx;
Signature · 1 line
1.7.4.4
PATCH 3/7 mei: rename enum mei_cb_major_types to enum mei_cb_file_ops
In reply to Tomas Winkler1. Rename mei_cb_major_types to more understandable mei_cb_file_ops
2. Rename member struct mei_cl_cb of this type to simple 'fop_type'
3. Add kernel doc for the type
--- drivers/misc/mei/amthif.c | 2 +- drivers/misc/mei/init.c | 2 +- drivers/misc/mei/interrupt.c | 18 +++++++++--------- drivers/misc/mei/iorw.c | 4 ++-- drivers/misc/mei/main.c | 2 +- drivers/misc/mei/mei_dev.h | 26 +++++++++++++++++--------- 6 files changed, 31 insertions(+), 23 deletions(-)
drivers/misc/mei/amthif.c +1 -1
@@ -347,7 +347,7 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)if (ret)return ret; - cb->major_file_operations =MEI_IOCTL ; + cb->fop_type =MEI_FOP_IOCTL ;if (!list_empty (&dev->amthif_cmd_list.list) || dev->iamthif_state !=MEI_IAMTHIF_IDLE ) {
drivers/misc/mei/init.c +1 -1
@@ -597,7 +597,7 @@ int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)if (!cb)return -ENOMEM ; - cb->major_file_operations =MEI_CLOSE ; + cb->fop_type =MEI_FOP_CLOSE ;if (dev->mei_host_buffer_is_empty) { dev->mei_host_buffer_is_empty = false;if (mei_disconnect (dev, cl)) {
drivers/misc/mei/interrupt.c +9 -9
@@ -57,14 +57,14 @@ irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id)*/ static void _mei_cmpl (struct mei_cl *cl,struct mei_cl_cb *cb_pos) { -if (cb_pos->major_file_operations ==MEI_WRITE ) { +if (cb_pos->fop_type ==MEI_FOP_WRITE ) {mei_io_cb_free (cb_pos); cb_pos =NULL ; cl->writing_state =MEI_WRITE_COMPLETE ;if (waitqueue_active (&cl->tx_wait))wake_up_interruptible (&cl->tx_wait); - }else if (cb_pos->major_file_operations ==MEI_READ && + }else if (cb_pos->fop_type ==MEI_FOP_READ &&MEI_READING == cl->reading_state) { cl->reading_state =MEI_READ_COMPLETE ;if (waitqueue_active (&cl->rx_wait))
@@ -268,7 +268,7 @@ static void mei_client_connect_response(struct mei_device *dev,list_del (&pos->list);return ; } -if (MEI_IOCTL == pos->major_file_operations) { +if (pos->fop_type ==MEI_FOP_IOCTL ) {if (is_treat_specially_client (cl, rs)) {list_del (&pos->list); cl->status =0 ;
@@ -988,8 +988,8 @@ static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list, cl->status =0 ;list_del (&pos->list);if (MEI_WRITING == cl->writing_state && - (pos->major_file_operations ==MEI_WRITE ) && - (cl != &dev->iamthif_cl)) { + pos->fop_type ==MEI_FOP_WRITE && + cl != &dev->iamthif_cl) {dev_dbg (&dev->pdev->dev,"MEI WRITE COMPLETE\n" ); cl->writing_state =MEI_WRITE_COMPLETE ;list_add_tail (&pos->list, &cmpl_list->list);
@@ -1044,22 +1044,22 @@ static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list,list_del (&pos->list);return -ENODEV ; } -switch (pos->major_file_operations) { -case MEI_CLOSE : +switch (pos->fop_type) { +case MEI_FOP_CLOSE :/* send disconnect message */ ret =_mei_irq_thread_close (dev, slots, pos, cl, cmpl_list);if (ret)return ret;break ; -case MEI_READ : +case MEI_FOP_READ :/* send flow control message */ ret =_mei_irq_thread_read (dev, slots, pos, cl, cmpl_list);if (ret)return ret;break ; -case MEI_IOCTL : +case MEI_FOP_IOCTL :/* connect message */ if (mei_other_client_is_connecting (dev, cl))continue ;
drivers/misc/mei/iorw.c +2 -2
@@ -193,7 +193,7 @@ int mei_ioctl_connect_client(struct file *file, goto end; } - cb->major_file_operations =MEI_IOCTL ; + cb->fop_type =MEI_FOP_IOCTL ;if (dev->dev_state !=MEI_DEV_ENABLED ) { rets = -ENODEV ;
@@ -360,7 +360,7 @@ int mei_start_read(struct mei_device *dev, struct mei_cl *cl)if (rets) goto err; - cb->major_file_operations =MEI_READ ; + cb->fop_type =MEI_FOP_READ ; cl->read_cb = cb;if (dev->mei_host_buffer_is_empty) { dev->mei_host_buffer_is_empty = false;
drivers/misc/mei/main.c +1 -1
@@ -626,7 +626,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,return length; } - write_cb->major_file_operations =MEI_WRITE ; + write_cb->fop_type =MEI_FOP_WRITE ;dev_dbg (&dev->pdev->dev,"host client = %d, ME client = %d\n" , cl->host_client_id, cl->me_client_id);
drivers/misc/mei/mei_dev.h +17 -9
@@ -125,13 +125,20 @@ enum mei_wd_states { MEI_WD_STOPPING, }; -/* MEI CB */ -enum mei_cb_major_types { -MEI_READ =0 , -MEI_WRITE , -MEI_IOCTL , -MEI_OPEN , -MEI_CLOSE +/** +* enum mei_cb_file_ops - file operation associated with the callback +* @MEI_FOP_READ - read +* @MEI_FOP_WRITE - write +* @MEI_FOP_IOCTL - ioctl +* @MEI_FOP_OPEN - open +* @MEI_FOP_CLOSE - close +*/ +enum mei_cb_file_ops { +MEI_FOP_READ =0 , +MEI_FOP_WRITE , +MEI_FOP_IOCTL , +MEI_FOP_OPEN , +MEI_FOP_CLOSE };/*
@@ -145,15 +152,16 @@ struct mei_message_data {struct mei_cl ; -/* +/** * struct mei_cl_cb - file operation callback structure * * @cl - file client who is running this operation +* @fop_type - file operation type */ struct mei_cl_cb {struct list_head list;struct mei_cl *cl; -enum mei_cb_major_types major_file_operations; +enum mei_cb_file_ops fop_type;struct mei_message_data request_buffer;struct mei_message_data response_buffer;unsigned long buf_idx;
Signature · 1 line
1.7.4.4
PATCH 4/7 mei: move amthif specific release code to amithif
In reply to Tomas WinklerMove amthif code part into separate function mei_amthif_release.
Also helper functions mei_clear_list and mei_clear_lists are moved along
--- drivers/misc/mei/amthif.c | 114 ++++++++++++++++++++++++++++ drivers/misc/mei/main.c | 178 ++++++++++---------------------------------- drivers/misc/mei/mei_dev.h | 2 + 3 files changed, 155 insertions(+), 139 deletions(-)
drivers/misc/mei/amthif.c +114 -0
@@ -596,4 +596,118 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)wake_up_interruptible (&dev->iamthif_cl.wait); } +/** +* mei_clear_list - removes all callbacks associated with file +* from mei_cb_list +* +* @dev: device structure. +* @file: file structure +* @mei_cb_list: callbacks list +* +* mei_clear_list is called to clear resources associated with file +* when application calls close function or Ctrl-C was pressed +* +* returns true if callback removed from the list, false otherwise +*/ +static bool mei_clear_list (struct mei_device *dev, +const struct file *file,struct list_head *mei_cb_list) +{ +struct mei_cl_cb *cb_pos =NULL ; +struct mei_cl_cb *cb_next =NULL ; +bool removed = false; + +/* list all list member */ +list_for_each_entry_safe (cb_pos, cb_next, mei_cb_list, list) { +/* check if list member associated with a file */ +if (file == cb_pos->file_object) { +/* remove member from the list */ +list_del (&cb_pos->list); +/* check if cb equal to current iamthif cb */ +if (dev->iamthif_current_cb == cb_pos) { + dev->iamthif_current_cb =NULL ; +/* send flow control to iamthif client */ +mei_send_flow_control (dev, &dev->iamthif_cl); + } +/* free all allocated buffers */ +mei_io_cb_free (cb_pos); + cb_pos =NULL ; + removed = true; + } + } +return removed; +} + +/** +* mei_clear_lists - removes all callbacks associated with file +* +* @dev: device structure +* @file: file structure +* +* mei_clear_lists is called to clear resources associated with file +* when application calls close function or Ctrl-C was pressed +* +* returns true if callback removed from the list, false otherwise +*/ +static bool mei_clear_lists (struct mei_device *dev,struct file *file) +{ +bool removed = false; + +/* remove callbacks associated with a file */ +mei_clear_list (dev, file, &dev->amthif_cmd_list.list); +if (mei_clear_list (dev, file, &dev->amthif_rd_complete_list.list)) + removed = true; +mei_clear_list (dev, file, &dev->ctrl_rd_list.list); + +if (mei_clear_list (dev, file, &dev->ctrl_wr_list.list)) + removed = true; + +if (mei_clear_list (dev, file, &dev->write_waiting_list.list)) + removed = true; + +if (mei_clear_list (dev, file, &dev->write_list.list)) + removed = true; + +/* check if iamthif_current_cb not NULL */ +if (dev->iamthif_current_cb && !removed) { +/* check file and iamthif current cb association */ +if (dev->iamthif_current_cb->file_object == file) { +/* remove cb */ +mei_io_cb_free (dev->iamthif_current_cb); + dev->iamthif_current_cb =NULL ; + removed = true; + } + } +return removed; +} + +/** +* mei_amthif_release - the release function +* +* @inode: pointer to inode structure +* @file: pointer to file structure +* +* returns 0 on success, <0 on error +*/ +int mei_amthif_release (struct mei_device *dev,struct file *file) +{ +if (dev->open_handle_count >0 ) + dev->open_handle_count--; + +if (dev->iamthif_file_object == file && + dev->iamthif_state !=MEI_IAMTHIF_IDLE ) { + +dev_dbg (&dev->pdev->dev,"amthi canceled iamthif state %d\n" , + dev->iamthif_state); + dev->iamthif_canceled = true; +if (dev->iamthif_state ==MEI_IAMTHIF_READ_COMPLETE ) { +dev_dbg (&dev->pdev->dev,"run next amthi iamthif cb\n" ); +mei_amthif_run_next_cmd (dev); + } + } + +if (mei_clear_lists (dev, file)) + dev->iamthif_state =MEI_IAMTHIF_IDLE ; + +return 0 ; +}
drivers/misc/mei/main.c +38 -138
195 lines not on this page · raw message
drivers/misc/mei/mei_dev.h +2 -0
@@ -389,6 +389,8 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);int mei_amthif_read (struct mei_device *dev,struct file *file,char __user *ubuf,size_t length,loff_t *offset); +int mei_amthif_release (struct mei_device *dev,struct file *file); +struct mei_cl_cb *mei_amthif_find_read_list_entry (struct mei_device *dev,struct file *file);
Signature · 1 line
1.7.4.4
PATCH 5/7 mei: extract amthif specific code from mei_poll to mei_amthif_poll
In reply to Tomas Winkler--- drivers/misc/mei/amthif.c | 19 +++++++++++++++++++ drivers/misc/mei/main.c | 10 +--------- drivers/misc/mei/mei_dev.h | 6 +++++- 3 files changed, 25 insertions(+), 10 deletions(-)
drivers/misc/mei/amthif.c +19 -0
@@ -401,6 +401,25 @@ void mei_amthif_run_next_cmd(struct mei_device *dev) } } + +unsigned int mei_amthif_poll (struct mei_device *dev, +struct file *file,poll_table *wait) +{ +unsigned int mask =0 ; +mutex_unlock (&dev->device_lock); +poll_wait (file, &dev->iamthif_cl.wait, wait); +mutex_lock (&dev->device_lock); +if (dev->iamthif_state ==MEI_IAMTHIF_READ_COMPLETE && + dev->iamthif_file_object == file) { + mask |= (POLLIN |POLLRDNORM ); +dev_dbg (&dev->pdev->dev,"run next amthi cb\n" ); +mei_amthif_run_next_cmd (dev); + } +return mask; +} + + +/** * mei_amthif_irq_process_completed - processes completed iamthif operation. *
drivers/misc/mei/main.c +1 -9
@@ -694,15 +694,7 @@ static unsigned int mei_poll(struct file *file, poll_table *wait)if (cl == &dev->iamthif_cl) { -mutex_unlock (&dev->device_lock); -poll_wait (file, &dev->iamthif_cl.wait, wait); -mutex_lock (&dev->device_lock); -if (dev->iamthif_state ==MEI_IAMTHIF_READ_COMPLETE && - dev->iamthif_file_object == file) { - mask |= (POLLIN |POLLRDNORM ); -dev_dbg (&dev->pdev->dev,"run next amthi cb\n" ); -mei_amthif_run_next_cmd (dev); - } + mask =mei_amthif_poll (dev, file, wait); goto out; }
drivers/misc/mei/mei_dev.h +5 -1
@@ -19,6 +19,7 @@#include <linux/types.h> #include <linux/watchdog.h> +#include <linux/poll.h> #include <linux/mei.h> #include "hw.h"
@@ -387,7 +388,10 @@ void mei_amthif_host_init(struct mei_device *dev);int mei_amthif_write (struct mei_device *dev,struct mei_cl_cb *priv_cb);int mei_amthif_read (struct mei_device *dev,struct file *file, -char __user *ubuf,size_t length,loff_t *offset); +char __user *ubuf,size_t length,loff_t *offset); + +unsigned int mei_amthif_poll (struct mei_device *dev, +struct file *file,poll_table *wait);int mei_amthif_release (struct mei_device *dev,struct file *file);
Signature · 1 line
1.7.4.4
PATCH 7/7 mei: use the same bus msg for connect and disconnect request
In reply to Tomas Winklerstructs hbm_client_connect_request and hbm_client_disconnect_request have the same layout so we can drop the later
Add kdoc for the request and response structure so it is clear they can be used for both purposes
--- drivers/misc/mei/hw.h | 22 ++++++++++++++++------ drivers/misc/mei/interface.c | 22 ++++++++++------------ drivers/misc/mei/interrupt.c | 17 ++++++++--------- 3 files changed, 34 insertions(+), 27 deletions(-)
drivers/misc/mei/hw.h +16 -6
@@ -293,6 +293,14 @@ struct hbm_props_response {struct mei_client_properties client_properties; } __packed; +/** +* struct hbm_client_connect_request - connect/disconnect request +* +* @hbm_cmd - bus message command header +* @me_addr - address of the client in ME +* @host_addr - address of the client in the driver +* @reserved +*/ struct hbm_client_connect_request {u8 hbm_cmd;u8 me_addr;
@@ -300,6 +308,14 @@ struct hbm_client_connect_request {u8 reserved; } __packed; +/** +* struct hbm_client_connect_response - connect/disconnect response +* +* @hbm_cmd - bus message command header +* @me_addr - address of the client in ME +* @host_addr - address of the client in the driver +* @status - status of the request +*/ struct hbm_client_connect_response {u8 hbm_cmd;u8 me_addr;
@@ -307,12 +323,6 @@ struct hbm_client_connect_response {u8 status; } __packed; -struct hbm_client_disconnect_request { -u8 hbm_cmd; -u8 me_addr; -u8 host_addr; -u8 reserved[1 ]; -} __packed;#define MEI_FC_MESSAGE_RESERVED_LENGTH 5
drivers/misc/mei/interface.c +10 -12
@@ -352,26 +352,24 @@ int mei_other_client_is_connecting(struct mei_device *dev,int mei_disconnect (struct mei_device *dev,struct mei_cl *cl) {struct mei_msg_hdr *mei_hdr; -struct hbm_client_disconnect_request *mei_cli_disconnect; +struct hbm_client_connect_request *req; mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0 ]; mei_hdr->host_addr =0 ; mei_hdr->me_addr =0 ; - mei_hdr->length =sizeof (struct hbm_client_disconnect_request ); + mei_hdr->length =sizeof (struct hbm_client_connect_request ); mei_hdr->msg_complete =1 ; mei_hdr->reserved =0 ; - mei_cli_disconnect = - (struct hbm_client_disconnect_request *) &dev->wr_msg_buf[1 ]; -memset (mei_cli_disconnect,0 ,sizeof (*mei_cli_disconnect)); - mei_cli_disconnect->host_addr = cl->host_client_id; - mei_cli_disconnect->me_addr = cl->me_client_id; - mei_cli_disconnect->hbm_cmd =CLIENT_DISCONNECT_REQ_CMD ; - mei_cli_disconnect->reserved[0 ] =0 ; + req = (struct hbm_client_connect_request *)&dev->wr_msg_buf[1 ]; +memset (req,0 ,sizeof (*req)); + req->host_addr = cl->host_client_id; + req->me_addr = cl->me_client_id; + req->hbm_cmd =CLIENT_DISCONNECT_REQ_CMD ; + req->reserved =0 ; -return mei_write_message (dev, mei_hdr, - (unsigned char *) mei_cli_disconnect, -sizeof (struct hbm_client_disconnect_request )); +return mei_write_message (dev, mei_hdr, (unsigned char *)req, +sizeof (struct hbm_client_connect_request )); }/**
drivers/misc/mei/interrupt.c +8 -9
@@ -174,10 +174,10 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots, struct mei_cl_cb *cmpl_list) {if ((*slots *sizeof (u32)) < (sizeof (struct mei_msg_hdr ) + -sizeof (struct hbm_client_disconnect_request ))) +sizeof (struct hbm_client_connect_request )))return -EBADMSG ; - *slots -=mei_data2slots (sizeof (struct hbm_client_disconnect_request )); + *slots -=mei_data2slots (sizeof (struct hbm_client_connect_request ));if (mei_disconnect (dev, cl)) { cl->status =0 ;
@@ -414,10 +414,10 @@ static void mei_client_flow_control_response(struct mei_device *dev,* returns !=0, same; 0,not. */ static int same_disconn_addr (struct mei_cl *cl, -struct hbm_client_disconnect_request *disconn) +struct hbm_client_connect_request *req) { -return (cl->host_client_id == disconn->host_addr && - cl->me_client_id == disconn->me_addr); +return (cl->host_client_id == req->host_addr && + cl->me_client_id == req->me_addr); }/**
@@ -427,7 +427,7 @@ static int same_disconn_addr(struct mei_cl *cl,* @disconnect_req: disconnect request bus message. */ static void mei_client_disconnect_request (struct mei_device *dev, -struct hbm_client_disconnect_request *disconnect_req) +struct hbm_client_connect_request *disconnect_req) {struct mei_msg_hdr *mei_hdr;struct hbm_client_connect_response *disconnect_res;
@@ -484,10 +484,10 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,struct hbm_host_version_response *version_res;struct hbm_client_connect_response *connect_res;struct hbm_client_connect_response *disconnect_res; +struct hbm_client_connect_request *disconnect_req;struct hbm_flow_control *flow_control;struct hbm_props_response *props_res;struct hbm_host_enum_response *enum_res; -struct hbm_client_disconnect_request *disconnect_req;struct hbm_host_stop_request *host_stop_req;int res;
@@ -653,8 +653,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,case CLIENT_DISCONNECT_REQ_CMD :/* search for client */ - disconnect_req = - (struct hbm_client_disconnect_request *) mei_msg; + disconnect_req = (struct hbm_client_connect_request *)mei_msg;mei_client_disconnect_request (dev, disconnect_req);break ;
Signature · 1 line
1.7.4.4
PATCH 6/7 mei: use link and unlink terms for connecting ME and HOST client
In reply to Tomas Winkler1. rename mei_me_cl_update_filext to mei_me_cl_link
2. rename mei_remove_client_from_file_list to mei_me_cl_unlink
Code style, documenation, and usage of both function is updated
--- drivers/misc/mei/amthif.c | 4 +- drivers/misc/mei/init.c | 67 +++++++++++++++++++++----------------------- drivers/misc/mei/iorw.c | 16 +---------- drivers/misc/mei/main.c | 6 ++-- drivers/misc/mei/mei_dev.h | 4 +- drivers/misc/mei/wd.c | 8 ++-- 6 files changed, 44 insertions(+), 61 deletions(-)
drivers/misc/mei/amthif.c +2 -2
@@ -73,10 +73,10 @@ void mei_amthif_host_init(struct mei_device *dev) dev->iamthif_cl.state =MEI_FILE_DISCONNECTED ;/* find ME amthi client */ - i =mei_me_cl_update_filext (dev, &dev->iamthif_cl, + i =mei_me_cl_link (dev, &dev->iamthif_cl, &mei_amthi_guid,MEI_IAMTHIF_HOST_CLIENT_ID );if (i <0 ) { -dev_dbg (&dev->pdev->dev,"failed to find iamthif client.\n" ); +dev_info (&dev->pdev->dev,"failed to find iamthif client.\n" );return ; }
drivers/misc/mei/init.c +32 -35
92 lines not on this page · raw message
drivers/misc/mei/iorw.c +1 -15
@@ -171,8 +171,6 @@ int mei_ioctl_connect_client(struct file *file,struct mei_cl_cb *cb;struct mei_client *client;struct mei_cl *cl; -struct mei_cl *cl_pos =NULL ; -struct mei_cl *cl_next =NULL ;long timeout =mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT );int i;int err;
@@ -229,21 +227,9 @@ int mei_ioctl_connect_client(struct file *file, goto end; }clear_bit (cl->host_client_id, dev->host_clients_map); -list_for_each_entry_safe (cl_pos, cl_next, - &dev->file_list, link) { -if (mei_cl_cmp_id (cl, cl_pos)) { -dev_dbg (&dev->pdev->dev, -"remove file private data node host" -" client = %d, ME client = %d.\n" , - cl_pos->host_client_id, - cl_pos->me_client_id); -list_del (&cl_pos->link); - } +mei_me_cl_unlink (dev, cl); - } -dev_dbg (&dev->pdev->dev,"free file private data memory.\n" );kfree (cl); - cl =NULL ; file->private_data = &dev->iamthif_cl;
drivers/misc/mei/main.c +3 -3
@@ -227,7 +227,7 @@ static int mei_release(struct inode *inode, struct file *file)clear_bit (cl->host_client_id, dev->host_clients_map); dev->open_handle_count--; } -mei_remove_client_from_file_list (dev, cl->host_client_id); +mei_me_cl_unlink (dev, cl);/* free read cb */ cb =NULL ;
@@ -913,8 +913,8 @@ static void __devexit mei_remove(struct pci_dev *pdev)/* remove entry if already in list */ dev_dbg (&pdev->dev,"list del iamthif and wd file list.\n" ); -mei_remove_client_from_file_list (dev, dev->wd_cl.host_client_id); -mei_remove_client_from_file_list (dev, dev->iamthif_cl.host_client_id); +mei_me_cl_unlink (dev, &dev->wd_cl); +mei_me_cl_unlink (dev, &dev->iamthif_cl); dev->iamthif_current_cb =NULL ; dev->me_clients_num =0 ;
drivers/misc/mei/mei_dev.h +2 -2
@@ -301,12 +301,12 @@ int mei_hw_init(struct mei_device *dev);int mei_task_initialize_clients (void *data);int mei_initialize_clients (struct mei_device *dev);int mei_disconnect_host_client (struct mei_device *dev,struct mei_cl *cl); -void mei_remove_client_from_file_list (struct mei_device *dev,u8 host_client_id);void mei_allocate_me_clients_storage (struct mei_device *dev); -int mei_me_cl_update_filext (struct mei_device *dev,struct mei_cl *cl, +int mei_me_cl_link (struct mei_device *dev,struct mei_cl *cl,const uuid_le *cguid,u8 host_client_id); +void mei_me_cl_unlink (struct mei_device *dev,struct mei_cl *cl);int mei_me_cl_by_uuid (const struct mei_device *dev,const uuid_le *cuuid);int mei_me_cl_by_id (struct mei_device *dev,u8 client_id);
drivers/misc/mei/wd.c +4 -4
@@ -62,6 +62,7 @@ static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)*/ int mei_wd_host_init (struct mei_device *dev) { +int id;mei_cl_init (&dev->wd_cl, dev);/* look for WD client and connect to it */
@@ -69,12 +70,11 @@ int mei_wd_host_init(struct mei_device *dev) dev->wd_timeout =MEI_WD_DEFAULT_TIMEOUT ; dev->wd_state =MEI_WD_IDLE ; -/* find ME WD client */ -mei_me_cl_update_filext (dev, &dev->wd_cl, +/* Connect WD ME client to the host client */ + id =mei_me_cl_link (dev, &dev->wd_cl, &mei_wd_guid,MEI_WD_HOST_CLIENT_ID ); -dev_dbg (&dev->pdev->dev,"wd: check client\n" ); -if (MEI_FILE_CONNECTING != dev->wd_cl.state) { +if (id <0 ) {dev_info (&dev->pdev->dev,"wd: failed to find the client\n" );return -ENOENT ; }
Signature · 1 line
1.7.4.4