Skip to contentSkip to conversation

rtc: m48t59: Remove division condition with direct comparison

PATCH Applied Abhishek Tamboli 2 participants 3 messages Aug 9, 2024 – Sep 11, 2024 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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'

---
 drivers/rtc/rtc-m48t59.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-m48t59.c +1 -1
index f0f6b9b6daec..cd2ca49805d8 100644
@@ -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);

--
2.34.1

#1 lore raw

PATCH 1/1 rtc: m48t59: Remove division condition with direct comparison

Hi Alexandre,

I wanted to check if you had a chance to review the patch I sent to you [1]. I understand you may have a busy schedule, but I would appreciate any feedback you can provide when you have time.

The patch is available here:
[1]: https://lore.kernel.org/all/[email protected]/

Thank you for your time.

Best regards,
Abhishek

maintainer Applied
#2 lore raw
In reply to Abhishek Tamboli
Quoted 9 lines · Abhishek Tamboli

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'

[...]

Applied, thanks!

[1/1] rtc: m48t59: Remove division condition with direct comparison

      https://git.kernel.org/abelloni/c/60a06efc56d7

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com