diff options
Diffstat (limited to 'arch/x86/platform/efi')
| -rw-r--r-- | arch/x86/platform/efi/efi.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 5f2ecaf3f9d8..28d9efacc9b6 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
| @@ -48,6 +48,7 @@ | |||
| 48 | #include <asm/cacheflush.h> | 48 | #include <asm/cacheflush.h> |
| 49 | #include <asm/tlbflush.h> | 49 | #include <asm/tlbflush.h> |
| 50 | #include <asm/x86_init.h> | 50 | #include <asm/x86_init.h> |
| 51 | #include <asm/rtc.h> | ||
| 51 | 52 | ||
| 52 | #define EFI_DEBUG 1 | 53 | #define EFI_DEBUG 1 |
| 53 | 54 | ||
| @@ -258,10 +259,10 @@ static efi_status_t __init phys_efi_get_time(efi_time_t *tm, | |||
| 258 | 259 | ||
| 259 | int efi_set_rtc_mmss(unsigned long nowtime) | 260 | int efi_set_rtc_mmss(unsigned long nowtime) |
| 260 | { | 261 | { |
| 261 | int real_seconds, real_minutes; | ||
| 262 | efi_status_t status; | 262 | efi_status_t status; |
| 263 | efi_time_t eft; | 263 | efi_time_t eft; |
| 264 | efi_time_cap_t cap; | 264 | efi_time_cap_t cap; |
| 265 | struct rtc_time tm; | ||
| 265 | 266 | ||
| 266 | status = efi.get_time(&eft, &cap); | 267 | status = efi.get_time(&eft, &cap); |
| 267 | if (status != EFI_SUCCESS) { | 268 | if (status != EFI_SUCCESS) { |
| @@ -269,13 +270,20 @@ int efi_set_rtc_mmss(unsigned long nowtime) | |||
| 269 | return -1; | 270 | return -1; |
| 270 | } | 271 | } |
| 271 | 272 | ||
| 272 | real_seconds = nowtime % 60; | 273 | rtc_time_to_tm(nowtime, &tm); |
| 273 | real_minutes = nowtime / 60; | 274 | if (!rtc_valid_tm(&tm)) { |
| 274 | if (((abs(real_minutes - eft.minute) + 15)/30) & 1) | 275 | eft.year = tm.tm_year + 1900; |
| 275 | real_minutes += 30; | 276 | eft.month = tm.tm_mon + 1; |
| 276 | real_minutes %= 60; | 277 | eft.day = tm.tm_mday; |
| 277 | eft.minute = real_minutes; | 278 | eft.minute = tm.tm_min; |
| 278 | eft.second = real_seconds; | 279 | eft.second = tm.tm_sec; |
| 280 | eft.nanosecond = 0; | ||
| 281 | } else { | ||
| 282 | printk(KERN_ERR | ||
| 283 | "%s: Invalid EFI RTC value: write of %lx to EFI RTC failed\n", | ||
| 284 | __FUNCTION__, nowtime); | ||
| 285 | return -1; | ||
| 286 | } | ||
| 279 | 287 | ||
| 280 | status = efi.set_time(&eft); | 288 | status = efi.set_time(&eft); |
| 281 | if (status != EFI_SUCCESS) { | 289 | if (status != EFI_SUCCESS) { |
