dt->tm_min = BCD2BIN(buf[2]);
dt->tm_hour = BCD2BIN(buf[3]);
dt->tm_mday = BCD2BIN(buf[4]);
- dt->tm_mon = BCD2BIN(buf[5]);
+ dt->tm_mon = BCD2BIN(buf[5]) - 1;
}
return ret == 2 ? 0 : -EIO;
if (datetoo) {
len = 8;
buf[6] = BIN2BCD(dt->tm_mday) | (dt->tm_year << 6);
- buf[7] = BIN2BCD(dt->tm_mon) | (dt->tm_wday << 5);
+ buf[7] = BIN2BCD(dt->tm_mon + 1) | (dt->tm_wday << 5);
}
ret = i2c_master_send(client, (char *)buf, len);
*/
year_offset += 4;
- tm->tm_year = real_year + year_offset + year[1] * 100;
+ tm->tm_year = (real_year + year_offset + year[1] * 100) - 1900;
return 0;
}
unsigned char year[2], chk;
struct rtc_mem cmos_year = { CMOS_YEAR, sizeof(year), year };
struct rtc_mem cmos_check = { CMOS_CHECKSUM, 1, &chk };
+ unsigned int proper_year = tm->tm_year + 1900;
int ret;
/*
chk -= year[1] + year[0];
- year[1] = tm->tm_year / 100;
- year[0] = tm->tm_year % 100;
+ year[1] = proper_year / 100;
+ year[0] = proper_year % 100;
chk += year[1] + year[0];