summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2019-03-20 07:59:09 -0400
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2019-04-04 04:07:08 -0400
commit606cc43c720bdef01a22c9d221434c635139d84e (patch)
treefcb6a8c1a393aee18894191db8e5893dbf76e3a9
parent6875404fdb44f5353ef374c7c95c7701862fe2b3 (diff)
rtc: core: correct trivial checkpatch warnings
Correct trivial checkpatch warnings, mostly whitespace issues and unbalanced braces. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r--drivers/rtc/class.c14
-rw-r--r--drivers/rtc/dev.c13
-rw-r--r--drivers/rtc/hctosys.c3
-rw-r--r--drivers/rtc/interface.c99
-rw-r--r--drivers/rtc/lib.c22
-rw-r--r--drivers/rtc/nvmem.c2
-rw-r--r--drivers/rtc/proc.c14
-rw-r--r--drivers/rtc/sysfs.c16
8 files changed, 93 insertions, 90 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 22190ad28e8b..0f492b0940b3 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -20,13 +20,13 @@
20 20
21#include "rtc-core.h" 21#include "rtc-core.h"
22 22
23
24static DEFINE_IDA(rtc_ida); 23static DEFINE_IDA(rtc_ida);
25struct class *rtc_class; 24struct class *rtc_class;
26 25
27static void rtc_device_release(struct device *dev) 26static void rtc_device_release(struct device *dev)
28{ 27{
29 struct rtc_device *rtc = to_rtc_device(dev); 28 struct rtc_device *rtc = to_rtc_device(dev);
29
30 ida_simple_remove(&rtc_ida, rtc->id); 30 ida_simple_remove(&rtc_ida, rtc->id);
31 kfree(rtc); 31 kfree(rtc);
32} 32}
@@ -44,7 +44,6 @@ int rtc_hctosys_ret = -ENODEV;
44 44
45static struct timespec64 old_rtc, old_system, old_delta; 45static struct timespec64 old_rtc, old_system, old_delta;
46 46
47
48static int rtc_suspend(struct device *dev) 47static int rtc_suspend(struct device *dev)
49{ 48{
50 struct rtc_device *rtc = to_rtc_device(dev); 49 struct rtc_device *rtc = to_rtc_device(dev);
@@ -68,7 +67,6 @@ static int rtc_suspend(struct device *dev)
68 ktime_get_real_ts64(&old_system); 67 ktime_get_real_ts64(&old_system);
69 old_rtc.tv_sec = rtc_tm_to_time64(&tm); 68 old_rtc.tv_sec = rtc_tm_to_time64(&tm);
70 69
71
72 /* 70 /*
73 * To avoid drift caused by repeated suspend/resumes, 71 * To avoid drift caused by repeated suspend/resumes,
74 * which each can add ~1 second drift error, 72 * which each can add ~1 second drift error,
@@ -80,7 +78,7 @@ static int rtc_suspend(struct device *dev)
80 if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { 78 if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) {
81 /* 79 /*
82 * if delta_delta is too large, assume time correction 80 * if delta_delta is too large, assume time correction
83 * has occured and set old_delta to the current delta. 81 * has occurred and set old_delta to the current delta.
84 */ 82 */
85 old_delta = delta; 83 old_delta = delta;
86 } else { 84 } else {
@@ -133,7 +131,7 @@ static int rtc_resume(struct device *dev)
133 * to keep things accurate. 131 * to keep things accurate.
134 */ 132 */
135 sleep_time = timespec64_sub(sleep_time, 133 sleep_time = timespec64_sub(sleep_time,
136 timespec64_sub(new_system, old_system)); 134 timespec64_sub(new_system, old_system));
137 135
138 if (sleep_time.tv_sec >= 0) 136 if (sleep_time.tv_sec >= 0)
139 timekeeping_inject_sleeptime64(&sleep_time); 137 timekeeping_inject_sleeptime64(&sleep_time);
@@ -394,9 +392,9 @@ EXPORT_SYMBOL_GPL(__rtc_register_device);
394 * rtc_register_device instead 392 * rtc_register_device instead
395 */ 393 */
396struct rtc_device *devm_rtc_device_register(struct device *dev, 394struct rtc_device *devm_rtc_device_register(struct device *dev,
397 const char *name, 395 const char *name,
398 const struct rtc_class_ops *ops, 396 const struct rtc_class_ops *ops,
399 struct module *owner) 397 struct module *owner)
400{ 398{
401 struct rtc_device *rtc; 399 struct rtc_device *rtc;
402 int err; 400 int err;
diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c
index f68aae035b81..84feb2565abd 100644
--- a/drivers/rtc/dev.c
+++ b/drivers/rtc/dev.c
@@ -57,7 +57,7 @@ static void rtc_uie_task(struct work_struct *work)
57 } else if (rtc->oldsecs != tm.tm_sec) { 57 } else if (rtc->oldsecs != tm.tm_sec) {
58 num = (tm.tm_sec + 60 - rtc->oldsecs) % 60; 58 num = (tm.tm_sec + 60 - rtc->oldsecs) % 60;
59 rtc->oldsecs = tm.tm_sec; 59 rtc->oldsecs = tm.tm_sec;
60 rtc->uie_timer.expires = jiffies + HZ - (HZ/10); 60 rtc->uie_timer.expires = jiffies + HZ - (HZ / 10);
61 rtc->uie_timer_active = 1; 61 rtc->uie_timer_active = 1;
62 rtc->uie_task_active = 0; 62 rtc->uie_task_active = 0;
63 add_timer(&rtc->uie_timer); 63 add_timer(&rtc->uie_timer);
@@ -68,6 +68,7 @@ static void rtc_uie_task(struct work_struct *work)
68 if (num) 68 if (num)
69 rtc_handle_legacy_irq(rtc, num, RTC_UF); 69 rtc_handle_legacy_irq(rtc, num, RTC_UF);
70} 70}
71
71static void rtc_uie_timer(struct timer_list *t) 72static void rtc_uie_timer(struct timer_list *t)
72{ 73{
73 struct rtc_device *rtc = from_timer(rtc, t, uie_timer); 74 struct rtc_device *rtc = from_timer(rtc, t, uie_timer);
@@ -199,14 +200,14 @@ static __poll_t rtc_dev_poll(struct file *file, poll_table *wait)
199} 200}
200 201
201static long rtc_dev_ioctl(struct file *file, 202static long rtc_dev_ioctl(struct file *file,
202 unsigned int cmd, unsigned long arg) 203 unsigned int cmd, unsigned long arg)
203{ 204{
204 int err = 0; 205 int err = 0;
205 struct rtc_device *rtc = file->private_data; 206 struct rtc_device *rtc = file->private_data;
206 const struct rtc_class_ops *ops = rtc->ops; 207 const struct rtc_class_ops *ops = rtc->ops;
207 struct rtc_time tm; 208 struct rtc_time tm;
208 struct rtc_wkalrm alarm; 209 struct rtc_wkalrm alarm;
209 void __user *uarg = (void __user *) arg; 210 void __user *uarg = (void __user *)arg;
210 211
211 err = mutex_lock_interruptible(&rtc->ops_lock); 212 err = mutex_lock_interruptible(&rtc->ops_lock);
212 if (err) 213 if (err)
@@ -230,7 +231,7 @@ static long rtc_dev_ioctl(struct file *file,
230 231
231 case RTC_PIE_ON: 232 case RTC_PIE_ON:
232 if (rtc->irq_freq > rtc->max_user_freq && 233 if (rtc->irq_freq > rtc->max_user_freq &&
233 !capable(CAP_SYS_RESOURCE)) 234 !capable(CAP_SYS_RESOURCE))
234 err = -EACCES; 235 err = -EACCES;
235 break; 236 break;
236 } 237 }
@@ -387,8 +388,9 @@ static long rtc_dev_ioctl(struct file *file,
387 err = ops->ioctl(rtc->dev.parent, cmd, arg); 388 err = ops->ioctl(rtc->dev.parent, cmd, arg);
388 if (err == -ENOIOCTLCMD) 389 if (err == -ENOIOCTLCMD)
389 err = -ENOTTY; 390 err = -ENOTTY;
390 } else 391 } else {
391 err = -ENOTTY; 392 err = -ENOTTY;
393 }
392 break; 394 break;
393 } 395 }
394 396
@@ -400,6 +402,7 @@ done:
400static int rtc_dev_fasync(int fd, struct file *file, int on) 402static int rtc_dev_fasync(int fd, struct file *file, int on)
401{ 403{
402 struct rtc_device *rtc = file->private_data; 404 struct rtc_device *rtc = file->private_data;
405
403 return fasync_helper(fd, file, on, &rtc->async_queue); 406 return fasync_helper(fd, file, on, &rtc->async_queue);
404} 407}
405 408
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index eacbe500c44b..a74d0d890600 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -30,7 +30,7 @@ static int __init rtc_hctosys(void)
30 }; 30 };
31 struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); 31 struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
32 32
33 if (rtc == NULL) { 33 if (!rtc) {
34 pr_info("unable to open rtc device (%s)\n", 34 pr_info("unable to open rtc device (%s)\n",
35 CONFIG_RTC_HCTOSYS_DEVICE); 35 CONFIG_RTC_HCTOSYS_DEVICE);
36 goto err_open; 36 goto err_open;
@@ -41,7 +41,6 @@ static int __init rtc_hctosys(void)
41 dev_err(rtc->dev.parent, 41 dev_err(rtc->dev.parent,
42 "hctosys: unable to read the hardware clock\n"); 42 "hctosys: unable to read the hardware clock\n");
43 goto err_read; 43 goto err_read;
44
45 } 44 }
46 45
47 tv64.tv_sec = rtc_tm_to_time64(&tm); 46 tv64.tv_sec = rtc_tm_to_time64(&tm);
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 28bd767e03a0..ccb7d6b4da3b 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -84,11 +84,12 @@ static int rtc_valid_range(struct rtc_device *rtc, struct rtc_time *tm)
84static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) 84static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
85{ 85{
86 int err; 86 int err;
87 if (!rtc->ops) 87
88 if (!rtc->ops) {
88 err = -ENODEV; 89 err = -ENODEV;
89 else if (!rtc->ops->read_time) 90 } else if (!rtc->ops->read_time) {
90 err = -EINVAL; 91 err = -EINVAL;
91 else { 92 } else {
92 memset(tm, 0, sizeof(struct rtc_time)); 93 memset(tm, 0, sizeof(struct rtc_time));
93 err = rtc->ops->read_time(rtc->dev.parent, tm); 94 err = rtc->ops->read_time(rtc->dev.parent, tm);
94 if (err < 0) { 95 if (err < 0) {
@@ -144,14 +145,13 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
144 err = -ENODEV; 145 err = -ENODEV;
145 else if (rtc->ops->set_time) 146 else if (rtc->ops->set_time)
146 err = rtc->ops->set_time(rtc->dev.parent, tm); 147 err = rtc->ops->set_time(rtc->dev.parent, tm);
147 else if (rtc->ops->set_mmss64) { 148 else if (rtc->ops->set_mmss64)
148 time64_t secs64 = rtc_tm_to_time64(tm); 149 err = rtc->ops->set_mmss64(rtc->dev.parent,
149 150 rtc_tm_to_time64(tm));
150 err = rtc->ops->set_mmss64(rtc->dev.parent, secs64); 151 else if (rtc->ops->set_mmss)
151 } else if (rtc->ops->set_mmss) { 152 err = rtc->ops->set_mmss(rtc->dev.parent,
152 time64_t secs64 = rtc_tm_to_time64(tm); 153 rtc_tm_to_time64(tm));
153 err = rtc->ops->set_mmss(rtc->dev.parent, secs64); 154 else
154 } else
155 err = -EINVAL; 155 err = -EINVAL;
156 156
157 pm_stay_awake(rtc->dev.parent); 157 pm_stay_awake(rtc->dev.parent);
@@ -164,7 +164,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
164} 164}
165EXPORT_SYMBOL_GPL(rtc_set_time); 165EXPORT_SYMBOL_GPL(rtc_set_time);
166 166
167static int rtc_read_alarm_internal(struct rtc_device *rtc, struct rtc_wkalrm *alarm) 167static int rtc_read_alarm_internal(struct rtc_device *rtc,
168 struct rtc_wkalrm *alarm)
168{ 169{
169 int err; 170 int err;
170 171
@@ -172,11 +173,11 @@ static int rtc_read_alarm_internal(struct rtc_device *rtc, struct rtc_wkalrm *al
172 if (err) 173 if (err)
173 return err; 174 return err;
174 175
175 if (rtc->ops == NULL) 176 if (!rtc->ops) {
176 err = -ENODEV; 177 err = -ENODEV;
177 else if (!rtc->ops->read_alarm) 178 } else if (!rtc->ops->read_alarm) {
178 err = -EINVAL; 179 err = -EINVAL;
179 else { 180 } else {
180 alarm->enabled = 0; 181 alarm->enabled = 0;
181 alarm->pending = 0; 182 alarm->pending = 0;
182 alarm->time.tm_sec = -1; 183 alarm->time.tm_sec = -1;
@@ -204,7 +205,7 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
204 int first_time = 1; 205 int first_time = 1;
205 time64_t t_now, t_alm; 206 time64_t t_now, t_alm;
206 enum { none, day, month, year } missing = none; 207 enum { none, day, month, year } missing = none;
207 unsigned days; 208 unsigned int days;
208 209
209 /* The lower level RTC driver may return -1 in some fields, 210 /* The lower level RTC driver may return -1 in some fields,
210 * creating invalid alarm->time values, for reasons like: 211 * creating invalid alarm->time values, for reasons like:
@@ -273,10 +274,10 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
273 return err; 274 return err;
274 275
275 /* note that tm_sec is a "don't care" value here: */ 276 /* note that tm_sec is a "don't care" value here: */
276 } while ( before.tm_min != now.tm_min 277 } while (before.tm_min != now.tm_min ||
277 || before.tm_hour != now.tm_hour 278 before.tm_hour != now.tm_hour ||
278 || before.tm_mon != now.tm_mon 279 before.tm_mon != now.tm_mon ||
279 || before.tm_year != now.tm_year); 280 before.tm_year != now.tm_year);
280 281
281 /* Fill in the missing alarm fields using the timestamp; we 282 /* Fill in the missing alarm fields using the timestamp; we
282 * know there's at least one since alarm->time is invalid. 283 * know there's at least one since alarm->time is invalid.
@@ -293,7 +294,7 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
293 alarm->time.tm_mday = now.tm_mday; 294 alarm->time.tm_mday = now.tm_mday;
294 missing = day; 295 missing = day;
295 } 296 }
296 if ((unsigned)alarm->time.tm_mon >= 12) { 297 if ((unsigned int)alarm->time.tm_mon >= 12) {
297 alarm->time.tm_mon = now.tm_mon; 298 alarm->time.tm_mon = now.tm_mon;
298 if (missing == none) 299 if (missing == none)
299 missing = month; 300 missing = month;
@@ -318,7 +319,6 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
318 goto done; 319 goto done;
319 320
320 switch (missing) { 321 switch (missing) {
321
322 /* 24 hour rollover ... if it's now 10am Monday, an alarm that 322 /* 24 hour rollover ... if it's now 10am Monday, an alarm that
323 * that will trigger at 5am will do so at 5am Tuesday, which 323 * that will trigger at 5am will do so at 5am Tuesday, which
324 * could also be in the next month or year. This is a common 324 * could also be in the next month or year. This is a common
@@ -338,14 +338,14 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
338 case month: 338 case month:
339 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "month"); 339 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "month");
340 do { 340 do {
341 if (alarm->time.tm_mon < 11) 341 if (alarm->time.tm_mon < 11) {
342 alarm->time.tm_mon++; 342 alarm->time.tm_mon++;
343 else { 343 } else {
344 alarm->time.tm_mon = 0; 344 alarm->time.tm_mon = 0;
345 alarm->time.tm_year++; 345 alarm->time.tm_year++;
346 } 346 }
347 days = rtc_month_days(alarm->time.tm_mon, 347 days = rtc_month_days(alarm->time.tm_mon,
348 alarm->time.tm_year); 348 alarm->time.tm_year);
349 } while (days < alarm->time.tm_mday); 349 } while (days < alarm->time.tm_mday);
350 break; 350 break;
351 351
@@ -354,8 +354,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
354 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year"); 354 dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year");
355 do { 355 do {
356 alarm->time.tm_year++; 356 alarm->time.tm_year++;
357 } while (!is_leap_year(alarm->time.tm_year + 1900) 357 } while (!is_leap_year(alarm->time.tm_year + 1900) &&
358 && rtc_valid_tm(&alarm->time) != 0); 358 rtc_valid_tm(&alarm->time) != 0);
359 break; 359 break;
360 360
361 default: 361 default:
@@ -366,7 +366,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
366 366
367done: 367done:
368 if (err) 368 if (err)
369 dev_warn(&rtc->dev, "invalid alarm value: %ptR\n", &alarm->time); 369 dev_warn(&rtc->dev, "invalid alarm value: %ptR\n",
370 &alarm->time);
370 371
371 return err; 372 return err;
372} 373}
@@ -378,11 +379,11 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
378 err = mutex_lock_interruptible(&rtc->ops_lock); 379 err = mutex_lock_interruptible(&rtc->ops_lock);
379 if (err) 380 if (err)
380 return err; 381 return err;
381 if (rtc->ops == NULL) 382 if (!rtc->ops) {
382 err = -ENODEV; 383 err = -ENODEV;
383 else if (!rtc->ops->read_alarm) 384 } else if (!rtc->ops->read_alarm) {
384 err = -EINVAL; 385 err = -EINVAL;
385 else { 386 } else {
386 memset(alarm, 0, sizeof(struct rtc_wkalrm)); 387 memset(alarm, 0, sizeof(struct rtc_wkalrm));
387 alarm->enabled = rtc->aie_timer.enabled; 388 alarm->enabled = rtc->aie_timer.enabled;
388 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires); 389 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires);
@@ -491,7 +492,6 @@ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
491 /* Alarm has to be enabled & in the future for us to enqueue it */ 492 /* Alarm has to be enabled & in the future for us to enqueue it */
492 if (alarm->enabled && (rtc_tm_to_ktime(now) < 493 if (alarm->enabled && (rtc_tm_to_ktime(now) <
493 rtc->aie_timer.node.expires)) { 494 rtc->aie_timer.node.expires)) {
494
495 rtc->aie_timer.enabled = 1; 495 rtc->aie_timer.enabled = 1;
496 timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); 496 timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node);
497 trace_rtc_timer_enqueue(&rtc->aie_timer); 497 trace_rtc_timer_enqueue(&rtc->aie_timer);
@@ -503,7 +503,9 @@ EXPORT_SYMBOL_GPL(rtc_initialize_alarm);
503 503
504int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) 504int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
505{ 505{
506 int err = mutex_lock_interruptible(&rtc->ops_lock); 506 int err;
507
508 err = mutex_lock_interruptible(&rtc->ops_lock);
507 if (err) 509 if (err)
508 return err; 510 return err;
509 511
@@ -532,7 +534,9 @@ EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable);
532 534
533int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) 535int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
534{ 536{
535 int err = mutex_lock_interruptible(&rtc->ops_lock); 537 int err;
538
539 err = mutex_lock_interruptible(&rtc->ops_lock);
536 if (err) 540 if (err)
537 return err; 541 return err;
538 542
@@ -561,8 +565,9 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
561 rtc->uie_rtctimer.node.expires = ktime_add(now, onesec); 565 rtc->uie_rtctimer.node.expires = ktime_add(now, onesec);
562 rtc->uie_rtctimer.period = ktime_set(1, 0); 566 rtc->uie_rtctimer.period = ktime_set(1, 0);
563 err = rtc_timer_enqueue(rtc, &rtc->uie_rtctimer); 567 err = rtc_timer_enqueue(rtc, &rtc->uie_rtctimer);
564 } else 568 } else {
565 rtc_timer_remove(rtc, &rtc->uie_rtctimer); 569 rtc_timer_remove(rtc, &rtc->uie_rtctimer);
570 }
566 571
567out: 572out:
568 mutex_unlock(&rtc->ops_lock); 573 mutex_unlock(&rtc->ops_lock);
@@ -577,11 +582,9 @@ out:
577 err = rtc_dev_update_irq_enable_emul(rtc, enabled); 582 err = rtc_dev_update_irq_enable_emul(rtc, enabled);
578#endif 583#endif
579 return err; 584 return err;
580
581} 585}
582EXPORT_SYMBOL_GPL(rtc_update_irq_enable); 586EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
583 587
584
585/** 588/**
586 * rtc_handle_legacy_irq - AIE, UIE and PIE event hook 589 * rtc_handle_legacy_irq - AIE, UIE and PIE event hook
587 * @rtc: pointer to the rtc device 590 * @rtc: pointer to the rtc device
@@ -596,14 +599,13 @@ void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode)
596 599
597 /* mark one irq of the appropriate mode */ 600 /* mark one irq of the appropriate mode */
598 spin_lock_irqsave(&rtc->irq_lock, flags); 601 spin_lock_irqsave(&rtc->irq_lock, flags);
599 rtc->irq_data = (rtc->irq_data + (num << 8)) | (RTC_IRQF|mode); 602 rtc->irq_data = (rtc->irq_data + (num << 8)) | (RTC_IRQF | mode);
600 spin_unlock_irqrestore(&rtc->irq_lock, flags); 603 spin_unlock_irqrestore(&rtc->irq_lock, flags);
601 604
602 wake_up_interruptible(&rtc->irq_queue); 605 wake_up_interruptible(&rtc->irq_queue);
603 kill_fasync(&rtc->async_queue, SIGIO, POLL_IN); 606 kill_fasync(&rtc->async_queue, SIGIO, POLL_IN);
604} 607}
605 608
606
607/** 609/**
608 * rtc_aie_update_irq - AIE mode rtctimer hook 610 * rtc_aie_update_irq - AIE mode rtctimer hook
609 * @rtc: pointer to the rtc_device 611 * @rtc: pointer to the rtc_device
@@ -615,7 +617,6 @@ void rtc_aie_update_irq(struct rtc_device *rtc)
615 rtc_handle_legacy_irq(rtc, 1, RTC_AF); 617 rtc_handle_legacy_irq(rtc, 1, RTC_AF);
616} 618}
617 619
618
619/** 620/**
620 * rtc_uie_update_irq - UIE mode rtctimer hook 621 * rtc_uie_update_irq - UIE mode rtctimer hook
621 * @rtc: pointer to the rtc_device 622 * @rtc: pointer to the rtc_device
@@ -627,7 +628,6 @@ void rtc_uie_update_irq(struct rtc_device *rtc)
627 rtc_handle_legacy_irq(rtc, 1, RTC_UF); 628 rtc_handle_legacy_irq(rtc, 1, RTC_UF);
628} 629}
629 630
630
631/** 631/**
632 * rtc_pie_update_irq - PIE mode hrtimer hook 632 * rtc_pie_update_irq - PIE mode hrtimer hook
633 * @timer: pointer to the pie mode hrtimer 633 * @timer: pointer to the pie mode hrtimer
@@ -641,6 +641,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)
641 struct rtc_device *rtc; 641 struct rtc_device *rtc;
642 ktime_t period; 642 ktime_t period;
643 int count; 643 int count;
644
644 rtc = container_of(timer, struct rtc_device, pie_timer); 645 rtc = container_of(timer, struct rtc_device, pie_timer);
645 646
646 period = NSEC_PER_SEC / rtc->irq_freq; 647 period = NSEC_PER_SEC / rtc->irq_freq;
@@ -659,7 +660,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)
659 * Context: any 660 * Context: any
660 */ 661 */
661void rtc_update_irq(struct rtc_device *rtc, 662void rtc_update_irq(struct rtc_device *rtc,
662 unsigned long num, unsigned long events) 663 unsigned long num, unsigned long events)
663{ 664{
664 if (IS_ERR_OR_NULL(rtc)) 665 if (IS_ERR_OR_NULL(rtc))
665 return; 666 return;
@@ -808,6 +809,7 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
808 if (!next || ktime_before(timer->node.expires, next->expires)) { 809 if (!next || ktime_before(timer->node.expires, next->expires)) {
809 struct rtc_wkalrm alarm; 810 struct rtc_wkalrm alarm;
810 int err; 811 int err;
812
811 alarm.time = rtc_ktime_to_tm(timer->node.expires); 813 alarm.time = rtc_ktime_to_tm(timer->node.expires);
812 alarm.enabled = 1; 814 alarm.enabled = 1;
813 err = __rtc_set_alarm(rtc, &alarm); 815 err = __rtc_set_alarm(rtc, &alarm);
@@ -848,12 +850,14 @@ static void rtc_alarm_disable(struct rtc_device *rtc)
848static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) 850static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
849{ 851{
850 struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue); 852 struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue);
853
851 timerqueue_del(&rtc->timerqueue, &timer->node); 854 timerqueue_del(&rtc->timerqueue, &timer->node);
852 trace_rtc_timer_dequeue(timer); 855 trace_rtc_timer_dequeue(timer);
853 timer->enabled = 0; 856 timer->enabled = 0;
854 if (next == &timer->node) { 857 if (next == &timer->node) {
855 struct rtc_wkalrm alarm; 858 struct rtc_wkalrm alarm;
856 int err; 859 int err;
860
857 next = timerqueue_getnext(&rtc->timerqueue); 861 next = timerqueue_getnext(&rtc->timerqueue);
858 if (!next) { 862 if (!next) {
859 rtc_alarm_disable(rtc); 863 rtc_alarm_disable(rtc);
@@ -926,9 +930,9 @@ again:
926 alarm.enabled = 1; 930 alarm.enabled = 1;
927reprogram: 931reprogram:
928 err = __rtc_set_alarm(rtc, &alarm); 932 err = __rtc_set_alarm(rtc, &alarm);
929 if (err == -ETIME) 933 if (err == -ETIME) {
930 goto again; 934 goto again;
931 else if (err) { 935 } else if (err) {
932 if (retry-- > 0) 936 if (retry-- > 0)
933 goto reprogram; 937 goto reprogram;
934 938
@@ -939,14 +943,14 @@ reprogram:
939 dev_err(&rtc->dev, "__rtc_set_alarm: err=%d\n", err); 943 dev_err(&rtc->dev, "__rtc_set_alarm: err=%d\n", err);
940 goto again; 944 goto again;
941 } 945 }
942 } else 946 } else {
943 rtc_alarm_disable(rtc); 947 rtc_alarm_disable(rtc);
948 }
944 949
945 pm_relax(rtc->dev.parent); 950 pm_relax(rtc->dev.parent);
946 mutex_unlock(&rtc->ops_lock); 951 mutex_unlock(&rtc->ops_lock);
947} 952}
948 953
949
950/* rtc_timer_init - Initializes an rtc_timer 954/* rtc_timer_init - Initializes an rtc_timer
951 * @timer: timer to be intiialized 955 * @timer: timer to be intiialized
952 * @f: function pointer to be called when timer fires 956 * @f: function pointer to be called when timer fires
@@ -972,9 +976,10 @@ void rtc_timer_init(struct rtc_timer *timer, void (*f)(struct rtc_device *r),
972 * Kernel interface to set an rtc_timer 976 * Kernel interface to set an rtc_timer
973 */ 977 */
974int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer *timer, 978int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer *timer,
975 ktime_t expires, ktime_t period) 979 ktime_t expires, ktime_t period)
976{ 980{
977 int ret = 0; 981 int ret = 0;
982
978 mutex_lock(&rtc->ops_lock); 983 mutex_lock(&rtc->ops_lock);
979 if (timer->enabled) 984 if (timer->enabled)
980 rtc_timer_remove(rtc, timer); 985 rtc_timer_remove(rtc, timer);
diff --git a/drivers/rtc/lib.c b/drivers/rtc/lib.c
index 3d0dc70ff7d8..e36c233455ee 100644
--- a/drivers/rtc/lib.c
+++ b/drivers/rtc/lib.c
@@ -22,7 +22,7 @@ static const unsigned short rtc_ydays[2][13] = {
22 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } 22 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
23}; 23};
24 24
25#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400) 25#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
26 26
27/* 27/*
28 * The number of days in the month. 28 * The number of days in the month.
@@ -38,11 +38,10 @@ EXPORT_SYMBOL(rtc_month_days);
38 */ 38 */
39int rtc_year_days(unsigned int day, unsigned int month, unsigned int year) 39int rtc_year_days(unsigned int day, unsigned int month, unsigned int year)
40{ 40{
41 return rtc_ydays[is_leap_year(year)][month] + day-1; 41 return rtc_ydays[is_leap_year(year)][month] + day - 1;
42} 42}
43EXPORT_SYMBOL(rtc_year_days); 43EXPORT_SYMBOL(rtc_year_days);
44 44
45
46/* 45/*
47 * rtc_time64_to_tm - Converts time64_t to rtc_time. 46 * rtc_time64_to_tm - Converts time64_t to rtc_time.
48 * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. 47 * Convert seconds since 01-01-1970 00:00:00 to Gregorian date.
@@ -94,13 +93,14 @@ EXPORT_SYMBOL(rtc_time64_to_tm);
94 */ 93 */
95int rtc_valid_tm(struct rtc_time *tm) 94int rtc_valid_tm(struct rtc_time *tm)
96{ 95{
97 if (tm->tm_year < 70 96 if (tm->tm_year < 70 ||
98 || ((unsigned)tm->tm_mon) >= 12 97 ((unsigned int)tm->tm_mon) >= 12 ||
99 || tm->tm_mday < 1 98 tm->tm_mday < 1 ||
100 || tm->tm_mday > rtc_month_days(tm->tm_mon, ((unsigned)tm->tm_year + 1900)) 99 tm->tm_mday > rtc_month_days(tm->tm_mon,
101 || ((unsigned)tm->tm_hour) >= 24 100 ((unsigned int)tm->tm_year + 1900)) ||
102 || ((unsigned)tm->tm_min) >= 60 101 ((unsigned int)tm->tm_hour) >= 24 ||
103 || ((unsigned)tm->tm_sec) >= 60) 102 ((unsigned int)tm->tm_min) >= 60 ||
103 ((unsigned int)tm->tm_sec) >= 60)
104 return -EINVAL; 104 return -EINVAL;
105 105
106 return 0; 106 return 0;
@@ -113,7 +113,7 @@ EXPORT_SYMBOL(rtc_valid_tm);
113 */ 113 */
114time64_t rtc_tm_to_time64(struct rtc_time *tm) 114time64_t rtc_tm_to_time64(struct rtc_time *tm)
115{ 115{
116 return mktime64(((unsigned)tm->tm_year + 1900), tm->tm_mon + 1, 116 return mktime64(((unsigned int)tm->tm_year + 1900), tm->tm_mon + 1,
117 tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); 117 tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
118} 118}
119EXPORT_SYMBOL(rtc_tm_to_time64); 119EXPORT_SYMBOL(rtc_tm_to_time64);
diff --git a/drivers/rtc/nvmem.c b/drivers/rtc/nvmem.c
index 7481a4cd2753..4312096c7738 100644
--- a/drivers/rtc/nvmem.c
+++ b/drivers/rtc/nvmem.c
@@ -43,7 +43,7 @@ static int rtc_nvram_register(struct rtc_device *rtc,
43{ 43{
44 int err; 44 int err;
45 45
46 rtc->nvram = kzalloc(sizeof(struct bin_attribute), GFP_KERNEL); 46 rtc->nvram = kzalloc(sizeof(*rtc->nvram), GFP_KERNEL);
47 if (!rtc->nvram) 47 if (!rtc->nvram)
48 return -ENOMEM; 48 return -ENOMEM;
49 49
diff --git a/drivers/rtc/proc.c b/drivers/rtc/proc.c
index a741c4d8f5a5..73344598fc1b 100644
--- a/drivers/rtc/proc.c
+++ b/drivers/rtc/proc.c
@@ -57,17 +57,17 @@ static int rtc_proc_show(struct seq_file *seq, void *offset)
57 seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time); 57 seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time);
58 seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time); 58 seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time);
59 seq_printf(seq, "alarm_IRQ\t: %s\n", 59 seq_printf(seq, "alarm_IRQ\t: %s\n",
60 alrm.enabled ? "yes" : "no"); 60 alrm.enabled ? "yes" : "no");
61 seq_printf(seq, "alrm_pending\t: %s\n", 61 seq_printf(seq, "alrm_pending\t: %s\n",
62 alrm.pending ? "yes" : "no"); 62 alrm.pending ? "yes" : "no");
63 seq_printf(seq, "update IRQ enabled\t: %s\n", 63 seq_printf(seq, "update IRQ enabled\t: %s\n",
64 (rtc->uie_rtctimer.enabled) ? "yes" : "no"); 64 (rtc->uie_rtctimer.enabled) ? "yes" : "no");
65 seq_printf(seq, "periodic IRQ enabled\t: %s\n", 65 seq_printf(seq, "periodic IRQ enabled\t: %s\n",
66 (rtc->pie_enabled) ? "yes" : "no"); 66 (rtc->pie_enabled) ? "yes" : "no");
67 seq_printf(seq, "periodic IRQ frequency\t: %d\n", 67 seq_printf(seq, "periodic IRQ frequency\t: %d\n",
68 rtc->irq_freq); 68 rtc->irq_freq);
69 seq_printf(seq, "max user IRQ frequency\t: %d\n", 69 seq_printf(seq, "max user IRQ frequency\t: %d\n",
70 rtc->max_user_freq); 70 rtc->max_user_freq);
71 } 71 }
72 72
73 seq_printf(seq, "24hr\t\t: yes\n"); 73 seq_printf(seq, "24hr\t\t: yes\n");
@@ -82,7 +82,7 @@ void rtc_proc_add_device(struct rtc_device *rtc)
82{ 82{
83 if (is_rtc_hctosys(rtc)) 83 if (is_rtc_hctosys(rtc))
84 proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show, 84 proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show,
85 rtc); 85 rtc);
86} 86}
87 87
88void rtc_proc_del_device(struct rtc_device *rtc) 88void rtc_proc_del_device(struct rtc_device *rtc)
diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c
index 0d3dac557df5..be3531e7f868 100644
--- a/drivers/rtc/sysfs.c
+++ b/drivers/rtc/sysfs.c
@@ -11,7 +11,6 @@
11 11
12#include "rtc-core.h" 12#include "rtc-core.h"
13 13
14
15/* device attributes */ 14/* device attributes */
16 15
17/* 16/*
@@ -83,7 +82,7 @@ max_user_freq_show(struct device *dev, struct device_attribute *attr, char *buf)
83 82
84static ssize_t 83static ssize_t
85max_user_freq_store(struct device *dev, struct device_attribute *attr, 84max_user_freq_store(struct device *dev, struct device_attribute *attr,
86 const char *buf, size_t n) 85 const char *buf, size_t n)
87{ 86{
88 struct rtc_device *rtc = to_rtc_device(dev); 87 struct rtc_device *rtc = to_rtc_device(dev);
89 unsigned long val; 88 unsigned long val;
@@ -113,12 +112,11 @@ hctosys_show(struct device *dev, struct device_attribute *attr, char *buf)
113{ 112{
114#ifdef CONFIG_RTC_HCTOSYS_DEVICE 113#ifdef CONFIG_RTC_HCTOSYS_DEVICE
115 if (rtc_hctosys_ret == 0 && 114 if (rtc_hctosys_ret == 0 &&
116 strcmp(dev_name(&to_rtc_device(dev)->dev), 115 strcmp(dev_name(&to_rtc_device(dev)->dev),
117 CONFIG_RTC_HCTOSYS_DEVICE) == 0) 116 CONFIG_RTC_HCTOSYS_DEVICE) == 0)
118 return sprintf(buf, "1\n"); 117 return sprintf(buf, "1\n");
119 else
120#endif 118#endif
121 return sprintf(buf, "0\n"); 119 return sprintf(buf, "0\n");
122} 120}
123static DEVICE_ATTR_RO(hctosys); 121static DEVICE_ATTR_RO(hctosys);
124 122
@@ -172,15 +170,15 @@ wakealarm_store(struct device *dev, struct device_attribute *attr,
172 if (*buf_ptr == '=') { 170 if (*buf_ptr == '=') {
173 buf_ptr++; 171 buf_ptr++;
174 push = 1; 172 push = 1;
175 } else 173 } else {
176 adjust = 1; 174 adjust = 1;
175 }
177 } 176 }
178 retval = kstrtos64(buf_ptr, 0, &alarm); 177 retval = kstrtos64(buf_ptr, 0, &alarm);
179 if (retval) 178 if (retval)
180 return retval; 179 return retval;
181 if (adjust) { 180 if (adjust)
182 alarm += now; 181 alarm += now;
183 }
184 if (alarm > now || push) { 182 if (alarm > now || push) {
185 /* Avoid accidentally clobbering active alarms; we can't 183 /* Avoid accidentally clobbering active alarms; we can't
186 * entirely prevent that here, without even the minimal 184 * entirely prevent that here, without even the minimal