Skip to content

Commit c9cb2e3

Browse files
KAGA-KOKOLinus Torvalds
authored andcommitted
[PATCH] hrtimers: namespace and enum cleanup
- hrtimers did not use the hrtimer_restart enum and relied on the implict int representation. Fix the prototypes and the functions using the enums. - Use seperate name spaces for the enumerations - Convert hrtimer_restart macro to inline function - Add comments No functional changes. [akpm@osdl.org: fix input driver] Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: john stultz <johnstul@us.ibm.com> Cc: Roman Zippel <zippel@linux-m68k.org> Cc: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent fd064b9 commit c9cb2e3

9 files changed

Lines changed: 40 additions & 34 deletions

File tree

‎drivers/input/touchscreen/ads7846.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static void ads7846_rx(void *ads)
546546
ts->spi->dev.bus_id, ts->tc.ignore, Rt);
547547
#endif
548548
hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD),
549-
HRTIMER_REL);
549+
HRTIMER_MODE_REL);
550550
return;
551551
}
552552

@@ -578,7 +578,8 @@ static void ads7846_rx(void *ads)
578578
#endif
579579
}
580580

581-
hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), HRTIMER_REL);
581+
hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD),
582+
HRTIMER_MODE_REL);
582583
}
583584

584585
static int ads7846_debounce(void *ads, int data_idx, int *val)
@@ -667,7 +668,7 @@ static void ads7846_rx_val(void *ads)
667668
status);
668669
}
669670

670-
static int ads7846_timer(struct hrtimer *handle)
671+
static enum hrtimer_restart ads7846_timer(struct hrtimer *handle)
671672
{
672673
struct ads7846 *ts = container_of(handle, struct ads7846, timer);
673674
int status = 0;
@@ -724,7 +725,7 @@ static irqreturn_t ads7846_irq(int irq, void *handle)
724725
disable_irq(ts->spi->irq);
725726
ts->pending = 1;
726727
hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_DELAY),
727-
HRTIMER_REL);
728+
HRTIMER_MODE_REL);
728729
}
729730
}
730731
spin_unlock_irqrestore(&ts->lock, flags);
@@ -862,7 +863,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
862863
ts->spi = spi;
863864
ts->input = input_dev;
864865

865-
hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_REL);
866+
hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
866867
ts->timer.function = ads7846_timer;
867868

868869
spin_lock_init(&ts->lock);

‎include/linux/hrtimer.h‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@
2525
* Mode arguments of xxx_hrtimer functions:
2626
*/
2727
enum hrtimer_mode {
28-
HRTIMER_ABS, /* Time value is absolute */
29-
HRTIMER_REL, /* Time value is relative to now */
28+
HRTIMER_MODE_ABS, /* Time value is absolute */
29+
HRTIMER_MODE_REL, /* Time value is relative to now */
3030
};
3131

32+
/*
33+
* Return values for the callback function
34+
*/
3235
enum hrtimer_restart {
33-
HRTIMER_NORESTART,
34-
HRTIMER_RESTART,
36+
HRTIMER_NORESTART, /* Timer is not restarted */
37+
HRTIMER_RESTART, /* Timer must be restarted */
3538
};
3639

37-
#define HRTIMER_INACTIVE ((void *)1UL)
38-
3940
struct hrtimer_base;
4041

4142
/**
@@ -52,7 +53,7 @@ struct hrtimer_base;
5253
struct hrtimer {
5354
struct rb_node node;
5455
ktime_t expires;
55-
int (*function)(struct hrtimer *);
56+
enum hrtimer_restart (*function)(struct hrtimer *);
5657
struct hrtimer_base *base;
5758
};
5859

@@ -114,7 +115,10 @@ extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
114115
extern int hrtimer_cancel(struct hrtimer *timer);
115116
extern int hrtimer_try_to_cancel(struct hrtimer *timer);
116117

117-
#define hrtimer_restart(timer) hrtimer_start((timer), (timer)->expires, HRTIMER_ABS)
118+
static inline int hrtimer_restart(struct hrtimer *timer)
119+
{
120+
return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
121+
}
118122

119123
/* Query timers: */
120124
extern ktime_t hrtimer_get_remaining(const struct hrtimer *timer);

