diff options
author | Tony Breeds <tony@bakeyournoodle.com> | 2007-03-28 22:10:12 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 04:54:20 -0400 |
commit | 644923d4a5f117d437aefd47688d1141cc8361ed (patch) | |
tree | 9fa754c4e8ec4176ef97b7ee1ab6807cefd68936 /arch | |
parent | d62c6f093a1ef8fa5f8951e8da93c8ddd3ce193a (diff) |
[SPARC64]: Small cleanups time.c
- Removes days_in_mo[], as it's almost identical to month_days[]
- Use the leapyear() macro
- Line length wrapping.
Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc64/kernel/time.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 0eb846534ff4..3cb761ec8953 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
@@ -1177,10 +1177,6 @@ static int set_rtc_mmss(unsigned long nowtime) | |||
1177 | #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ | 1177 | #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ |
1178 | static unsigned char mini_rtc_status; /* bitmapped status byte. */ | 1178 | static unsigned char mini_rtc_status; /* bitmapped status byte. */ |
1179 | 1179 | ||
1180 | /* months start at 0 now */ | ||
1181 | static unsigned char days_in_mo[] = | ||
1182 | {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | ||
1183 | |||
1184 | #define FEBRUARY 2 | 1180 | #define FEBRUARY 2 |
1185 | #define STARTOFTIME 1970 | 1181 | #define STARTOFTIME 1970 |
1186 | #define SECDAY 86400L | 1182 | #define SECDAY 86400L |
@@ -1329,8 +1325,7 @@ static int mini_rtc_ioctl(struct inode *inode, struct file *file, | |||
1329 | 1325 | ||
1330 | case RTC_SET_TIME: /* Set the RTC */ | 1326 | case RTC_SET_TIME: /* Set the RTC */ |
1331 | { | 1327 | { |
1332 | int year; | 1328 | int year, days; |
1333 | unsigned char leap_yr; | ||
1334 | 1329 | ||
1335 | if (!capable(CAP_SYS_TIME)) | 1330 | if (!capable(CAP_SYS_TIME)) |
1336 | return -EACCES; | 1331 | return -EACCES; |
@@ -1339,14 +1334,14 @@ static int mini_rtc_ioctl(struct inode *inode, struct file *file, | |||
1339 | return -EFAULT; | 1334 | return -EFAULT; |
1340 | 1335 | ||
1341 | year = wtime.tm_year + 1900; | 1336 | year = wtime.tm_year + 1900; |
1342 | leap_yr = ((!(year % 4) && (year % 100)) || | 1337 | days = month_days[wtime.tm_mon] + |
1343 | !(year % 400)); | 1338 | ((wtime.tm_mon == 1) && leapyear(year)); |
1344 | 1339 | ||
1345 | if ((wtime.tm_mon < 0 || wtime.tm_mon > 11) || (wtime.tm_mday < 1)) | 1340 | if ((wtime.tm_mon < 0 || wtime.tm_mon > 11) || |
1341 | (wtime.tm_mday < 1)) | ||
1346 | return -EINVAL; | 1342 | return -EINVAL; |
1347 | 1343 | ||
1348 | if (wtime.tm_mday < 0 || wtime.tm_mday > | 1344 | if (wtime.tm_mday < 0 || wtime.tm_mday > days) |
1349 | (days_in_mo[wtime.tm_mon] + ((wtime.tm_mon == 1) && leap_yr))) | ||
1350 | return -EINVAL; | 1345 | return -EINVAL; |
1351 | 1346 | ||
1352 | if (wtime.tm_hour < 0 || wtime.tm_hour >= 24 || | 1347 | if (wtime.tm_hour < 0 || wtime.tm_hour >= 24 || |