Skip to content

Commit 407e9ef

Browse files
committed
compat_ioctl: move drivers to compat_ptr_ioctl
Each of these drivers has a copy of the same trivial helper function to convert the pointer argument and then call the native ioctl handler. We now have a generic implementation of that, so use it. Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Reviewed-by: Jiri Kosina <jkosina@suse.cz> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 076ff65 commit 407e9ef

16 files changed

Lines changed: 20 additions & 237 deletions

File tree

‎drivers/char/ppdev.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -670,14 +670,6 @@ static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
670670
return ret;
671671
}
672672

673-
#ifdef CONFIG_COMPAT
674-
static long pp_compat_ioctl(struct file *file, unsigned int cmd,
675-
unsigned long arg)
676-
{
677-
return pp_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
678-
}
679-
#endif
680-
681673
static int pp_open(struct inode *inode, struct file *file)
682674
{
683675
unsigned int minor = iminor(inode);
@@ -786,9 +778,7 @@ static const struct file_operations pp_fops = {
786778
.write = pp_write,
787779
.poll = pp_poll,
788780
.unlocked_ioctl = pp_ioctl,
789-
#ifdef CONFIG_COMPAT
790-
.compat_ioctl = pp_compat_ioctl,
791-
#endif
781+
.compat_ioctl = compat_ptr_ioctl,
792782
.open = pp_open,
793783
.release = pp_release,
794784
};

‎drivers/char/tpm/tpm_vtpm_proxy.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -670,20 +670,10 @@ static long vtpmx_fops_ioctl(struct file *f, unsigned int ioctl,
670670
}
671671
}
672672

673-
#ifdef CONFIG_COMPAT
674-
static long vtpmx_fops_compat_ioctl(struct file *f, unsigned int ioctl,
675-
unsigned long arg)
676-
{
677-
return vtpmx_fops_ioctl(f, ioctl, (unsigned long)compat_ptr(arg));
678-
}
679-
#endif
680-
681673
static const struct file_operations vtpmx_fops = {
682674
.owner = THIS_MODULE,
683675
.unlocked_ioctl = vtpmx_fops_ioctl,
684-
#ifdef CONFIG_COMPAT
685-
.compat_ioctl = vtpmx_fops_compat_ioctl,
686-
#endif
676+
.compat_ioctl = compat_ptr_ioctl,
687677
.llseek = noop_llseek,
688678
};
689679

‎drivers/firewire/core-cdev.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,14 +1646,6 @@ static long fw_device_op_ioctl(struct file *file,
16461646
return dispatch_ioctl(file->private_data, cmd, (void __user *)arg);
16471647
}
16481648

1649-
#ifdef CONFIG_COMPAT
1650-
static long fw_device_op_compat_ioctl(struct file *file,
1651-
unsigned int cmd, unsigned long arg)
1652-
{
1653-
return dispatch_ioctl(file->private_data, cmd, compat_ptr(arg));
1654-
}
1655-
#endif
1656-
16571649
static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma)
16581650
{
16591651
struct client *client = file->private_data;
@@ -1795,7 +1787,5 @@ const struct file_operations fw_device_ops = {
17951787
.mmap = fw_device_op_mmap,
17961788
.release = fw_device_op_release,
17971789
.poll = fw_device_op_poll,
1798-
#ifdef CONFIG_COMPAT
1799-
.compat_ioctl = fw_device_op_compat_ioctl,
1800-
#endif
1790+
.compat_ioctl = compat_ptr_ioctl,
18011791
};

‎drivers/hid/usbhid/hiddev.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -854,13 +854,6 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
854854
return r;
855855
}
856856

857-
#ifdef CONFIG_COMPAT
858-
static long hiddev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
859-
{
860-
return hiddev_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
861-
}
862-
#endif
863-
864857
static const struct file_operations hiddev_fops = {
865858
.owner = THIS_MODULE,
866859
.read = hiddev_read,
@@ -870,9 +863,7 @@ static const struct file_operations hiddev_fops = {
870863
.release = hiddev_release,
871864
.unlocked_ioctl = hiddev_ioctl,
872865
.fasync = hiddev_fasync,
873-
#ifdef CONFIG_COMPAT
874-
.compat_ioctl = hiddev_compat_ioctl,
875-
#endif
866+
.compat_ioctl = compat_ptr_ioctl,
876867
.llseek = noop_llseek,
877868
};
878869

‎drivers/hwtracing/stm/core.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -832,23 +832,13 @@ stm_char_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
832832
return err;
833833
}
834834

