diff options
author | John Stultz <john.stultz@linaro.org> | 2011-04-28 15:58:11 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2011-04-28 16:39:17 -0400 |
commit | 180bf812ceaf01eb8ac69b86f3be0bd57f697668 (patch) | |
tree | e61166d1267a15115dc602875ec03835afc1afe7 /kernel/time | |
parent | 9a7adcf5c6dea63d2e47e6f6d2f7a6c9f48b9337 (diff) |
timers: Improve alarmtimer comments and minor fixes
This patch addresses a number of minor comment improvements and
other minor issues from Thomas' review of the alarmtimers code.
CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/alarmtimer.c | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 4058ad79d55f..bed98004ae1a 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c | |||
@@ -26,7 +26,15 @@ | |||
26 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
27 | #include <linux/freezer.h> | 27 | #include <linux/freezer.h> |
28 | 28 | ||
29 | 29 | /** | |
30 | * struct alarm_base - Alarm timer bases | ||
31 | * @lock: Lock for syncrhonized access to the base | ||
32 | * @timerqueue: Timerqueue head managing the list of events | ||
33 | * @timer: hrtimer used to schedule events while running | ||
34 | * @gettime: Function to read the time correlating to the base | ||
35 | * @base_clockid: clockid for the base | ||
36 | * @irqwork Delayed work structure for expiring timers | ||
37 | */ | ||
30 | static struct alarm_base { | 38 | static struct alarm_base { |
31 | spinlock_t lock; | 39 | spinlock_t lock; |
32 | struct timerqueue_head timerqueue; | 40 | struct timerqueue_head timerqueue; |
@@ -36,18 +44,16 @@ static struct alarm_base { | |||
36 | struct work_struct irqwork; | 44 | struct work_struct irqwork; |
37 | } alarm_bases[ALARM_NUMTYPE]; | 45 | } alarm_bases[ALARM_NUMTYPE]; |
38 | 46 | ||
47 | /* rtc timer and device for setting alarm wakeups at suspend */ | ||
39 | static struct rtc_timer rtctimer; | 48 | static struct rtc_timer rtctimer; |
40 | static struct rtc_device *rtcdev; | 49 | static struct rtc_device *rtcdev; |
41 | 50 | ||
51 | /* freezer delta & lock used to handle clock_nanosleep triggered wakeups */ | ||
42 | static ktime_t freezer_delta; | 52 | static ktime_t freezer_delta; |
43 | static DEFINE_SPINLOCK(freezer_delta_lock); | 53 | static DEFINE_SPINLOCK(freezer_delta_lock); |
44 | 54 | ||
45 | 55 | ||
46 | /************************************************************************** | 56 | /** |
47 | * alarmtimer management code | ||
48 | */ | ||
49 | |||
50 | /* | ||
51 | * alarmtimer_enqueue - Adds an alarm timer to an alarm_base timerqueue | 57 | * alarmtimer_enqueue - Adds an alarm timer to an alarm_base timerqueue |
52 | * @base: pointer to the base where the timer is being run | 58 | * @base: pointer to the base where the timer is being run |
53 | * @alarm: pointer to alarm being enqueued. | 59 | * @alarm: pointer to alarm being enqueued. |
@@ -67,7 +73,7 @@ static void alarmtimer_enqueue(struct alarm_base *base, struct alarm *alarm) | |||
67 | } | 73 | } |
68 | } | 74 | } |
69 | 75 | ||
70 | /* | 76 | /** |
71 | * alarmtimer_remove - Removes an alarm timer from an alarm_base timerqueue | 77 | * alarmtimer_remove - Removes an alarm timer from an alarm_base timerqueue |
72 | * @base: pointer to the base where the timer is running | 78 | * @base: pointer to the base where the timer is running |
73 | * @alarm: pointer to alarm being removed | 79 | * @alarm: pointer to alarm being removed |
@@ -91,16 +97,16 @@ static void alarmtimer_remove(struct alarm_base *base, struct alarm *alarm) | |||
91 | } | 97 | } |
92 | } | 98 | } |
93 | 99 | ||
94 | /* | 100 | /** |
95 | * alarmtimer_do_work - Handles alarm being fired. | 101 | * alarmtimer_do_work - Handles alarm being fired. |
96 | * @work: pointer to workqueue being run | 102 | * @work: pointer to workqueue being run |
97 | * | 103 | * |
98 | * When a timer fires, this runs through the timerqueue to see | 104 | * When a alarm timer fires, this runs through the timerqueue to |
99 | * which alarm timers, and run those that expired. If there are | 105 | * see which alarms expired, and runs those. If there are more alarm |
100 | * more alarm timers queued, we set the hrtimer to fire in the | 106 | * timers queued for the future, we set the hrtimer to fire when |
101 | * future. | 107 | * when the next future alarm timer expires. |
102 | */ | 108 | */ |
103 | void alarmtimer_do_work(struct work_struct *work) | 109 | static void alarmtimer_do_work(struct work_struct *work) |
104 | { | 110 | { |
105 | struct alarm_base *base = container_of(work, struct alarm_base, | 111 | struct alarm_base *base = container_of(work, struct alarm_base, |
106 | irqwork); | 112 | irqwork); |
@@ -141,7 +147,7 @@ void alarmtimer_do_work(struct work_struct *work) | |||
141 | } | 147 | } |
142 | 148 | ||
143 | 149 | ||
144 | /* | 150 | /** |
145 | * alarmtimer_fired - Handles alarm hrtimer being fired. | 151 | * alarmtimer_fired - Handles alarm hrtimer being fired. |
146 | * @timer: pointer to hrtimer being run | 152 | * @timer: pointer to hrtimer being run |
147 | * | 153 | * |
@@ -156,7 +162,7 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer) | |||
156 | } | 162 | } |
157 | 163 | ||
158 | 164 | ||
159 | /* | 165 | /** |
160 | * alarmtimer_suspend - Suspend time callback | 166 | * alarmtimer_suspend - Suspend time callback |
161 | * @dev: unused | 167 | * @dev: unused |
162 | * @state: unused | 168 | * @state: unused |
@@ -230,17 +236,11 @@ static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type) | |||
230 | } | 236 | } |
231 | 237 | ||
232 | 238 | ||
233 | /************************************************************************** | 239 | /** |
234 | * alarm kernel interface code | ||
235 | */ | ||
236 | |||
237 | /* | ||
238 | * alarm_init - Initialize an alarm structure | 240 | * alarm_init - Initialize an alarm structure |
239 | * @alarm: ptr to alarm to be initialized | 241 | * @alarm: ptr to alarm to be initialized |
240 | * @type: the type of the alarm | 242 | * @type: the type of the alarm |
241 | * @function: callback that is run when the alarm fires | 243 | * @function: callback that is run when the alarm fires |
242 | * | ||
243 | * In-kernel interface to initializes the alarm structure. | ||
244 | */ | 244 | */ |
245 | void alarm_init(struct alarm *alarm, enum alarmtimer_type type, | 245 | void alarm_init(struct alarm *alarm, enum alarmtimer_type type, |
246 | void (*function)(struct alarm *)) | 246 | void (*function)(struct alarm *)) |
@@ -252,13 +252,11 @@ void alarm_init(struct alarm *alarm, enum alarmtimer_type type, | |||
252 | alarm->enabled = 0; | 252 | alarm->enabled = 0; |
253 | } | 253 | } |
254 | 254 | ||
255 | /* | 255 | /** |
256 | * alarm_start - Sets an alarm to fire | 256 | * alarm_start - Sets an alarm to fire |
257 | * @alarm: ptr to alarm to set | 257 | * @alarm: ptr to alarm to set |
258 | * @start: time to run the alarm | 258 | * @start: time to run the alarm |
259 | * @period: period at which the alarm will recur | 259 | * @period: period at which the alarm will recur |
260 | * | ||
261 | * In-kernel interface set an alarm timer. | ||
262 | */ | 260 | */ |
263 | void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period) | 261 | void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period) |
264 | { | 262 | { |
@@ -275,11 +273,9 @@ void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period) | |||
275 | spin_unlock_irqrestore(&base->lock, flags); | 273 | spin_unlock_irqrestore(&base->lock, flags); |
276 | } | 274 | } |
277 | 275 | ||
278 | /* | 276 | /** |
279 | * alarm_cancel - Tries to cancel an alarm timer | 277 | * alarm_cancel - Tries to cancel an alarm timer |
280 | * @alarm: ptr to alarm to be canceled | 278 | * @alarm: ptr to alarm to be canceled |
281 | * | ||
282 | * In-kernel interface to cancel an alarm timer. | ||
283 | */ | 279 | */ |
284 | void alarm_cancel(struct alarm *alarm) | 280 | void alarm_cancel(struct alarm *alarm) |
285 | { | 281 | { |
@@ -294,15 +290,9 @@ void alarm_cancel(struct alarm *alarm) | |||
294 | } | 290 | } |
295 | 291 | ||
296 | 292 | ||
297 | /************************************************************************** | 293 | /** |
298 | * alarm posix interface code | ||
299 | */ | ||
300 | |||
301 | /* | ||
302 | * clock2alarm - helper that converts from clockid to alarmtypes | 294 | * clock2alarm - helper that converts from clockid to alarmtypes |
303 | * @clockid: clockid. | 295 | * @clockid: clockid. |
304 | * | ||
305 | * Helper function that converts from clockids to alarmtypes | ||
306 | */ | 296 | */ |
307 | static enum alarmtimer_type clock2alarm(clockid_t clockid) | 297 | static enum alarmtimer_type clock2alarm(clockid_t clockid) |
308 | { | 298 | { |
@@ -313,7 +303,7 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid) | |||
313 | return -1; | 303 | return -1; |
314 | } | 304 | } |
315 | 305 | ||
316 | /* | 306 | /** |
317 | * alarm_handle_timer - Callback for posix timers | 307 | * alarm_handle_timer - Callback for posix timers |
318 | * @alarm: alarm that fired | 308 | * @alarm: alarm that fired |
319 | * | 309 | * |
@@ -327,7 +317,7 @@ static void alarm_handle_timer(struct alarm *alarm) | |||
327 | ptr->it_overrun++; | 317 | ptr->it_overrun++; |
328 | } | 318 | } |
329 | 319 | ||
330 | /* | 320 | /** |
331 | * alarm_clock_getres - posix getres interface | 321 | * alarm_clock_getres - posix getres interface |
332 | * @which_clock: clockid | 322 | * @which_clock: clockid |
333 | * @tp: timespec to fill | 323 | * @tp: timespec to fill |
@@ -598,9 +588,6 @@ out: | |||
598 | return ret; | 588 | return ret; |
599 | } | 589 | } |
600 | 590 | ||
601 | /************************************************************************** | ||
602 | * alarmtimer initialization code | ||
603 | */ | ||
604 | 591 | ||
605 | /* Suspend hook structures */ | 592 | /* Suspend hook structures */ |
606 | static const struct dev_pm_ops alarmtimer_pm_ops = { | 593 | static const struct dev_pm_ops alarmtimer_pm_ops = { |