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

staging/mei: normalize prototypes of all read buffers

1. convert all read buffers to unsigned char and drop useless castings
2. simplify mei_read_slots implementation
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 733ba91c
...@@ -215,26 +215,17 @@ int mei_count_full_read_slots(struct mei_device *dev) ...@@ -215,26 +215,17 @@ int mei_count_full_read_slots(struct mei_device *dev)
* @buffer: message buffer will be written * @buffer: message buffer will be written
* @buffer_length: message size will be read * @buffer_length: message size will be read
*/ */
void mei_read_slots(struct mei_device *dev, void mei_read_slots(struct mei_device *dev, unsigned char *buffer,
unsigned char *buffer, unsigned long buffer_length) unsigned long buffer_length)
{ {
u32 i = 0; u32 *reg_buf = (u32 *)buffer;
unsigned char temp_buf[sizeof(u32)];
while (buffer_length >= sizeof(u32)) { for (; buffer_length >= sizeof(u32); buffer_length -= sizeof(u32))
((u32 *) buffer)[i] = mei_mecbrw_read(dev); *reg_buf++ = mei_mecbrw_read(dev);
dev_dbg(&dev->pdev->dev,
"buffer[%d]= %d\n",
i, ((u32 *) buffer)[i]);
i++;
buffer_length -= sizeof(u32);
}
if (buffer_length > 0) { if (buffer_length > 0) {
*((u32 *) &temp_buf) = mei_mecbrw_read(dev); u32 reg = mei_mecbrw_read(dev);
memcpy(&buffer[i * 4], temp_buf, buffer_length); memcpy(reg_buf, &reg, buffer_length);
} }
dev->host_hw_state |= H_IG; dev->host_hw_state |= H_IG;
......
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
void mei_read_slots(struct mei_device *dev, void mei_read_slots(struct mei_device *dev,
unsigned char *buffer, unsigned long buffer_length); unsigned char *buffer,
unsigned long buffer_length);
int mei_write_message(struct mei_device *dev, int mei_write_message(struct mei_device *dev,
struct mei_msg_hdr *header, struct mei_msg_hdr *header,
......
...@@ -123,8 +123,7 @@ static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list, ...@@ -123,8 +123,7 @@ static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list,
BUG_ON(mei_hdr->me_addr != dev->iamthif_cl.me_client_id); BUG_ON(mei_hdr->me_addr != dev->iamthif_cl.me_client_id);
BUG_ON(dev->iamthif_state != MEI_IAMTHIF_READING); BUG_ON(dev->iamthif_state != MEI_IAMTHIF_READING);
buffer = (unsigned char *) (dev->iamthif_msg_buf + buffer = dev->iamthif_msg_buf + dev->iamthif_msg_buf_index;
dev->iamthif_msg_buf_index);
BUG_ON(dev->iamthif_mtu < dev->iamthif_msg_buf_index + mei_hdr->length); BUG_ON(dev->iamthif_mtu < dev->iamthif_msg_buf_index + mei_hdr->length);
mei_read_slots(dev, buffer, mei_hdr->length); mei_read_slots(dev, buffer, mei_hdr->length);
...@@ -206,9 +205,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list, ...@@ -206,9 +205,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
cl = (struct mei_cl *)cb_pos->file_private; cl = (struct mei_cl *)cb_pos->file_private;
if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) { if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
cl->reading_state = MEI_READING; cl->reading_state = MEI_READING;
buffer = (unsigned char *) buffer = cb_pos->response_buffer.data + cb_pos->information;
(cb_pos->response_buffer.data +
cb_pos->information);
if (cb_pos->response_buffer.size < if (cb_pos->response_buffer.size <
mei_hdr->length + cb_pos->information) { mei_hdr->length + cb_pos->information) {
...@@ -247,8 +244,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list, ...@@ -247,8 +244,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
quit: quit:
dev_dbg(&dev->pdev->dev, "message read\n"); dev_dbg(&dev->pdev->dev, "message read\n");
if (!buffer) { if (!buffer) {
mei_read_slots(dev, (unsigned char *) dev->rd_msg_buf, mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
mei_hdr->length);
dev_dbg(&dev->pdev->dev, "discarding message, header =%08x.\n", dev_dbg(&dev->pdev->dev, "discarding message, header =%08x.\n",
*(u32 *) dev->rd_msg_buf); *(u32 *) dev->rd_msg_buf);
} }
...@@ -632,13 +628,11 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, ...@@ -632,13 +628,11 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
struct hbm_host_stop_request *host_stop_req; struct hbm_host_stop_request *host_stop_req;
int res; int res;
unsigned char *buffer;
/* read the message to our buffer */ /* read the message to our buffer */
buffer = (unsigned char *) dev->rd_msg_buf;
BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf)); BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf));
mei_read_slots(dev, buffer, mei_hdr->length); mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
mei_msg = (struct mei_bus_message *) buffer; mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
switch (*(u8 *) mei_msg) { switch (*(u8 *) mei_msg) {
case HOST_START_RES_CMD: case HOST_START_RES_CMD:
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#define MEI_WD_PARAMS_SIZE 4 #define MEI_WD_PARAMS_SIZE 4
#define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0) #define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)
#define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32))
/* /*
* MEI PCI Device object * MEI PCI Device object
*/ */
...@@ -125,7 +127,7 @@ enum mei_cb_major_types { ...@@ -125,7 +127,7 @@ enum mei_cb_major_types {
*/ */
struct mei_message_data { struct mei_message_data {
u32 size; u32 size;
char *data; unsigned char *data;
} __packed; } __packed;
...@@ -219,7 +221,7 @@ struct mei_device { ...@@ -219,7 +221,7 @@ struct mei_device {
bool need_reset; bool need_reset;
u32 extra_write_index; u32 extra_write_index;
u32 rd_msg_buf[128]; /* used for control messages */ unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */
u32 wr_msg_buf[128]; /* used for control messages */ u32 wr_msg_buf[128]; /* used for control messages */
u32 ext_msg_buf[8]; /* for control responses */ u32 ext_msg_buf[8]; /* for control responses */
u32 rd_msg_hdr; u32 rd_msg_hdr;
......
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