835-
#ifdef CONFIG_COMPAT
836-
static long
837-
stm_char_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
838-
{
839-
return stm_char_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
840-
}
841-
#else
842-
#define stm_char_compat_ioctl NULL
843-
#endif
844-
845835
static const struct file_operations stm_fops = {
846836
.open = stm_char_open,
847837
.release = stm_char_release,
848838
.write = stm_char_write,
849839
.mmap = stm_char_mmap,
850840
.unlocked_ioctl = stm_char_ioctl,
851-
.compat_ioctl = stm_char_compat_ioctl,
841+
.compat_ioctl = compat_ptr_ioctl,
852842
.llseek = no_llseek,
853843
};
854844

‎drivers/misc/mei/main.c‎

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -532,24 +532,6 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
532532
return rets;
533533
}
534534

535-
/**
536-
* mei_compat_ioctl - the compat IOCTL function
537-
*
538-
* @file: pointer to file structure
539-
* @cmd: ioctl command
540-
* @data: pointer to mei message structure
541-
*
542-
* Return: 0 on success , <0 on error
543-
*/
544-
#ifdef CONFIG_COMPAT
545-
static long mei_compat_ioctl(struct file *file,
546-
unsigned int cmd, unsigned long data)
547-
{
548-
return mei_ioctl(file, cmd, (unsigned long)compat_ptr(data));
549-
}
550-
#endif
551-
552-
553535
/**
554536
* mei_poll - the poll function
555537
*
@@ -898,9 +880,7 @@ static const struct file_operations mei_fops = {
898880
.owner = THIS_MODULE,
899881
.read = mei_read,
900882
.unlocked_ioctl = mei_ioctl,
901-
#ifdef CONFIG_COMPAT
902-
.compat_ioctl = mei_compat_ioctl,
903-
#endif
883+
.compat_ioctl = compat_ptr_ioctl,
904884
.open = mei_open,
905885
.release = mei_release,
906886
.write = mei_write,

‎drivers/mtd/ubi/cdev.c‎

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,36 +1078,6 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,
10781078
return err;
10791079
}
10801080

1081-
#ifdef CONFIG_COMPAT
1082-
static long vol_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1083-
unsigned long arg)
1084-
{
1085-
unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1086-
1087-
return vol_cdev_ioctl(file, cmd, translated_arg);
1088-
}
1089-
1090-
static long ubi_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1091-
unsigned long arg)
1092-
{
1093-
unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1094-
1095-
return ubi_cdev_ioctl(file, cmd, translated_arg);
1096-
}
1097-
1098-
static long ctrl_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1099-
unsigned long arg)
1100-
{
1101-
unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1102-
1103-
return ctrl_cdev_ioctl(file, cmd, translated_arg);
1104-
}
1105-
#else
1106-
#define vol_cdev_compat_ioctl NULL
1107-
#define ubi_cdev_compat_ioctl NULL
1108-
#define ctrl_cdev_compat_ioctl NULL
1109-
#endif
1110-
11111081
/* UBI volume character device operations */
11121082
const struct file_operations ubi_vol_cdev_operations = {
11131083
.owner = THIS_MODULE,
@@ -1118,21 +1088,21 @@ const struct file_operations ubi_vol_cdev_operations = {
11181088
.write = vol_cdev_write,
11191089
.fsync = vol_cdev_fsync,
11201090
.unlocked_ioctl = vol_cdev_ioctl,
1121-
.compat_ioctl = vol_cdev_compat_ioctl,
1091+
.compat_ioctl = compat_ptr_ioctl,
11221092
};
11231093

11241094
/* UBI character device operations */
11251095
const struct file_operations ubi_cdev_operations = {
11261096
.owner = THIS_MODULE,
11271097
.llseek = no_llseek,
11281098
.unlocked_ioctl = ubi_cdev_ioctl,
1129-
.compat_ioctl = ubi_cdev_compat_ioctl,
1099+
.compat_ioctl = compat_ptr_ioctl,
11301100
};
11311101

11321102
/* UBI control character device operations */
11331103
const struct file_operations ubi_ctrl_cdev_operations = {
11341104
.owner = THIS_MODULE,
11351105
.unlocked_ioctl = ctrl_cdev_ioctl,
1136-
.compat_ioctl = ctrl_cdev_compat_ioctl,
1106+
.compat_ioctl = compat_ptr_ioctl,
11371107
.llseek = no_llseek,
11381108
};

‎drivers/net/tap.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,14 +1123,6 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
11231123
}
11241124
}
11251125

