aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-01-23 20:38:13 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:55 -0500
commit52ebc763d8e0c9f2ab48af89a75e90e2318bac86 (patch)
tree5699ff9425fb1da30a18b00661fcea659ace6a72 /drivers/media/video/pvrusb2
parentdbbff48f39263f7e5c96a55624da87879de2bf71 (diff)
V4L/DVB (5146): Make VIDIOC_INT_[SG]_REGISTER ioctls no longer internal only
The direct register access ioctls were defined as kernel internal only, but they are very useful for debugging hardware from userspace and are used as such. Officially export them. VIDIOC_INT_[SG]_REGISTER is renamed to VIDIOC_DBG_[SG]_REGISTER Definition of ioctl and struct v4l2_register is moved from v4l2-common.h to videodev2.h. Types used in struct v4l2_register are changed to the userspace exportable versions (u32 -> __u32, etc). Use of VIDIOC_DBG_S_REGISTER requires CAP_SYS_ADMIN permission, so move the check into the video_ioctl2() dispatcher so it doesn't need to be duplicated in each driver's call-back function. CAP_SYS_ADMIN check is added to pvrusb2 (which doesn't use video_ioctl2). Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c14
3 files changed, 13 insertions, 9 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 5e166ed19fc5..2a350755bd30 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -3277,7 +3277,7 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3277 3277
3278 3278
3279int pvr2_hdw_register_access(struct pvr2_hdw *hdw, 3279int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
3280 u32 chip_id,unsigned long reg_id, 3280 u32 chip_id, u32 reg_id,
3281 int setFl,u32 *val_ptr) 3281 int setFl,u32 *val_ptr)
3282{ 3282{
3283#ifdef CONFIG_VIDEO_ADV_DEBUG 3283#ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -3295,8 +3295,8 @@ int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
3295 cp = list_entry(item,struct pvr2_i2c_client,list); 3295 cp = list_entry(item,struct pvr2_i2c_client,list);
3296 if (cp->client->driver->id != chip_id) continue; 3296 if (cp->client->driver->id != chip_id) continue;
3297 stat = pvr2_i2c_client_cmd( 3297 stat = pvr2_i2c_client_cmd(
3298 cp,(setFl ? VIDIOC_INT_S_REGISTER : 3298 cp,(setFl ? VIDIOC_DBG_S_REGISTER :
3299 VIDIOC_INT_G_REGISTER),&req); 3299 VIDIOC_DBG_G_REGISTER),&req);
3300 if (!setFl) *val_ptr = req.val; 3300 if (!setFl) *val_ptr = req.val;
3301 okFl = !0; 3301 okFl = !0;
3302 break; 3302 break;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index dc7a3ba8dd18..e6df8e4a7fe0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -222,7 +222,7 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,
222 setFl - true to set the register, false to read it 222 setFl - true to set the register, false to read it
223 val_ptr - storage location for source / result. */ 223 val_ptr - storage location for source / result. */
224int pvr2_hdw_register_access(struct pvr2_hdw *, 224int pvr2_hdw_register_access(struct pvr2_hdw *,
225 u32 chip_id,unsigned long reg_id, 225 u32 chip_id,u32 reg_id,
226 int setFl,u32 *val_ptr); 226 int setFl,u32 *val_ptr);
227 227
228/* The following entry points are all lower level things you normally don't 228/* The following entry points are all lower level things you normally don't
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 49f5d3c3614c..cde5f5f3e8f2 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -738,16 +738,20 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
738 break; 738 break;
739 } 739 }
740#ifdef CONFIG_VIDEO_ADV_DEBUG 740#ifdef CONFIG_VIDEO_ADV_DEBUG
741 case VIDIOC_INT_G_REGISTER: 741 case VIDIOC_DBG_S_REGISTER:
742 case VIDIOC_INT_S_REGISTER: 742 if (!capable(CAP_SYS_ADMIN)) {
743 ret = -EPERM;
744 break;
745 } /* fall through */
746 case VIDIOC_DBG_G_REGISTER:
743 { 747 {
744 u32 val; 748 u32 val;
745 struct v4l2_register *req = (struct v4l2_register *)arg; 749 struct v4l2_register *req = (struct v4l2_register *)arg;
746 if (cmd == VIDIOC_INT_S_REGISTER) val = req->val; 750 if (cmd == VIDIOC_DBG_S_REGISTER) val = req->val;
747 ret = pvr2_hdw_register_access( 751 ret = pvr2_hdw_register_access(
748 hdw,req->i2c_id,req->reg, 752 hdw,req->i2c_id,req->reg,
749 cmd == VIDIOC_INT_S_REGISTER,&val); 753 cmd == VIDIOC_DBG_S_REGISTER,&val);
750 if (cmd == VIDIOC_INT_G_REGISTER) req->val = val; 754 if (cmd == VIDIOC_DBG_G_REGISTER) req->val = val;
751 break; 755 break;
752 } 756 }
753#endif 757#endif