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

[PATCH] ARM: RTC: allow driver methods to return error

Allow RTC drivers to return error codes from their read_time
or read_alarm methods.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>

+35 -23
+15 -14
arch/arm/common/rtctime.c
··· 141 141 next->tm_sec = alrm->tm_sec; 142 142 } 143 143 144 - static inline void rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm) 144 + static inline int rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm) 145 145 { 146 146 memset(tm, 0, sizeof(struct rtc_time)); 147 - ops->read_time(tm); 147 + return ops->read_time(tm); 148 148 } 149 149 150 150 static inline int rtc_set_time(struct rtc_ops *ops, struct rtc_time *tm) ··· 163 163 int ret = -EINVAL; 164 164 if (ops->read_alarm) { 165 165 memset(alrm, 0, sizeof(struct rtc_wkalrm)); 166 - ops->read_alarm(alrm); 167 - ret = 0; 166 + ret = ops->read_alarm(alrm); 168 167 } 169 168 return ret; 170 169 } ··· 282 283 break; 283 284 284 285 case RTC_RD_TIME: 285 - rtc_read_time(ops, &tm); 286 + ret = rtc_read_time(ops, &tm); 287 + if (ret) 288 + break; 286 289 ret = copy_to_user(uarg, &tm, sizeof(tm)); 287 290 if (ret) 288 291 ret = -EFAULT; ··· 425 424 struct rtc_time tm; 426 425 char *p = page; 427 426 428 - rtc_read_time(ops, &tm); 429 - 430 - p += sprintf(p, 431 - "rtc_time\t: %02d:%02d:%02d\n" 432 - "rtc_date\t: %04d-%02d-%02d\n" 433 - "rtc_epoch\t: %04lu\n", 434 - tm.tm_hour, tm.tm_min, tm.tm_sec, 435 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 436 - rtc_epoch); 427 + if (rtc_read_time(ops, &tm) == 0) { 428 + p += sprintf(p, 429 + "rtc_time\t: %02d:%02d:%02d\n" 430 + "rtc_date\t: %04d-%02d-%02d\n" 431 + "rtc_epoch\t: %04lu\n", 432 + tm.tm_hour, tm.tm_min, tm.tm_sec, 433 + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 434 + rtc_epoch); 435 + } 437 436 438 437 if (rtc_read_alarm(ops, &alrm) == 0) { 439 438 p += sprintf(p, "alrm_time\t: ");
+12 -5
arch/arm/mach-integrator/time.c
··· 40 40 return 1; 41 41 } 42 42 43 - static void rtc_read_alarm(struct rtc_wkalrm *alrm) 43 + static int rtc_read_alarm(struct rtc_wkalrm *alrm) 44 44 { 45 45 rtc_time_to_tm(readl(rtc_base + RTC_MR), &alrm->time); 46 + return 0; 46 47 } 47 48 48 - static int rtc_set_alarm(struct rtc_wkalrm *alrm) 49 + static inline int rtc_set_alarm(struct rtc_wkalrm *alrm) 49 50 { 50 51 unsigned long time; 51 52 int ret; 52 53 53 - ret = rtc_tm_to_time(&alrm->time, &time); 54 + /* 55 + * At the moment, we can only deal with non-wildcarded alarm times. 56 + */ 57 + ret = rtc_valid_tm(&alrm->time); 58 + if (ret == 0) 59 + ret = rtc_tm_to_time(&alrm->time, &time); 54 60 if (ret == 0) 55 61 writel(time, rtc_base + RTC_MR); 56 62 return ret; 57 63 } 58 64 59 - static void rtc_read_time(struct rtc_time *tm) 65 + static int rtc_read_time(struct rtc_time *tm) 60 66 { 61 67 rtc_time_to_tm(readl(rtc_base + RTC_DR), tm); 68 + return 0; 62 69 } 63 70 64 71 /* ··· 76 69 * edge of the 1Hz clock, we must write the time one second 77 70 * in advance. 78 71 */ 79 - static int rtc_set_time(struct rtc_time *tm) 72 + static inline int rtc_set_time(struct rtc_time *tm) 80 73 { 81 74 unsigned long time; 82 75 int ret;
+6 -2
drivers/char/s3c2410-rtc.c
··· 116 116 117 117 /* Time read/write */ 118 118 119 - static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm) 119 + static int s3c2410_rtc_gettime(struct rtc_time *rtc_tm) 120 120 { 121 121 unsigned int have_retried = 0; 122 122 ··· 151 151 152 152 rtc_tm->tm_year += 100; 153 153 rtc_tm->tm_mon -= 1; 154 + 155 + return 0; 154 156 } 155 157 156 158 ··· 173 171 return 0; 174 172 } 175 173 176 - static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm) 174 + static int s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm) 177 175 { 178 176 struct rtc_time *alm_tm = &alrm->time; 179 177 unsigned int alm_en; ··· 233 231 } 234 232 235 233 /* todo - set alrm->enabled ? */ 234 + 235 + return 0; 236 236 } 237 237 238 238 static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm)
+2 -2
include/asm-arm/rtc.h
··· 18 18 void (*release)(void); 19 19 int (*ioctl)(unsigned int, unsigned long); 20 20 21 - void (*read_time)(struct rtc_time *); 21 + int (*read_time)(struct rtc_time *); 22 22 int (*set_time)(struct rtc_time *); 23 - void (*read_alarm)(struct rtc_wkalrm *); 23 + int (*read_alarm)(struct rtc_wkalrm *); 24 24 int (*set_alarm)(struct rtc_wkalrm *); 25 25 int (*proc)(char *buf); 26 26 };