static uint32_t alarm_enabled;
static uint32_t wait_pending;
-static struct alarm alarms[ANDROID_ALARM_TYPE_COUNT];
+static struct android_alarm alarms[ANDROID_ALARM_TYPE_COUNT];
static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
case ANDROID_ALARM_CLEAR(0):
spin_lock_irqsave(&alarm_slock, flags);
pr_alarm(IO, "alarm %d clear\n", alarm_type);
- alarm_try_to_cancel(&alarms[alarm_type]);
+ android_alarm_try_to_cancel(&alarms[alarm_type]);
if (alarm_pending) {
alarm_pending &= ~alarm_type_mask;
if (!alarm_pending && !wait_pending)
pr_alarm(IO, "alarm %d set %ld.%09ld\n", alarm_type,
new_alarm_time.tv_sec, new_alarm_time.tv_nsec);
alarm_enabled |= alarm_type_mask;
- alarm_start_range(&alarms[alarm_type],
+ android_alarm_start_range(&alarms[alarm_type],
timespec_to_ktime(new_alarm_time),
timespec_to_ktime(new_alarm_time));
spin_unlock_irqrestore(&alarm_slock, flags);
rv = -EFAULT;
goto err1;
}
- rv = alarm_set_rtc(new_rtc_time);
+ rv = android_alarm_set_rtc(new_rtc_time);
spin_lock_irqsave(&alarm_slock, flags);
alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
wake_up(&alarm_wait_queue);
alarm_enabled &= ~alarm_type_mask;
}
spin_unlock_irqrestore(&alarm_slock, flags);
- alarm_cancel(&alarms[i]);
+ android_alarm_cancel(&alarms[i]);
spin_lock_irqsave(&alarm_slock, flags);
}
if (alarm_pending | wait_pending) {
return 0;
}
-static void alarm_triggered(struct alarm *alarm)
+static void alarm_triggered(struct android_alarm *alarm)
{
unsigned long flags;
uint32_t alarm_type_mask = 1U << alarm->type;
return err;
for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++)
- alarm_init(&alarms[i], i, alarm_triggered);
+ android_alarm_init(&alarms[i], i, alarm_triggered);
wake_lock_init(&alarm_wake_lock, WAKE_LOCK_SUSPEND, "alarm");
return 0;
static void update_timer_locked(struct alarm_queue *base, bool head_removed)
{
- struct alarm *alarm;
+ struct android_alarm *alarm;
bool is_wakeup = base == &alarms[ANDROID_ALARM_RTC_WAKEUP] ||
base == &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP];
if (!base->first)
return;
- alarm = container_of(base->first, struct alarm, node);
+ alarm = container_of(base->first, struct android_alarm, node);
pr_alarm(FLOW, "selected alarm, type %d, func %pF at %lld\n",
alarm->type, alarm->function, ktime_to_ns(alarm->expires));
hrtimer_start_expires(&base->timer, HRTIMER_MODE_ABS);
}
-static void alarm_enqueue_locked(struct alarm *alarm)
+static void alarm_enqueue_locked(struct android_alarm *alarm)
{
struct alarm_queue *base = &alarms[alarm->type];
struct rb_node **link = &base->alarms.rb_node;
struct rb_node *parent = NULL;
- struct alarm *entry;
+ struct android_alarm *entry;
int leftmost = 1;
pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n",
while (*link) {
parent = *link;
- entry = rb_entry(parent, struct alarm, node);
+ entry = rb_entry(parent, struct android_alarm, node);
/*
* We dont care about collisions. Nodes with
* the same expiry time stay together.
}
/**
- * alarm_init - initialize an alarm
+ * android_alarm_init - initialize an alarm
* @alarm: the alarm to be initialized
* @type: the alarm type to be used
* @function: alarm callback function
*/
-void alarm_init(struct alarm *alarm,
- enum android_alarm_type type, void (*function)(struct alarm *))
+void android_alarm_init(struct android_alarm *alarm,
+ enum android_alarm_type type, void (*function)(struct android_alarm *))
{
RB_CLEAR_NODE(&alarm->node);
alarm->type = type;
/**
- * alarm_start_range - (re)start an alarm
+ * android_alarm_start_range - (re)start an alarm
* @alarm: the alarm to be added
* @start: earliest expiry time
* @end: expiry time
*/
-void alarm_start_range(struct alarm *alarm, ktime_t start, ktime_t end)
+void android_alarm_start_range(struct android_alarm *alarm, ktime_t start,
+ ktime_t end)
{
unsigned long flags;
}
/**
- * alarm_try_to_cancel - try to deactivate an alarm
+ * android_alarm_try_to_cancel - try to deactivate an alarm
* @alarm: alarm to stop
*
* Returns:
* -1 when the alarm may currently be excuting the callback function and
* cannot be stopped (it may also be inactive)
*/
-int alarm_try_to_cancel(struct alarm *alarm)
+int android_alarm_try_to_cancel(struct android_alarm *alarm)
{
struct alarm_queue *base = &alarms[alarm->type];
unsigned long flags;
}
/**
- * alarm_cancel - cancel an alarm and wait for the handler to finish.
+ * android_alarm_cancel - cancel an alarm and wait for the handler to finish.
* @alarm: the alarm to be cancelled
*
* Returns:
* 0 when the alarm was not active
* 1 when the alarm was active
*/
-int alarm_cancel(struct alarm *alarm)
+int android_alarm_cancel(struct android_alarm *alarm)
{
for (;;) {
- int ret = alarm_try_to_cancel(alarm);
+ int ret = android_alarm_try_to_cancel(alarm);
if (ret >= 0)
return ret;
cpu_relax();
* alarm_set_rtc - set the kernel and rtc walltime
* @new_time: timespec value containing the new time
*/
-int alarm_set_rtc(struct timespec new_time)
+int android_alarm_set_rtc(struct timespec new_time)
{
int i;
int ret;
static enum hrtimer_restart alarm_timer_triggered(struct hrtimer *timer)
{
struct alarm_queue *base;
- struct alarm *alarm;
+ struct android_alarm *alarm;
unsigned long flags;
ktime_t now;
base - alarms, ktime_to_ns(now));
while (base->first) {
- alarm = container_of(base->first, struct alarm, node);
+ alarm = container_of(base->first, struct android_alarm, node);
if (alarm->softexpires.tv64 > now.tv64) {
pr_alarm(FLOW, "don't call alarm, %pF, %lld (s %lld)\n",
alarm->function, ktime_to_ns(alarm->expires),
*
*/
-struct alarm {
+struct android_alarm {
struct rb_node node;
enum android_alarm_type type;
ktime_t softexpires;
ktime_t expires;
- void (*function)(struct alarm *);
+ void (*function)(struct android_alarm *);
};
-void alarm_init(struct alarm *alarm,
- enum android_alarm_type type, void (*function)(struct alarm *));
-void alarm_start_range(struct alarm *alarm, ktime_t start, ktime_t end);
-int alarm_try_to_cancel(struct alarm *alarm);
-int alarm_cancel(struct alarm *alarm);
+void android_alarm_init(struct android_alarm *alarm,
+ enum android_alarm_type type, void (*function)(struct android_alarm *));
+void android_alarm_start_range(struct android_alarm *alarm, ktime_t start,
+ ktime_t end);
+int android_alarm_try_to_cancel(struct android_alarm *alarm);
+int android_alarm_cancel(struct android_alarm *alarm);
ktime_t alarm_get_elapsed_realtime(void);
/* set rtc while preserving elapsed realtime */
-int alarm_set_rtc(const struct timespec ts);
+int android_alarm_set_rtc(const struct timespec ts);
#endif