/* write a new value to an AD1843 bitfield and return the old value.  */
static int ad1843_write_bits(struct snd_ad1843 *ad1843, const struct ad1843_bitfield *field, int newval)
/* write a new value to an AD1843 bitfield and return the old value.  */
static int ad1843_write_bits(struct snd_ad1843 *ad1843, const struct ad1843_bitfield *field, int newval)
{
	int w, mask, oldval, newbits;
	w = ad1843->read(ad1843->chip, field->reg);
	mask = ((1 << field->nbits) - 1) << field->lo_bit;
	oldval = (w & mask) >> field->lo_bit;
	newbits = (newval << field->lo_bit) & mask;
	w = (w & ~mask) | newbits;
	ad1843->write(ad1843->chip, field->reg, w);
	return oldval;
}