1
0
Fork 0

[media] r820t: split the function that read cached regs

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>
hifive-unleashed-5.1
Mauro Carvalho Chehab 2013-04-10 10:50:50 -03:00
parent 75c1819e5e
commit 8678b03428
1 changed files with 15 additions and 5 deletions

View File

@ -402,15 +402,25 @@ static int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val)
return r820t_write(priv, reg, &val, 1);
}
static int r820t_read_cache_reg(struct r820t_priv *priv, int reg)
{
reg -= REG_SHADOW_START;
if (reg >= 0 && reg < NUM_REGS)
return priv->regs[reg];
else
return -EINVAL;
}
static int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val,
u8 bit_mask)
{
int r = reg - REG_SHADOW_START;
int rc = r820t_read_cache_reg(priv, reg);
if (r >= 0 && r < NUM_REGS)
val = (priv->regs[r] & ~bit_mask) | (val & bit_mask);
else
return -EINVAL;
if (rc < 0)
return rc;
val = (rc & ~bit_mask) | (val & bit_mask);
return r820t_write(priv, reg, &val, 1);
}