lkml.org 
[lkml]   [2010]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] RTC: DaVinci RTC driver
On Fri, 12 Mar 2010 11:08:33 -0800
Kevin Hilman <khilman@deeprootsystems.com> wrote:

> +static int convertfromdays(u16 days, struct rtc_time *tm)
> +{
> + int tmp_days, year, mon;
> +
> + for (year = 2000;; year++) {
> + tmp_days = rtc_year_days(1, 12, year);
> + if (days >= tmp_days)
> + days -= tmp_days;
> + else {
> + for (mon = 0;; mon++) {
> + tmp_days = rtc_month_days(mon, year);
> + if (days >= tmp_days) {
> + days -= tmp_days;
> + } else {
> + tm->tm_year = year - 1900;
> + tm->tm_mon = mon;
> + tm->tm_mday = days + 1;
> + break;
> + }
> + }
> + break;
> + }
> + }
> + return 0;
> +}
> +
> +static int convert2days(u16 *days, struct rtc_time *tm)
> +{
> + int i;
> + *days = 0;
> +
> + /* epoch == 1900 */
> + if (tm->tm_year < 100 || tm->tm_year > 199)
> + return -EINVAL;
> +
> + for (i = 2000; i < 1900 + tm->tm_year; i++)
> + *days += rtc_year_days(1, 12, i);
> +
> + *days += rtc_year_days(tm->tm_mday, tm->tm_mon, 1900 + tm->tm_year);
> +
> + return 0;
> +}

I'm looking suspiciously at these (slow-looking) functions. Are they
really specific to this device, or could we be making better use of
library code, or adding functionality to library code?



\
 
 \ /
  Last update: 2010-03-15 22:23    [W:0.169 / U:3.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site