Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: opal: constify opal_rtc_ops

Use RTC_FEATURE_ALARM to signal to the core whether alarms are available
instead of changing the global struct rtc_class_ops, allowing to make it
const.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210110231752.1418816-13-alexandre.belloni@bootlin.com

+7 -6
+7 -6
drivers/rtc/rtc-opal.c
··· 224 224 return enabled ? 0 : opal_set_tpo_time(dev, &alarm); 225 225 } 226 226 227 - static struct rtc_class_ops opal_rtc_ops = { 227 + static const struct rtc_class_ops opal_rtc_ops = { 228 228 .read_time = opal_get_rtc_time, 229 229 .set_time = opal_set_rtc_time, 230 + .read_alarm = opal_get_tpo_time, 231 + .set_alarm = opal_set_tpo_time, 232 + .alarm_irq_enable = opal_tpo_alarm_irq_enable, 230 233 }; 231 234 232 235 static int opal_rtc_probe(struct platform_device *pdev) ··· 242 239 243 240 if (pdev->dev.of_node && 244 241 (of_property_read_bool(pdev->dev.of_node, "wakeup-source") || 245 - of_property_read_bool(pdev->dev.of_node, "has-tpo")/* legacy */)) { 242 + of_property_read_bool(pdev->dev.of_node, "has-tpo")/* legacy */)) 246 243 device_set_wakeup_capable(&pdev->dev, true); 247 - opal_rtc_ops.read_alarm = opal_get_tpo_time; 248 - opal_rtc_ops.set_alarm = opal_set_tpo_time; 249 - opal_rtc_ops.alarm_irq_enable = opal_tpo_alarm_irq_enable; 250 - } 244 + else 245 + clear_bit(RTC_FEATURE_ALARM, rtc->features); 251 246 252 247 rtc->ops = &opal_rtc_ops; 253 248 rtc->range_min = RTC_TIMESTAMP_BEGIN_0000;