/* Configures the output amplifier, DAC coding, SDO state and the linearity error compensation.  */
int32_t ad5791_setup(struct ad5791_dev *dev, uint32_t setup_word)
/* Configures the output amplifier, DAC coding, SDO state and the linearity error compensation.  */
int32_t ad5791_setup(struct ad5791_dev *dev, uint32_t setup_word)
{
	uint32_t old_ctrl = 0;
	uint32_t new_ctrl = 0;
	int32_t status = 0;
	status = ad5791_get_register_value(dev,
					   AD5791_REG_CTRL);
	if(status < 0) {
		return status;
	}
	old_ctrl = status;
	old_ctrl = old_ctrl & ~(AD5791_CTRL_LINCOMP(-1) |
				AD5791_CTRL_SDODIS |
				AD5791_CTRL_BIN2SC |
				AD5791_CTRL_RBUF);
	new_ctrl = old_ctrl | setup_word;
	status = ad5791_set_register_value(dev,
					   AD5791_REG_CTRL,
					   new_ctrl);
	return status;
}