From e53ad0841c4e56eafb7244b89932b157b4abbb1d Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Mon, 11 Jan 2021 00:17:41 +0100 Subject: [PATCH] rtc: m48t59: remove m48t02_rtc_ops Clear RTC_FEATURE_ALARM to signal that alarms are not available instead of having a supplementary struct rtc_class_ops without alarm callbacks. Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20210110231752.1418816-7-alexandre.belloni@bootlin.com --- drivers/rtc/rtc-m48t59.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index 5f5898d3b055..1d2e99a70fce 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c @@ -313,11 +313,6 @@ static const struct rtc_class_ops m48t59_rtc_ops = { .alarm_irq_enable = m48t59_rtc_alarm_irq_enable, }; -static const struct rtc_class_ops m48t02_rtc_ops = { - .read_time = m48t59_rtc_read_time, - .set_time = m48t59_rtc_set_time, -}; - static int m48t59_nvram_read(void *priv, unsigned int offset, void *val, size_t size) { @@ -366,7 +361,6 @@ static int m48t59_rtc_probe(struct platform_device *pdev) struct m48t59_private *m48t59 = NULL; struct resource *res; int ret = -ENOMEM; - const struct rtc_class_ops *ops; struct nvmem_config nvmem_cfg = { .name = "m48t59-", .word_size = 1, @@ -438,17 +432,21 @@ static int m48t59_rtc_probe(struct platform_device *pdev) if (ret) return ret; } + + m48t59->rtc = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(m48t59->rtc)) + return PTR_ERR(m48t59->rtc); + switch (pdata->type) { case M48T59RTC_TYPE_M48T59: - ops = &m48t59_rtc_ops; pdata->offset = 0x1ff0; break; case M48T59RTC_TYPE_M48T02: - ops = &m48t02_rtc_ops; + clear_bit(RTC_FEATURE_ALARM, m48t59->rtc->features); pdata->offset = 0x7f0; break; case M48T59RTC_TYPE_M48T08: - ops = &m48t02_rtc_ops; + clear_bit(RTC_FEATURE_ALARM, m48t59->rtc->features); pdata->offset = 0x1ff0; break; default: @@ -459,11 +457,7 @@ static int m48t59_rtc_probe(struct platform_device *pdev) spin_lock_init(&m48t59->lock); platform_set_drvdata(pdev, m48t59); - m48t59->rtc = devm_rtc_allocate_device(&pdev->dev); - if (IS_ERR(m48t59->rtc)) - return PTR_ERR(m48t59->rtc); - - m48t59->rtc->ops = ops; + m48t59->rtc->ops = &m48t59_rtc_ops; nvmem_cfg.size = pdata->offset; ret = devm_rtc_nvmem_register(m48t59->rtc, &nvmem_cfg);