mei: mei_device can be const for mei register access functions
Subsystems (2)
PATCH 1/6 mei: mei_device can be const for mei register access functions
Signed-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/mei_dev.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
drivers/misc/mei/mei_dev.h +7 -6
@@ -363,7 +363,8 @@ int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid);* * returns register value (u32) */ -static inline u32 mei_reg_read (struct mei_device *dev,unsigned long offset) +static inline u32 mei_reg_read (const struct mei_device *dev, +unsigned long offset) {return ioread32 (dev->mem_addr + offset); }
@@ -375,8 +376,8 @@ static inline u32 mei_reg_read(struct mei_device *dev, unsigned long offset)* @offset: offset from which to write the data * @value: register value to write (u32) */ -static inline void mei_reg_write (struct mei_device *dev, -unsigned long offset,u32 value) +static inline void mei_reg_write (const struct mei_device *dev, +unsigned long offset,u32 value) {iowrite32 (value, dev->mem_addr + offset); }
@@ -388,7 +389,7 @@ static inline void mei_reg_write(struct mei_device *dev,* * returns the byte read. */ -static inline u32 mei_hcsr_read (struct mei_device *dev) +static inline u32 mei_hcsr_read (const struct mei_device *dev) {return mei_reg_read (dev,H_CSR ); }
@@ -400,7 +401,7 @@ static inline u32 mei_hcsr_read(struct mei_device *dev)* * returns ME_CSR_HA register value (u32) */ -static inline u32 mei_mecsr_read (struct mei_device *dev) +static inline u32 mei_mecsr_read (const struct mei_device *dev) {return mei_reg_read (dev,ME_CSR_HA ); }
@@ -412,7 +413,7 @@ static inline u32 mei_mecsr_read(struct mei_device *dev)* * returns ME_CB_RW register value (u32) */ -static inline u32 mei_mecbrw_read (struct mei_device *dev) +static inline u32 mei_mecbrw_read (const struct mei_device *dev) {return mei_reg_read (dev,ME_CB_RW ); }
Signature · 1 line
1.7.4.4
PATCH 2/6 mei: remove write only wariable wd_due_counter
Signed-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/init.c | 1 - drivers/misc/mei/interrupt.c | 12 ++++-------- drivers/misc/mei/mei_dev.h | 1 - drivers/misc/mei/wd.c | 3 --- 4 files changed, 4 insertions(+), 13 deletions(-)
drivers/misc/mei/init.c +0 -1
@@ -306,7 +306,6 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) dev->iamthif_cl.host_client_id);mei_reset_iamthif_params (dev); - dev->wd_due_counter =0 ; dev->extra_write_index =0 ; }
drivers/misc/mei/interrupt.c +4 -8
@@ -575,10 +575,9 @@ static void mei_client_disconnect_request(struct mei_device *dev, disconnect_req->me_addr); cl_pos->state =MEI_FILE_DISCONNECTED ; cl_pos->timer_count =0 ; -if (cl_pos == &dev->wd_cl) { - dev->wd_due_counter =0 ; +if (cl_pos == &dev->wd_cl) dev->wd_pending = false; - }else if (cl_pos == &dev->iamthif_cl) +else if (cl_pos == &dev->iamthif_cl) dev->iamthif_timer =0 ;/* prepare disconnect response */
@@ -1266,15 +1265,12 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, dev->wd_pending = false; -if (dev->wd_timeout) { +if (dev->wd_timeout) *slots -= (sizeof (struct mei_msg_hdr ) +MEI_START_WD_DATA_SIZE +3 ) /4 ; - dev->wd_due_counter =2 ; - }else { +else *slots -= (sizeof (struct mei_msg_hdr ) +MEI_WD_PARAMS_SIZE +3 ) /4 ; - dev->wd_due_counter =0 ; - } } }
drivers/misc/mei/mei_dev.h +0 -1
@@ -246,7 +246,6 @@ struct mei_device {bool wd_stopped;bool wd_bypass;/* if false, don't refresh watchdog ME client */ u16 wd_timeout;/* seconds ((wd_data[1] << 8) + wd_data[0]) */ -u16 wd_due_counter;unsigned char wd_data[MEI_START_WD_DATA_SIZE ];
drivers/misc/mei/wd.c +0 -3
@@ -137,7 +137,6 @@ int mei_wd_stop(struct mei_device *dev, bool preserve)return 0 ; dev->wd_timeout =0 ; - dev->wd_due_counter =0 ;memcpy (dev->wd_data, mei_stop_wd_params,MEI_WD_PARAMS_SIZE ); dev->stop = true;
@@ -357,8 +356,6 @@ void mei_watchdog_register(struct mei_device *dev) {dev_dbg (&dev->pdev->dev,"dev->wd_timeout =%d.\n" , dev->wd_timeout); - dev->wd_due_counter = !!dev->wd_timeout; -if (watchdog_register_device (&amt_wd_dev)) {dev_err (&dev->pdev->dev,"wd: unable to register watchdog device.\n" );
Signature · 1 line
1.7.4.4
PATCH 3/6 mei: mei_wd_host_init: update the comment
In reply to Tomas WinklerSigned-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/wd.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/misc/mei/wd.c +2 -1
@@ -53,11 +53,12 @@ static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout) }/** -* host_init_wd - mei initialization wd. +* mei_wd_host_init - connect to the watchdog client * * @dev: the device structure * returns -ENENT if wd client cannot be found * -EIO if write has failed +* 0 on success */ int mei_wd_host_init (struct mei_device *dev) {
Signature · 1 line
1.7.4.4
PATCH 4/6 mei: introduce mei_data2slots wrapper
In reply to Tomas WinklerIntroduce mei_data2slots wrapper for sake of readability. This wrapper close up the open code for computing slots from a message length:
rond up dwords count from payload and header byte size
Signed-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/interface.c | 2 +- drivers/misc/mei/interface.h | 6 ++++++ drivers/misc/mei/interrupt.c | 33 +++++++++++---------------------- 3 files changed, 18 insertions(+), 23 deletions(-)
drivers/misc/mei/interface.c +1 -1
@@ -135,7 +135,7 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, empty_slots =mei_hbuf_empty_slots (dev);dev_dbg (&dev->pdev->dev,"empty slots = %hu.\n" , empty_slots); - dw_cnt = (length +sizeof (*header) +3 ) /4 ; + dw_cnt =mei_data2slots (length);if (empty_slots <0 || dw_cnt > empty_slots)return -EIO ;
drivers/misc/mei/interface.h +6 -0
@@ -50,6 +50,12 @@ static inline size_t mei_hbuf_max_data(const struct mei_device *dev)return dev->hbuf_depth *sizeof (u32) -sizeof (struct mei_msg_hdr ); } +/* get slots (dwords) from a message length + header (bytes) */ +static inline unsigned char mei_data2slots (size_t length) +{ +return DIV_ROUND_UP (sizeof (struct mei_msg_hdr ) + length,4 ); +} +int mei_count_full_read_slots (struct mei_device *dev);
drivers/misc/mei/interrupt.c +11 -22
@@ -267,8 +267,7 @@ static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots) + sizeof(struct hbm_flow_control))) {return -EMSGSIZE ; } - *slots -= (sizeof (struct mei_msg_hdr ) + -sizeof (struct hbm_flow_control ) +3 ) /4 ; + *slots -=mei_data2slots (sizeof (struct hbm_flow_control ));if (mei_send_flow_control (dev, &dev->iamthif_cl)) {dev_dbg (&dev->pdev->dev,"iamthif flow control failed\n" );return -EIO ;
@@ -302,8 +301,7 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots, {if ((*slots *sizeof (u32)) >= (sizeof (struct mei_msg_hdr ) +sizeof (struct hbm_client_disconnect_request ))) { - *slots -= (sizeof (struct mei_msg_hdr ) + -sizeof (struct hbm_client_disconnect_request ) +3 ) /4 ; + *slots -=mei_data2slots (sizeof (struct hbm_client_disconnect_request ));if (mei_disconnect (dev, cl)) { cl->status =0 ;
@@ -841,8 +839,8 @@ static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,return -EBADMSG ; } - *slots -= (sizeof (struct mei_msg_hdr ) + -sizeof (struct hbm_flow_control ) +3 ) /4 ; + *slots -=mei_data2slots (sizeof (struct hbm_flow_control )); +if (mei_send_flow_control (dev, cl)) { cl->status = -ENODEV ; cb_pos->information =0 ;
@@ -874,8 +872,7 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,if ((*slots *sizeof (u32)) >= (sizeof (struct mei_msg_hdr ) +sizeof (struct hbm_client_connect_request ))) { cl->state =MEI_FILE_CONNECTING ; - *slots -= (sizeof (struct mei_msg_hdr ) + -sizeof (struct hbm_client_connect_request ) +3 ) /4 ; + *slots -=mei_data2slots (sizeof (struct hbm_client_connect_request ));if (mei_connect (dev, cl)) { cl->status = -ENODEV ; cb_pos->information =0 ;
@@ -931,8 +928,7 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots, cb_pos->information);dev_dbg (&dev->pdev->dev,"mei_hdr->length =%d\n" , mei_hdr->length); - *slots -= (sizeof (struct mei_msg_hdr ) + - mei_hdr->length +3 ) /4 ; + *slots -=mei_data2slots (mei_hdr->length); if (mei_write_message(dev, mei_hdr, (unsigned char *) (cb_pos->request_buffer.data +
@@ -959,9 +955,7 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots, (*slots *sizeof (u32)) -sizeof (struct mei_msg_hdr ); mei_hdr->msg_complete =0 ; mei_hdr->reserved =0 ; - - (*slots) -= (sizeof (struct mei_msg_hdr ) + - mei_hdr->length +3 ) /4 ; + *slots -=mei_data2slots (mei_hdr->length); if (mei_write_message(dev, mei_hdr, (unsigned char *) (cb_pos->request_buffer.data +
@@ -1020,8 +1014,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots, mei_hdr->msg_complete =1 ; mei_hdr->reserved =0 ; - *slots -= (sizeof (struct mei_msg_hdr ) + - mei_hdr->length +3 ) /4 ; + *slots -=mei_data2slots (mei_hdr->length); if (mei_write_message(dev, mei_hdr, (dev->iamthif_msg_buf +
@@ -1055,8 +1048,7 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots, mei_hdr->msg_complete =0 ; mei_hdr->reserved =0 ; - *slots -= (sizeof (struct mei_msg_hdr ) + - mei_hdr->length +3 ) /4 ; + *slots -=mei_data2slots (mei_hdr->length); if (mei_write_message(dev, mei_hdr, (dev->iamthif_msg_buf +
@@ -1266,12 +1258,9 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, dev->wd_pending = false;if (dev->wd_timeout) - *slots -= (sizeof (struct mei_msg_hdr ) + -MEI_START_WD_DATA_SIZE +3 ) /4 ; + *slots -=mei_data2slots (MEI_START_WD_DATA_SIZE );else - *slots -= (sizeof (struct mei_msg_hdr ) + -MEI_WD_PARAMS_SIZE +3 ) /4 ; - + *slots -=mei_data2slots (MEI_START_WD_DATA_SIZE ); } }if (dev->stop)
Signature · 1 line
1.7.4.4
PATCH 5/6 mei: streamline the _mei_irq_thread_close/ioctol functions
In reply to Tomas Winklerchange statements of types
if (ok) do something else return err
into
if (err)
return err
do something
Signed-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/interrupt.c | 63 ++++++++++++++++++++---------------------- 1 files changed, 30 insertions(+), 33 deletions(-)
drivers/misc/mei/interrupt.c +30 -33
@@ -299,27 +299,25 @@ static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots, struct mei_cl *cl, struct mei_io_list *cmpl_list) { -if ((*slots *sizeof (u32)) >= (sizeof (struct mei_msg_hdr ) + -sizeof (struct hbm_client_disconnect_request ))) { - *slots -=mei_data2slots (sizeof (struct hbm_client_disconnect_request )); +if ((*slots *sizeof (u32)) < (sizeof (struct mei_msg_hdr ) + +sizeof (struct hbm_client_disconnect_request ))) +return -EBADMSG ; -if (mei_disconnect (dev, cl)) { - cl->status =0 ; - cb_pos->information =0 ; -list_move_tail (&cb_pos->cb_list, - &cmpl_list->mei_cb.cb_list); -return -EMSGSIZE ; - }else { - cl->state =MEI_FILE_DISCONNECTING ; - cl->status =0 ; - cb_pos->information =0 ; -list_move_tail (&cb_pos->cb_list, - &dev->ctrl_rd_list.mei_cb.cb_list); - cl->timer_count =MEI_CONNECT_TIMEOUT ; - } + *slots -=mei_data2slots (sizeof (struct hbm_client_disconnect_request )); + +if (mei_disconnect (dev, cl)) { + cl->status =0 ; + cb_pos->information =0 ; +list_move_tail (&cb_pos->cb_list, + &cmpl_list->mei_cb.cb_list); +return -EMSGSIZE ; }else { -/* return the cancel routine */ -return -EBADMSG ; + cl->state =MEI_FILE_DISCONNECTING ; + cl->status =0 ; + cb_pos->information =0 ; +list_move_tail (&cb_pos->cb_list, + &dev->ctrl_rd_list.mei_cb.cb_list); + cl->timer_count =MEI_CONNECT_TIMEOUT ; }return 0 ;
@@ -869,26 +867,25 @@ static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots, struct mei_cl *cl, struct mei_io_list *cmpl_list) { -if ((*slots *sizeof (u32)) >= (sizeof (struct mei_msg_hdr ) + +if ((*slots *sizeof (u32)) < (sizeof (struct mei_msg_hdr ) +sizeof (struct hbm_client_connect_request ))) { - cl->state =MEI_FILE_CONNECTING ; - *slots -=mei_data2slots (sizeof (struct hbm_client_connect_request )); -if (mei_connect (dev, cl)) { - cl->status = -ENODEV ; - cb_pos->information =0 ; -list_del (&cb_pos->cb_list); -return -ENODEV ; - }else { -list_move_tail (&cb_pos->cb_list, - &dev->ctrl_rd_list.mei_cb.cb_list); - cl->timer_count =MEI_CONNECT_TIMEOUT ; - } - }else {/* return the cancel routine */ list_del (&cb_pos->cb_list);return -EBADMSG ; } + cl->state =MEI_FILE_CONNECTING ; + *slots -=mei_data2slots (sizeof (struct hbm_client_connect_request )); +if (mei_connect (dev, cl)) { + cl->status = -ENODEV ; + cb_pos->information =0 ; +list_del (&cb_pos->cb_list); +return -ENODEV ; + }else { +list_move_tail (&cb_pos->cb_list, + &dev->ctrl_rd_list.mei_cb.cb_list); + cl->timer_count =MEI_CONNECT_TIMEOUT ; + }return 0 ; }
Signature · 1 line
1.7.4.4
PATCH 6/6 mei: mei_irq_thread_write_handler - line break fix
In reply to Tomas Winkler1. straight up lines that doesn't cross 80 characters
2. don't break strings
Signed-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/interrupt.c | 44 +++++++++++++++-------------------------- 1 files changed, 16 insertions(+), 28 deletions(-)
drivers/misc/mei/interrupt.c +16 -28
@@ -1199,8 +1199,7 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,dev_dbg (&dev->pdev->dev,"complete all waiting for write cb.\n" ); list = &dev->write_waiting_list; -list_for_each_entry_safe (pos, next, - &list->mei_cb.cb_list, cb_list) { +list_for_each_entry_safe (pos, next, &list->mei_cb.cb_list, cb_list) { cl = (struct mei_cl *)pos->file_private;if (cl ==NULL )continue ;
@@ -1210,17 +1209,15 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,if (MEI_WRITING == cl->writing_state && (pos->major_file_operations ==MEI_WRITE ) && (cl != &dev->iamthif_cl)) { -dev_dbg (&dev->pdev->dev, -"MEI WRITE COMPLETE\n" ); +dev_dbg (&dev->pdev->dev,"MEI WRITE COMPLETE\n" ); cl->writing_state =MEI_WRITE_COMPLETE ;list_add_tail (&pos->cb_list, - &cmpl_list->mei_cb.cb_list); + &cmpl_list->mei_cb.cb_list); }if (cl == &dev->iamthif_cl) {dev_dbg (&dev->pdev->dev,"check iamthif flow control.\n" );if (dev->iamthif_flow_control_pending) { - ret =_mei_irq_thread_iamthif_read ( - dev, slots); + ret =_mei_irq_thread_iamthif_read (dev, slots);if (ret)return ret; }
@@ -1245,12 +1242,11 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, }if (dev->mei_state ==MEI_ENABLED ) {if (dev->wd_pending && -mei_flow_ctrl_creds (dev, &dev->wd_cl) >0 ) { +mei_flow_ctrl_creds (dev, &dev->wd_cl) >0 ) {if (mei_wd_send (dev))dev_dbg (&dev->pdev->dev,"wd send failed.\n" ); -else -if (mei_flow_ctrl_reduce (dev, &dev->wd_cl)) -return -ENODEV ; +else if (mei_flow_ctrl_reduce (dev, &dev->wd_cl)) +return -ENODEV ; dev->wd_pending = false;
@@ -1305,7 +1301,7 @@ static int mei_irq_thread_write_handler(struct mei_io_list *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.mei_cb.cb_list, cb_list) { + &dev->write_list.mei_cb.cb_list, cb_list) { cl = (struct mei_cl *)pos->file_private;if (cl ==NULL )continue ;
@@ -1313,15 +1309,12 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,if (cl != &dev->iamthif_cl) {if (mei_flow_ctrl_creds (dev, cl) <=0 ) {dev_dbg (&dev->pdev->dev, -"No flow control" -" credentials for client" -" %d, not sending.\n" , - cl->host_client_id); +"No flow control credentials for client %d, not sending.\n" , + cl->host_client_id);continue ; } - ret =_mei_irq_thread_cmpl (dev, slots, - pos, - cl, cmpl_list); + ret =_mei_irq_thread_cmpl (dev, slots, pos, + cl, cmpl_list);if (ret)return ret;
@@ -1330,17 +1323,12 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,dev_dbg (&dev->pdev->dev,"complete amthi write cb.\n" );if (mei_flow_ctrl_creds (dev, cl) <=0 ) {dev_dbg (&dev->pdev->dev, -"No flow control" -" credentials for amthi" -" client %d.\n" , - cl->host_client_id); +"No flow control credentials for amthi client %d.\n" , + cl->host_client_id);continue ; } - ret =_mei_irq_thread_cmpl_iamthif (dev, - slots, - pos, - cl, - cmpl_list); + ret =_mei_irq_thread_cmpl_iamthif (dev, slots, pos, + cl, cmpl_list);if (ret)return ret;
Signature · 1 line
1.7.4.4