mei: don't query HCSR for host buffer depth
1. We record host (write) buffer depth during reset
so we don't need to query HCSR register later on.
The host buffer depth doesn't change after the reset
2. Use mei_hbuf_max_data function to compute payload size in bytes
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/misc/mei/interface.c b/drivers/misc/mei/interface.c
index 6c05691..784a606 100644
--- a/drivers/misc/mei/interface.c
+++ b/drivers/misc/mei/interface.c
@@ -103,15 +103,14 @@
*/
int mei_count_empty_write_slots(struct mei_device *dev)
{
- unsigned char buffer_depth, filled_slots, empty_slots;
+ unsigned char filled_slots, empty_slots;
dev->host_hw_state = mei_hcsr_read(dev);
- buffer_depth = (unsigned char) ((dev->host_hw_state & H_CBD) >> 24);
filled_slots = _host_get_filled_slots(dev);
- empty_slots = buffer_depth - filled_slots;
+ empty_slots = dev->hbuf_depth - filled_slots;
/* check for overflow */
- if (filled_slots > buffer_depth)
+ if (filled_slots > dev->hbuf_depth)
return -EOVERFLOW;
return empty_slots;