rtc: ds1511: drop useless checks
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Tue, 27 Feb 2024 23:04:16 +0000 (00:04 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 29 Feb 2024 21:15:46 +0000 (22:15 +0100)
The RTC core will always pass a valid rtc_tm, it is unnecessary to check
the validity of its members, especially with an open coded version of
rtc_valid_tm().

Link: https://lore.kernel.org/r/20240227230431.1837717-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-ds1511.c

index 1109cad83838496d92cd328bc14213f50f2c4413..87c52d20d31a21585706ef24b1910e8d04ba5536 100644 (file)
@@ -182,9 +182,6 @@ static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm)
        if (rtc_tm->tm_year < 1900)
                rtc_tm->tm_year += 1900;
 
-       if (rtc_tm->tm_year < 1970)
-               return -EINVAL;
-
        yrs = rtc_tm->tm_year % 100;
        cen = rtc_tm->tm_year / 100;
        mon = rtc_tm->tm_mon + 1;   /* tm_mon starts at zero */
@@ -194,15 +191,6 @@ static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm)
        min = rtc_tm->tm_min;
        sec = rtc_tm->tm_sec;
 
-       if ((mon > 12) || (day == 0))
-               return -EINVAL;
-
-       if (day > rtc_month_days(rtc_tm->tm_mon, rtc_tm->tm_year))
-               return -EINVAL;
-
-       if ((hrs >= 24) || (min >= 60) || (sec >= 60))
-               return -EINVAL;
-
        /*
         * each register is a different number of valid bits
         */