diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-21 13:57:13 -0800 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-21 13:57:13 -0800 | 
| commit | 7ed214ac2095f561a94335ca672b6c42a1ea40ff (patch) | |
| tree | da41901bff1d0d8d61170bf362384fdc61deb3ab /drivers/misc/mei/amthif.c | |
| parent | 21eaab6d19ed43e82ed39c8deb7f192134fb4a0e (diff) | |
| parent | 29e5507ae4ab34397f538f06b7070c81a4e4a2bf (diff) | |
| download | olio-linux-3.10-7ed214ac2095f561a94335ca672b6c42a1ea40ff.tar.xz olio-linux-3.10-7ed214ac2095f561a94335ca672b6c42a1ea40ff.zip  | |
Merge tag 'char-misc-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver patches from Greg Kroah-Hartman:
 "Here's the big char/misc driver patches for 3.9-rc1.
  Nothing major here, just lots of different driver updates (mei,
  hyperv, ipack, extcon, vmci, etc.).
  All of these have been in the linux-next tree for a while."
* tag 'char-misc-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (209 commits)
  w1: w1_therm: Add force-pullup option for "broken" sensors
  w1: ds2482: Added 1-Wire pull-up support to the driver
  vme: add missing put_device() after device_register() fails
  extcon: max8997: Use workqueue to check cable state after completing boot of platform
  extcon: max8997: Set default UART/USB path on probe
  extcon: max8997: Consolidate duplicate code for checking ADC/CHG cable type
  extcon: max8997: Set default of ADC debounce time during initialization
  extcon: max8997: Remove duplicate code related to set H/W line path
  extcon: max8997: Move defined constant to header file
  extcon: max77693: Make max77693_extcon_cable static
  extcon: max8997: Remove unreachable code
  extcon: max8997: Make max8997_extcon_cable static
  extcon: max77693: Remove unnecessary goto statement to improve readability
  extcon: max77693: Convert to devm_input_allocate_device()
  extcon: gpio: Rename filename of extcon-gpio.c according to kernel naming style
  CREDITS: update email and address of Harald Hoyer
  extcon: arizona: Use MICDET for final microphone identification
  extcon: arizona: Always take the first HPDET reading as the final one
  extcon: arizona: Clear _trig_sts bits after jack detection
  extcon: arizona: Don't HPDET magic when headphones are enabled
  ...
