Skip to contentSkip to conversation

char: rtc: remove unused rtc_control() API

PATCH In review Alexandre Belloni 3 participants 5 messages Feb 6, 2018 – Feb 7, 2018

Subsystems (3)
lore
Share & tools
lore

Alexandre Belloni

author maintainer
#0 lore raw

PATCH 1/1 char: rtc: remove unused rtc_control() API

Since commit 34ce71a96dcb ("ALSA: timer: remove legacy rtctimer"), the rtc_register/rtc_control/rtc_unregister API is unused. As it is highly unlikely to be needed again, remove it.

---

Hi,

I'd like that one to go through the RTC tree as I have other changes in rtc.h planned for the next release.

 drivers/char/rtc.c  | 83 -----------------------------------------------------
 include/linux/rtc.h |  4 ---
 2 files changed, 87 deletions(-)
drivers/char/rtc.c +0 -83
index c6a317120a55..3d86115e5624 100644
@@ -809,89 +809,6 @@ static __poll_t rtc_poll(struct file *file, poll_table *wait)
 }
 #endif
 
-int rtc_register(rtc_task_t *task)
-{
-#ifndef RTC_IRQ
-	return -EIO;
-#else
-	if (task == NULL || task->func == NULL)
-		return -EINVAL;
-	spin_lock_irq(&rtc_lock);
-	if (rtc_status & RTC_IS_OPEN) {
-		spin_unlock_irq(&rtc_lock);
-		return -EBUSY;
-	}
-	spin_lock(&rtc_task_lock);
-	if (rtc_callback) {
-		spin_unlock(&rtc_task_lock);
-		spin_unlock_irq(&rtc_lock);
-		return -EBUSY;
-	}
-	rtc_status |= RTC_IS_OPEN;
-	rtc_callback = task;
-	spin_unlock(&rtc_task_lock);
-	spin_unlock_irq(&rtc_lock);
-	return 0;
-#endif
-}
-EXPORT_SYMBOL(rtc_register);
-
-int rtc_unregister(rtc_task_t *task)
-{
-#ifndef RTC_IRQ
-	return -EIO;
-#else
-	unsigned char tmp;
-
-	spin_lock_irq(&rtc_lock);
-	spin_lock(&rtc_task_lock);
-	if (rtc_callback != task) {
-		spin_unlock(&rtc_task_lock);
-		spin_unlock_irq(&rtc_lock);
-		return -ENXIO;
-	}
-	rtc_callback = NULL;
-
-	/* disable controls */
-	if (!hpet_mask_rtc_irq_bit(RTC_PIE | RTC_AIE | RTC_UIE)) {
-		tmp = CMOS_READ(RTC_CONTROL);
-		tmp &= ~RTC_PIE;
-		tmp &= ~RTC_AIE;
-		tmp &= ~RTC_UIE;
-		CMOS_WRITE(tmp, RTC_CONTROL);
-		CMOS_READ(RTC_INTR_FLAGS);
-	}
-	if (rtc_status & RTC_TIMER_ON) {
-		rtc_status &= ~RTC_TIMER_ON;
-		del_timer(&rtc_irq_timer);
-	}
-	rtc_status &= ~RTC_IS_OPEN;
-	spin_unlock(&rtc_task_lock);
-	spin_unlock_irq(&rtc_lock);
-	return 0;
-#endif
-}
-EXPORT_SYMBOL(rtc_unregister);
-
-int rtc_control(rtc_task_t *task, unsigned int cmd, unsigned long arg)
-{
-#ifndef RTC_IRQ
-	return -EIO;
-#else
-	unsigned long flags;
-	if (cmd != RTC_PIE_ON && cmd != RTC_PIE_OFF && cmd != RTC_IRQP_SET)
-		return -EINVAL;
-	spin_lock_irqsave(&rtc_task_lock, flags);
-	if (rtc_callback != task) {
-		spin_unlock_irqrestore(&rtc_task_lock, flags);
-		return -ENXIO;
-	}
-	spin_unlock_irqrestore(&rtc_task_lock, flags);
-	return rtc_do_ioctl(cmd, arg, 1);
-#endif
-}
-EXPORT_SYMBOL(rtc_control);
-
 /*
  *	The various file operations we support.
  */
include/linux/rtc.h +0 -4
index fc6c90b57be0..5024b61119b6 100644
@@ -212,10 +212,6 @@ void rtc_aie_update_irq(void *private);
 void rtc_uie_update_irq(void *private);
 enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer);
 