1126-
#ifdef CONFIG_COMPAT
1127-
static long tap_compat_ioctl(struct file *file, unsigned int cmd,
1128-
unsigned long arg)
1129-
{
1130-
return tap_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
1131-
}
1132-
#endif
1133-
11341126
static const struct file_operations tap_fops = {
11351127
.owner = THIS_MODULE,
11361128
.open = tap_open,
@@ -1140,9 +1132,7 @@ static const struct file_operations tap_fops = {
11401132
.poll = tap_poll,
11411133
.llseek = no_llseek,
11421134
.unlocked_ioctl = tap_ioctl,
1143-
#ifdef CONFIG_COMPAT
1144-
.compat_ioctl = tap_compat_ioctl,
1145-
#endif
1135+
.compat_ioctl = compat_ptr_ioctl,
11461136
};
11471137

11481138
static int tap_get_user_xdp(struct tap_queue *q, struct xdp_buff *xdp)

‎drivers/staging/pi433/pi433_if.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -928,16 +928,6 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
928928
return 0;
929929
}
930930

931-
#ifdef CONFIG_COMPAT
932-
static long
933-
pi433_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
934-
{
935-
return pi433_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
936-
}
937-
#else
938-
#define pi433_compat_ioctl NULL
939-
#endif /* CONFIG_COMPAT */
940-
941931
/*-------------------------------------------------------------------------*/
942932

943933
static int pi433_open(struct inode *inode, struct file *filp)
@@ -1094,7 +1084,7 @@ static const struct file_operations pi433_fops = {
10941084
.write = pi433_write,
10951085
.read = pi433_read,
10961086
.unlocked_ioctl = pi433_ioctl,
1097-
.compat_ioctl = pi433_compat_ioctl,
1087+
.compat_ioctl = compat_ptr_ioctl,
10981088
.open = pi433_open,
10991089
.release = pi433_release,
11001090
.llseek = no_llseek,

‎drivers/usb/core/devio.c‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,18 +2685,6 @@ static long usbdev_ioctl(struct file *file, unsigned int cmd,
26852685
return ret;
26862686
}
26872687

2688-
#ifdef CONFIG_COMPAT
2689-
static long usbdev_compat_ioctl(struct file *file, unsigned int cmd,
2690-
unsigned long arg)
2691-
{
2692-
int ret;
2693-
2694-
ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg));
2695-
2696-
return ret;
2697-
}
2698-
#endif
2699-
27002688
/* No kernel lock - fine */
27012689
static __poll_t usbdev_poll(struct file *file,
27022690
struct poll_table_struct *wait)
@@ -2720,9 +2708,7 @@ const struct file_operations usbdev_file_operations = {
27202708
.read = usbdev_read,
27212709
.poll = usbdev_poll,
27222710
.unlocked_ioctl = usbdev_ioctl,
2723-
#ifdef CONFIG_COMPAT
2724-
.compat_ioctl = usbdev_compat_ioctl,
2725-
#endif
2711+
.compat_ioctl = compat_ptr_ioctl,
27262712
.mmap = usbdev_mmap,
27272713
.open = usbdev_open,
27282714
.release = usbdev_release,

0 commit comments

Comments
 (0)