]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
staging/mei: normalize prototypes of all read buffers
authorTomas Winkler <tomas.winkler@intel.com>
Thu, 9 Feb 2012 17:25:54 +0000 (19:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2012 17:44:57 +0000 (09:44 -0800)
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>
drivers/staging/mei/interface.c
drivers/staging/mei/interface.h
drivers/staging/mei/interrupt.c
drivers/staging/mei/mei_dev.h

index 951e61f427b8b3871b255e738bdd9935f3c434af..484be56a6594428f4de96d4a929ffd0a7fcca9f7 100644 (file)
@@ -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;
index 392987469e3bf4d289bafd1f63b501455b7f3c8d..e5bfb18865fcdd6bebd5cf7feed0396b571bde80 100644 (file)
@@ -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,
index 8e16e9485604129031d3d14eff5e66095d6f67ef..3c21c93af8eae8ae4737eeeaceef13f05a459216 100644 (file)
@@ -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);
@@ -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) {
@@ -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);
        }
@@ -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:
index b9957e00f52cd5d850261a2363255f46a108313c..0d937b0753221f23caab2f1301cb636caeefd618 100644 (file)
@@ -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
  */
@@ -125,7 +127,7 @@ enum mei_cb_major_types {
  */
 struct mei_message_data {
        u32 size;
-       char *data;
+       unsigned char *data;
 } __packed;
 
 
@@ -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;