-int rtc_register(rtc_task_t *task);
-int rtc_unregister(rtc_task_t *task);
-int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg);
-
 void rtc_timer_init(struct rtc_timer *timer, void (*f)(void *p), void *data);
 int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer *timer,
 		    ktime_t expires, ktime_t period);
Signature · 1 line
2.15.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Alexandre Belloni

Since commit 34ce71a96dcb ("ALSA: timer: remove legacy rtctimer"), the rtc_register/rtc_control/rtc_unregister API is unused. As it is highly unlikely to be needed again, remove it.

Quoted 8 lines

---

Hi,

I'd like that one to go through the RTC tree as I have other changes in rtc.h planned for the next release.

Fine with me!

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Alexandre Belloni
Quoted 6 lines · Alexandre Belloni

Since commit 34ce71a96dcb ("ALSA: timer: remove legacy rtctimer"), the rtc_register/rtc_control/rtc_unregister API is unused. As it is highly unlikely to be needed again, remove it.

---

Nice!

I forgot what's stopping us from removing the rest of that driver ;-) Since we can only build it on alpha and mips/loongson64 these days, is there anything that this driver does that the normal one doesn't? If it's just a question of testing, we could probably just move it to staging and see if anyone notices a difference.

author maintainer
#3 lore raw
Quoted 11 lines · Arnd Bergmann
Quoted 6 lines · Alexandre Belloni

Since commit 34ce71a96dcb ("ALSA: timer: remove legacy rtctimer"), the rtc_register/rtc_control/rtc_unregister API is unused. As it is highly unlikely to be needed again, remove it.

---

Nice!

Quoted 7 lines

I forgot what's stopping us from removing the rest of that driver ;-) Since we can only build it on alpha and mips/loongson64 these days, is there anything that this driver does that the normal one doesn't? If it's just a question of testing, we could probably just move it to staging and see if anyone notices a difference.

I'd say it is a matter of testing. The loongsoon maintainers seem responsive so we may get testing for that architecture. I'm not so sure about alpha. Actually, I'm not even sure it is really used on alpha because arch/alpha/kernel/rtc.c seems to do the right thing.

I think I'll start by ripping of all the x86 and sparc specific parts and see what's left.

I would also love to get rid of drivers/char/efirtc.c but that probably means doing some testing on both an ARM/ARM64 platform with EFI and IA64.

Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
maintainer
#4 lore raw
Quoted 20 lines · Alexandre Belloni
Quoted 11 lines · Arnd Bergmann
Quoted 6 lines · Alexandre Belloni

Since commit 34ce71a96dcb ("ALSA: timer: remove legacy rtctimer"), the rtc_register/rtc_control/rtc_unregister API is unused. As it is highly unlikely to be needed again, remove it.

---

Nice!

Quoted 7 lines

I forgot what's stopping us from removing the rest of that driver ;-) Since we can only build it on alpha and mips/loongson64 these days, is there anything that this driver does that the normal one doesn't? If it's just a question of testing, we could probably just move it to staging and see if anyone notices a difference.

Quoted 4 lines

I'd say it is a matter of testing. The loongsoon maintainers seem responsive so we may get testing for that architecture. I'm not so sure about alpha. Actually, I'm not even sure it is really used on alpha because arch/alpha/kernel/rtc.c seems to do the right thing.

The Alpha defconfig still enables it, and doesn't enable RTC_CLASS, so at least that has to be changed. I've added the Alpha maintainers to Cc, they can probably find out whether it works or not.

Quoted 2 lines

I think I'll start by ripping of all the x86 and sparc specific parts and see what's left.

Just wait till we hear back from the others, removing it completely would be simpler ;-)

Quoted 3 lines

I would also love to get rid of drivers/char/efirtc.c but that probably means doing some testing on both an ARM/ARM64 platform with EFI and IA64.

On ARM/ARM64, we can only use the drivers/rtc/rtc-efi.c driver, not drivers/char/efirtc.c, so it's only IA64, and they were also the ones that sent the rtc-efi driver before the start of the git history. However, the EFI_RTC driver is still in their defconfigs.

For the other RTC drivers in drivers/char, JS_RTC has been dead for a while, since sparc selects RTC_CLASS. For DS1302, we have both a driver that is used on m32r and a generic rtc class driver for the same chip, but I wouldn't trust on that to work on m32r. We can probably find a solution for this one once the others are gone, e.g. removing arch/m32r, or adding some glue logic to make it plausible for the rtc class driver to work, without actually testing it.

Arnd