/* Read a value from the CMOS. Because of the address latch, we have to spinlock to make the access atomic.  */
static uint8_t read_register(uint8_t addr)
/* Read a value from the CMOS. Because of the address latch, we have to spinlock to make the access atomic.  */
static uint8_t read_register(uint8_t addr)
{
	static struct k_spinlock lock;
	k_spinlock_key_t k;
	uint8_t val;
	k = k_spin_lock(&lock);
	sys_out8(addr, X86_CMOS_ADDR);
	val = sys_in8(X86_CMOS_DATA);
	k_spin_unlock(&lock, k);
	return val;
}