[U-Boot] [PATCH v2 08/11] rtc: Don't allow setting unsuported years on s3c24x0_rtc

Marek Vasut
2012-09-14T18:08:46Z

Dear Jos? Miguel Gon?alves,

> This RTC only supports a 100 years range so rtc_set() should not allow
> setting years bellow 1970 or above 2069.

Acked-by: Marek Vasut <marex@denx.de>

> Signed-off-by: Jos? Miguel Gon?alves <jose.goncalves@inov.pt>
> ---
> Changes for v2:
> - New patch
> ---
> drivers/rtc/s3c24x0_rtc.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/rtc/s3c24x0_rtc.c b/drivers/rtc/s3c24x0_rtc.c
> index 54bf6e3..f96cb11 100644
> --- a/drivers/rtc/s3c24x0_rtc.c
> +++ b/drivers/rtc/s3c24x0_rtc.c
> @@ -139,6 +139,11 @@ int rtc_set(struct rtc_time *tmp)
> tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
> tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
> #endif
> + if (tmp->tm_year < 1970 || tmp->tm_year > 2069) {
> + puts("ERROR: year should be between 1970 and 2069!\n");
> + return -1;
> + }
> +
> year = bin2bcd(tmp->tm_year % 100);
> mon = bin2bcd(tmp->tm_mon);
> wday = bin2bcd(tmp->tm_wday);

Best regards,
Marek Vasut