summaryrefslogtreecommitdiff
path: root/drivers/media/tuners
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2013-04-10 10:50:50 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-04-16 21:31:01 -0300
commit8678b03428b6894d146695980f04f26af7b9b3ec (patch)
treef798020d9a1a296ffa71c27b751446af7c548a1e /drivers/media/tuners
parent75c1819e5e42064e66d4f88a5af628a1604ad52d (diff)
downloadlinux-next-8678b03428b6894d146695980f04f26af7b9b3ec.tar.gz
[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>
Diffstat (limited to 'drivers/media/tuners')
-rw-r--r--drivers/media/tuners/r820t.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index d5686e8a8bc6..ef100ab3564d 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -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_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];
else
return -EINVAL;
+}
+
+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);
}