aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2012-12-25 12:05:59 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-07 13:31:27 -0500
commit438763f37eb9664b6372bdfee990f8c33acdc63c (patch)
tree71f2feab0d7b91cfd28c538c2943a8d8fe000c96 /drivers/misc
parentd1c3ed669a2d452cacfb48c2d171a1f364dae2ed (diff)
mei: drop redundant length parameter from mei_write_message function
The length is already part of the message header and it is validated before the function call 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/amthif.c6
-rw-r--r--drivers/misc/mei/init.c7
-rw-r--r--drivers/misc/mei/interface.c24
-rw-r--r--drivers/misc/mei/interface.h5
-rw-r--r--drivers/misc/mei/interrupt.c17
-rw-r--r--drivers/misc/mei/main.c3
-rw-r--r--drivers/misc/mei/wd.c18
7 files changed, 36 insertions, 44 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 18794aea6062..8a9313a1ee7b 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -300,8 +300,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
300 mei_hdr.reserved = 0; 300 mei_hdr.reserved = 0;
301 dev->iamthif_msg_buf_index += mei_hdr.length; 301 dev->iamthif_msg_buf_index += mei_hdr.length;
302 if (mei_write_message(dev, &mei_hdr, 302 if (mei_write_message(dev, &mei_hdr,
303 (unsigned char *)(dev->iamthif_msg_buf), 303 (unsigned char *)dev->iamthif_msg_buf))
304 mei_hdr.length))
305 return -ENODEV; 304 return -ENODEV;
306 305
307 if (mei_hdr.msg_complete) { 306 if (mei_hdr.msg_complete) {
@@ -463,8 +462,7 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,
463 462
464 *slots -= msg_slots; 463 *slots -= msg_slots;
465 if (mei_write_message(dev, mei_hdr, 464 if (mei_write_message(dev, mei_hdr,
466 dev->iamthif_msg_buf + dev->iamthif_msg_buf_index, 465 dev->iamthif_msg_buf + dev->iamthif_msg_buf_index)) {
467 mei_hdr->length)) {
468 dev->iamthif_state = MEI_IAMTHIF_IDLE; 466 dev->iamthif_state = MEI_IAMTHIF_IDLE;
469 cl->status = -ENODEV; 467 cl->status = -ENODEV;
470 list_del(&cb->list); 468 list_del(&cb->list);
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index a54cd5567ca2..c0c0b3e22579 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -345,7 +345,7 @@ void mei_host_start_message(struct mei_device *dev)
345 start_req->host_version.minor_version = HBM_MINOR_VERSION; 345 start_req->host_version.minor_version = HBM_MINOR_VERSION;
346 346
347 dev->recvd_msg = false; 347 dev->recvd_msg = false;
348 if (mei_write_message(dev, mei_hdr, (unsigned char *)start_req, len)) { 348 if (mei_write_message(dev, mei_hdr, (unsigned char *)start_req)) {
349 dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n"); 349 dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n");
350 dev->dev_state = MEI_DEV_RESETING; 350 dev->dev_state = MEI_DEV_RESETING;
351 mei_reset(dev, 1); 351 mei_reset(dev, 1);
@@ -374,7 +374,7 @@ void mei_host_enum_clients_message(struct mei_device *dev)
374 memset(enum_req, 0, sizeof(struct hbm_host_enum_request)); 374 memset(enum_req, 0, sizeof(struct hbm_host_enum_request));
375 enum_req->hbm_cmd = HOST_ENUM_REQ_CMD; 375 enum_req->hbm_cmd = HOST_ENUM_REQ_CMD;
376 376
377 if (mei_write_message(dev, mei_hdr, (unsigned char *)enum_req, len)) { 377 if (mei_write_message(dev, mei_hdr, (unsigned char *)enum_req)) {
378 dev->dev_state = MEI_DEV_RESETING; 378 dev->dev_state = MEI_DEV_RESETING;
379 dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); 379 dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n");
380 mei_reset(dev, 1); 380 mei_reset(dev, 1);
@@ -492,8 +492,7 @@ int mei_host_client_enumerate(struct mei_device *dev)
492 prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD; 492 prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
493 prop_req->address = next_client_index; 493 prop_req->address = next_client_index;
494 494
495 if (mei_write_message(dev, mei_hdr, (unsigned char *) prop_req, 495 if (mei_write_message(dev, mei_hdr, (unsigned char *) prop_req)) {
496 mei_hdr->length)) {
497 dev->dev_state = MEI_DEV_RESETING; 496 dev->dev_state = MEI_DEV_RESETING;
498 dev_err(&dev->pdev->dev, "Properties request command failed\n"); 497 dev_err(&dev->pdev->dev, "Properties request command failed\n");
499 mei_reset(dev, 1); 498 mei_reset(dev, 1);
diff --git a/drivers/misc/mei/interface.c b/drivers/misc/mei/interface.c
index 8de854785960..21ccbe6f7162 100644
--- a/drivers/misc/mei/interface.c
+++ b/drivers/misc/mei/interface.c
@@ -113,21 +113,20 @@ int mei_hbuf_empty_slots(struct mei_device *dev)
113 * mei_write_message - writes a message to mei device. 113 * mei_write_message - writes a message to mei device.
114 * 114 *
115 * @dev: the device structure 115 * @dev: the device structure
116 * @header: header of message 116 * @hader: mei HECI header of message
117 * @write_buffer: message buffer will be written 117 * @buf: message payload will be written
118 * @write_length: message size will be written
119 * 118 *
120 * This function returns -EIO if write has failed 119 * This function returns -EIO if write has failed
121 */ 120 */
122int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, 121int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header,
123 unsigned char *buf, unsigned long length) 122 unsigned char *buf)
124{ 123{
125 unsigned long rem, dw_cnt; 124 unsigned long rem, dw_cnt;
125 unsigned long length = header->length;
126 u32 *reg_buf = (u32 *)buf; 126 u32 *reg_buf = (u32 *)buf;
127 int i; 127 int i;
128 int empty_slots; 128 int empty_slots;
129 129
130
131 dev_dbg(&dev->pdev->dev, 130 dev_dbg(&dev->pdev->dev,
132 "mei_write_message header=%08x.\n", 131 "mei_write_message header=%08x.\n",
133 *((u32 *) header)); 132 *((u32 *) header));
@@ -307,8 +306,7 @@ int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl)
307 dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n", 306 dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n",
308 cl->host_client_id, cl->me_client_id); 307 cl->host_client_id, cl->me_client_id);
309 308
310 return mei_write_message(dev, mei_hdr, 309 return mei_write_message(dev, mei_hdr, (unsigned char *) flow_ctrl);
311 (unsigned char *) flow_ctrl, len);
312} 310}
313 311
314/** 312/**
@@ -346,11 +344,11 @@ int mei_other_client_is_connecting(struct mei_device *dev,
346 */ 344 */
347int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) 345int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
348{ 346{
349 struct mei_msg_hdr *mei_hdr; 347 struct mei_msg_hdr *hdr;
350 struct hbm_client_connect_request *req; 348 struct hbm_client_connect_request *req;
351 const size_t len = sizeof(struct hbm_client_connect_request); 349 const size_t len = sizeof(struct hbm_client_connect_request);
352 350
353 mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); 351 hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len);
354 352
355 req = (struct hbm_client_connect_request *)&dev->wr_msg_buf[1]; 353 req = (struct hbm_client_connect_request *)&dev->wr_msg_buf[1];
356 memset(req, 0, len); 354 memset(req, 0, len);
@@ -359,7 +357,7 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
359 req->me_addr = cl->me_client_id; 357 req->me_addr = cl->me_client_id;
360 req->reserved = 0; 358 req->reserved = 0;
361 359
362 return mei_write_message(dev, mei_hdr, (unsigned char *)req, len); 360 return mei_write_message(dev, hdr, (unsigned char *)req);
363} 361}
364 362
365/** 363/**
@@ -372,11 +370,11 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
372 */ 370 */
373int mei_connect(struct mei_device *dev, struct mei_cl *cl) 371int mei_connect(struct mei_device *dev, struct mei_cl *cl)
374{ 372{
375 struct mei_msg_hdr *mei_hdr; 373 struct mei_msg_hdr *hdr;
376 struct hbm_client_connect_request *req; 374 struct hbm_client_connect_request *req;
377 const size_t len = sizeof(struct hbm_client_connect_request); 375 const size_t len = sizeof(struct hbm_client_connect_request);
378 376
379 mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); 377 hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len);
380 378
381 req = (struct hbm_client_connect_request *) &dev->wr_msg_buf[1]; 379 req = (struct hbm_client_connect_request *) &dev->wr_msg_buf[1];
382 req->hbm_cmd = CLIENT_CONNECT_REQ_CMD; 380 req->hbm_cmd = CLIENT_CONNECT_REQ_CMD;
@@ -384,5 +382,5 @@ int mei_connect(struct mei_device *dev, struct mei_cl *cl)
384 req->me_addr = cl->me_client_id; 382 req->me_addr = cl->me_client_id;
385 req->reserved = 0; 383 req->reserved = 0;
386 384
387 return mei_write_message(dev, mei_hdr, (unsigned char *) req, len); 385 return mei_write_message(dev, hdr, (unsigned char *) req);
388} 386}
diff --git a/drivers/misc/mei/interface.h b/drivers/misc/mei/interface.h
index ec6c785a3961..ca732990a7eb 100644
--- a/drivers/misc/mei/interface.h
+++ b/drivers/misc/mei/interface.h
@@ -29,9 +29,8 @@ void mei_read_slots(struct mei_device *dev,
29 unsigned long buffer_length); 29 unsigned long buffer_length);
30 30
31int mei_write_message(struct mei_device *dev, 31int mei_write_message(struct mei_device *dev,
32 struct mei_msg_hdr *header, 32 struct mei_msg_hdr *header,
33 unsigned char *write_buffer, 33 unsigned char *buf);
34 unsigned long write_length);
35 34
36bool mei_hbuf_is_empty(struct mei_device *dev); 35bool mei_hbuf_is_empty(struct mei_device *dev);
37 36
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 04fa2134615e..b72fa8196ddb 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -465,7 +465,7 @@ static void mei_client_disconnect_request(struct mei_device *dev,
465 * @mei_hdr: header of bus message 465 * @mei_hdr: header of bus message
466 */ 466 */
467static void mei_irq_thread_read_bus_message(struct mei_device *dev, 467static void mei_irq_thread_read_bus_message(struct mei_device *dev,
468 struct mei_msg_hdr *mei_hdr) 468 struct mei_msg_hdr *hdr)
469{ 469{
470 struct mei_bus_message *mei_msg; 470 struct mei_bus_message *mei_msg;
471 struct mei_me_client *me_client; 471 struct mei_me_client *me_client;
@@ -479,8 +479,8 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
479 struct hbm_host_stop_request *stop_req; 479 struct hbm_host_stop_request *stop_req;
480 480
481 /* read the message to our buffer */ 481 /* read the message to our buffer */
482 BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf)); 482 BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
483 mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length); 483 mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
484 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf; 484 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
485 485
486 switch (mei_msg->hbm_cmd) { 486 switch (mei_msg->hbm_cmd) {
@@ -506,14 +506,13 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
506 dev->version = version_res->me_max_version; 506 dev->version = version_res->me_max_version;
507 507
508 /* send stop message */ 508 /* send stop message */
509 mei_hdr = mei_hbm_hdr(&buf[0], len); 509 hdr = mei_hbm_hdr(&buf[0], len);
510 stop_req = (struct hbm_host_stop_request *)&buf[1]; 510 stop_req = (struct hbm_host_stop_request *)&buf[1];
511 memset(stop_req, 0, len); 511 memset(stop_req, 0, len);
512 stop_req->hbm_cmd = HOST_STOP_REQ_CMD; 512 stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
513 stop_req->reason = DRIVER_STOP_REQUEST; 513 stop_req->reason = DRIVER_STOP_REQUEST;
514 514
515 mei_write_message(dev, mei_hdr, 515 mei_write_message(dev, hdr, (unsigned char *)stop_req);
516 (unsigned char *)stop_req, len);
517 dev_dbg(&dev->pdev->dev, "version mismatch.\n"); 516 dev_dbg(&dev->pdev->dev, "version mismatch.\n");
518 return; 517 return;
519 } 518 }
@@ -615,7 +614,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
615 614
616 const size_t len = sizeof(struct hbm_host_stop_request); 615 const size_t len = sizeof(struct hbm_host_stop_request);
617 616
618 mei_hdr = mei_hbm_hdr((u32 *)&dev->wr_ext_msg.hdr, len); 617 hdr = mei_hbm_hdr((u32 *)&dev->wr_ext_msg.hdr, len);
619 stop_req = (struct hbm_host_stop_request *)&dev->wr_ext_msg.data; 618 stop_req = (struct hbm_host_stop_request *)&dev->wr_ext_msg.data;
620 memset(stop_req, 0, len); 619 memset(stop_req, 0, len);
621 stop_req->hbm_cmd = HOST_STOP_REQ_CMD; 620 stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
@@ -748,7 +747,7 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,
748 747
749 *slots -= msg_slots; 748 *slots -= msg_slots;
750 if (mei_write_message(dev, mei_hdr, 749 if (mei_write_message(dev, mei_hdr,
751 cb->request_buffer.data + cb->buf_idx, len)) { 750 cb->request_buffer.data + cb->buf_idx)) {
752 cl->status = -ENODEV; 751 cl->status = -ENODEV;
753 list_move_tail(&cb->list, &cmpl_list->list); 752 list_move_tail(&cb->list, &cmpl_list->list);
754 return -ENODEV; 753 return -ENODEV;
@@ -930,7 +929,7 @@ static int mei_irq_thread_write_handler(struct mei_device *dev,
930 929
931 if (dev->wr_ext_msg.hdr.length) { 930 if (dev->wr_ext_msg.hdr.length) {
932 mei_write_message(dev, &dev->wr_ext_msg.hdr, 931 mei_write_message(dev, &dev->wr_ext_msg.hdr,
933 dev->wr_ext_msg.data, dev->wr_ext_msg.hdr.length); 932 dev->wr_ext_msg.data);
934 slots -= mei_data2slots(dev->wr_ext_msg.hdr.length); 933 slots -= mei_data2slots(dev->wr_ext_msg.hdr.length);
935 dev->wr_ext_msg.hdr.length = 0; 934 dev->wr_ext_msg.hdr.length = 0;
936 } 935 }
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 43fb52ff98ad..b281c235d898 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -554,8 +554,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
554 mei_hdr.reserved = 0; 554 mei_hdr.reserved = 0;
555 dev_dbg(&dev->pdev->dev, "call mei_write_message header=%08x.\n", 555 dev_dbg(&dev->pdev->dev, "call mei_write_message header=%08x.\n",
556 *((u32 *) &mei_hdr)); 556 *((u32 *) &mei_hdr));
557 if (mei_write_message(dev, &mei_hdr, 557 if (mei_write_message(dev, &mei_hdr, write_cb->request_buffer.data)) {
558 write_cb->request_buffer.data, mei_hdr.length)) {
559 rets = -ENODEV; 558 rets = -ENODEV;
560 goto err; 559 goto err;
561 } 560 }
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 9299a8c29a6f..9d4d4aa0f0e8 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -101,22 +101,22 @@ int mei_wd_host_init(struct mei_device *dev)
101 */ 101 */
102int mei_wd_send(struct mei_device *dev) 102int mei_wd_send(struct mei_device *dev)
103{ 103{
104 struct mei_msg_hdr *mei_hdr; 104 struct mei_msg_hdr *hdr;
105 105
106 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; 106 hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
107 mei_hdr->host_addr = dev->wd_cl.host_client_id; 107 hdr->host_addr = dev->wd_cl.host_client_id;
108 mei_hdr->me_addr = dev->wd_cl.me_client_id; 108 hdr->me_addr = dev->wd_cl.me_client_id;
109 mei_hdr->msg_complete = 1; 109 hdr->msg_complete = 1;
110 mei_hdr->reserved = 0; 110 hdr->reserved = 0;
111 111
112 if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE)) 112 if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE))
113 mei_hdr->length = MEI_WD_START_MSG_SIZE; 113 hdr->length = MEI_WD_START_MSG_SIZE;
114 else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE)) 114 else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE))
115 mei_hdr->length = MEI_WD_STOP_MSG_SIZE; 115 hdr->length = MEI_WD_STOP_MSG_SIZE;
116 else 116 else
117 return -EINVAL; 117 return -EINVAL;
118 118
119 return mei_write_message(dev, mei_hdr, dev->wd_data, mei_hdr->length); 119 return mei_write_message(dev, hdr, dev->wd_data);
120} 120}
121 121
122/** 122/**