On Wed, 2010-02-03 at 01:43 +0100, Benjamin Cama wrote: > Hi, > > I tested Ben Hutchings' patch and got this result (on a PowerBook6,8) : > > rtc-generic rtc-generic: hctosys: unable to read the hardware clock > (-22) > > Hope this can help solve this bug.
Error 22 is EINVAL and actually indicates an invalid time. If you don't mind applying another patch, this would help debug this further: diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c index 1810e42..2b60d12 100644 --- a/arch/powerpc/platforms/powermac/time.c +++ b/arch/powerpc/platforms/powermac/time.c @@ -108,8 +108,10 @@ static unsigned long cuda_get_time(void) struct adb_request req; unsigned int now; - if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0) + if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0) { + printk(KERN_ERR "cuda_get_time: cuda_request failed\n"); return 0; + } while (!req.complete) cuda_poll(); if (req.reply_len != 7) @@ -117,6 +119,7 @@ static unsigned long cuda_get_time(void) req.reply_len); now = (req.reply[3] << 24) + (req.reply[4] << 16) + (req.reply[5] << 8) + req.reply[6]; + printk(KERN_ERR "cuda_get_time: now = %u\n", now); return ((unsigned long)now) - RTC_OFFSET; } @@ -152,14 +155,17 @@ static unsigned long pmu_get_time(void) struct adb_request req; unsigned int now; - if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0) + if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0) { + printk(KERN_ERR "pmu_get_time: pmu_request failed\n"); return 0; + } pmu_wait_complete(&req); if (req.reply_len != 4) printk(KERN_ERR "pmu_get_time: got %d byte reply from PMU\n", req.reply_len); now = (req.reply[0] << 24) + (req.reply[1] << 16) + (req.reply[2] << 8) + req.reply[3]; + printk(KERN_ERR "pmu_get_time: now = %u\n", now); return ((unsigned long)now) - RTC_OFFSET; } --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -385,14 +385,20 @@ int smu_get_rtc_time(struct rtc_time *time, int spinwait) struct smu_simple_cmd cmd; int rc; - if (smu == NULL) + if (smu == NULL) { + printk(KERN_ERR "smu_get_rtc_time: SMU not present\n"); return -ENODEV; + } memset(time, 0, sizeof(struct rtc_time)); rc = smu_queue_simple(&cmd, SMU_CMD_RTC_COMMAND, 1, NULL, NULL, SMU_CMD_RTC_GET_DATETIME); - if (rc) + if (rc) { + printk(KERN_ERR + "smu_get_rtc_time: smu_queue_simple returned %d\n", + rc); return rc; + } smu_spinwait_simple(&cmd); time->tm_sec = bcd2hex(cmd.buffer[0]); --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c @@ -99,8 +99,13 @@ int rtc_valid_tm(struct rtc_time *tm) || tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + 1900) || ((unsigned)tm->tm_hour) >= 24 || ((unsigned)tm->tm_min) >= 60 - || ((unsigned)tm->tm_sec) >= 60) + || ((unsigned)tm->tm_sec) >= 60) { + printk(KERN_ERR "rtc_valid_tm: invalid time" + " { %d, %d, %d, %d, %d, %d }\n", + tm->tm_year, tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); return -EINVAL; + } return 0; } --- END --- Ben. -- Ben Hutchings I'm not a reverse psychological virus. Please don't copy me into your sig.
signature.asc
Description: This is a digitally signed message part