Skip to contentSkip to conversation

rtc: st-lpc: Constify st_rtc_ops

PATCH Applied Rikard Falkeborn 2 participants 2 messages Sep 13, 2020 – Sep 15, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: st-lpc: Constify st_rtc_ops

The only usage of st_rtc_ops is to assign its address to the ops field in the rtc_device struct. which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/rtc/rtc-st-lpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-st-lpc.c +1 -1
index 51041dc08af4..0c65448b85ee 100644
@@ -173,7 +173,7 @@ static int st_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t)
 	return 0;
 }
 
-static struct rtc_class_ops st_rtc_ops = {
+static const struct rtc_class_ops st_rtc_ops = {
 	.read_time		= st_rtc_read_time,
 	.set_time		= st_rtc_set_time,
 	.read_alarm		= st_rtc_read_alarm,
Signature · 1 line
2.28.0
maintainer Applied
#1 lore raw
Quoted 3 lines · Rikard Falkeborn

The only usage of st_rtc_ops is to assign its address to the ops field in the rtc_device struct. which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

Applied, thanks!

[1/1] rtc: st-lpc: Constify st_rtc_ops

      commit: d0a3b65052f041852c855ea1135659770ba0bc09

Best regards,

Signature · 1 line
Alexandre Belloni <[email protected]>