aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@redhat.com>2008-12-20 14:56:08 -0500
committerGreg Kroah-Hartman <gregkh@kvm.kroah.org>2009-01-27 19:15:36 -0500
commit7abce6bedc118eb39fe177c2c26be5d008505c14 (patch)
tree21c1740f03c8a13227c4cac36a06c26ebcf36b90 /drivers
parent11e76ae0f3a82bbb6c06df8af2167af8b96a0584 (diff)
USB: usbmon: Implement compat_ioctl
Running a 32-bit usbmon(8) on 2.6.28-rc9 produces the following: ioctl32(usbmon:28563): Unknown cmd fd(3) cmd(400c9206){t:ffffff92;sz:12} arg(ffd3f458) on /dev/usbmon0 It happens because the compatibility mode was implemented for 2.6.18 and not updated for the fsops.compat_ioctl API. This patch relocates the pieces from under #ifdef CONFIG_COMPAT into compat_ioctl with no other changes except one new whitespace. Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/mon/mon_bin.c105
1 files changed, 66 insertions, 39 deletions
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index e06810aef2df..4cf27c72423e 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -37,6 +37,7 @@
37#define MON_IOCX_GET _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get) 37#define MON_IOCX_GET _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get)
38#define MON_IOCX_MFETCH _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch) 38#define MON_IOCX_MFETCH _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch)
39#define MON_IOCH_MFLUSH _IO(MON_IOC_MAGIC, 8) 39#define MON_IOCH_MFLUSH _IO(MON_IOC_MAGIC, 8)
40
40#ifdef CONFIG_COMPAT 41#ifdef CONFIG_COMPAT
41#define MON_IOCX_GET32 _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get32) 42#define MON_IOCX_GET32 _IOW(MON_IOC_MAGIC, 6, struct mon_bin_get32)
42#define MON_IOCX_MFETCH32 _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch32) 43#define MON_IOCX_MFETCH32 _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch32)
@@ -921,21 +922,6 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
921 } 922 }
922 break; 923 break;
923 924
924#ifdef CONFIG_COMPAT
925 case MON_IOCX_GET32: {
926 struct mon_bin_get32 getb;
927
928 if (copy_from_user(&getb, (void __user *)arg,
929 sizeof(struct mon_bin_get32)))
930 return -EFAULT;
931
932 ret = mon_bin_get_event(file, rp,
933 compat_ptr(getb.hdr32), compat_ptr(getb.data32),
934 getb.alloc32);
935 }
936 break;
937#endif
938
939 case MON_IOCX_MFETCH: 925 case MON_IOCX_MFETCH:
940 { 926 {
941 struct mon_bin_mfetch mfetch; 927 struct mon_bin_mfetch mfetch;
@@ -962,7 +948,57 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
962 } 948 }
963 break; 949 break;
964 950
951 case MON_IOCG_STATS: {
952 struct mon_bin_stats __user *sp;
953 unsigned int nevents;
954 unsigned int ndropped;
955
956 spin_lock_irqsave(&rp->b_lock, flags);
957 ndropped = rp->cnt_lost;
958 rp->cnt_lost = 0;
959 spin_unlock_irqrestore(&rp->b_lock, flags);
960 nevents = mon_bin_queued(rp);
961
962 sp = (struct mon_bin_stats __user *)arg;
963 if (put_user(rp->cnt_lost, &sp->dropped))
964 return -EFAULT;
965 if (put_user(nevents, &sp->queued))
966 return -EFAULT;
967
968 }
969 break;
970
971 default:
972 return -ENOTTY;
973 }
974
975 return ret;
976}
977
965#ifdef CONFIG_COMPAT 978#ifdef CONFIG_COMPAT
979static long mon_bin_compat_ioctl(struct file *file,
980 unsigned int cmd, unsigned long arg)
981{
982 struct mon_reader_bin *rp = file->private_data;
983 int ret;
984
985 switch (cmd) {
986
987 case MON_IOCX_GET32: {
988 struct mon_bin_get32 getb;
989
990 if (copy_from_user(&getb, (void __user *)arg,
991 sizeof(struct mon_bin_get32)))
992 return -EFAULT;
993
994 ret = mon_bin_get_event(file, rp,
995 compat_ptr(getb.hdr32), compat_ptr(getb.data32),
996 getb.alloc32);
997 if (ret < 0)
998 return ret;
999 }
1000 return 0;
1001
966 case MON_IOCX_MFETCH32: 1002 case MON_IOCX_MFETCH32:
967 { 1003 {
968 struct mon_bin_mfetch32 mfetch; 1004 struct mon_bin_mfetch32 mfetch;
@@ -986,37 +1022,25 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
986 return ret; 1022 return ret;
987 if (put_user(ret, &uptr->nfetch32)) 1023 if (put_user(ret, &uptr->nfetch32))
988 return -EFAULT; 1024 return -EFAULT;
989 ret = 0;
990 } 1025 }
991 break; 1026 return 0;
992#endif
993
994 case MON_IOCG_STATS: {
995 struct mon_bin_stats __user *sp;
996 unsigned int nevents;
997 unsigned int ndropped;
998
999 spin_lock_irqsave(&rp->b_lock, flags);
1000 ndropped = rp->cnt_lost;
1001 rp->cnt_lost = 0;
1002 spin_unlock_irqrestore(&rp->b_lock, flags);
1003 nevents = mon_bin_queued(rp);
1004 1027
1005 sp = (struct mon_bin_stats __user *)arg; 1028 case MON_IOCG_STATS:
1006 if (put_user(rp->cnt_lost, &sp->dropped)) 1029 return mon_bin_ioctl(NULL, file, cmd,
1007 return -EFAULT; 1030 (unsigned long) compat_ptr(arg));
1008 if (put_user(nevents, &sp->queued))
1009 return -EFAULT;
1010 1031
1011 } 1032 case MON_IOCQ_URB_LEN:
1012 break; 1033 case MON_IOCQ_RING_SIZE:
1034 case MON_IOCT_RING_SIZE:
1035 case MON_IOCH_MFLUSH:
1036 return mon_bin_ioctl(NULL, file, cmd, arg);
1013 1037
1014 default: 1038 default:
1015 return -ENOTTY; 1039 ;
1016 } 1040 }
1017 1041 return -ENOTTY;
1018 return ret;
1019} 1042}
1043#endif /* CONFIG_COMPAT */
1020 1044
1021static unsigned int 1045static unsigned int
1022mon_bin_poll(struct file *file, struct poll_table_struct *wait) 1046mon_bin_poll(struct file *file, struct poll_table_struct *wait)
@@ -1094,6 +1118,9 @@ static const struct file_operations mon_fops_binary = {
1094 /* .write = mon_text_write, */ 1118 /* .write = mon_text_write, */
1095 .poll = mon_bin_poll, 1119 .poll = mon_bin_poll,
1096 .ioctl = mon_bin_ioctl, 1120 .ioctl = mon_bin_ioctl,
1121#ifdef CONFIG_COMPAT
1122 .compat_ioctl = mon_bin_compat_ioctl,
1123#endif
1097 .release = mon_bin_release, 1124 .release = mon_bin_release,
1098 .mmap = mon_bin_mmap, 1125 .mmap = mon_bin_mmap,
1099}; 1126};