Skip to content

Commit 60a06ef

Browse files
Abhishek-Tamboli9alexandrebelloni
authored andcommitted
rtc: m48t59: Remove division condition with direct comparison
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>
1 parent 73580e2 commit 60a06ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/rtc/rtc-m48t59.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm)
132132
M48T59_WRITE((bin2bcd(tm->tm_mon + 1) & 0x1F), M48T59_MONTH);
133133
M48T59_WRITE(bin2bcd(year % 100), M48T59_YEAR);
134134

135-
if (pdata->type == M48T59RTC_TYPE_M48T59 && (year / 100))
135+
if (pdata->type == M48T59RTC_TYPE_M48T59 && (year >= 100))
136136
val = (M48T59_WDAY_CEB | M48T59_WDAY_CB);
137137
val |= (bin2bcd(tm->tm_wday) & 0x07);
138138
M48T59_WRITE(val, M48T59_WDAY);

0 commit comments

Comments
 (0)