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

powerpc: use time64_t in update_persistent_clock

update_persistent_clock() is deprecated because it suffers from overflow
in 2038 on 32-bit architectures. This changes powerpc to use the
update_persistent_clock64() replacement, and to pass down 64-bit
timestamps consistently.

This is now simpler, as we no longer have to worry about the offset
numbers in tm_year and tm_mon that are different between the Linux
conventions and RTAS.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Arnd Bergmann and committed by
Michael Ellerman
5235afa8 5bfd6435

+9 -21
+2 -4
arch/powerpc/kernel/time.c
··· 811 811 } 812 812 } 813 813 814 - int update_persistent_clock(struct timespec now) 814 + int update_persistent_clock64(struct timespec64 now) 815 815 { 816 816 struct rtc_time tm; 817 817 818 818 if (!ppc_md.set_rtc_time) 819 819 return -ENODEV; 820 820 821 - to_tm(now.tv_sec + 1 + timezone_offset, &tm); 822 - tm.tm_year -= 1900; 823 - tm.tm_mon -= 1; 821 + rtc_time64_to_tm(now.tv_sec + 1 + timezone_offset, &tm); 824 822 825 823 return ppc_md.set_rtc_time(&tm); 826 824 }
+3 -4
arch/powerpc/platforms/8xx/m8xx_setup.c
··· 169 169 { 170 170 sitk8xx_t __iomem *sys_tmr1; 171 171 sit8xx_t __iomem *sys_tmr2; 172 - int time; 172 + time64_t time; 173 173 174 174 sys_tmr1 = immr_map(im_sitk); 175 175 sys_tmr2 = immr_map(im_sit); 176 - time = mktime(tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, 177 - tm->tm_hour, tm->tm_min, tm->tm_sec); 176 + time = rtc_tm_to_time64(tm); 178 177 179 178 out_be32(&sys_tmr1->sitk_rtck, KAPWR_KEY); 180 - out_be32(&sys_tmr2->sit_rtc, time); 179 + out_be32(&sys_tmr2->sit_rtc, (u32)time); 181 180 out_be32(&sys_tmr1->sitk_rtck, ~KAPWR_KEY); 182 181 183 182 immr_unmap(sys_tmr2);
+4 -13
arch/powerpc/platforms/powermac/time.c
··· 84 84 return delta; 85 85 } 86 86 87 - #if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) || \ 88 - defined(CONFIG_PMAC_SMU) 89 - static unsigned long from_rtc_time(struct rtc_time *tm) 90 - { 91 - return mktime(tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, 92 - tm->tm_hour, tm->tm_min, tm->tm_sec); 93 - } 94 - #endif 95 - 96 87 #ifdef CONFIG_ADB_CUDA 97 88 static time64_t cuda_get_time(void) 98 89 { ··· 106 115 107 116 static int cuda_set_rtc_time(struct rtc_time *tm) 108 117 { 109 - unsigned int nowtime; 118 + time64_t nowtime; 110 119 struct adb_request req; 111 120 112 - nowtime = from_rtc_time(tm) + RTC_OFFSET; 121 + nowtime = rtc_tm_to_time64(tm) + RTC_OFFSET; 113 122 if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME, 114 123 nowtime >> 24, nowtime >> 16, nowtime >> 8, 115 124 nowtime) < 0) ··· 149 158 150 159 static int pmu_set_rtc_time(struct rtc_time *tm) 151 160 { 152 - unsigned int nowtime; 161 + time64_t nowtime; 153 162 struct adb_request req; 154 163 155 - nowtime = from_rtc_time(tm) + RTC_OFFSET; 164 + nowtime = rtc_tm_to_time64(tm) + RTC_OFFSET; 156 165 if (pmu_request(&req, NULL, 5, PMU_SET_RTC, nowtime >> 24, 157 166 nowtime >> 16, nowtime >> 8, nowtime) < 0) 158 167 return -ENXIO;