forked from mirrors/linux
		
	HID: intel-ish-hid: ishtp: add helper functions for client buffer operation
Add helper ishtp_cl_tx_empty() and ishtp_cl_rx_get_rb() to hide internal details from callers, who needs this functionality. Signed-off-by: Even Xu <even.xu@intel.com> Reviewed-by: Andriy Shevchenko <andriy.shevchenko@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
		
							parent
							
								
									d174c6664f
								
							
						
					
					
						commit
						a1c40ce62f
					
				
					 2 changed files with 47 additions and 0 deletions
				
			
		|  | @ -255,3 +255,48 @@ int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb) | ||||||
| 	return	rets; | 	return	rets; | ||||||
| } | } | ||||||
| EXPORT_SYMBOL(ishtp_cl_io_rb_recycle); | EXPORT_SYMBOL(ishtp_cl_io_rb_recycle); | ||||||
|  | 
 | ||||||
|  | /**
 | ||||||
|  |  * ishtp_cl_tx_empty() -test whether client device tx buffer is empty | ||||||
|  |  * @cl: Pointer to client device instance | ||||||
|  |  * | ||||||
|  |  * Look client device tx buffer list, and check whether this list is empty | ||||||
|  |  * | ||||||
|  |  * Return: true if client tx buffer list is empty else false | ||||||
|  |  */ | ||||||
|  | bool ishtp_cl_tx_empty(struct ishtp_cl *cl) | ||||||
|  | { | ||||||
|  | 	int tx_list_empty; | ||||||
|  | 	unsigned long tx_flags; | ||||||
|  | 
 | ||||||
|  | 	spin_lock_irqsave(&cl->tx_list_spinlock, tx_flags); | ||||||
|  | 	tx_list_empty = list_empty(&cl->tx_list.list); | ||||||
|  | 	spin_unlock_irqrestore(&cl->tx_list_spinlock, tx_flags); | ||||||
|  | 
 | ||||||
|  | 	return !!tx_list_empty; | ||||||
|  | } | ||||||
|  | EXPORT_SYMBOL(ishtp_cl_tx_empty); | ||||||
|  | 
 | ||||||
|  | /**
 | ||||||
|  |  * ishtp_cl_rx_get_rb() -Get a rb from client device rx buffer list | ||||||
|  |  * @cl: Pointer to client device instance | ||||||
|  |  * | ||||||
|  |  * Check client device in-processing buffer list and get a rb from it. | ||||||
|  |  * | ||||||
|  |  * Return: rb pointer if buffer list isn't empty else NULL | ||||||
|  |  */ | ||||||
|  | struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl) | ||||||
|  | { | ||||||
|  | 	unsigned long rx_flags; | ||||||
|  | 	struct ishtp_cl_rb *rb; | ||||||
|  | 
 | ||||||
|  | 	spin_lock_irqsave(&cl->in_process_spinlock, rx_flags); | ||||||
|  | 	rb = list_first_entry_or_null(&cl->in_process_list.list, | ||||||
|  | 				struct ishtp_cl_rb, list); | ||||||
|  | 	if (rb) | ||||||
|  | 		list_del_init(&rb->list); | ||||||
|  | 	spin_unlock_irqrestore(&cl->in_process_spinlock, rx_flags); | ||||||
|  | 
 | ||||||
|  | 	return rb; | ||||||
|  | } | ||||||
|  | EXPORT_SYMBOL(ishtp_cl_rx_get_rb); | ||||||
|  |  | ||||||
|  | @ -178,5 +178,7 @@ int ishtp_cl_flush_queues(struct ishtp_cl *cl); | ||||||
| 
 | 
 | ||||||
| /* exported functions from ISHTP client buffer management scope */ | /* exported functions from ISHTP client buffer management scope */ | ||||||
| int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); | int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); | ||||||
|  | bool ishtp_cl_tx_empty(struct ishtp_cl *cl); | ||||||
|  | struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); | ||||||
| 
 | 
 | ||||||
| #endif /* _ISHTP_CLIENT_H_ */ | #endif /* _ISHTP_CLIENT_H_ */ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Even Xu
						Even Xu