Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

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