/* Writes bits at positions specified by mask to an OV51x reg. Bits that are in the same position as 1's in "mask" are cleared and set to "value". Bits that are in the same position as 0's in "mask" are preserved, regardless of their respective state in "value".  */
static int reg_w_mask(struct sd *sd, __u16 index, __u8 value, __u8 mask)
/* Writes bits at positions specified by mask to an OV51x reg. Bits that are in the same position as 1's in "mask" are cleared and set to "value". Bits that are in the same position as 0's in "mask" are preserved, regardless of their respective state in "value".  */
static int reg_w_mask(struct sd *sd, __u16 index, __u8 value, __u8 mask)
{
	int ret;
	__u8 oldval;
	if (mask != 0xff) {
		value &= mask;
		ret = reg_r(sd, index);
		if (ret < 0)
			return ret;
		oldval = ret & ~mask;
		value |= oldval;
	}
	return reg_w(sd, index, value);
}