diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2012-11-18 08:13:14 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-21 15:43:57 -0500 |
commit | 5bd647144151082f0e8beb58741e27e6dbd23827 (patch) | |
tree | dc63f6e68046d280135cc1823ef65a03dc63dcda /drivers/misc/mei/interface.c | |
parent | 2c9e9fdc0b2d55886609f0503fb91f96dfec6948 (diff) |
mei: compact code for mei bus message creation
1. replace boilerplate code for filling up the bus message header
with a common wrapper function
2. shorten variable names and use temporal variables
to save some screen space
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/interface.c')
-rw-r--r-- | drivers/misc/mei/interface.c | 75 |
1 files changed, 29 insertions, 46 deletions
diff --git a/drivers/misc/mei/interface.c b/drivers/misc/mei/interface.c index 6b50cf0253e5..8de854785960 100644 --- a/drivers/misc/mei/interface.c +++ b/drivers/misc/mei/interface.c | |||
@@ -292,28 +292,23 @@ int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl) | |||
292 | int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl) | 292 | int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl) |
293 | { | 293 | { |
294 | struct mei_msg_hdr *mei_hdr; | 294 | struct mei_msg_hdr *mei_hdr; |
295 | struct hbm_flow_control *mei_flow_control; | 295 | struct hbm_flow_control *flow_ctrl; |
296 | 296 | const size_t len = sizeof(struct hbm_flow_control); | |
297 | mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; | 297 | |
298 | mei_hdr->host_addr = 0; | 298 | mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); |
299 | mei_hdr->me_addr = 0; | 299 | |
300 | mei_hdr->length = sizeof(struct hbm_flow_control); | 300 | flow_ctrl = (struct hbm_flow_control *)&dev->wr_msg_buf[1]; |
301 | mei_hdr->msg_complete = 1; | 301 | memset(flow_ctrl, 0, len); |
302 | mei_hdr->reserved = 0; | 302 | flow_ctrl->hbm_cmd = MEI_FLOW_CONTROL_CMD; |
303 | 303 | flow_ctrl->host_addr = cl->host_client_id; | |
304 | mei_flow_control = (struct hbm_flow_control *) &dev->wr_msg_buf[1]; | 304 | flow_ctrl->me_addr = cl->me_client_id; |
305 | memset(mei_flow_control, 0, sizeof(*mei_flow_control)); | 305 | /* FIXME: reserved !? */ |
306 | mei_flow_control->host_addr = cl->host_client_id; | 306 | memset(flow_ctrl->reserved, 0, sizeof(flow_ctrl->reserved)); |
307 | mei_flow_control->me_addr = cl->me_client_id; | ||
308 | mei_flow_control->hbm_cmd = MEI_FLOW_CONTROL_CMD; | ||
309 | memset(mei_flow_control->reserved, 0, | ||
310 | sizeof(mei_flow_control->reserved)); | ||
311 | dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n", | 307 | dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n", |
312 | cl->host_client_id, cl->me_client_id); | 308 | cl->host_client_id, cl->me_client_id); |
313 | 309 | ||
314 | return mei_write_message(dev, mei_hdr, | 310 | return mei_write_message(dev, mei_hdr, |
315 | (unsigned char *) mei_flow_control, | 311 | (unsigned char *) flow_ctrl, len); |
316 | sizeof(struct hbm_flow_control)); | ||
317 | } | 312 | } |
318 | 313 | ||
319 | /** | 314 | /** |
@@ -353,23 +348,18 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) | |||
353 | { | 348 | { |
354 | struct mei_msg_hdr *mei_hdr; | 349 | struct mei_msg_hdr *mei_hdr; |
355 | struct hbm_client_connect_request *req; | 350 | struct hbm_client_connect_request *req; |
351 | const size_t len = sizeof(struct hbm_client_connect_request); | ||
356 | 352 | ||
357 | mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; | 353 | mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); |
358 | mei_hdr->host_addr = 0; | ||
359 | mei_hdr->me_addr = 0; | ||
360 | mei_hdr->length = sizeof(struct hbm_client_connect_request); | ||
361 | mei_hdr->msg_complete = 1; | ||
362 | mei_hdr->reserved = 0; | ||
363 | 354 | ||
364 | req = (struct hbm_client_connect_request *)&dev->wr_msg_buf[1]; | 355 | req = (struct hbm_client_connect_request *)&dev->wr_msg_buf[1]; |
365 | memset(req, 0, sizeof(*req)); | 356 | memset(req, 0, len); |
357 | req->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD; | ||
366 | req->host_addr = cl->host_client_id; | 358 | req->host_addr = cl->host_client_id; |
367 | req->me_addr = cl->me_client_id; | 359 | req->me_addr = cl->me_client_id; |
368 | req->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD; | ||
369 | req->reserved = 0; | 360 | req->reserved = 0; |
370 | 361 | ||
371 | return mei_write_message(dev, mei_hdr, (unsigned char *)req, | 362 | return mei_write_message(dev, mei_hdr, (unsigned char *)req, len); |
372 | sizeof(struct hbm_client_connect_request)); | ||
373 | } | 363 | } |
374 | 364 | ||
375 | /** | 365 | /** |
@@ -383,23 +373,16 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) | |||
383 | int mei_connect(struct mei_device *dev, struct mei_cl *cl) | 373 | int mei_connect(struct mei_device *dev, struct mei_cl *cl) |
384 | { | 374 | { |
385 | struct mei_msg_hdr *mei_hdr; | 375 | struct mei_msg_hdr *mei_hdr; |
386 | struct hbm_client_connect_request *mei_cli_connect; | 376 | struct hbm_client_connect_request *req; |
387 | 377 | const size_t len = sizeof(struct hbm_client_connect_request); | |
388 | mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; | ||
389 | mei_hdr->host_addr = 0; | ||
390 | mei_hdr->me_addr = 0; | ||
391 | mei_hdr->length = sizeof(struct hbm_client_connect_request); | ||
392 | mei_hdr->msg_complete = 1; | ||
393 | mei_hdr->reserved = 0; | ||
394 | |||
395 | mei_cli_connect = | ||
396 | (struct hbm_client_connect_request *) &dev->wr_msg_buf[1]; | ||
397 | mei_cli_connect->host_addr = cl->host_client_id; | ||
398 | mei_cli_connect->me_addr = cl->me_client_id; | ||
399 | mei_cli_connect->hbm_cmd = CLIENT_CONNECT_REQ_CMD; | ||
400 | mei_cli_connect->reserved = 0; | ||
401 | 378 | ||
402 | return mei_write_message(dev, mei_hdr, | 379 | mei_hdr = mei_hbm_hdr(&dev->wr_msg_buf[0], len); |
403 | (unsigned char *) mei_cli_connect, | 380 | |
404 | sizeof(struct hbm_client_connect_request)); | 381 | req = (struct hbm_client_connect_request *) &dev->wr_msg_buf[1]; |
382 | req->hbm_cmd = CLIENT_CONNECT_REQ_CMD; | ||
383 | req->host_addr = cl->host_client_id; | ||
384 | req->me_addr = cl->me_client_id; | ||
385 | req->reserved = 0; | ||
386 | |||
387 | return mei_write_message(dev, mei_hdr, (unsigned char *) req, len); | ||
405 | } | 388 | } |