/* Returns unsigned register value on success, -errno on failure.  */
static int li_read_ad1843_reg(lithium_t *lith, int reg)
/* Returns unsigned register value on success, -errno on failure.  */
static int li_read_ad1843_reg(lithium_t *lith, int reg)
{
	int val;
	ASSERT(!in_interrupt());
	spin_lock(&lith->lock);
	{
		val = li_ad1843_wait(lith);
		if (val == 0) {
			li_writel(lith, LI_CODEC_COMMAND, LI_CC_DIR_RD | reg);
			val = li_ad1843_wait(lith);
		}
		if (val == 0)
			val = li_readl(lith, LI_CODEC_DATA);
	}
	spin_unlock(&lith->lock);
	DBGXV("li_read_ad1843_reg(lith=0x%p, reg=%d) returns 0x%04x\n",
	      lith, reg, val);
	return val;
}