‎include/linux/timer.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static inline void add_timer(struct timer_list *timer)
106106
extern void init_timers(void);
107107
extern void run_local_timers(void);
108108
struct hrtimer;
109-
extern int it_real_fn(struct hrtimer *);
109+
extern enum hrtimer_restart it_real_fn(struct hrtimer *);
110110

111111
unsigned long __round_jiffies(unsigned long j, int cpu);
112112
unsigned long __round_jiffies_relative(unsigned long j, int cpu);

‎kernel/fork.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
858858
init_sigpending(&sig->shared_pending);
859859
INIT_LIST_HEAD(&sig->posix_timers);
860860

861-
hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL);
861+
hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
862862
sig->it_real_incr.tv64 = 0;
863863
sig->real_timer.function = it_real_fn;
864864
sig->tsk = tsk;

‎kernel/futex.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
11341134

11351135
if (sec != MAX_SCHEDULE_TIMEOUT) {
11361136
to = &timeout;
1137-
hrtimer_init(&to->timer, CLOCK_REALTIME, HRTIMER_ABS);
1137+
hrtimer_init(&to->timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
11381138
hrtimer_init_sleeper(to, current);
11391139
to->timer.expires = ktime_set(sec, nsec);
11401140
}

‎kernel/hrtimer.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
444444
/* Switch the timer base, if necessary: */
445445
new_base = switch_hrtimer_base(timer, base);
446446

447-
if (mode == HRTIMER_REL) {
447+
if (mode == HRTIMER_MODE_REL) {
448448
tim = ktime_add(tim, new_base->get_time());
449449
/*
450450
* CONFIG_TIME_LOW_RES is a temporary way for architectures
@@ -583,7 +583,7 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
583583

584584
bases = __raw_get_cpu_var(hrtimer_bases);
585585

586-
if (clock_id == CLOCK_REALTIME && mode != HRTIMER_ABS)
586+
if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS)
587587
clock_id = CLOCK_MONOTONIC;
588588

589589
timer->base = &bases[clock_id];
@@ -627,7 +627,7 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base)
627627

628628
while ((node = base->first)) {
629629
struct hrtimer *timer;
630-
int (*fn)(struct hrtimer *);
630+
enum hrtimer_restart (*fn)(struct hrtimer *);
631631
int restart;
632632

633633
timer = rb_entry(node, struct hrtimer, node);
@@ -669,7 +669,7 @@ void hrtimer_run_queues(void)
669669
/*
670670
* Sleep related functions:
671671
*/
672-
static int hrtimer_wakeup(struct hrtimer *timer)
672+
static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer)
673673
{
674674
struct hrtimer_sleeper *t =
675675
container_of(timer, struct hrtimer_sleeper, timer);
@@ -699,7 +699,7 @@ static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mod
699699
schedule();
700700

701701
hrtimer_cancel(&t->timer);
702-
mode = HRTIMER_ABS;
702+
mode = HRTIMER_MODE_ABS;
703703

704704
} while (t->task && !signal_pending(current));
705705

@@ -715,10 +715,10 @@ long __sched hrtimer_nanosleep_restart(struct restart_block *restart)
715715

716716
restart->fn = do_no_restart_syscall;
717717

718-
hrtimer_init(&t.timer, restart->arg0, HRTIMER_ABS);
718+
hrtimer_init(&t.timer, restart->arg0, HRTIMER_MODE_ABS);
719719
t.timer.expires.tv64 = ((u64)restart->arg3 << 32) | (u64) restart->arg2;
720720

721-
if (do_nanosleep(&t, HRTIMER_ABS))
721+
if (do_nanosleep(&t, HRTIMER_MODE_ABS))
722722
return 0;
723723

724724
rmtp = (struct timespec __user *) restart->arg1;
@@ -751,7 +751,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
751751
return 0;
752752

753753
/* Absolute timers do not update the rmtp value and restart: */
754-
if (mode == HRTIMER_ABS)
754+
if (mode == HRTIMER_MODE_ABS)
755755
return -ERESTARTNOHAND;
756756

757757
if (rmtp) {
@@ -784,7 +784,7 @@ sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp)
784784
if (!timespec_valid(&tu))
785785
return -EINVAL;
786786

787-
return hrtimer_nanosleep(&tu, rmtp, HRTIMER_REL, CLOCK_MONOTONIC);
787+
return hrtimer_nanosleep(&tu, rmtp, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
788788
}
789789

790790
/*

‎kernel/itimer.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ asmlinkage long sys_getitimer(int which, struct itimerval __user *value)
128128
/*
129129
* The timer is automagically restarted, when interval != 0
130130
*/
131-
int it_real_fn(struct hrtimer *timer)
131+
enum hrtimer_restart it_real_fn(struct hrtimer *timer)
132132
{
133133
struct signal_struct *sig =
134134
container_of(timer, struct signal_struct, real_timer);
@@ -235,7 +235,7 @@ int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
235235
timeval_to_ktime(value->it_interval);
236236
expires = timeval_to_ktime(value->it_value);
237237
if (expires.tv64 != 0)
238-
hrtimer_start(timer, expires, HRTIMER_REL);
238+
hrtimer_start(timer, expires, HRTIMER_MODE_REL);
239239
spin_unlock_irq(&tsk->sighand->siglock);
240240
break;
241241
case ITIMER_VIRTUAL:

‎kernel/posix-timers.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int common_timer_set(struct k_itimer *, int,
145145
struct itimerspec *, struct itimerspec *);
146146
static int common_timer_del(struct k_itimer *timer);
147147

148-
static int posix_timer_fn(struct hrtimer *data);
148+
static enum hrtimer_restart posix_timer_fn(struct hrtimer *data);
149149

150150
static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags);
151151

@@ -334,12 +334,12 @@ EXPORT_SYMBOL_GPL(posix_timer_event);
334334
335335
* This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers.
336336
*/
337-
static int posix_timer_fn(struct hrtimer *timer)
337+
static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)
338338
{
339339
struct k_itimer *timr;
340340
unsigned long flags;
341341
int si_private = 0;
342-
int ret = HRTIMER_NORESTART;
342+
enum hrtimer_restart ret = HRTIMER_NORESTART;
343343

344344
timr = container_of(timer, struct k_itimer, it.real.timer);
345345
spin_lock_irqsave(&timr->it_lock, flags);
@@ -722,7 +722,7 @@ common_timer_set(struct k_itimer *timr, int flags,
722722
if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec)
723723
return 0;
724724

725-
mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
725+
mode = flags & TIMER_ABSTIME ? HRTIMER_MODE_ABS : HRTIMER_MODE_REL;
726726
hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
727727
timr->it.real.timer.function = posix_timer_fn;
728728

@@ -734,7 +734,7 @@ common_timer_set(struct k_itimer *timr, int flags,
734734
/* SIGEV_NONE timers are not queued ! See common_timer_get */
735735
if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
736736
/* Setup correct expiry time for relative timers */
737-
if (mode == HRTIMER_REL)
737+
if (mode == HRTIMER_MODE_REL)
738738
timer->expires = ktime_add(timer->expires,
739739
timer->base->get_time());
740740
return 0;
@@ -950,7 +950,8 @@ static int common_nsleep(const clockid_t which_clock, int flags,
950950
struct timespec *tsave, struct timespec __user *rmtp)
951951
{
952952
return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ?
953-
HRTIMER_ABS : HRTIMER_REL, which_clock);
953+
HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
954+
which_clock);
954955
}
955956

956957
asmlinkage long

‎kernel/rtmutex.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
625625
/* Setup the timer, when timeout != NULL */
626626
if (unlikely(timeout))
627627
hrtimer_start(&timeout->timer, timeout->timer.expires,
628-
HRTIMER_ABS);
628+
HRTIMER_MODE_ABS);
629629

630630
for (;;) {
631631
/* Try to acquire the lock: */

0 commit comments

Comments
 (0)