As we'll need to retrieve cached registers, make this
function explicit.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Tested-by: Antti Palosaari <crope@iki.fi>
return r820t_write(priv, reg, &val, 1);
}
return r820t_write(priv, reg, &val, 1);
}
-static int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val,
- u8 bit_mask)
+static int r820t_read_cache_reg(struct r820t_priv *priv, int reg)
- int r = reg - REG_SHADOW_START;
+ reg -= REG_SHADOW_START;
- if (r >= 0 && r < NUM_REGS)
- val = (priv->regs[r] & ~bit_mask) | (val & bit_mask);
+ if (reg >= 0 && reg < NUM_REGS)
+ return priv->regs[reg];
+}
+
+static int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val,
+ u8 bit_mask)
+{
+ int rc = r820t_read_cache_reg(priv, reg);
+
+ if (rc < 0)
+ return rc;
+
+ val = (rc & ~bit_mask) | (val & bit_mask);
return r820t_write(priv, reg, &val, 1);
}
return r820t_write(priv, reg, &val, 1);
}