]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rtc: m48t59: Remove division condition with direct comparison
authorAbhishek Tamboli <abhishektamboli9@gmail.com>
Fri, 9 Aug 2024 15:56:31 +0000 (21:26 +0530)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 11 Sep 2024 22:36:53 +0000 (00:36 +0200)
Replace 'year / 100' with a direct comparison 'year >= 100'
in m48t59_rtc_set_time() function. Improve the code clarity
and eliminate division overhead.

Fix the following smatch warning:
drivers/rtc/rtc-m48t59.c:135 m48t59_rtc_set_time() warn:
replace divide condition 'year / 100' with 'year >= 100'

Signed-off-by: Abhishek Tamboli <abhishektamboli9@gmail.com>
Link: https://lore.kernel.org/r/20240809155631.548044-1-abhishektamboli9@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-m48t59.c

index f0f6b9b6daecbfeb118676f6e71e7e480a24b246..cd2ca49805d8a24e3c7ba68769a8d4b88ab6cc55 100644 (file)
@@ -132,7 +132,7 @@ static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm)
        M48T59_WRITE((bin2bcd(tm->tm_mon + 1) & 0x1F), M48T59_MONTH);
        M48T59_WRITE(bin2bcd(year % 100), M48T59_YEAR);
 
-       if (pdata->type == M48T59RTC_TYPE_M48T59 && (year / 100))
+       if (pdata->type == M48T59RTC_TYPE_M48T59 && (year >= 100))
                val = (M48T59_WDAY_CEB | M48T59_WDAY_CB);
        val |= (bin2bcd(tm->tm_wday) & 0x07);
        M48T59_WRITE(val, M48T59_WDAY);