Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78c4def6 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'timers-core-for-linus' of...

Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  hrtimer: Make lookup table const
  RTC: Disable CONFIG_RTC_CLASS from being built as a module
  timers: Fix alarmtimer build issues when CONFIG_RTC_CLASS=n
  timers: Remove delayed irqwork from alarmtimers implementation
  timers: Improve alarmtimer comments and minor fixes
  timers: Posix interface for alarm-timers
  timers: Introduce in-kernel alarm-timer interface
  timers: Add rb_init_node() to allow for stack allocated rb nodes
  time: Add timekeeping_inject_sleeptime
parents 7e6628e4 942c3c5c
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -3,10 +3,10 @@
#

config RTC_LIB
	tristate
	bool

menuconfig RTC_CLASS
	tristate "Real Time Clock"
	bool "Real Time Clock"
	default n
	depends on !S390
	select RTC_LIB
@@ -15,9 +15,6 @@ menuconfig RTC_CLASS
 	  be allowed to plug one or more RTCs to your system. You will
	  probably want to enable one or more of the interfaces below.

	  This driver can also be built as a module. If so, the module
	  will be called rtc-core.

if RTC_CLASS

config RTC_HCTOSYS
+9 −14
Original line number Diff line number Diff line
@@ -41,26 +41,21 @@ static void rtc_device_release(struct device *dev)
 * system's wall clock; restore it on resume().
 */

static struct timespec	delta;
static time_t		oldtime;
static struct timespec	oldts;

static int rtc_suspend(struct device *dev, pm_message_t mesg)
{
	struct rtc_device	*rtc = to_rtc_device(dev);
	struct rtc_time		tm;
	struct timespec		ts = current_kernel_time();

	if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0)
		return 0;

	rtc_read_time(rtc, &tm);
	ktime_get_ts(&oldts);
	rtc_tm_to_time(&tm, &oldtime);

	/* RTC precision is 1 second; adjust delta for avg 1/2 sec err */
	set_normalized_timespec(&delta,
				ts.tv_sec - oldtime,
				ts.tv_nsec - (NSEC_PER_SEC >> 1));

	return 0;
}

@@ -70,10 +65,12 @@ static int rtc_resume(struct device *dev)
	struct rtc_time		tm;
	time_t			newtime;
	struct timespec		time;
	struct timespec		newts;

	if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0)
		return 0;

	ktime_get_ts(&newts);
	rtc_read_time(rtc, &tm);
	if (rtc_valid_tm(&tm) != 0) {
		pr_debug("%s:  bogus resume time\n", dev_name(&rtc->dev));
@@ -85,15 +82,13 @@ static int rtc_resume(struct device *dev)
			pr_debug("%s:  time travel!\n", dev_name(&rtc->dev));
		return 0;
	}
	/* calculate the RTC time delta */
	set_normalized_timespec(&time, newtime - oldtime, 0);

	/* restore wall clock using delta against this RTC;
	 * adjust again for avg 1/2 second RTC sampling error
	 */
	set_normalized_timespec(&time,
				newtime + delta.tv_sec,
				(NSEC_PER_SEC >> 1) + delta.tv_nsec);
	do_settimeofday(&time);
	/* subtract kernel time between rtc_suspend to rtc_resume */
	time = timespec_sub(time, timespec_sub(newts, oldts));

	timekeeping_inject_sleeptime(&time);
	return 0;
}

+40 −0
Original line number Diff line number Diff line
#ifndef _LINUX_ALARMTIMER_H
#define _LINUX_ALARMTIMER_H

#include <linux/time.h>
#include <linux/hrtimer.h>
#include <linux/timerqueue.h>
#include <linux/rtc.h>

enum alarmtimer_type {
	ALARM_REALTIME,
	ALARM_BOOTTIME,

	ALARM_NUMTYPE,
};

/**
 * struct alarm - Alarm timer structure
 * @node:	timerqueue node for adding to the event list this value
 *		also includes the expiration time.
 * @period:	Period for recuring alarms
 * @function:	Function pointer to be executed when the timer fires.
 * @type:	Alarm type (BOOTTIME/REALTIME)
 * @enabled:	Flag that represents if the alarm is set to fire or not
 * @data:	Internal data value.
 */
struct alarm {
	struct timerqueue_node	node;
	ktime_t			period;
	void			(*function)(struct alarm *);
	enum alarmtimer_type	type;
	bool			enabled;
	void			*data;
};

void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
		void (*function)(struct alarm *));
void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
void alarm_cancel(struct alarm *alarm);

#endif
+6 −1
Original line number Diff line number Diff line
@@ -355,7 +355,12 @@ struct cpu_vfs_cap_data {

#define CAP_SYSLOG           34

#define CAP_LAST_CAP         CAP_SYSLOG
/* Allow triggering something that will wake the system */

#define CAP_WAKE_ALARM            35


#define CAP_LAST_CAP         CAP_WAKE_ALARM

#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)

+2 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include <linux/list.h>
#include <linux/sched.h>
#include <linux/timex.h>
#include <linux/alarmtimer.h>

union cpu_time_count {
	cputime_t cpu;
@@ -80,6 +81,7 @@ struct k_itimer {
			unsigned long incr;
			unsigned long expires;
		} mmtimer;
		struct alarm alarmtimer;
	} it;
};

Loading