int rtc72421_read_snapshot(rtc_72421_t *context, snapshot_t *s) { DWORD latch_lo = 0; DWORD latch_hi = 0; DWORD offset_lo = 0; DWORD offset_hi = 0; DWORD old_offset_lo = 0; DWORD old_offset_hi = 0; BYTE vmajor, vminor; snapshot_module_t *m; m = snapshot_module_open(s, snap_module_name, &vmajor, &vminor); if (m == NULL) { return -1; } /* Do not accept versions higher than current */ if (vmajor > SNAP_MAJOR || vminor > SNAP_MINOR) { snapshot_set_error(SNAPSHOT_MODULE_HIGHER_VERSION); goto fail; } if (0 || SMR_B_INT(m, &context->stop) < 0 || SMR_B_INT(m, &context->hour24) < 0 || SMR_DW(m, &latch_hi) < 0 || SMR_DW(m, &latch_lo) < 0 || SMR_DW(m, &offset_hi) < 0 || SMR_DW(m, &offset_lo) < 0 || SMR_DW(m, &old_offset_hi) < 0 || SMR_DW(m, &old_offset_lo) < 0 || SMR_STR(m, &context->device) < 0) { goto fail; } #if (SIZE_OF_TIME_T == 8) context->latch = (time_t)(latch_hi) << 32; context->latch |= latch_lo; context->offset = (time_t)(offset_hi) << 32; context->offset |= offset_lo; context->old_offset = (time_t)(old_offset_hi) << 32; context->old_offset |= old_offset_lo; #else context->latch = latch_lo; context->offset = offset_lo; context->old_offset = old_offset_lo; #endif return snapshot_module_close(m); fail: snapshot_module_close(m); return -1; }
int ds1216e_read_snapshot(rtc_ds1216e_t *context, snapshot_t *s) { DWORD latch_lo = 0; DWORD latch_hi = 0; DWORD offset_lo = 0; DWORD offset_hi = 0; DWORD old_offset_lo = 0; DWORD old_offset_hi = 0; BYTE vmajor, vminor; snapshot_module_t *m; m = snapshot_module_open(s, snap_module_name, &vmajor, &vminor); if (m == NULL) { return -1; } /* Do not accept versions higher than current */ if (vmajor > SNAP_MAJOR || vminor > SNAP_MINOR) { snapshot_set_error(SNAPSHOT_MODULE_HIGHER_VERSION); goto fail; } if (0 || SMR_B_INT(m, &context->reset) < 0 || SMR_B_INT(m, &context->inactive) < 0 || SMR_B_INT(m, &context->hours12) < 0 || SMR_B_INT(m, &context->pattern_pos) < 0 || SMR_B_INT(m, &context->pattern_ignore) < 0 || SMR_B_INT(m, &context->output) < 0 || SMR_B_INT(m, &context->output_pos) < 0 || SMR_DW(m, &latch_hi) < 0 || SMR_DW(m, &latch_lo) < 0 || SMR_DW(m, &offset_hi) < 0 || SMR_DW(m, &offset_lo) < 0 || SMR_DW(m, &old_offset_hi) < 0 || SMR_DW(m, &old_offset_lo) < 0 || SMR_BA(m, context->clock_regs, DS1216E_REG_SIZE) < 0 || SMR_BA(m, context->old_clock_regs, DS1216E_REG_SIZE) < 0 || SMR_BA(m, context->clock_regs_changed, DS1216E_REG_SIZE) < 0 || SMR_STR(m, &context->device) < 0) { goto fail; } #if (SIZE_OF_TIME_T == 8) context->latch = (time_t)(latch_hi) << 32; context->latch |= latch_lo; context->offset = (time_t)(offset_hi) << 32; context->offset |= offset_lo; context->old_offset = (time_t)(old_offset_hi) << 32; context->old_offset |= old_offset_lo; #else context->latch = latch_lo; context->offset = offset_lo; context->old_offset = old_offset_lo; #endif return snapshot_module_close(m); fail: snapshot_module_close(m); return -1; }