2626#include <linux/workqueue.h>
2727#include <linux/freezer.h>
2828
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+ */
3038static struct alarm_base {
3139 spinlock_t lock ;
3240 struct timerqueue_head timerqueue ;
@@ -36,18 +44,16 @@ static struct alarm_base {
3644 struct work_struct irqwork ;
3745} alarm_bases [ALARM_NUMTYPE ];
3846
47+ /* rtc timer and device for setting alarm wakeups at suspend */
3948static struct rtc_timer rtctimer ;
4049static struct rtc_device * rtcdev ;
4150
51+ /* freezer delta & lock used to handle clock_nanosleep triggered wakeups */
4252static ktime_t freezer_delta ;
4353static DEFINE_SPINLOCK (freezer_delta_lock );
4454
4555
46- /**************************************************************************
47- * alarmtimer management code
48- */
49-
50- /*
56+ /**
5157 * alarmtimer_enqueue - Adds an alarm timer to an alarm_base timerqueue
5258 * @base: pointer to the base where the timer is being run
5359 * @alarm: pointer to alarm being enqueued.
@@ -67,7 +73,7 @@ static void alarmtimer_enqueue(struct alarm_base *base, struct alarm *alarm)
6773 }
6874}
6975
70- /*
76+ /**
7177 * alarmtimer_remove - Removes an alarm timer from an alarm_base timerqueue
7278 * @base: pointer to the base where the timer is running
7379 * @alarm: pointer to alarm being removed
@@ -91,16 +97,16 @@ static void alarmtimer_remove(struct alarm_base *base, struct alarm *alarm)
9197 }
9298}
9399
94- /*
100+ /**
95101 * alarmtimer_do_work - Handles alarm being fired.
96102 * @work: pointer to workqueue being run
97103 *
98- * When a timer fires, this runs through the timerqueue to see
99- * which alarm timers , and run those that expired . If there are
100- * more alarm timers queued, we set the hrtimer to fire in the
101- * future.
104+ * When a alarm timer fires, this runs through the timerqueue to
105+ * see which alarms expired , and runs those. If there are more alarm
106+ * timers queued for the future , we set the hrtimer to fire when
107+ * when the next future alarm timer expires .
102108 */
103- void alarmtimer_do_work (struct work_struct * work )
109+ static void alarmtimer_do_work (struct work_struct * work )
104110{
105111 struct alarm_base * base = container_of (work , struct alarm_base ,
106112 irqwork );
@@ -141,7 +147,7 @@ void alarmtimer_do_work(struct work_struct *work)
141147}
142148
143149
144- /*
150+ /**
145151 * alarmtimer_fired - Handles alarm hrtimer being fired.
146152 * @timer: pointer to hrtimer being run
147153 *
@@ -156,7 +162,7 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer)
156162}
157163
158164
159- /*
165+ /**
160166 * alarmtimer_suspend - Suspend time callback
161167 * @dev: unused
162168 * @state: unused
@@ -230,17 +236,11 @@ static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
230236}
231237
232238
233- /**************************************************************************
234- * alarm kernel interface code
235- */
236-
237- /*
239+ /**
238240 * alarm_init - Initialize an alarm structure
239241 * @alarm: ptr to alarm to be initialized
240242 * @type: the type of the alarm
241243 * @function: callback that is run when the alarm fires
242- *
243- * In-kernel interface to initializes the alarm structure.
244244 */
245245void alarm_init (struct alarm * alarm , enum alarmtimer_type type ,
246246 void (* function )(struct alarm * ))
@@ -252,13 +252,11 @@ void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
252252 alarm -> enabled = 0 ;
253253}
254254
255- /*
255+ /**
256256 * alarm_start - Sets an alarm to fire
257257 * @alarm: ptr to alarm to set
258258 * @start: time to run the alarm
259259 * @period: period at which the alarm will recur
260- *
261- * In-kernel interface set an alarm timer.
262260 */
263261void alarm_start (struct alarm * alarm , ktime_t start , ktime_t period )
264262{
@@ -275,11 +273,9 @@ void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period)
275273 spin_unlock_irqrestore (& base -> lock , flags );
276274}
277275
278- /*
276+ /**
279277 * alarm_cancel - Tries to cancel an alarm timer
280278 * @alarm: ptr to alarm to be canceled
281- *
282- * In-kernel interface to cancel an alarm timer.
283279 */
284280void alarm_cancel (struct alarm * alarm )
285281{
@@ -294,15 +290,9 @@ void alarm_cancel(struct alarm *alarm)
294290}
295291
296292
297- /**************************************************************************
298- * alarm posix interface code
299- */
300-
301- /*
293+ /**
302294 * clock2alarm - helper that converts from clockid to alarmtypes
303295 * @clockid: clockid.
304- *
305- * Helper function that converts from clockids to alarmtypes
306296 */
307297static enum alarmtimer_type clock2alarm (clockid_t clockid )
308298{
@@ -313,7 +303,7 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid)
313303 return -1 ;
314304}
315305
316- /*
306+ /**
317307 * alarm_handle_timer - Callback for posix timers
318308 * @alarm: alarm that fired
319309 *
@@ -327,7 +317,7 @@ static void alarm_handle_timer(struct alarm *alarm)
327317 ptr -> it_overrun ++ ;
328318}
329319
330- /*
320+ /**
331321 * alarm_clock_getres - posix getres interface
332322 * @which_clock: clockid
333323 * @tp: timespec to fill
@@ -598,9 +588,6 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
598588 return ret ;
599589}
600590
601- /**************************************************************************
602- * alarmtimer initialization code
603- */
604591
605592/* Suspend hook structures */
606593static const struct dev_pm_ops alarmtimer_pm_ops = {
0 commit comments