| 
									
										
										
										
											2009-03-27 14:25:36 +01:00
										 |  |  | #ifndef _ASM_MICROBLAZE_ATOMIC_H
 | 
					
						
							|  |  |  | #define _ASM_MICROBLAZE_ATOMIC_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 19:55:33 +02:00
										 |  |  | #include <asm-generic/atomic.h>
 | 
					
						
							| 
									
										
										
										
											2009-03-27 14:25:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Atomically test *v and decrement if it is greater than 0. | 
					
						
							|  |  |  |  * The function returns the old value of *v minus 1. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static inline int atomic_dec_if_positive(atomic_t *v) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	unsigned long flags; | 
					
						
							|  |  |  | 	int res; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	local_irq_save(flags); | 
					
						
							|  |  |  | 	res = v->counter - 1; | 
					
						
							|  |  |  | 	if (res >= 0) | 
					
						
							|  |  |  | 		v->counter = res; | 
					
						
							|  |  |  | 	local_irq_restore(flags); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* _ASM_MICROBLAZE_ATOMIC_H */
 |