.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * 32bit -> 64bit ioctl wrapper for timer API |
---|
3 | 4 | * 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 | | - * |
---|
19 | 5 | */ |
---|
20 | 6 | |
---|
21 | 7 | /* This file included from timer.c */ |
---|
.. | .. |
---|
83 | 69 | return 0; |
---|
84 | 70 | } |
---|
85 | 71 | |
---|
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 | | - |
---|
127 | 72 | enum { |
---|
128 | 73 | SNDRV_TIMER_IOCTL_GPARAMS32 = _IOW('T', 0x04, struct snd_timer_gparams32), |
---|
129 | 74 | 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), |
---|
134 | 77 | }; |
---|
135 | 78 | |
---|
136 | 79 | static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, |
---|
.. | .. |
---|
140 | 83 | |
---|
141 | 84 | switch (cmd) { |
---|
142 | 85 | case SNDRV_TIMER_IOCTL_PVERSION: |
---|
143 | | - case SNDRV_TIMER_IOCTL_TREAD: |
---|
| 86 | + case SNDRV_TIMER_IOCTL_TREAD_OLD: |
---|
| 87 | + case SNDRV_TIMER_IOCTL_TREAD64: |
---|
144 | 88 | case SNDRV_TIMER_IOCTL_GINFO: |
---|
145 | 89 | case SNDRV_TIMER_IOCTL_GSTATUS: |
---|
146 | 90 | case SNDRV_TIMER_IOCTL_SELECT: |
---|
.. | .. |
---|
154 | 98 | case SNDRV_TIMER_IOCTL_PAUSE: |
---|
155 | 99 | case SNDRV_TIMER_IOCTL_PAUSE_OLD: |
---|
156 | 100 | 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); |
---|
158 | 102 | case SNDRV_TIMER_IOCTL_GPARAMS32: |
---|
159 | 103 | return snd_timer_user_gparams_compat(file, argp); |
---|
160 | 104 | case SNDRV_TIMER_IOCTL_INFO32: |
---|
161 | 105 | 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); |
---|
168 | 110 | } |
---|
169 | 111 | return -ENOIOCTLCMD; |
---|
170 | 112 | } |
---|