mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	alarmtimer: Implement remaining callback
Preparatory change to utilize the common posix timer mechanisms. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: John Stultz <john.stultz@linaro.org> Link: http://lkml.kernel.org/r/20170530211657.592676753@linutronix.de
This commit is contained in:
		
							parent
							
								
									e7561f1633
								
							
						
					
					
						commit
						d653d8457c
					
				
					 1 changed files with 22 additions and 9 deletions
				
			
		| 
						 | 
					@ -560,6 +560,18 @@ static int alarm_timer_forward(struct k_itimer *timr, ktime_t now)
 | 
				
			||||||
	return (int) alarm_forward(alarm, timr->it_interval, now);
 | 
						return (int) alarm_forward(alarm, timr->it_interval, now);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * alarm_timer_remaining - Posix timer callback to retrieve remaining time
 | 
				
			||||||
 | 
					 * @timr:	Pointer to the posixtimer data struct
 | 
				
			||||||
 | 
					 * @now:	Current time to calculate against
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static ktime_t alarm_timer_remaining(struct k_itimer *timr, ktime_t now)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct alarm *alarm = &timr->it.alarm.alarmtimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return ktime_sub(now, alarm->node.expires);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * alarm_clock_getres - posix getres interface
 | 
					 * alarm_clock_getres - posix getres interface
 | 
				
			||||||
 * @which_clock: clockid
 | 
					 * @which_clock: clockid
 | 
				
			||||||
| 
						 | 
					@ -881,15 +893,16 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct k_clock alarm_clock = {
 | 
					const struct k_clock alarm_clock = {
 | 
				
			||||||
	.clock_getres	= alarm_clock_getres,
 | 
						.clock_getres		= alarm_clock_getres,
 | 
				
			||||||
	.clock_get	= alarm_clock_get,
 | 
						.clock_get		= alarm_clock_get,
 | 
				
			||||||
	.timer_create	= alarm_timer_create,
 | 
						.timer_create		= alarm_timer_create,
 | 
				
			||||||
	.timer_set	= alarm_timer_set,
 | 
						.timer_set		= alarm_timer_set,
 | 
				
			||||||
	.timer_del	= alarm_timer_del,
 | 
						.timer_del		= alarm_timer_del,
 | 
				
			||||||
	.timer_get	= alarm_timer_get,
 | 
						.timer_get		= alarm_timer_get,
 | 
				
			||||||
	.timer_rearm	= alarm_timer_rearm,
 | 
						.timer_rearm		= alarm_timer_rearm,
 | 
				
			||||||
	.timer_forward	= alarm_timer_forward,
 | 
						.timer_forward		= alarm_timer_forward,
 | 
				
			||||||
	.nsleep		= alarm_timer_nsleep,
 | 
						.timer_remaining	= alarm_timer_remaining,
 | 
				
			||||||
 | 
						.nsleep			= alarm_timer_nsleep,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif /* CONFIG_POSIX_TIMERS */
 | 
					#endif /* CONFIG_POSIX_TIMERS */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue