rtc: restoring of periodic irq freqeuncy to original state

From: dev@xxxxxxxxxxxxxxxxxx
Date: Wed May 02 2012 - 04:33:37 EST


Hi Kernel Folks,

Dont' know whether this is a bug or feature. sorry :(.

when the periodic irq's are enabled from the application through the ioctl, and when the application suddenly stops, the irq frequency was not reverted back to the original one.

say for ex..
if my original freq was 1024, and i set it using IRQP_SET with 512.
so when i stop my program the original freq was not set back and the program set frequency is appearing in the /proc/driver/rtc.

Attached is the test program.


Thanks,
Devendra C.

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/rtc.h>

main()
{
struct rtc_time rtc_time;
int fd;
char data[BUFSIZ];
int irqfre;
int ret;

fd = open("/dev/rtc", O_RDWR);
if (fd < 0) {
printf("can't open /dev/rtc\n");
return;
}

ret = ioctl(fd, RTC_IRQP_READ, &irqfre);
if (ret == 0) {
/*
printf("Rate: %d\n", irqfre);
*/
irqfre = 1024;
ret = ioctl(fd, RTC_IRQP_SET, irqfre);
}
if (ret < 0) {
printf("Can't read periodic IRQ's\n");
}

ret = ioctl(fd, RTC_PIE_ON, NULL);
if (ret < 0) {
printf("can't set the periodic irq\n");
close(fd);
return;
}


while(read(fd, &data, sizeof(data)) > 0) {
printf("Intr\n");
}

}