| 
									
										
										
										
											2010-11-16 10:58:37 +09:00
										 |  |  | #ifndef _LINUX_AVERAGE_H
 | 
					
						
							|  |  |  | #define _LINUX_AVERAGE_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Exponentially weighted moving average (EWMA) */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* For more documentation see lib/average.c */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct ewma { | 
					
						
							|  |  |  | 	unsigned long internal; | 
					
						
							|  |  |  | 	unsigned long factor; | 
					
						
							|  |  |  | 	unsigned long weight; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern void ewma_init(struct ewma *avg, unsigned long factor, | 
					
						
							|  |  |  | 		      unsigned long weight); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern struct ewma *ewma_add(struct ewma *avg, unsigned long val); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * ewma_read() - Get average value | 
					
						
							|  |  |  |  * @avg: Average structure | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Returns the average value held in @avg. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static inline unsigned long ewma_read(const struct ewma *avg) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-12-02 19:50:37 +09:00
										 |  |  | 	return avg->internal >> avg->factor; | 
					
						
							| 
									
										
										
										
											2010-11-16 10:58:37 +09:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* _LINUX_AVERAGE_H */
 |