/* Do a read and write of a register to update only part of a register.  */
int32_t adpd410x_reg_write_mask(struct adpd410x_dev *dev, uint16_t address, uint16_t data, uint16_t mask)
/* Do a read and write of a register to update only part of a register.  */
int32_t adpd410x_reg_write_mask(struct adpd410x_dev *dev, uint16_t address, uint16_t data, uint16_t mask)
{
	int32_t ret;
	uint16_t reg_val;
	uint32_t bit_pos;
	ret = adpd410x_reg_read(dev, address, &reg_val);
	if (ret != SUCCESS)
		return FAILURE;
	reg_val &= ~mask;
	bit_pos = find_first_set_bit((uint32_t)mask);
	reg_val |= (data << bit_pos) & mask;
	return adpd410x_reg_write(dev, address, reg_val);
}