Diffstat (limited to 'drivers/misc/mei/amthif.c')
| -rw-r--r-- | drivers/misc/mei/amthif.c | 164 | 
1 files changed, 87 insertions, 77 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c index e40ffd9502d..c86d7e3839a 100644 --- a/drivers/misc/mei/amthif.c +++ b/drivers/misc/mei/amthif.c @@ -31,15 +31,16 @@  #include <linux/jiffies.h>  #include <linux/uaccess.h> +#include <linux/mei.h>  #include "mei_dev.h" -#include "hw.h" -#include <linux/mei.h> -#include "interface.h" +#include "hbm.h" +#include "hw-me.h" +#include "client.h" -const uuid_le mei_amthi_guid  = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac, -						0xa8, 0x46, 0xe0, 0xff, 0x65, -						0x81, 0x4c); +const uuid_le mei_amthif_guid  = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, +					 0xac, 0xa8, 0x46, 0xe0, +					 0xff, 0x65, 0x81, 0x4c);  /**   * mei_amthif_reset_params - initializes mei device iamthif @@ -64,22 +65,24 @@ void mei_amthif_reset_params(struct mei_device *dev)   * @dev: the device structure   *   */ -void mei_amthif_host_init(struct mei_device *dev) +int mei_amthif_host_init(struct mei_device *dev)  { -	int i; +	struct mei_cl *cl = &dev->iamthif_cl;  	unsigned char *msg_buf; +	int ret, i; + +	dev->iamthif_state = MEI_IAMTHIF_IDLE; -	mei_cl_init(&dev->iamthif_cl, dev); -	dev->iamthif_cl.state = MEI_FILE_DISCONNECTED; +	mei_cl_init(cl, dev); -	/* find ME amthi client */ -	i = mei_me_cl_link(dev, &dev->iamthif_cl, -			    &mei_amthi_guid, MEI_IAMTHIF_HOST_CLIENT_ID); +	i = mei_me_cl_by_uuid(dev, &mei_amthif_guid);  	if (i < 0) { -		dev_info(&dev->pdev->dev, "failed to find iamthif client.\n"); -		return; +		dev_info(&dev->pdev->dev, "amthif: failed to find the client\n"); +		return -ENOENT;  	} +	cl->me_client_id = dev->me_clients[i].client_id; +  	/* Assign iamthif_mtu to the value received from ME  */  	dev->iamthif_mtu = dev->me_clients[i].props.max_msg_length; @@ -93,19 +96,29 @@ void mei_amthif_host_init(struct mei_device *dev)  	msg_buf = kcalloc(dev->iamthif_mtu,  			sizeof(unsigned char), GFP_KERNEL);  	if (!msg_buf) { -		dev_dbg(&dev->pdev->dev, "memory allocation for ME message buffer failed.\n"); -		return; +		dev_err(&dev->pdev->dev, "amthif: memory allocation for ME message buffer failed.\n"); +		return -ENOMEM;  	}  	dev->iamthif_msg_buf = msg_buf; -	if (mei_connect(dev, &dev->iamthif_cl)) { -		dev_dbg(&dev->pdev->dev, "Failed to connect to AMTHI client\n"); -		dev->iamthif_cl.state = MEI_FILE_DISCONNECTED; -		dev->iamthif_cl.host_client_id = 0; +	ret = mei_cl_link(cl, MEI_IAMTHIF_HOST_CLIENT_ID); + +	if (ret < 0) { +		dev_err(&dev->pdev->dev, "amthif: failed link client\n"); +		return -ENOENT; +	} + +	cl->state = MEI_FILE_CONNECTING; + +	if (mei_hbm_cl_connect_req(dev, cl)) { +		dev_dbg(&dev->pdev->dev, "amthif: Failed to connect to ME client\n"); +		cl->state = MEI_FILE_DISCONNECTED; +		cl->host_client_id = 0;  	} else { -		dev->iamthif_cl.timer_count = MEI_CONNECT_TIMEOUT; +		cl->timer_count = MEI_CONNECT_TIMEOUT;  	} +	return 0;  }  /** @@ -168,10 +181,10 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,  	i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id);  	if (i < 0) { -		dev_dbg(&dev->pdev->dev, "amthi client not found.\n"); +		dev_dbg(&dev->pdev->dev, "amthif client not found.\n");  		return -ENODEV;  	} -	dev_dbg(&dev->pdev->dev, "checking amthi data\n"); +	dev_dbg(&dev->pdev->dev, "checking amthif data\n");  	cb = mei_amthif_find_read_list_entry(dev, file);  	/* Check for if we can block or not*/ @@ -179,7 +192,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,  		return -EAGAIN; -	dev_dbg(&dev->pdev->dev, "waiting for amthi data\n"); +	dev_dbg(&dev->pdev->dev, "waiting for amthif data\n");  	while (cb == NULL) {  		/* unlock the Mutex */  		mutex_unlock(&dev->device_lock); @@ -197,17 +210,17 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,  	} -	dev_dbg(&dev->pdev->dev, "Got amthi data\n"); +	dev_dbg(&dev->pdev->dev, "Got amthif data\n");  	dev->iamthif_timer = 0;  	if (cb) {  		timeout = cb->read_time +  			mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER); -		dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n", +		dev_dbg(&dev->pdev->dev, "amthif timeout = %lud\n",  				timeout);  		if  (time_after(jiffies, timeout)) { -			dev_dbg(&dev->pdev->dev, "amthi Time out\n"); +			dev_dbg(&dev->pdev->dev, "amthif Time out\n");  			/* 15 sec for the message has expired */  			list_del(&cb->list);  			rets = -ETIMEDOUT; @@ -227,9 +240,9 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,  		 * remove message from deletion list  		 */ -	dev_dbg(&dev->pdev->dev, "amthi cb->response_buffer size - %d\n", +	dev_dbg(&dev->pdev->dev, "amthif cb->response_buffer size - %d\n",  	    cb->response_buffer.size); -	dev_dbg(&dev->pdev->dev, "amthi cb->buf_idx - %lu\n", cb->buf_idx); +	dev_dbg(&dev->pdev->dev, "amthif cb->buf_idx - %lu\n", cb->buf_idx);  	/* length is being turncated to PAGE_SIZE, however,  	 * the buf_idx may point beyond */ @@ -245,7 +258,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,  		}  	}  free: -	dev_dbg(&dev->pdev->dev, "free amthi cb memory.\n"); +	dev_dbg(&dev->pdev->dev, "free amthif cb memory.\n");  	*offset = 0;  	mei_io_cb_free(cb);  out: @@ -269,7 +282,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)  	if (!dev || !cb)  		return -ENODEV; -	dev_dbg(&dev->pdev->dev, "write data to amthi client.\n"); +	dev_dbg(&dev->pdev->dev, "write data to amthif client.\n");  	dev->iamthif_state = MEI_IAMTHIF_WRITING;  	dev->iamthif_current_cb = cb; @@ -280,15 +293,15 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)  	memcpy(dev->iamthif_msg_buf, cb->request_buffer.data,  	       cb->request_buffer.size); -	ret = mei_flow_ctrl_creds(dev, &dev->iamthif_cl); +	ret = mei_cl_flow_ctrl_creds(&dev->iamthif_cl);  	if (ret < 0)  		return ret; -	if (ret && dev->mei_host_buffer_is_empty) { +	if (ret && dev->hbuf_is_ready) {  		ret = 0; -		dev->mei_host_buffer_is_empty = false; -		if (cb->request_buffer.size > mei_hbuf_max_data(dev)) { -			mei_hdr.length = mei_hbuf_max_data(dev); +		dev->hbuf_is_ready = false; +		if (cb->request_buffer.size > mei_hbuf_max_len(dev)) { +			mei_hdr.length = mei_hbuf_max_len(dev);  			mei_hdr.msg_complete = 0;  		} else {  			mei_hdr.length = cb->request_buffer.size; @@ -300,25 +313,24 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)  		mei_hdr.reserved = 0;  		dev->iamthif_msg_buf_index += mei_hdr.length;  		if (mei_write_message(dev, &mei_hdr, -					(unsigned char *)(dev->iamthif_msg_buf), -					mei_hdr.length)) +					(unsigned char *)dev->iamthif_msg_buf))  			return -ENODEV;  		if (mei_hdr.msg_complete) { -			if (mei_flow_ctrl_reduce(dev, &dev->iamthif_cl)) +			if (mei_cl_flow_ctrl_reduce(&dev->iamthif_cl))  				return -ENODEV;  			dev->iamthif_flow_control_pending = true;  			dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL; -			dev_dbg(&dev->pdev->dev, "add amthi cb to write waiting list\n"); +			dev_dbg(&dev->pdev->dev, "add amthif cb to write waiting list\n");  			dev->iamthif_current_cb = cb;  			dev->iamthif_file_object = cb->file_object;  			list_add_tail(&cb->list, &dev->write_waiting_list.list);  		} else { -			dev_dbg(&dev->pdev->dev, "message does not complete, so add amthi cb to write list.\n"); +			dev_dbg(&dev->pdev->dev, "message does not complete, so add amthif cb to write list.\n");  			list_add_tail(&cb->list, &dev->write_list.list);  		}  	} else { -		if (!(dev->mei_host_buffer_is_empty)) +		if (!dev->hbuf_is_ready)  			dev_dbg(&dev->pdev->dev, "host buffer is not empty");  		dev_dbg(&dev->pdev->dev, "No flow control credentials, so add iamthif cb to write list.\n"); @@ -383,7 +395,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)  	dev->iamthif_timer = 0;  	dev->iamthif_file_object = NULL; -	dev_dbg(&dev->pdev->dev, "complete amthi cmd_list cb.\n"); +	dev_dbg(&dev->pdev->dev, "complete amthif cmd_list cb.\n");  	list_for_each_entry_safe(pos, next, &dev->amthif_cmd_list.list, list) {  		list_del(&pos->list); @@ -392,7 +404,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)  			status = mei_amthif_send_cmd(dev, pos);  			if (status) {  				dev_dbg(&dev->pdev->dev, -					"amthi write failed status = %d\n", +					"amthif write failed status = %d\n",  						status);  				return;  			} @@ -412,7 +424,7 @@ unsigned int mei_amthif_poll(struct mei_device *dev,  	if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE &&  		dev->iamthif_file_object == file) {  		mask |= (POLLIN | POLLRDNORM); -		dev_dbg(&dev->pdev->dev, "run next amthi cb\n"); +		dev_dbg(&dev->pdev->dev, "run next amthif cb\n");  		mei_amthif_run_next_cmd(dev);  	}  	return mask; @@ -434,54 +446,51 @@ unsigned int mei_amthif_poll(struct mei_device *dev,  int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,  			struct mei_cl_cb *cb, struct mei_cl_cb *cmpl_list)  { -	struct mei_msg_hdr *mei_hdr; +	struct mei_msg_hdr mei_hdr;  	struct mei_cl *cl = cb->cl;  	size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;  	size_t msg_slots = mei_data2slots(len); -	mei_hdr = (struct mei_msg_hdr *)&dev->wr_msg_buf[0]; -	mei_hdr->host_addr = cl->host_client_id; -	mei_hdr->me_addr = cl->me_client_id; -	mei_hdr->reserved = 0; +	mei_hdr.host_addr = cl->host_client_id; +	mei_hdr.me_addr = cl->me_client_id; +	mei_hdr.reserved = 0;  	if (*slots >= msg_slots) { -		mei_hdr->length = len; -		mei_hdr->msg_complete = 1; +		mei_hdr.length = len; +		mei_hdr.msg_complete = 1;  	/* Split the message only if we can write the whole host buffer */  	} else if (*slots == dev->hbuf_depth) {  		msg_slots = *slots;  		len = (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr); -		mei_hdr->length = len; -		mei_hdr->msg_complete = 0; +		mei_hdr.length = len; +		mei_hdr.msg_complete = 0;  	} else {  		/* wait for next time the host buffer is empty */  		return 0;  	} -	dev_dbg(&dev->pdev->dev, "msg: len = %d complete = %d\n", -			mei_hdr->length, mei_hdr->msg_complete); +	dev_dbg(&dev->pdev->dev, MEI_HDR_FMT,  MEI_HDR_PRM(&mei_hdr));  	*slots -=  msg_slots; -	if (mei_write_message(dev, mei_hdr, -		dev->iamthif_msg_buf + dev->iamthif_msg_buf_index, -		mei_hdr->length)) { +	if (mei_write_message(dev, &mei_hdr, +		dev->iamthif_msg_buf + dev->iamthif_msg_buf_index)) {  			dev->iamthif_state = MEI_IAMTHIF_IDLE;  			cl->status = -ENODEV;  			list_del(&cb->list);  			return -ENODEV;  	} -	if (mei_flow_ctrl_reduce(dev, cl)) +	if (mei_cl_flow_ctrl_reduce(cl))  		return -ENODEV; -	dev->iamthif_msg_buf_index += mei_hdr->length; +	dev->iamthif_msg_buf_index += mei_hdr.length;  	cl->status = 0; -	if (mei_hdr->msg_complete) { +	if (mei_hdr.msg_complete) {  		dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;  		dev->iamthif_flow_control_pending = true; -		/* save iamthif cb sent to amthi client */ +		/* save iamthif cb sent to amthif client */  		cb->buf_idx = dev->iamthif_msg_buf_index;  		dev->iamthif_current_cb = cb; @@ -494,11 +503,11 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,  /**   * mei_amthif_irq_read_message - read routine after ISR to - *			handle the read amthi message + *			handle the read amthif message   *   * @complete_list: An instance of our list structure   * @dev: the device structure - * @mei_hdr: header of amthi message + * @mei_hdr: header of amthif message   *   * returns 0 on success, <0 on failure.   */ @@ -522,10 +531,10 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,  		return 0;  	dev_dbg(&dev->pdev->dev, -			"amthi_message_buffer_index =%d\n", +			"amthif_message_buffer_index =%d\n",  			mei_hdr->length); -	dev_dbg(&dev->pdev->dev, "completed amthi read.\n "); +	dev_dbg(&dev->pdev->dev, "completed amthif read.\n ");  	if (!dev->iamthif_current_cb)  		return -ENODEV; @@ -540,8 +549,8 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,  	cb->read_time = jiffies;  	if (dev->iamthif_ioctl && cb->cl == &dev->iamthif_cl) {  		/* found the iamthif cb */ -		dev_dbg(&dev->pdev->dev, "complete the amthi read cb.\n "); -		dev_dbg(&dev->pdev->dev, "add the amthi read cb to complete.\n "); +		dev_dbg(&dev->pdev->dev, "complete the amthif read cb.\n "); +		dev_dbg(&dev->pdev->dev, "add the amthif read cb to complete.\n ");  		list_add_tail(&cb->list, &complete_list->list);  	}  	return 0; @@ -563,7 +572,7 @@ int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)  		return -EMSGSIZE;  	}  	*slots -= mei_data2slots(sizeof(struct hbm_flow_control)); -	if (mei_send_flow_control(dev, &dev->iamthif_cl)) { +	if (mei_hbm_cl_flow_control_req(dev, &dev->iamthif_cl)) {  		dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");  		return -EIO;  	} @@ -574,7 +583,7 @@ int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)  	dev->iamthif_msg_buf_index = 0;  	dev->iamthif_msg_buf_size = 0;  	dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER; -	dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev); +	dev->hbuf_is_ready = mei_hbuf_is_ready(dev);  	return 0;  } @@ -593,7 +602,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)  				dev->iamthif_msg_buf,  				dev->iamthif_msg_buf_index);  		list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list); -		dev_dbg(&dev->pdev->dev, "amthi read completed\n"); +		dev_dbg(&dev->pdev->dev, "amthif read completed\n");  		dev->iamthif_timer = jiffies;  		dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",  				dev->iamthif_timer); @@ -601,7 +610,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)  		mei_amthif_run_next_cmd(dev);  	} -	dev_dbg(&dev->pdev->dev, "completing amthi call back.\n"); +	dev_dbg(&dev->pdev->dev, "completing amthif call back.\n");  	wake_up_interruptible(&dev->iamthif_cl.wait);  } @@ -635,7 +644,8 @@ static bool mei_clear_list(struct mei_device *dev,  			if (dev->iamthif_current_cb == cb_pos) {  				dev->iamthif_current_cb = NULL;  				/* send flow control to iamthif client */ -				mei_send_flow_control(dev, &dev->iamthif_cl); +				mei_hbm_cl_flow_control_req(dev, +							&dev->iamthif_cl);  			}  			/* free all allocated buffers */  			mei_io_cb_free(cb_pos); @@ -706,11 +716,11 @@ int mei_amthif_release(struct mei_device *dev, struct file *file)  	if (dev->iamthif_file_object == file &&  	    dev->iamthif_state != MEI_IAMTHIF_IDLE) { -		dev_dbg(&dev->pdev->dev, "amthi canceled iamthif state %d\n", +		dev_dbg(&dev->pdev->dev, "amthif canceled iamthif state %d\n",  		    dev->iamthif_state);  		dev->iamthif_canceled = true;  		if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) { -			dev_dbg(&dev->pdev->dev, "run next amthi iamthif cb\n"); +			dev_dbg(&dev->pdev->dev, "run next amthif iamthif cb\n");  			mei_amthif_run_next_cmd(dev);  		}  	}  |