blob: 84ee29c3b1a0b938217e49de12f5a8ba0f327913 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * compat ioctls for control API
3 *
4 * Copyright (c) by Takashi Iwai <tiwai@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/* this file included from control.c */
22
23#include <linux/compat.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090024#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Takashi Iwai82e9bae2005-11-17 13:53:23 +010026struct snd_ctl_elem_list32 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 u32 offset;
28 u32 space;
29 u32 used;
30 u32 count;
31 u32 pids;
32 unsigned char reserved[50];
33} /* don't set packed attribute here */;
34
Takashi Iwai82e9bae2005-11-17 13:53:23 +010035static int snd_ctl_elem_list_compat(struct snd_card *card,
36 struct snd_ctl_elem_list32 __user *data32)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037{
Takashi Iwai82e9bae2005-11-17 13:53:23 +010038 struct snd_ctl_elem_list __user *data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 compat_caddr_t ptr;
40 int err;
41
42 data = compat_alloc_user_space(sizeof(*data));
43
44 /* offset, space, used, count */
45 if (copy_in_user(data, data32, 4 * sizeof(u32)))
46 return -EFAULT;
47 /* pids */
48 if (get_user(ptr, &data32->pids) ||
49 put_user(compat_ptr(ptr), &data->pids))
50 return -EFAULT;
51 err = snd_ctl_elem_list(card, data);
52 if (err < 0)
53 return err;
54 /* copy the result */
55 if (copy_in_user(data32, data, 4 * sizeof(u32)))
56 return -EFAULT;
57 return 0;
58}
59
60/*
61 * control element info
62 * it uses union, so the things are not easy..
63 */
64
Takashi Iwai82e9bae2005-11-17 13:53:23 +010065struct snd_ctl_elem_info32 {
66 struct snd_ctl_elem_id id; // the size of struct is same
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 s32 type;
68 u32 access;
69 u32 count;
70 s32 owner;
71 union {
72 struct {
73 s32 min;
74 s32 max;
75 s32 step;
76 } integer;
77 struct {
78 u64 min;
79 u64 max;
80 u64 step;
81 } integer64;
82 struct {
83 u32 items;
84 u32 item;
85 char name[64];
Clemens Ladisch8d448162011-10-07 22:38:59 +020086 u64 names_ptr;
87 u32 names_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 } enumerated;
89 unsigned char reserved[128];
90 } value;
91 unsigned char reserved[64];
92} __attribute__((packed));
93
Takashi Iwai82e9bae2005-11-17 13:53:23 +010094static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl,
95 struct snd_ctl_elem_info32 __user *data32)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Takashi Iwai82e9bae2005-11-17 13:53:23 +010097 struct snd_ctl_elem_info *data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 int err;
99
Takashi Iwaica2c0962005-09-09 14:20:23 +0200100 data = kzalloc(sizeof(*data), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 if (! data)
102 return -ENOMEM;
103
104 err = -EFAULT;
105 /* copy id */
106 if (copy_from_user(&data->id, &data32->id, sizeof(data->id)))
107 goto error;
108 /* we need to copy the item index.
109 * hope this doesn't break anything..
110 */
111 if (get_user(data->value.enumerated.item, &data32->value.enumerated.item))
112 goto error;
Giuliano Pochini64649402006-03-13 14:11:11 +0100113
114 snd_power_lock(ctl->card);
Takashi Iwaicbac4b02006-03-27 12:38:07 +0200115 err = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0);
Giuliano Pochini64649402006-03-13 14:11:11 +0100116 if (err >= 0)
117 err = snd_ctl_elem_info(ctl, data);
118 snd_power_unlock(ctl->card);
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 if (err < 0)
121 goto error;
122 /* restore info to 32bit */
123 err = -EFAULT;
124 /* id, type, access, count */
125 if (copy_to_user(&data32->id, &data->id, sizeof(data->id)) ||
126 copy_to_user(&data32->type, &data->type, 3 * sizeof(u32)))
127 goto error;
128 if (put_user(data->owner, &data32->owner))
129 goto error;
130 switch (data->type) {
131 case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
132 case SNDRV_CTL_ELEM_TYPE_INTEGER:
133 if (put_user(data->value.integer.min, &data32->value.integer.min) ||
134 put_user(data->value.integer.max, &data32->value.integer.max) ||
135 put_user(data->value.integer.step, &data32->value.integer.step))
136 goto error;
137 break;
138 case SNDRV_CTL_ELEM_TYPE_INTEGER64:
139 if (copy_to_user(&data32->value.integer64,
140 &data->value.integer64,
141 sizeof(data->value.integer64)))
142 goto error;
143 break;
144 case SNDRV_CTL_ELEM_TYPE_ENUMERATED:
145 if (copy_to_user(&data32->value.enumerated,
146 &data->value.enumerated,
147 sizeof(data->value.enumerated)))
148 goto error;
149 break;
150 default:
151 break;
152 }
153 err = 0;
154 error:
155 kfree(data);
156 return err;
157}
158
159/* read / write */
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100160struct snd_ctl_elem_value32 {
161 struct snd_ctl_elem_id id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 unsigned int indirect; /* bit-field causes misalignment */
163 union {
164 s32 integer[128];
165 unsigned char data[512];
166#ifndef CONFIG_X86_64
167 s64 integer64[64];
168#endif
169 } value;
170 unsigned char reserved[128];
171};
172
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100173#ifdef CONFIG_X86_X32
174/* x32 has a different alignment for 64bit values from ia32 */
175struct snd_ctl_elem_value_x32 {
176 struct snd_ctl_elem_id id;
177 unsigned int indirect; /* bit-field causes misalignment */
178 union {
179 s32 integer[128];
180 unsigned char data[512];
181 s64 integer64[64];
182 } value;
183 unsigned char reserved[128];
184};
185#endif /* CONFIG_X86_X32 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
187/* get the value type and count of the control */
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100188static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
189 int *countp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190{
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100191 struct snd_kcontrol *kctl;
Juergen Kreilederaa657ca2006-02-20 18:28:00 -0800192 struct snd_ctl_elem_info *info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 int err;
194
195 down_read(&card->controls_rwsem);
196 kctl = snd_ctl_find_id(card, id);
197 if (! kctl) {
198 up_read(&card->controls_rwsem);
Takashi Sakamoto6f021742016-03-17 21:14:36 +0900199 return -ENOENT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 }
Juergen Kreilederaa657ca2006-02-20 18:28:00 -0800201 info = kzalloc(sizeof(*info), GFP_KERNEL);
202 if (info == NULL) {
203 up_read(&card->controls_rwsem);
204 return -ENOMEM;
205 }
206 info->id = *id;
207 err = kctl->info(kctl, info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 up_read(&card->controls_rwsem);
209 if (err >= 0) {
Juergen Kreilederaa657ca2006-02-20 18:28:00 -0800210 err = info->type;
211 *countp = info->count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 }
Juergen Kreilederaa657ca2006-02-20 18:28:00 -0800213 kfree(info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 return err;
215}
216
217static int get_elem_size(int type, int count)
218{
219 switch (type) {
220 case SNDRV_CTL_ELEM_TYPE_INTEGER64:
221 return sizeof(s64) * count;
222 case SNDRV_CTL_ELEM_TYPE_ENUMERATED:
223 return sizeof(int) * count;
224 case SNDRV_CTL_ELEM_TYPE_BYTES:
225 return 512;
226 case SNDRV_CTL_ELEM_TYPE_IEC958:
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100227 return sizeof(struct snd_aes_iec958);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 default:
229 return -1;
230 }
231}
232
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100233static int copy_ctl_value_from_user(struct snd_card *card,
234 struct snd_ctl_elem_value *data,
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100235 void __user *userdata,
236 void __user *valuep,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 int *typep, int *countp)
238{
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100239 struct snd_ctl_elem_value32 __user *data32 = userdata;
Andrew Morton5050b092007-12-14 12:13:12 +0100240 int i, type, size;
241 int uninitialized_var(count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 unsigned int indirect;
243
244 if (copy_from_user(&data->id, &data32->id, sizeof(data->id)))
245 return -EFAULT;
246 if (get_user(indirect, &data32->indirect))
247 return -EFAULT;
248 if (indirect)
249 return -EINVAL;
250 type = get_ctl_type(card, &data->id, &count);
251 if (type < 0)
252 return type;
253
254 if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
255 type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
256 for (i = 0; i < count; i++) {
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100257 s32 __user *intp = valuep;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 int val;
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100259 if (get_user(val, &intp[i]))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 return -EFAULT;
261 data->value.integer.value[i] = val;
262 }
263 } else {
264 size = get_elem_size(type, count);
265 if (size < 0) {
Takashi Iwaibb009452014-02-04 18:18:16 +0100266 dev_err(card->dev, "snd_ioctl32_ctl_elem_value: unknown type %d\n", type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 return -EINVAL;
268 }
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100269 if (copy_from_user(data->value.bytes.data, valuep, size))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 return -EFAULT;
271 }
272
273 *typep = type;
274 *countp = count;
275 return 0;
276}
277
278/* restore the value to 32bit */
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100279static int copy_ctl_value_to_user(void __user *userdata,
280 void __user *valuep,
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100281 struct snd_ctl_elem_value *data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 int type, int count)
283{
284 int i, size;
285
286 if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
287 type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
288 for (i = 0; i < count; i++) {
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100289 s32 __user *intp = valuep;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 int val;
291 val = data->value.integer.value[i];
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100292 if (put_user(val, &intp[i]))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 return -EFAULT;
294 }
295 } else {
296 size = get_elem_size(type, count);
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100297 if (copy_to_user(valuep, data->value.bytes.data, size))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 return -EFAULT;
299 }
300 return 0;
301}
302
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100303static int ctl_elem_read_user(struct snd_card *card,
304 void __user *userdata, void __user *valuep)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305{
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100306 struct snd_ctl_elem_value *data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 int err, type, count;
308
Takashi Iwaica2c0962005-09-09 14:20:23 +0200309 data = kzalloc(sizeof(*data), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 if (data == NULL)
311 return -ENOMEM;
312
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100313 err = copy_ctl_value_from_user(card, data, userdata, valuep,
314 &type, &count);
315 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 goto error;
Giuliano Pochini64649402006-03-13 14:11:11 +0100317
318 snd_power_lock(card);
Takashi Iwaicbac4b02006-03-27 12:38:07 +0200319 err = snd_power_wait(card, SNDRV_CTL_POWER_D0);
Giuliano Pochini64649402006-03-13 14:11:11 +0100320 if (err >= 0)
321 err = snd_ctl_elem_read(card, data);
322 snd_power_unlock(card);
323 if (err >= 0)
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100324 err = copy_ctl_value_to_user(userdata, valuep, data,
325 type, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 error:
327 kfree(data);
328 return err;
329}
330
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100331static int ctl_elem_write_user(struct snd_ctl_file *file,
332 void __user *userdata, void __user *valuep)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100334 struct snd_ctl_elem_value *data;
Giuliano Pochini64649402006-03-13 14:11:11 +0100335 struct snd_card *card = file->card;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 int err, type, count;
337
Takashi Iwaica2c0962005-09-09 14:20:23 +0200338 data = kzalloc(sizeof(*data), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 if (data == NULL)
340 return -ENOMEM;
341
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100342 err = copy_ctl_value_from_user(card, data, userdata, valuep,
343 &type, &count);
344 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 goto error;
Giuliano Pochini64649402006-03-13 14:11:11 +0100346
347 snd_power_lock(card);
Takashi Iwaicbac4b02006-03-27 12:38:07 +0200348 err = snd_power_wait(card, SNDRV_CTL_POWER_D0);
Giuliano Pochini64649402006-03-13 14:11:11 +0100349 if (err >= 0)
350 err = snd_ctl_elem_write(card, file, data);
351 snd_power_unlock(card);
352 if (err >= 0)
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100353 err = copy_ctl_value_to_user(userdata, valuep, data,
354 type, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 error:
356 kfree(data);
357 return err;
358}
359
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100360static int snd_ctl_elem_read_user_compat(struct snd_card *card,
361 struct snd_ctl_elem_value32 __user *data32)
362{
363 return ctl_elem_read_user(card, data32, &data32->value);
364}
365
366static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
367 struct snd_ctl_elem_value32 __user *data32)
368{
369 return ctl_elem_write_user(file, data32, &data32->value);
370}
371
372#ifdef CONFIG_X86_X32
373static int snd_ctl_elem_read_user_x32(struct snd_card *card,
374 struct snd_ctl_elem_value_x32 __user *data32)
375{
376 return ctl_elem_read_user(card, data32, &data32->value);
377}
378
379static int snd_ctl_elem_write_user_x32(struct snd_ctl_file *file,
380 struct snd_ctl_elem_value_x32 __user *data32)
381{
382 return ctl_elem_write_user(file, data32, &data32->value);
383}
384#endif /* CONFIG_X86_X32 */
385
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386/* add or replace a user control */
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100387static int snd_ctl_elem_add_compat(struct snd_ctl_file *file,
388 struct snd_ctl_elem_info32 __user *data32,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 int replace)
390{
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100391 struct snd_ctl_elem_info *data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 int err;
393
Takashi Iwaica2c0962005-09-09 14:20:23 +0200394 data = kzalloc(sizeof(*data), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 if (! data)
396 return -ENOMEM;
397
398 err = -EFAULT;
399 /* id, type, access, count */ \
400 if (copy_from_user(&data->id, &data32->id, sizeof(data->id)) ||
401 copy_from_user(&data->type, &data32->type, 3 * sizeof(u32)))
402 goto error;
Wenwen Wangc5d82372018-05-05 13:38:03 -0500403 if (get_user(data->owner, &data32->owner))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 goto error;
405 switch (data->type) {
406 case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
407 case SNDRV_CTL_ELEM_TYPE_INTEGER:
408 if (get_user(data->value.integer.min, &data32->value.integer.min) ||
409 get_user(data->value.integer.max, &data32->value.integer.max) ||
410 get_user(data->value.integer.step, &data32->value.integer.step))
411 goto error;
412 break;
413 case SNDRV_CTL_ELEM_TYPE_INTEGER64:
414 if (copy_from_user(&data->value.integer64,
415 &data32->value.integer64,
416 sizeof(data->value.integer64)))
417 goto error;
418 break;
419 case SNDRV_CTL_ELEM_TYPE_ENUMERATED:
420 if (copy_from_user(&data->value.enumerated,
421 &data32->value.enumerated,
422 sizeof(data->value.enumerated)))
423 goto error;
Clemens Ladisch8d448162011-10-07 22:38:59 +0200424 data->value.enumerated.names_ptr =
425 (uintptr_t)compat_ptr(data->value.enumerated.names_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 break;
427 default:
428 break;
429 }
430 err = snd_ctl_elem_add(file, data, replace);
431 error:
432 kfree(data);
433 return err;
434}
435
436enum {
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100437 SNDRV_CTL_IOCTL_ELEM_LIST32 = _IOWR('U', 0x10, struct snd_ctl_elem_list32),
438 SNDRV_CTL_IOCTL_ELEM_INFO32 = _IOWR('U', 0x11, struct snd_ctl_elem_info32),
439 SNDRV_CTL_IOCTL_ELEM_READ32 = _IOWR('U', 0x12, struct snd_ctl_elem_value32),
440 SNDRV_CTL_IOCTL_ELEM_WRITE32 = _IOWR('U', 0x13, struct snd_ctl_elem_value32),
441 SNDRV_CTL_IOCTL_ELEM_ADD32 = _IOWR('U', 0x17, struct snd_ctl_elem_info32),
442 SNDRV_CTL_IOCTL_ELEM_REPLACE32 = _IOWR('U', 0x18, struct snd_ctl_elem_info32),
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100443#ifdef CONFIG_X86_X32
444 SNDRV_CTL_IOCTL_ELEM_READ_X32 = _IOWR('U', 0x12, struct snd_ctl_elem_value_x32),
445 SNDRV_CTL_IOCTL_ELEM_WRITE_X32 = _IOWR('U', 0x13, struct snd_ctl_elem_value_x32),
446#endif /* CONFIG_X86_X32 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447};
448
449static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
450{
Takashi Iwai82e9bae2005-11-17 13:53:23 +0100451 struct snd_ctl_file *ctl;
Johannes Berg9244b2c2006-10-05 16:02:22 +0200452 struct snd_kctl_ioctl *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 void __user *argp = compat_ptr(arg);
454 int err;
455
456 ctl = file->private_data;
Takashi Iwai7eaa9432008-08-08 17:09:09 +0200457 if (snd_BUG_ON(!ctl || !ctl->card))
458 return -ENXIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
460 switch (cmd) {
461 case SNDRV_CTL_IOCTL_PVERSION:
462 case SNDRV_CTL_IOCTL_CARD_INFO:
463 case SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS:
464 case SNDRV_CTL_IOCTL_POWER:
465 case SNDRV_CTL_IOCTL_POWER_STATE:
466 case SNDRV_CTL_IOCTL_ELEM_LOCK:
467 case SNDRV_CTL_IOCTL_ELEM_UNLOCK:
Takashi Iwai2b1181e2006-09-17 22:02:22 +0200468 case SNDRV_CTL_IOCTL_ELEM_REMOVE:
469 case SNDRV_CTL_IOCTL_TLV_READ:
470 case SNDRV_CTL_IOCTL_TLV_WRITE:
471 case SNDRV_CTL_IOCTL_TLV_COMMAND:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 return snd_ctl_ioctl(file, cmd, (unsigned long)argp);
473 case SNDRV_CTL_IOCTL_ELEM_LIST32:
474 return snd_ctl_elem_list_compat(ctl->card, argp);
475 case SNDRV_CTL_IOCTL_ELEM_INFO32:
476 return snd_ctl_elem_info_compat(ctl, argp);
477 case SNDRV_CTL_IOCTL_ELEM_READ32:
478 return snd_ctl_elem_read_user_compat(ctl->card, argp);
479 case SNDRV_CTL_IOCTL_ELEM_WRITE32:
480 return snd_ctl_elem_write_user_compat(ctl, argp);
481 case SNDRV_CTL_IOCTL_ELEM_ADD32:
482 return snd_ctl_elem_add_compat(ctl, argp, 0);
483 case SNDRV_CTL_IOCTL_ELEM_REPLACE32:
484 return snd_ctl_elem_add_compat(ctl, argp, 1);
Takashi Iwai6236d8b2016-02-27 17:52:42 +0100485#ifdef CONFIG_X86_X32
486 case SNDRV_CTL_IOCTL_ELEM_READ_X32:
487 return snd_ctl_elem_read_user_x32(ctl->card, argp);
488 case SNDRV_CTL_IOCTL_ELEM_WRITE_X32:
489 return snd_ctl_elem_write_user_x32(ctl, argp);
490#endif /* CONFIG_X86_X32 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 }
492
493 down_read(&snd_ioctl_rwsem);
Johannes Berg9244b2c2006-10-05 16:02:22 +0200494 list_for_each_entry(p, &snd_control_compat_ioctls, list) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 if (p->fioctl) {
496 err = p->fioctl(ctl->card, ctl, cmd, arg);
497 if (err != -ENOIOCTLCMD) {
498 up_read(&snd_ioctl_rwsem);
499 return err;
500 }
501 }
502 }
503 up_read(&snd_ioctl_rwsem);
504 return -ENOIOCTLCMD;
505}