diff options
Diffstat (limited to 'drivers/staging/mei/interface.c')
-rw-r--r-- | drivers/staging/mei/interface.c | 72 |
1 files changed, 27 insertions, 45 deletions
diff --git a/drivers/staging/mei/interface.c b/drivers/staging/mei/interface.c index eb5df7f..9a2cfaf 100644 --- a/drivers/staging/mei/interface.c +++ b/drivers/staging/mei/interface.c @@ -1,7 +1,7 @@ /* * * Intel Management Engine Interface (Intel MEI) Linux driver - * Copyright (c) 2003-2011, Intel Corporation. + * Copyright (c) 2003-2012, Intel Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -125,7 +125,7 @@ int mei_count_empty_write_slots(struct mei_device *dev) * @write_buffer: message buffer will be written * @write_length: message size will be written * - * returns 1 if success, 0 - otherwise. + * This function returns -EIO if write has failed */ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, @@ -157,7 +157,7 @@ int mei_write_message(struct mei_device *dev, dw_to_write = ((write_length + 3) / 4); if (dw_to_write > empty_slots) - return 0; + return -EIO; mei_reg_write(dev, H_CB_WW, *((u32 *) header)); @@ -177,9 +177,9 @@ int mei_write_message(struct mei_device *dev, mei_hcsr_set(dev); dev->me_hw_state = mei_mecsr_read(dev); if ((dev->me_hw_state & ME_RDY_HRA) != ME_RDY_HRA) - return 0; + return -EIO; - return 1; + return 0; } /** @@ -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)]; - - while (buffer_length >= sizeof(u32)) { - ((u32 *) buffer)[i] = mei_mecbrw_read(dev); + u32 *reg_buf = (u32 *)buffer; - 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, ®, buffer_length); } dev->host_hw_state |= H_IG; @@ -284,7 +275,7 @@ int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl) * @returns * 0 on success * -ENOENT when me client is not found - * -EINVAL wehn ctrl credits are <= 0 + * -EINVAL when ctrl credits are <= 0 */ int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl) { @@ -317,7 +308,7 @@ int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl) * @dev: the device structure * @cl: private data of the file object * - * returns 1 if success, 0 - otherwise. + * This function returns -EIO on write failure */ int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl) { @@ -335,18 +326,15 @@ int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl) memset(mei_flow_control, 0, sizeof(*mei_flow_control)); mei_flow_control->host_addr = cl->host_client_id; mei_flow_control->me_addr = cl->me_client_id; - mei_flow_control->cmd.cmd = MEI_FLOW_CONTROL_CMD; + mei_flow_control->hbm_cmd = MEI_FLOW_CONTROL_CMD; memset(mei_flow_control->reserved, 0, sizeof(mei_flow_control->reserved)); dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n", - cl->host_client_id, cl->me_client_id); - if (!mei_write_message(dev, mei_hdr, - (unsigned char *) mei_flow_control, - sizeof(struct hbm_flow_control))) - return 0; - - return 1; + cl->host_client_id, cl->me_client_id); + return mei_write_message(dev, mei_hdr, + (unsigned char *) mei_flow_control, + sizeof(struct hbm_flow_control)); } /** @@ -380,7 +368,7 @@ int mei_other_client_is_connecting(struct mei_device *dev, * @dev: the device structure * @cl: private data of the file object * - * returns 1 if success, 0 - otherwise. + * This function returns -EIO on write failure */ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) { @@ -399,15 +387,12 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) memset(mei_cli_disconnect, 0, sizeof(*mei_cli_disconnect)); mei_cli_disconnect->host_addr = cl->host_client_id; mei_cli_disconnect->me_addr = cl->me_client_id; - mei_cli_disconnect->cmd.cmd = CLIENT_DISCONNECT_REQ_CMD; + mei_cli_disconnect->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD; mei_cli_disconnect->reserved[0] = 0; - if (!mei_write_message(dev, mei_hdr, + return mei_write_message(dev, mei_hdr, (unsigned char *) mei_cli_disconnect, - sizeof(struct hbm_client_disconnect_request))) - return 0; - - return 1; + sizeof(struct hbm_client_disconnect_request)); } /** @@ -416,7 +401,7 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) * @dev: the device structure * @cl: private data of the file object * - * returns 1 if success, 0 - otherwise. + * This function returns -EIO on write failure */ int mei_connect(struct mei_device *dev, struct mei_cl *cl) { @@ -434,13 +419,10 @@ int mei_connect(struct mei_device *dev, struct mei_cl *cl) (struct hbm_client_connect_request *) &dev->wr_msg_buf[1]; mei_cli_connect->host_addr = cl->host_client_id; mei_cli_connect->me_addr = cl->me_client_id; - mei_cli_connect->cmd.cmd = CLIENT_CONNECT_REQ_CMD; + mei_cli_connect->hbm_cmd = CLIENT_CONNECT_REQ_CMD; mei_cli_connect->reserved = 0; - if (!mei_write_message(dev, mei_hdr, + return mei_write_message(dev, mei_hdr, (unsigned char *) mei_cli_connect, - sizeof(struct hbm_client_connect_request))) - return 0; - - return 1; + sizeof(struct hbm_client_connect_request)); } |