Messages in this thread | | | Date | Mon, 15 Mar 2010 14:20:24 -0700 | From | Andrew Morton <> | Subject | Re: [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?
| |