/* 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 usb_ov511 *ov, unsigned char reg, unsigned char value, unsigned char 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 usb_ov511 *ov, unsigned char reg, unsigned char value, unsigned char mask)
{
	int ret;
	unsigned char oldval, newval;
	ret = reg_r(ov, reg);
	if (ret < 0)
		return ret;
	oldval = (unsigned char) ret;
	oldval &= (~mask);
	value &= mask;
	newval = oldval | value;
	return (reg_w(ov, reg, newval));
}