/* Waits until the device finishes the power-on reset operation.  */
int32_t ad7124_wait_to_power_on(struct ad7124_dev *dev, uint32_t timeout)
/* Waits until the device finishes the power-on reset operation.  */
int32_t ad7124_wait_to_power_on(struct ad7124_dev *dev, uint32_t timeout)
{
	struct ad7124_st_reg *regs;
	int32_t ret;
	int8_t powered_on = 0;
	if(!dev)
		return INVALID_VAL;
	regs = dev->regs;
	while(!powered_on && timeout--) {
		ret = ad7124_read_register(dev,
					   &regs[AD7124_Status]);
		if(ret < 0)
			return ret;
		powered_on = (regs[AD7124_Status].value &
			      AD7124_STATUS_REG_POR_FLAG) == 0;
	}
	return (timeout || powered_on) ? 0 : TIMEOUT;
}