hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/sound/core/hwdep.c
....@@ -1,22 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Hardware dependent layer
34 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4
- *
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
- *
205 */
216
227 #include <linux/major.h>
....@@ -218,27 +203,34 @@
218203 }
219204
220205 static int snd_hwdep_dsp_load(struct snd_hwdep *hw,
221
- struct snd_hwdep_dsp_image __user *_info)
206
+ struct snd_hwdep_dsp_image *info)
222207 {
223
- struct snd_hwdep_dsp_image info;
224208 int err;
225209
226210 if (! hw->ops.dsp_load)
227211 return -ENXIO;
228
- memset(&info, 0, sizeof(info));
229
- if (copy_from_user(&info, _info, sizeof(info)))
230
- return -EFAULT;
231
- if (info.index >= 32)
212
+ if (info->index >= 32)
232213 return -EINVAL;
233214 /* check whether the dsp was already loaded */
234
- if (hw->dsp_loaded & (1u << info.index))
215
+ if (hw->dsp_loaded & (1u << info->index))
235216 return -EBUSY;
236
- err = hw->ops.dsp_load(hw, &info);
217
+ err = hw->ops.dsp_load(hw, info);
237218 if (err < 0)
238219 return err;
239
- hw->dsp_loaded |= (1u << info.index);
220
+ hw->dsp_loaded |= (1u << info->index);
240221 return 0;
241222 }
223
+
224
+static int snd_hwdep_dsp_load_user(struct snd_hwdep *hw,
225
+ struct snd_hwdep_dsp_image __user *_info)
226
+{
227
+ struct snd_hwdep_dsp_image info = {};
228
+
229
+ if (copy_from_user(&info, _info, sizeof(info)))
230
+ return -EFAULT;
231
+ return snd_hwdep_dsp_load(hw, &info);
232
+}
233
+
242234
243235 static long snd_hwdep_ioctl(struct file * file, unsigned int cmd,
244236 unsigned long arg)
....@@ -253,7 +245,7 @@
253245 case SNDRV_HWDEP_IOCTL_DSP_STATUS:
254246 return snd_hwdep_dsp_status(hw, argp);
255247 case SNDRV_HWDEP_IOCTL_DSP_LOAD:
256
- return snd_hwdep_dsp_load(hw, argp);
248
+ return snd_hwdep_dsp_load_user(hw, argp);
257249 }
258250 if (hw->ops.ioctl)
259251 return hw->ops.ioctl(hw, file, cmd, arg);
....@@ -368,7 +360,7 @@
368360 {
369361 struct snd_hwdep *hwdep;
370362 int err;
371
- static struct snd_device_ops ops = {
363
+ static const struct snd_device_ops ops = {
372364 .dev_free = snd_hwdep_dev_free,
373365 .dev_register = snd_hwdep_dev_register,
374366 .dev_disconnect = snd_hwdep_dev_disconnect,