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

Marek Vasut marex at denx.de
Fri Sep 14 20:08:46 CEST 2012


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 at denx.de>

> Signed-off-by: José Miguel Gonçalves <jose.goncalves at 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


More information about the U-Boot mailing list