hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/core/timer_compat.c
....@@ -1,21 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * 32bit -> 64bit ioctl wrapper for timer API
34 * Copyright (c) by Takashi Iwai <tiwai@suse.de>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
- *
195 */
206
217 /* This file included from timer.c */
....@@ -83,54 +69,11 @@
8369 return 0;
8470 }
8571
86
-struct snd_timer_status32 {
87
- struct compat_timespec tstamp;
88
- u32 resolution;
89
- u32 lost;
90
- u32 overrun;
91
- u32 queue;
92
- unsigned char reserved[64];
93
-};
94
-
95
-static int snd_timer_user_status_compat(struct file *file,
96
- struct snd_timer_status32 __user *_status)
97
-{
98
- struct snd_timer_user *tu;
99
- struct snd_timer_status32 status;
100
-
101
- tu = file->private_data;
102
- if (!tu->timeri)
103
- return -EBADFD;
104
- memset(&status, 0, sizeof(status));
105
- status.tstamp.tv_sec = tu->tstamp.tv_sec;
106
- status.tstamp.tv_nsec = tu->tstamp.tv_nsec;
107
- status.resolution = snd_timer_resolution(tu->timeri);
108
- status.lost = tu->timeri->lost;
109
- status.overrun = tu->overrun;
110
- spin_lock_irq(&tu->qlock);
111
- status.queue = tu->qused;
112
- spin_unlock_irq(&tu->qlock);
113
- if (copy_to_user(_status, &status, sizeof(status)))
114
- return -EFAULT;
115
- return 0;
116
-}
117
-
118
-#ifdef CONFIG_X86_X32
119
-/* X32 ABI has the same struct as x86-64 */
120
-#define snd_timer_user_status_x32(file, s) \
121
- snd_timer_user_status(file, s)
122
-#endif /* CONFIG_X86_X32 */
123
-
124
-/*
125
- */
126
-
12772 enum {
12873 SNDRV_TIMER_IOCTL_GPARAMS32 = _IOW('T', 0x04, struct snd_timer_gparams32),
12974 SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct snd_timer_info32),
130
- SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct snd_timer_status32),
131
-#ifdef CONFIG_X86_X32
132
- SNDRV_TIMER_IOCTL_STATUS_X32 = _IOW('T', 0x14, struct snd_timer_status),
133
-#endif /* CONFIG_X86_X32 */
75
+ SNDRV_TIMER_IOCTL_STATUS_COMPAT32 = _IOW('T', 0x14, struct snd_timer_status32),
76
+ SNDRV_TIMER_IOCTL_STATUS_COMPAT64 = _IOW('T', 0x14, struct snd_timer_status64),
13477 };
13578
13679 static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
....@@ -140,7 +83,8 @@
14083
14184 switch (cmd) {
14285 case SNDRV_TIMER_IOCTL_PVERSION:
143
- case SNDRV_TIMER_IOCTL_TREAD:
86
+ case SNDRV_TIMER_IOCTL_TREAD_OLD:
87
+ case SNDRV_TIMER_IOCTL_TREAD64:
14488 case SNDRV_TIMER_IOCTL_GINFO:
14589 case SNDRV_TIMER_IOCTL_GSTATUS:
14690 case SNDRV_TIMER_IOCTL_SELECT:
....@@ -154,17 +98,15 @@
15498 case SNDRV_TIMER_IOCTL_PAUSE:
15599 case SNDRV_TIMER_IOCTL_PAUSE_OLD:
156100 case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
157
- return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
101
+ return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp, true);
158102 case SNDRV_TIMER_IOCTL_GPARAMS32:
159103 return snd_timer_user_gparams_compat(file, argp);
160104 case SNDRV_TIMER_IOCTL_INFO32:
161105 return snd_timer_user_info_compat(file, argp);
162
- case SNDRV_TIMER_IOCTL_STATUS32:
163
- return snd_timer_user_status_compat(file, argp);
164
-#ifdef CONFIG_X86_X32
165
- case SNDRV_TIMER_IOCTL_STATUS_X32:
166
- return snd_timer_user_status_x32(file, argp);
167
-#endif /* CONFIG_X86_X32 */
106
+ case SNDRV_TIMER_IOCTL_STATUS_COMPAT32:
107
+ return snd_timer_user_status32(file, argp);
108
+ case SNDRV_TIMER_IOCTL_STATUS_COMPAT64:
109
+ return snd_timer_user_status64(file, argp);
168110 }
169111 return -ENOIOCTLCMD;
170112 }