rtc: how should I handle an invalid state?

From: Uwe Kleine-König
Date: Tue Apr 29 2008 - 08:20:19 EST


Hello,

I'm still stuck with my rtc. My current problem is setting the rtc
using hwclock --systohc.

The problem is that hwclock tries to read the current time before
setting the new one. And if that fails, it doesn't update the rtc.

If no error occurs the procedure to read the time is:

fd = open("/dev/rtc", O_RDONLY|O_LARGEFILE)
ioctl(fd, RTC_UIE_ON, 0);
select(fd + 1, [fd], NULL, NULL, {5, 0});
ioctl(fd, RTC_RD_TIME, &rtc_time);

If one of ioctl(fd, RTC_UIE_ON, 0) or select(fd + 1, [fd], NULL, NULL,
{5, 0}) fail, hwclock aborts.

OTOH I don't want to report success in both because then there is no way
to distinguish between a valid and an unvalid date for hwclock.

Looking at some other drivers they don't seem to handle that case.

Maybe returning an invalid date could work?

What do you think?

Best regards
Uwe

--
Uwe Kleine-König, Software Engineer
Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/