mei: mei_release: drop redundant check if cb is NULL
Subsystems (2)
PATCH 1/2 mei: mei_release: drop redundant check if cb is NULL
mei_io_cb_free follows kfree design and check for NULL internally
Signed-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/misc/mei/main.c +1 -4
@@ -165,10 +165,7 @@ static int mei_release(struct inode *inode, struct file *file) file->private_data =NULL ; -if (cb) { -mei_io_cb_free (cb); - cb =NULL ; - } +mei_io_cb_free (cb);kfree (cl); out:
Signature · 1 line
1.8.3.1
PATCH 2/2 mei: prefix client log messages with client me and host ids
From: Alexander Usyskin <[email protected]>
define cl_dbg and cl_err macros that add me and host id prefix for debug and error log messages so we can track for the client context of the flow.
Signed-off-by Alexander Usyskin <[email protected]>
Signed-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/client.c | 43 ++++++++++++++++++++++--------------------- drivers/misc/mei/client.h | 9 +++++++++ drivers/misc/mei/interrupt.c | 18 +++++++----------- 3 files changed, 38 insertions(+), 32 deletions(-)
drivers/misc/mei/client.c +22 -21
@@ -187,10 +187,14 @@ int mei_io_cb_alloc_resp_buf(struct mei_cl_cb *cb, size_t length)*/ int mei_cl_flush_queues (struct mei_cl *cl) { +struct mei_device *dev; +if (WARN_ON (!cl || !cl->dev))return -EINVAL ; -dev_dbg (&cl->dev->pdev->dev,"remove list entry belonging to cl\n" ); + dev = cl->dev; + +cl_dbg (dev, cl,"remove list entry belonging to cl\n" );mei_io_list_flush (&cl->dev->read_list, cl);mei_io_list_flush (&cl->dev->write_list, cl);mei_io_list_flush (&cl->dev->write_waiting_list, cl);
@@ -296,7 +300,7 @@ int mei_cl_link(struct mei_cl *cl, int id) cl->state =MEI_FILE_INITIALIZING ; -dev_dbg (&dev->pdev->dev,"link cl host id = %d\n" , cl->host_client_id); +cl_dbg (dev, cl,"link cl\n" );return 0 ; }
@@ -322,7 +326,7 @@ int mei_cl_unlink(struct mei_cl *cl)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" , +cl_dbg (dev, cl,"remove host client = %d, ME client = %d\n" , pos->host_client_id, pos->me_client_id);list_del_init (&pos->link);break ;
@@ -390,6 +394,8 @@ int mei_cl_disconnect(struct mei_cl *cl) dev = cl->dev; +cl_dbg (dev, cl,"disconnecting" ); +if (cl->state !=MEI_FILE_DISCONNECTING )return 0 ;
@@ -402,13 +408,13 @@ int mei_cl_disconnect(struct mei_cl *cl) dev->hbuf_is_ready = false;if (mei_hbm_cl_disconnect_req (dev, cl)) { rets = -ENODEV ; -dev_err (&dev->pdev->dev,"failed to disconnect.\n" ); +cl_err (dev, cl,"failed to disconnect.\n" ); goto free; }mdelay (10 );/* Wait for hardware disconnection ready */ list_add_tail (&cb->list, &dev->ctrl_rd_list.list); }else { -dev_dbg (&dev->pdev->dev,"add disconnect cb to control write list\n" ); +cl_dbg (dev, cl,"add disconnect cb to control write list\n" );list_add_tail (&cb->list, &dev->ctrl_wr_list.list); }
@@ -421,18 +427,17 @@ int mei_cl_disconnect(struct mei_cl *cl)mutex_lock (&dev->device_lock);if (MEI_FILE_DISCONNECTED == cl->state) { rets =0 ; -dev_dbg (&dev->pdev->dev,"successfully disconnected from FW client.\n" ); +cl_dbg (dev, cl,"successfully disconnected from FW client.\n" ); }else { rets = -ENODEV ;if (MEI_FILE_DISCONNECTED != cl->state) -dev_dbg (&dev->pdev->dev,"wrong status client disconnect.\n" ); +cl_err (dev, cl,"wrong status client disconnect.\n" );if (err) -dev_dbg (&dev->pdev->dev, -"wait failed disconnect err=%08x\n" , +cl_dbg (dev, cl,"wait failed disconnect err=%08x\n" , err); -dev_dbg (&dev->pdev->dev,"failed to disconnect from FW client.\n" ); +cl_err (dev, cl,"failed to disconnect from FW client.\n" ); }mei_io_list_flush (&dev->ctrl_rd_list, cl);
@@ -639,13 +644,12 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length)return -ENODEV ;if (cl->read_cb) { -dev_dbg (&dev->pdev->dev,"read is pending.\n" ); +cl_dbg (dev, cl,"read is pending.\n" );return -EBUSY ; } i =mei_me_cl_by_id (dev, cl->me_client_id);if (i <0 ) { -dev_err (&dev->pdev->dev,"no such me client %d\n" , - cl->me_client_id); +cl_err (dev, cl,"no such me client %d\n" , cl->me_client_id);return -ENODEV ; }
@@ -664,6 +668,7 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length)if (dev->hbuf_is_ready) { dev->hbuf_is_ready = false;if (mei_hbm_cl_flow_control_req (dev, cl)) { +cl_err (dev, cl,"flow control send failed\n" ); rets = -ENODEV ; goto err; }
@@ -714,9 +719,8 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,return 0 ; } -dev_dbg (&dev->pdev->dev,"buf: size = %d idx = %lu\n" , +cl_dbg (dev, cl,"buf: size = %d idx = %lu\n" , cb->request_buffer.size, cb->buf_idx); -dev_dbg (&dev->pdev->dev,MEI_HDR_FMT ,MEI_HDR_PRM (&mei_hdr)); *slots -= msg_slots; if (mei_write_message(dev, &mei_hdr,
@@ -767,7 +771,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking) buf = &cb->request_buffer; -dev_dbg (&dev->pdev->dev,"mei_cl_write %d\n" , buf->size); +cl_dbg (dev, cl,"mei_cl_write %d\n" , buf->size); cb->fop_type =MEI_FOP_WRITE ;
@@ -800,9 +804,6 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking) mei_hdr.me_addr = cl->me_client_id; mei_hdr.reserved =0 ; -dev_dbg (&dev->pdev->dev,"write " MEI_HDR_FMT "\n" , -MEI_HDR_PRM (&mei_hdr)); -if (mei_write_message (dev, &mei_hdr, buf->data)) { rets = -EIO ;
@@ -898,11 +899,11 @@ void mei_cl_all_wakeup(struct mei_device *dev)struct mei_cl *cl, *next;list_for_each_entry_safe (cl, next, &dev->file_list, link) {if (waitqueue_active (&cl->rx_wait)) { -dev_dbg (&dev->pdev->dev,"Waking up reading client!\n" ); +cl_dbg (dev, cl,"Waking up reading client!\n" );wake_up_interruptible (&cl->rx_wait); }if (waitqueue_active (&cl->tx_wait)) { -dev_dbg (&dev->pdev->dev,"Waking up writing client!\n" ); +cl_dbg (dev, cl,"Waking up writing client!\n" );wake_up_interruptible (&cl->tx_wait); } }
drivers/misc/mei/client.h +9 -0
@@ -115,4 +115,13 @@ void mei_cl_all_disconnect(struct mei_device *dev);void mei_cl_all_wakeup (struct mei_device *dev);void mei_cl_all_write_clear (struct mei_device *dev); +#define MEI_CL_FMT "cl:host=%02d me=%02d " +#define MEI_CL_PRM (cl) (cl)->host_client_id, (cl)->me_client_id + +#define cl_dbg(dev, cl, format, arg...) \ + dev_dbg(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg) + +#define cl_err(dev, cl, format, arg...) \ + dev_err(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg) +#endif /* _MEI_CLIENT_H_ */
drivers/misc/mei/interrupt.c +7 -11
@@ -113,13 +113,13 @@ static int mei_cl_irq_read_msg(struct mei_device *dev,if (cb->response_buffer.size ==0 || cb->response_buffer.data ==NULL ) { -dev_err (&dev->pdev->dev,"response buffer is not allocated.\n" ); +cl_err (dev, cl,"response buffer is not allocated.\n" );list_del (&cb->list);return -ENOMEM ; }if (cb->response_buffer.size < mei_hdr->length + cb->buf_idx) { -dev_dbg (&dev->pdev->dev,"message overflow. size %d len %d idx %ld\n" , +cl_dbg (dev, cl,"message overflow. size %d len %d idx %ld\n" , cb->response_buffer.size, mei_hdr->length, cb->buf_idx); buffer = krealloc(cb->response_buffer.data,
@@ -127,7 +127,7 @@ static int mei_cl_irq_read_msg(struct mei_device *dev, GFP_KERNEL);if (!buffer) { -dev_err (&dev->pdev->dev,"allocation failed.\n" ); +cl_err (dev, cl,"allocation failed.\n" );list_del (&cb->list);return -ENOMEM ; }
@@ -143,9 +143,7 @@ static int mei_cl_irq_read_msg(struct mei_device *dev,if (mei_hdr->msg_complete) { cl->status =0 ;list_del (&cb->list); -dev_dbg (&dev->pdev->dev,"completed read H cl = %d, ME cl = %d, length = %lu\n" , - cl->host_client_id, - cl->me_client_id, +cl_dbg (dev, cl,"completed read length = %lu\n" , cb->buf_idx);list_add_tail (&cb->list, &complete_list->list); }
@@ -423,12 +421,12 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)if (MEI_WRITING == cl->writing_state && cb->fop_type ==MEI_FOP_WRITE && cl != &dev->iamthif_cl) { -dev_dbg (&dev->pdev->dev,"MEI WRITE COMPLETE\n" ); +cl_dbg (dev, cl,"MEI WRITE COMPLETE\n" ); cl->writing_state =MEI_WRITE_COMPLETE ;list_add_tail (&cb->list, &cmpl_list->list); }if (cl == &dev->iamthif_cl) { -dev_dbg (&dev->pdev->dev,"check iamthif flow control.\n" ); +cl_dbg (dev, cl,"check iamthif flow control.\n" );if (dev->iamthif_flow_control_pending) { ret =mei_amthif_irq_read (dev, &slots);if (ret)
@@ -510,9 +508,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)if (cl ==NULL )continue ;if (mei_cl_flow_ctrl_creds (cl) <=0 ) { -dev_dbg (&dev->pdev->dev, -"No flow control credentials for client %d, not sending.\n" , - cl->host_client_id); +cl_dbg (dev, cl,"No flow control credentials, not sending.\n" );continue ; }
Signature · 1 line
1.8.3.1