Commit 726917f0 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: revamp host buffer interface function

1. Use unified _hbuf_ prefix for host/write buffer functions.
2. Cleanup the code w/o functional changes.
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 24aadc80
...@@ -58,16 +58,18 @@ void mei_disable_interrupts(struct mei_device *dev) ...@@ -58,16 +58,18 @@ void mei_disable_interrupts(struct mei_device *dev)
} }
/** /**
* _host_get_filled_slots - gets number of device filled buffer slots * mei_hbuf_filled_slots - gets number of device filled buffer slots
* *
* @device: the device structure * @device: the device structure
* *
* returns number of filled slots * returns number of filled slots
*/ */
static unsigned char _host_get_filled_slots(const struct mei_device *dev) static unsigned char mei_hbuf_filled_slots(struct mei_device *dev)
{ {
char read_ptr, write_ptr; char read_ptr, write_ptr;
dev->host_hw_state = mei_hcsr_read(dev);
read_ptr = (char) ((dev->host_hw_state & H_CBRP) >> 8); read_ptr = (char) ((dev->host_hw_state & H_CBRP) >> 8);
write_ptr = (char) ((dev->host_hw_state & H_CBWP) >> 16); write_ptr = (char) ((dev->host_hw_state & H_CBWP) >> 16);
...@@ -75,38 +77,29 @@ static unsigned char _host_get_filled_slots(const struct mei_device *dev) ...@@ -75,38 +77,29 @@ static unsigned char _host_get_filled_slots(const struct mei_device *dev)
} }
/** /**
* mei_host_buffer_is_empty - checks if host buffer is empty. * mei_hbuf_is_empty - checks if host buffer is empty.
* *
* @dev: the device structure * @dev: the device structure
* *
* returns 1 if empty, 0 - otherwise. * returns true if empty, false - otherwise.
*/ */
int mei_host_buffer_is_empty(struct mei_device *dev) bool mei_hbuf_is_empty(struct mei_device *dev)
{ {
unsigned char filled_slots; return mei_hbuf_filled_slots(dev) == 0;
dev->host_hw_state = mei_hcsr_read(dev);
filled_slots = _host_get_filled_slots(dev);
if (filled_slots == 0)
return 1;
return 0;
} }
/** /**
* mei_count_empty_write_slots - counts write empty slots. * mei_hbuf_empty_slots - counts write empty slots.
* *
* @dev: the device structure * @dev: the device structure
* *
* returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count
*/ */
int mei_count_empty_write_slots(struct mei_device *dev) int mei_hbuf_empty_slots(struct mei_device *dev)
{ {
unsigned char filled_slots, empty_slots; unsigned char filled_slots, empty_slots;
dev->host_hw_state = mei_hcsr_read(dev); filled_slots = mei_hbuf_filled_slots(dev);
filled_slots = _host_get_filled_slots(dev);
empty_slots = dev->hbuf_depth - filled_slots; empty_slots = dev->hbuf_depth - filled_slots;
/* check for overflow */ /* check for overflow */
...@@ -139,7 +132,7 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, ...@@ -139,7 +132,7 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header,
"mei_write_message header=%08x.\n", "mei_write_message header=%08x.\n",
*((u32 *) header)); *((u32 *) header));
empty_slots = mei_count_empty_write_slots(dev); empty_slots = mei_hbuf_empty_slots(dev);
dev_dbg(&dev->pdev->dev, "empty slots = %hu.\n", empty_slots); dev_dbg(&dev->pdev->dev, "empty slots = %hu.\n", empty_slots);
dw_cnt = (length + sizeof(*header) + 3) / 4; dw_cnt = (length + sizeof(*header) + 3) / 4;
......
...@@ -41,19 +41,21 @@ int mei_write_message(struct mei_device *dev, ...@@ -41,19 +41,21 @@ int mei_write_message(struct mei_device *dev,
unsigned char *write_buffer, unsigned char *write_buffer,
unsigned long write_length); unsigned long write_length);
int mei_host_buffer_is_empty(struct mei_device *dev); bool mei_hbuf_is_empty(struct mei_device *dev);
int mei_count_full_read_slots(struct mei_device *dev); int mei_hbuf_empty_slots(struct mei_device *dev);
int mei_count_empty_write_slots(struct mei_device *dev);
int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
static inline size_t mei_hbuf_max_data(const struct mei_device *dev) static inline size_t mei_hbuf_max_data(const struct mei_device *dev)
{ {
return dev->hbuf_depth * sizeof(u32) - sizeof(struct mei_msg_hdr); return dev->hbuf_depth * sizeof(u32) - sizeof(struct mei_msg_hdr);
} }
int mei_count_full_read_slots(struct mei_device *dev);
int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
int mei_wd_send(struct mei_device *dev); int mei_wd_send(struct mei_device *dev);
int mei_wd_stop(struct mei_device *dev, bool preserve); int mei_wd_stop(struct mei_device *dev, bool preserve);
......
...@@ -280,7 +280,7 @@ static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots) ...@@ -280,7 +280,7 @@ static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
dev->iamthif_msg_buf_index = 0; dev->iamthif_msg_buf_index = 0;
dev->iamthif_msg_buf_size = 0; dev->iamthif_msg_buf_size = 0;
dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER; dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev); dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
return 0; return 0;
} }
...@@ -1199,11 +1199,11 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, ...@@ -1199,11 +1199,11 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
struct mei_io_list *list; struct mei_io_list *list;
int ret; int ret;
if (!mei_host_buffer_is_empty(dev)) { if (!mei_hbuf_is_empty(dev)) {
dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n"); dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n");
return 0; return 0;
} }
*slots = mei_count_empty_write_slots(dev); *slots = mei_hbuf_empty_slots(dev);
if (*slots <= 0) if (*slots <= 0)
return -EMSGSIZE; return -EMSGSIZE;
...@@ -1558,7 +1558,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) ...@@ -1558,7 +1558,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
end: end:
dev_dbg(&dev->pdev->dev, "end of bottom half function.\n"); dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
dev->host_hw_state = mei_hcsr_read(dev); dev->host_hw_state = mei_hcsr_read(dev);
dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev); dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
bus_message_received = false; bus_message_received = false;
if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) { if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment