* [char-misc-next 2/7] mei: use type struct mei_cl *cl instead of void in struct mei_cb
2012-11-11 15:37 [char-misc-next 1/7] mei: amthif: prefix cb list with amthif Tomas Winkler
@ 2012-11-11 15:37 ` Tomas Winkler
2012-11-11 15:38 ` [char-misc-next 3/7] mei: rename enum mei_cb_major_types to enum mei_cb_file_ops Tomas Winkler
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Tomas Winkler @ 2012-11-11 15:37 UTC (permalink / raw)
To: gregkh; +Cc: arnd, alan, linux-kernel, Tomas Winkler
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
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
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(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 1de28df..74d593f 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -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 ");
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 7e6d591..0046ca5 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -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);
}
}
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 7193149..acc994e 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -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) {
diff --git a/drivers/misc/mei/iorw.c b/drivers/misc/mei/iorw.c
index a1d9ba1..cc53ce7 100644
--- a/drivers/misc/mei/iorw.c
+++ b/drivers/misc/mei/iorw.c
@@ -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;
}
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index bea545a..e0e39c4 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -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;
}
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index ce246b0..da0c1f5 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -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;
--
1.7.4.4
^ permalink raw reply [flat|nested] 7+ messages in thread* [char-misc-next 3/7] mei: rename enum mei_cb_major_types to enum mei_cb_file_ops
2012-11-11 15:37 [char-misc-next 1/7] mei: amthif: prefix cb list with amthif Tomas Winkler
2012-11-11 15:37 ` [char-misc-next 2/7] mei: use type struct mei_cl *cl instead of void in struct mei_cb Tomas Winkler
@ 2012-11-11 15:38 ` Tomas Winkler
2012-11-11 15:38 ` [char-misc-next 4/7] mei: move amthif specific release code to amithif Tomas Winkler
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Tomas Winkler @ 2012-11-11 15:38 UTC (permalink / raw)
To: gregkh; +Cc: arnd, alan, linux-kernel, Tomas Winkler
1. 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
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
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(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 74d593f..34d37a9 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -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) {
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 0046ca5..85b6520 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -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)) {
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index acc994e..34e20cc 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -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;
diff --git a/drivers/misc/mei/iorw.c b/drivers/misc/mei/iorw.c
index cc53ce7..cf11076 100644
--- a/drivers/misc/mei/iorw.c
+++ b/drivers/misc/mei/iorw.c
@@ -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;
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index e0e39c4..57bf96c 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -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);
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index da0c1f5..59e94c2 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -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;
--
1.7.4.4
^ permalink raw reply [flat|nested] 7+ messages in thread* [char-misc-next 4/7] mei: move amthif specific release code to amithif
2012-11-11 15:37 [char-misc-next 1/7] mei: amthif: prefix cb list with amthif Tomas Winkler
2012-11-11 15:37 ` [char-misc-next 2/7] mei: use type struct mei_cl *cl instead of void in struct mei_cb Tomas Winkler
2012-11-11 15:38 ` [char-misc-next 3/7] mei: rename enum mei_cb_major_types to enum mei_cb_file_ops Tomas Winkler
@ 2012-11-11 15:38 ` Tomas Winkler
2012-11-11 15:38 ` [char-misc-next 5/7] mei: extract amthif specific code from mei_poll to mei_amthif_poll Tomas Winkler
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Tomas Winkler @ 2012-11-11 15:38 UTC (permalink / raw)
To: gregkh; +Cc: arnd, alan, linux-kernel, Tomas Winkler
Move amthif code part into separate function
mei_amthif_release.
Also helper functions mei_clear_list and mei_clear_lists
are moved along
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
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(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 34d37a9..8f4373a 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -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;
+}
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 57bf96c..43512e5 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -90,90 +90,6 @@ static DEFINE_MUTEX(mei_mutex);
/**
- * 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;
-}
-/**
* find_read_list_entry - find read list entry
*
* @dev: device structure
@@ -289,67 +205,51 @@ static int mei_release(struct inode *inode, struct file *file)
dev = cl->dev;
mutex_lock(&dev->device_lock);
- if (cl != &dev->iamthif_cl) {
- if (cl->state == MEI_FILE_CONNECTED) {
- cl->state = MEI_FILE_DISCONNECTING;
- dev_dbg(&dev->pdev->dev,
- "disconnecting client host client = %d, "
- "ME client = %d\n",
- cl->host_client_id,
- cl->me_client_id);
- rets = mei_disconnect_host_client(dev, cl);
- }
- mei_cl_flush_queues(cl);
- dev_dbg(&dev->pdev->dev, "remove client host client = %d, ME client = %d\n",
+ if (cl == &dev->iamthif_cl) {
+ rets = mei_amthif_release(dev, file);
+ goto out;
+ }
+ if (cl->state == MEI_FILE_CONNECTED) {
+ cl->state = MEI_FILE_DISCONNECTING;
+ dev_dbg(&dev->pdev->dev,
+ "disconnecting client host client = %d, "
+ "ME client = %d\n",
cl->host_client_id,
cl->me_client_id);
+ rets = mei_disconnect_host_client(dev, cl);
+ }
+ mei_cl_flush_queues(cl);
+ dev_dbg(&dev->pdev->dev, "remove client host client = %d, ME client = %d\n",
+ cl->host_client_id,
+ cl->me_client_id);
+
+ if (dev->open_handle_count > 0) {
+ 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);
- if (dev->open_handle_count > 0) {
- 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);
-
- /* free read cb */
- cb = NULL;
- if (cl->read_cb) {
- cb = find_read_list_entry(dev, cl);
- /* Remove entry from read list */
- if (cb)
- list_del(&cb->list);
-
- cb = cl->read_cb;
- cl->read_cb = NULL;
- }
-
- file->private_data = NULL;
-
- if (cb) {
- mei_io_cb_free(cb);
- cb = NULL;
- }
+ /* free read cb */
+ cb = NULL;
+ if (cl->read_cb) {
+ cb = find_read_list_entry(dev, cl);
+ /* Remove entry from read list */
+ if (cb)
+ list_del(&cb->list);
- kfree(cl);
- } else {
- 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);
- }
- }
+ cb = cl->read_cb;
+ cl->read_cb = NULL;
+ }
- if (mei_clear_lists(dev, file))
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
+ file->private_data = NULL;
+ if (cb) {
+ mei_io_cb_free(cb);
+ cb = NULL;
}
+
+ kfree(cl);
+out:
mutex_unlock(&dev->device_lock);
return rets;
}
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 59e94c2..bdad35e 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -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);
--
1.7.4.4
^ permalink raw reply [flat|nested] 7+ messages in thread* [char-misc-next 5/7] mei: extract amthif specific code from mei_poll to mei_amthif_poll
2012-11-11 15:37 [char-misc-next 1/7] mei: amthif: prefix cb list with amthif Tomas Winkler
` (2 preceding siblings ...)
2012-11-11 15:38 ` [char-misc-next 4/7] mei: move amthif specific release code to amithif Tomas Winkler
@ 2012-11-11 15:38 ` Tomas Winkler
2012-11-11 15:38 ` [char-misc-next 6/7] mei: use link and unlink terms for connecting ME and HOST client Tomas Winkler
2012-11-11 15:38 ` [char-misc-next 7/7] mei: use the same bus msg for connect and disconnect request Tomas Winkler
5 siblings, 0 replies; 7+ messages in thread
From: Tomas Winkler @ 2012-11-11 15:38 UTC (permalink / raw)
To: gregkh; +Cc: arnd, alan, linux-kernel, Tomas Winkler
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
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(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 8f4373a..7416241 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -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.
*
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 43512e5..2cc1ebb 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -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;
}
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index bdad35e..dad85f3 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -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);
--
1.7.4.4
^ permalink raw reply [flat|nested] 7+ messages in thread* [char-misc-next 6/7] mei: use link and unlink terms for connecting ME and HOST client
2012-11-11 15:37 [char-misc-next 1/7] mei: amthif: prefix cb list with amthif Tomas Winkler
` (3 preceding siblings ...)
2012-11-11 15:38 ` [char-misc-next 5/7] mei: extract amthif specific code from mei_poll to mei_amthif_poll Tomas Winkler
@ 2012-11-11 15:38 ` Tomas Winkler
2012-11-11 15:38 ` [char-misc-next 7/7] mei: use the same bus msg for connect and disconnect request Tomas Winkler
5 siblings, 0 replies; 7+ messages in thread
From: Tomas Winkler @ 2012-11-11 15:38 UTC (permalink / raw)
To: gregkh; +Cc: arnd, alan, linux-kernel, Tomas Winkler
1. 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
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
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(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 7416241..095d059 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -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;
}
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 85b6520..4fcb0bb 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -281,12 +281,10 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
cl_pos->timer_count = 0;
}
/* remove entry if already in list */
- dev_dbg(&dev->pdev->dev, "list del iamthif and wd file list.\n");
- mei_remove_client_from_file_list(dev,
- dev->wd_cl.host_client_id);
+ dev_dbg(&dev->pdev->dev, "remove iamthif and wd from the file list.\n");
+ mei_me_cl_unlink(dev, &dev->wd_cl);
- mei_remove_client_from_file_list(dev,
- dev->iamthif_cl.host_client_id);
+ mei_me_cl_unlink(dev, &dev->iamthif_cl);
mei_amthif_reset_params(dev);
dev->extra_write_index = 0;
@@ -520,17 +518,20 @@ int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid)
/**
- * mei_me_cl_update_filext - searches for ME client guid
- * sets client_id in mei_file_private if found
+ * mei_me_cl_link - create link between host and me clinet and add
+ * me_cl to the list
+ *
* @dev: the device structure
- * @cl: private file structure to set client_id in
- * @cuuid: searched uuid of ME client
- * @client_id: id of host client to be set in file private structure
+ * @cl: link between me and host client assocated with opened file descriptor
+ * @cuuid: uuid of ME client
+ * @client_id: id of the host client
*
- * returns ME client index
+ * returns ME client index if ME client
+ * -EINVAL on incorrect values
+ * -ENONET if client not found
*/
-int mei_me_cl_update_filext(struct mei_device *dev, struct mei_cl *cl,
- const uuid_le *cuuid, u8 host_cl_id)
+int mei_me_cl_link(struct mei_device *dev, struct mei_cl *cl,
+ const uuid_le *cuuid, u8 host_cl_id)
{
int i;
@@ -550,6 +551,24 @@ int mei_me_cl_update_filext(struct mei_device *dev, struct mei_cl *cl,
return -ENOENT;
}
+/**
+ * mei_me_cl_unlink - remove me_cl from the list
+ *
+ * @dev: the device structure
+ * @host_client_id: host client id to be removed
+ */
+void mei_me_cl_unlink(struct mei_device *dev, struct mei_cl *cl)
+{
+ struct mei_cl *pos, *next;
+ list_for_each_entry_safe(pos, next, &dev->file_list, link) {
+ if (cl->host_client_id == pos->host_client_id) {
+ dev_dbg(&dev->pdev->dev, "remove host client = %d, ME client = %d\n",
+ pos->host_client_id, pos->me_client_id);
+ list_del_init(&pos->link);
+ break;
+ }
+ }
+}
/**
* mei_alloc_file_private - allocates a private file structure and sets it up.
@@ -642,25 +661,3 @@ free:
return rets;
}
-/**
- * mei_remove_client_from_file_list -
- * removes file private data from device file list
- *
- * @dev: the device structure
- * @host_client_id: host client id to be removed
- */
-void mei_remove_client_from_file_list(struct mei_device *dev,
- u8 host_client_id)
-{
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
- list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
- if (host_client_id == cl_pos->host_client_id) {
- dev_dbg(&dev->pdev->dev, "remove host client = %d, ME client = %d\n",
- cl_pos->host_client_id,
- cl_pos->me_client_id);
- list_del_init(&cl_pos->link);
- break;
- }
- }
-}
diff --git a/drivers/misc/mei/iorw.c b/drivers/misc/mei/iorw.c
index cf11076..eb93a1b 100644
--- a/drivers/misc/mei/iorw.c
+++ b/drivers/misc/mei/iorw.c
@@ -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;
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 2cc1ebb..251aaff 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -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;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index dad85f3..aaee666 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -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);
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 4fc2b3d..636409f 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -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;
}
--
1.7.4.4
^ permalink raw reply [flat|nested] 7+ messages in thread* [char-misc-next 7/7] mei: use the same bus msg for connect and disconnect request
2012-11-11 15:37 [char-misc-next 1/7] mei: amthif: prefix cb list with amthif Tomas Winkler
` (4 preceding siblings ...)
2012-11-11 15:38 ` [char-misc-next 6/7] mei: use link and unlink terms for connecting ME and HOST client Tomas Winkler
@ 2012-11-11 15:38 ` Tomas Winkler
5 siblings, 0 replies; 7+ messages in thread
From: Tomas Winkler @ 2012-11-11 15:38 UTC (permalink / raw)
To: gregkh; +Cc: arnd, alan, linux-kernel, Tomas Winkler
structs 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
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
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(-)
diff --git a/drivers/misc/mei/hw.h b/drivers/misc/mei/hw.h
index f21721a..be8ca6b 100644
--- a/drivers/misc/mei/hw.h
+++ b/drivers/misc/mei/hw.h
@@ -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
diff --git a/drivers/misc/mei/interface.c b/drivers/misc/mei/interface.c
index 509c395..6b50cf0 100644
--- a/drivers/misc/mei/interface.c
+++ b/drivers/misc/mei/interface.c
@@ -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));
}
/**
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 34e20cc..f882101 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -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;
--
1.7.4.4
^ permalink raw reply [flat|nested] 7+ messages in thread