Skip to content

Commit

Permalink
staging/mei: normalize prototypes of all read buffers
Browse files Browse the repository at this point in the history
1. convert all read buffers to unsigned char and drop useless castings
2. simplify mei_read_slots implementation

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tomas Winkler authored and Greg Kroah-Hartman committed Feb 9, 2012
1 parent 733ba91 commit edf1eed
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 30 deletions.
23 changes: 7 additions & 16 deletions drivers/staging/mei/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,17 @@ int mei_count_full_read_slots(struct mei_device *dev)
* @buffer: message buffer will be written
* @buffer_length: message size will be read
*/
void mei_read_slots(struct mei_device *dev,
unsigned char *buffer, unsigned long buffer_length)
void mei_read_slots(struct mei_device *dev, unsigned char *buffer,
unsigned long buffer_length)
{
u32 i = 0;
unsigned char temp_buf[sizeof(u32)];
u32 *reg_buf = (u32 *)buffer;

while (buffer_length >= sizeof(u32)) {
((u32 *) buffer)[i] = mei_mecbrw_read(dev);

dev_dbg(&dev->pdev->dev,
"buffer[%d]= %d\n",
i, ((u32 *) buffer)[i]);

i++;
buffer_length -= sizeof(u32);
}
for (; buffer_length >= sizeof(u32); buffer_length -= sizeof(u32))
*reg_buf++ = mei_mecbrw_read(dev);

if (buffer_length > 0) {
*((u32 *) &temp_buf) = mei_mecbrw_read(dev);
memcpy(&buffer[i * 4], temp_buf, buffer_length);
u32 reg = mei_mecbrw_read(dev);
memcpy(reg_buf, &reg, buffer_length);
}

dev->host_hw_state |= H_IG;
Expand Down
3 changes: 2 additions & 1 deletion drivers/staging/mei/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@


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,
struct mei_msg_hdr *header,
Expand Down
16 changes: 5 additions & 11 deletions drivers/staging/mei/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(dev->iamthif_state != MEI_IAMTHIF_READING);

buffer = (unsigned char *) (dev->iamthif_msg_buf +
dev->iamthif_msg_buf_index);
buffer = dev->iamthif_msg_buf + dev->iamthif_msg_buf_index;
BUG_ON(dev->iamthif_mtu < dev->iamthif_msg_buf_index + mei_hdr->length);

mei_read_slots(dev, buffer, mei_hdr->length);
Expand Down Expand Up @@ -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;
if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
cl->reading_state = MEI_READING;
buffer = (unsigned char *)
(cb_pos->response_buffer.data +
cb_pos->information);
buffer = cb_pos->response_buffer.data + cb_pos->information;

if (cb_pos->response_buffer.size <
mei_hdr->length + cb_pos->information) {
Expand Down Expand Up @@ -247,8 +244,7 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
quit:
dev_dbg(&dev->pdev->dev, "message read\n");
if (!buffer) {
mei_read_slots(dev, (unsigned char *) dev->rd_msg_buf,
mei_hdr->length);
mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
dev_dbg(&dev->pdev->dev, "discarding message, header =%08x.\n",
*(u32 *) dev->rd_msg_buf);
}
Expand Down Expand Up @@ -632,13 +628,11 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
struct hbm_host_stop_request *host_stop_req;
int res;

unsigned char *buffer;

/* read the message to our buffer */
buffer = (unsigned char *) dev->rd_msg_buf;
BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf));
mei_read_slots(dev, buffer, mei_hdr->length);
mei_msg = (struct mei_bus_message *) buffer;
mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;

switch (*(u8 *) mei_msg) {
case HOST_START_RES_CMD:
Expand Down
6 changes: 4 additions & 2 deletions drivers/staging/mei/mei_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#define MEI_WD_PARAMS_SIZE 4
#define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)

#define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32))

/*
* MEI PCI Device object
*/
Expand Down Expand Up @@ -125,7 +127,7 @@ enum mei_cb_major_types {
*/
struct mei_message_data {
u32 size;
char *data;
unsigned char *data;
} __packed;


Expand Down Expand Up @@ -219,7 +221,7 @@ struct mei_device {
bool need_reset;

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 ext_msg_buf[8]; /* for control responses */
u32 rd_msg_hdr;
Expand Down

0 comments on commit edf1eed

Please sign in to comment.