/* ad1843_get_gain reads the specified register and extracts the gain value using the supplied gain type. It returns the gain in OSS format.  */
static int ad1843_get_gain(lithium_t *lith, const ad1843_gain_t *gp)
/* ad1843_get_gain reads the specified register and extracts the gain value using the supplied gain type. It returns the gain in OSS format.  */
static int ad1843_get_gain(lithium_t *lith, const ad1843_gain_t *gp)
{
	int lg, rg;
	unsigned short mask = (1 << gp->lfield->nbits) - 1;
	ad1843_read_multi(lith, 2, gp->lfield, &lg, gp->rfield, &rg);
	if (gp->negative) {
		lg = mask - lg;
		rg = mask - rg;
	}
	lg = (lg * 100 + (mask >> 1)) / mask;
	rg = (rg * 100 + (mask >> 1)) / mask;
	return lg << 0 | rg << 8;
}