@@ -270,7 +270,7 @@ int main(int argc, char **argv)
/* Turn on update interrupts (one per second) */
retval = ioctl(fd, RTC_UIE_ON, 0);
if (retval == -1) {
- if (errno == ENOTTY) {
+ if (errno == EINVAL) {
fprintf(stderr,
"\n...Update IRQs not supported.\n");
goto test_READ;
@@ -353,7 +353,7 @@ test_READ:
retval = ioctl(fd, RTC_ALM_SET, &rtc_tm);
if (retval == -1) {
- if (errno == ENOTTY) {
+ if (errno == EINVAL) {
fprintf(stderr,
"\n...Alarm IRQs not supported.\n");
goto test_PIE;
@@ -401,13 +401,12 @@ test_PIE:
/* Read periodic IRQ rate */
retval = ioctl(fd, RTC_IRQP_READ, &tmp);
if (retval == -1) {
- /* not all RTCs support periodic IRQs */
- if (errno == ENOTTY) {
- fprintf(stderr, "\nNo periodic IRQ support\n");
- goto done;
- }
perror("RTC_IRQP_READ ioctl");
exit(errno);
+ } else if (tmp == 0) {
+ /* not all RTCs support periodic IRQs */
+ fprintf(stderr, "\nNo periodic IRQ support\n");
+ goto done;
}
fprintf(stderr, "\nPeriodic IRQ rate is %ldHz.\n", tmp);