aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/pci
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-03-24 08:24:19 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-24 08:46:39 -0300
commitb5656e8b7363c4e248e6372dc34828d3dfb17832 (patch)
treefabec0fa0c862931c3987aeea538d4348de6a972 /drivers/media/pci
parent27d5a87cf4b44cbcbd0f4706a433e4a68d496236 (diff)
[media] ivtv: prepare ivtv for adding const to s_register
The ivtv_itvc function receives a pointer to v4l2_dbg_register. When we add const to that pointer in the s_register case we will run into a problem here since this common function would discard const in that case. So change this function so it receives the address and a pointer to a value. In addition we now set the size field in the g_register function which is where it belongs. This will simplify the next patch where const will be added to s_register. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r--drivers/media/pci/ivtv/ivtv-ioctl.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 080f179070a..861e4629c7f 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -711,28 +711,26 @@ static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_dbg_chip_i
}
#ifdef CONFIG_VIDEO_ADV_DEBUG
-static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
+static int ivtv_itvc(struct ivtv *itv, bool get, u64 reg, u64 *val)
{
- struct v4l2_dbg_register *regs = arg;
volatile u8 __iomem *reg_start;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (regs->reg >= IVTV_REG_OFFSET && regs->reg < IVTV_REG_OFFSET + IVTV_REG_SIZE)
+ if (reg >= IVTV_REG_OFFSET && reg < IVTV_REG_OFFSET + IVTV_REG_SIZE)
reg_start = itv->reg_mem - IVTV_REG_OFFSET;
- else if (itv->has_cx23415 && regs->reg >= IVTV_DECODER_OFFSET &&
- regs->reg < IVTV_DECODER_OFFSET + IVTV_DECODER_SIZE)
+ else if (itv->has_cx23415 && reg >= IVTV_DECODER_OFFSET &&
+ reg < IVTV_DECODER_OFFSET + IVTV_DECODER_SIZE)
reg_start = itv->dec_mem - IVTV_DECODER_OFFSET;
- else if (regs->reg < IVTV_ENCODER_SIZE)
+ else if (reg < IVTV_ENCODER_SIZE)
reg_start = itv->enc_mem;
else
return -EINVAL;
- regs->size = 4;
- if (cmd == VIDIOC_DBG_G_REGISTER)
- regs->val = readl(regs->reg + reg_start);
+ if (get)
+ *val = readl(reg + reg_start);
else
- writel(regs->val, regs->reg + reg_start);
+ writel(*val, reg + reg_start);
return 0;
}
@@ -740,8 +738,10 @@ static int ivtv_g_register(struct file *file, void *fh, struct v4l2_dbg_register
{
struct ivtv *itv = fh2id(fh)->itv;
- if (v4l2_chip_match_host(&reg->match))
- return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg);
+ if (v4l2_chip_match_host(&reg->match)) {
+ reg->size = 4;
+ return ivtv_itvc(itv, true, reg->reg, &reg->val);
+ }
/* TODO: subdev errors should not be ignored, this should become a
subdev helper function. */
ivtv_call_all(itv, core, g_register, reg);
@@ -753,7 +753,7 @@ static int ivtv_s_register(struct file *file, void *fh, struct v4l2_dbg_register
struct ivtv *itv = fh2id(fh)->itv;
if (v4l2_chip_match_host(&reg->match))
- return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg);
+ return ivtv_itvc(itv, false, reg->reg, &reg->val);
/* TODO: subdev errors should not be ignored, this should become a
subdev helper function. */
ivtv_call_all(itv, core, s_register, reg);