summaryrefslogtreecommitdiff
path: root/drivers/media/video/cx25840
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-01-30 23:25:41 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 13:35:10 -0200
commit62d50addf0774115adaa9e01e09099c3d7daa13d (patch)
tree5490c0acef3aa645c6974437b3ca7a508ed755a3 /drivers/media/video/cx25840
parente7b58f5259a81dbd9fbfea79408d272f44eb894f (diff)
V4L/DVB (5163): Add checks for CAP_SYS_ADMIN to VIDIOC_DBG_G_REGISTER
Before, root privileges were only needed to set hardware registers, not to read them. On some hardware, reading from the wrong place at the wrong time can hang the machine. So, to be consistent, root privileges are required to read registers on all hardware. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx25840')
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 6515b2a78417..923577723297 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -629,15 +629,6 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
/* ioctls to allow direct access to the
* cx25840 registers for testing */
case VIDIOC_DBG_G_REGISTER:
- {
- struct v4l2_register *reg = arg;
-
- if (reg->i2c_id != I2C_DRIVERID_CX25840)
- return -EINVAL;
- reg->val = cx25840_read(client, reg->reg & 0x0fff);
- break;
- }
-
case VIDIOC_DBG_S_REGISTER:
{
struct v4l2_register *reg = arg;
@@ -646,7 +637,10 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- cx25840_write(client, reg->reg & 0x0fff, reg->val & 0xff);
+ if (cmd == VIDIOC_DBG_G_REGISTER)
+ reg->val = cx25840_read(client, reg->reg & 0x0fff);
+ else
+ cx25840_write(client, reg->reg & 0x0fff, reg->val & 0xff);
break;
}
#endif