Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] media: Add 64--32 bit compat ioctl handler

Provide an ioctl handler for 32-bit binaries on 64-bit systems.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Sakari Ailus and committed by
Mauro Carvalho Chehab
c6c1d50b cab3e1ff

+29 -3
+28 -3
drivers/media/media-devnode.c
··· 116 116 return mdev->fops->poll(filp, poll); 117 117 } 118 118 119 - static long media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 119 + static long 120 + __media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg, 121 + long (*ioctl_func)(struct file *filp, unsigned int cmd, 122 + unsigned long arg)) 120 123 { 121 124 struct media_devnode *mdev = media_devnode_data(filp); 122 125 123 - if (!mdev->fops->ioctl) 126 + if (!ioctl_func) 124 127 return -ENOTTY; 125 128 126 129 if (!media_devnode_is_registered(mdev)) 127 130 return -EIO; 128 131 129 - return mdev->fops->ioctl(filp, cmd, arg); 132 + return ioctl_func(filp, cmd, arg); 130 133 } 134 + 135 + static long media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 136 + { 137 + struct media_devnode *mdev = media_devnode_data(filp); 138 + 139 + return __media_ioctl(filp, cmd, arg, mdev->fops->ioctl); 140 + } 141 + 142 + #ifdef CONFIG_COMPAT 143 + 144 + static long media_compat_ioctl(struct file *filp, unsigned int cmd, 145 + unsigned long arg) 146 + { 147 + struct media_devnode *mdev = media_devnode_data(filp); 148 + 149 + return __media_ioctl(filp, cmd, arg, mdev->fops->compat_ioctl); 150 + } 151 + 152 + #endif /* CONFIG_COMPAT */ 131 153 132 154 /* Override for the open function */ 133 155 static int media_open(struct inode *inode, struct file *filp) ··· 210 188 .write = media_write, 211 189 .open = media_open, 212 190 .unlocked_ioctl = media_ioctl, 191 + #ifdef CONFIG_COMPAT 192 + .compat_ioctl = media_compat_ioctl, 193 + #endif /* CONFIG_COMPAT */ 213 194 .release = media_release, 214 195 .poll = media_poll, 215 196 .llseek = no_llseek,
+1
include/media/media-devnode.h
··· 46 46 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); 47 47 unsigned int (*poll) (struct file *, struct poll_table_struct *); 48 48 long (*ioctl) (struct file *, unsigned int, unsigned long); 49 + long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 49 50 int (*open) (struct file *); 50 51 int (*release) (struct file *); 51 52 };