/* Certain control registers are protected against overwriting by the lock register and use a shared write address. This function allows writing of these registers. Lock must be held.  */
static int sca3000_write_ctrl_reg(struct sca3000_state *st, uint8_t sel, uint8_t val)
/* Certain control registers are protected against overwriting by the lock register and use a shared write address. This function allows writing of these registers. Lock must be held.  */
static int sca3000_write_ctrl_reg(struct sca3000_state *st, uint8_t sel, uint8_t val)
{
	int ret;
	ret = sca3000_reg_lock_on(st);
	if (ret < 0)
		goto error_ret;
	if (ret) {
		ret = __sca3000_unlock_reg_lock(st);
		if (ret)
			goto error_ret;
	}
	ret = sca3000_write_reg(st, SCA3000_REG_ADDR_CTRL_SEL, sel);
	if (ret)
		goto error_ret;
	ret = sca3000_write_reg(st, SCA3000_REG_ADDR_CTRL_DATA, val);
error_ret:
	return ret;
}