aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2012-06-25 16:46:28 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-26 18:59:44 -0400
commit726917f052e62d8012f63a763884957610399afb (patch)
treec3a8b57cd85180887357a90270a9d66c8cfce14b /drivers/misc
parent24aadc809f270857743e62d0882865fb3ba195d9 (diff)
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: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/interface.c31
-rw-r--r--drivers/misc/mei/interface.h14
-rw-r--r--drivers/misc/mei/interrupt.c8
3 files changed, 24 insertions, 29 deletions
diff --git a/drivers/misc/mei/interface.c b/drivers/misc/mei/interface.c
index 784a60626fa1..88ada64c0b54 100644
--- a/drivers/misc/mei/interface.c
+++ b/drivers/misc/mei/interface.c
@@ -58,16 +58,18 @@ void mei_disable_interrupts(struct mei_device *dev)
58} 58}
59 59
60/** 60/**
61 * _host_get_filled_slots - gets number of device filled buffer slots 61 * mei_hbuf_filled_slots - gets number of device filled buffer slots
62 * 62 *
63 * @device: the device structure 63 * @device: the device structure
64 * 64 *
65 * returns number of filled slots 65 * returns number of filled slots
66 */ 66 */
67static unsigned char _host_get_filled_slots(const struct mei_device *dev) 67static unsigned char mei_hbuf_filled_slots(struct mei_device *dev)
68{ 68{
69 char read_ptr, write_ptr; 69 char read_ptr, write_ptr;
70 70
71 dev->host_hw_state = mei_hcsr_read(dev);
72
71 read_ptr = (char) ((dev->host_hw_state & H_CBRP) >> 8); 73 read_ptr = (char) ((dev->host_hw_state & H_CBRP) >> 8);
72 write_ptr = (char) ((dev->host_hw_state & H_CBWP) >> 16); 74 write_ptr = (char) ((dev->host_hw_state & H_CBWP) >> 16);
73 75
@@ -75,38 +77,29 @@ static unsigned char _host_get_filled_slots(const struct mei_device *dev)
75} 77}
76 78
77/** 79/**
78 * mei_host_buffer_is_empty - checks if host buffer is empty. 80 * mei_hbuf_is_empty - checks if host buffer is empty.
79 * 81 *
80 * @dev: the device structure 82 * @dev: the device structure
81 * 83 *
82 * returns 1 if empty, 0 - otherwise. 84 * returns true if empty, false - otherwise.
83 */ 85 */
84int mei_host_buffer_is_empty(struct mei_device *dev) 86bool mei_hbuf_is_empty(struct mei_device *dev)
85{ 87{
86 unsigned char filled_slots; 88 return mei_hbuf_filled_slots(dev) == 0;
87
88 dev->host_hw_state = mei_hcsr_read(dev);
89 filled_slots = _host_get_filled_slots(dev);
90
91 if (filled_slots == 0)
92 return 1;
93
94 return 0;
95} 89}
96 90
97/** 91/**
98 * mei_count_empty_write_slots - counts write empty slots. 92 * mei_hbuf_empty_slots - counts write empty slots.
99 * 93 *
100 * @dev: the device structure 94 * @dev: the device structure
101 * 95 *
102 * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count 96 * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count
103 */ 97 */
104int mei_count_empty_write_slots(struct mei_device *dev) 98int mei_hbuf_empty_slots(struct mei_device *dev)
105{ 99{
106 unsigned char filled_slots, empty_slots; 100 unsigned char filled_slots, empty_slots;
107 101
108 dev->host_hw_state = mei_hcsr_read(dev); 102 filled_slots = mei_hbuf_filled_slots(dev);
109 filled_slots = _host_get_filled_slots(dev);
110 empty_slots = dev->hbuf_depth - filled_slots; 103 empty_slots = dev->hbuf_depth - filled_slots;
111 104
112 /* check for overflow */ 105 /* check for overflow */
@@ -139,7 +132,7 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header,
139 "mei_write_message header=%08x.\n", 132 "mei_write_message header=%08x.\n",
140 *((u32 *) header)); 133 *((u32 *) header));
141 134
142 empty_slots = mei_count_empty_write_slots(dev); 135 empty_slots = mei_hbuf_empty_slots(dev);
143 dev_dbg(&dev->pdev->dev, "empty slots = %hu.\n", empty_slots); 136 dev_dbg(&dev->pdev->dev, "empty slots = %hu.\n", empty_slots);
144 137
145 dw_cnt = (length + sizeof(*header) + 3) / 4; 138 dw_cnt = (length + sizeof(*header) + 3) / 4;
diff --git a/drivers/misc/mei/interface.h b/drivers/misc/mei/interface.h
index 8723d8880149..cd9b778e8dc5 100644
--- a/drivers/misc/mei/interface.h
+++ b/drivers/misc/mei/interface.h
@@ -41,19 +41,21 @@ int mei_write_message(struct mei_device *dev,
41 unsigned char *write_buffer, 41 unsigned char *write_buffer,
42 unsigned long write_length); 42 unsigned long write_length);
43 43
44int mei_host_buffer_is_empty(struct mei_device *dev); 44bool mei_hbuf_is_empty(struct mei_device *dev);
45 45
46int mei_count_full_read_slots(struct mei_device *dev); 46int mei_hbuf_empty_slots(struct mei_device *dev);
47
48int mei_count_empty_write_slots(struct mei_device *dev);
49
50int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
51 47
52static inline size_t mei_hbuf_max_data(const struct mei_device *dev) 48static inline size_t mei_hbuf_max_data(const struct mei_device *dev)
53{ 49{
54 return dev->hbuf_depth * sizeof(u32) - sizeof(struct mei_msg_hdr); 50 return dev->hbuf_depth * sizeof(u32) - sizeof(struct mei_msg_hdr);
55} 51}
56 52
53int mei_count_full_read_slots(struct mei_device *dev);
54
55
56int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
57
58
57 59
58int mei_wd_send(struct mei_device *dev); 60int mei_wd_send(struct mei_device *dev);
59int mei_wd_stop(struct mei_device *dev, bool preserve); 61int mei_wd_stop(struct mei_device *dev, bool preserve);
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 4ad6a6bab5a3..1872a2a760e5 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -280,7 +280,7 @@ static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
280 dev->iamthif_msg_buf_index = 0; 280 dev->iamthif_msg_buf_index = 0;
281 dev->iamthif_msg_buf_size = 0; 281 dev->iamthif_msg_buf_size = 0;
282 dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER; 282 dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
283 dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev); 283 dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
284 return 0; 284 return 0;
285} 285}
286 286
@@ -1199,11 +1199,11 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
1199 struct mei_io_list *list; 1199 struct mei_io_list *list;
1200 int ret; 1200 int ret;
1201 1201
1202 if (!mei_host_buffer_is_empty(dev)) { 1202 if (!mei_hbuf_is_empty(dev)) {
1203 dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n"); 1203 dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n");
1204 return 0; 1204 return 0;
1205 } 1205 }
1206 *slots = mei_count_empty_write_slots(dev); 1206 *slots = mei_hbuf_empty_slots(dev);
1207 if (*slots <= 0) 1207 if (*slots <= 0)
1208 return -EMSGSIZE; 1208 return -EMSGSIZE;
1209 1209
@@ -1558,7 +1558,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
1558end: 1558end:
1559 dev_dbg(&dev->pdev->dev, "end of bottom half function.\n"); 1559 dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
1560 dev->host_hw_state = mei_hcsr_read(dev); 1560 dev->host_hw_state = mei_hcsr_read(dev);
1561 dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev); 1561 dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
1562 1562
1563 bus_message_received = false; 1563 bus_message_received = false;
1564 if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) { 1564 if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {