V4L/DVB (5163): Add checks for CAP_SYS_ADMIN to VIDIOC_DBG_G_REGISTER
[pandora-kernel.git] / drivers / media / video / upd64031a.c
index 0eee82b..b3b5fd5 100644 (file)
@@ -163,26 +163,18 @@ static int upd64031a_command(struct i2c_client *client, unsigned int cmd, void *
 
 #ifdef CONFIG_VIDEO_ADV_DEBUG
        case VIDIOC_DBG_G_REGISTER:
-       {
-               struct v4l2_register *reg = arg;
-
-               if (reg->i2c_id != I2C_DRIVERID_UPD64031A)
-                       return -EINVAL;
-               reg->val = upd64031a_read(client, reg->reg & 0xff);
-               break;
-       }
-
        case VIDIOC_DBG_S_REGISTER:
        {
                struct v4l2_register *reg = arg;
-               u8 addr = reg->reg & 0xff;
-               u8 val = reg->val & 0xff;
 
                if (reg->i2c_id != I2C_DRIVERID_UPD64031A)
                        return -EINVAL;
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
-               upd64031a_write(client, addr, val);
+               if (cmd == VIDIOC_DBG_G_REGISTER)
+                       reg->val = upd64031a_read(client, reg->reg & 0xff);
+               else
+                       upd64031a_write(client, reg->reg & 0xff, reg->val & 0xff);
                break;
        }
 #endif