| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Hardware dependent layer |
|---|
| 3 | 4 | * 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 | | - * |
|---|
| 20 | 5 | */ |
|---|
| 21 | 6 | |
|---|
| 22 | 7 | #include <linux/major.h> |
|---|
| .. | .. |
|---|
| 218 | 203 | } |
|---|
| 219 | 204 | |
|---|
| 220 | 205 | 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) |
|---|
| 222 | 207 | { |
|---|
| 223 | | - struct snd_hwdep_dsp_image info; |
|---|
| 224 | 208 | int err; |
|---|
| 225 | 209 | |
|---|
| 226 | 210 | if (! hw->ops.dsp_load) |
|---|
| 227 | 211 | 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) |
|---|
| 232 | 213 | return -EINVAL; |
|---|
| 233 | 214 | /* check whether the dsp was already loaded */ |
|---|
| 234 | | - if (hw->dsp_loaded & (1u << info.index)) |
|---|
| 215 | + if (hw->dsp_loaded & (1u << info->index)) |
|---|
| 235 | 216 | return -EBUSY; |
|---|
| 236 | | - err = hw->ops.dsp_load(hw, &info); |
|---|
| 217 | + err = hw->ops.dsp_load(hw, info); |
|---|
| 237 | 218 | if (err < 0) |
|---|
| 238 | 219 | return err; |
|---|
| 239 | | - hw->dsp_loaded |= (1u << info.index); |
|---|
| 220 | + hw->dsp_loaded |= (1u << info->index); |
|---|
| 240 | 221 | return 0; |
|---|
| 241 | 222 | } |
|---|
| 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 | + |
|---|
| 242 | 234 | |
|---|
| 243 | 235 | static long snd_hwdep_ioctl(struct file * file, unsigned int cmd, |
|---|
| 244 | 236 | unsigned long arg) |
|---|
| .. | .. |
|---|
| 253 | 245 | case SNDRV_HWDEP_IOCTL_DSP_STATUS: |
|---|
| 254 | 246 | return snd_hwdep_dsp_status(hw, argp); |
|---|
| 255 | 247 | case SNDRV_HWDEP_IOCTL_DSP_LOAD: |
|---|
| 256 | | - return snd_hwdep_dsp_load(hw, argp); |
|---|
| 248 | + return snd_hwdep_dsp_load_user(hw, argp); |
|---|
| 257 | 249 | } |
|---|
| 258 | 250 | if (hw->ops.ioctl) |
|---|
| 259 | 251 | return hw->ops.ioctl(hw, file, cmd, arg); |
|---|
| .. | .. |
|---|
| 368 | 360 | { |
|---|
| 369 | 361 | struct snd_hwdep *hwdep; |
|---|
| 370 | 362 | int err; |
|---|
| 371 | | - static struct snd_device_ops ops = { |
|---|
| 363 | + static const struct snd_device_ops ops = { |
|---|
| 372 | 364 | .dev_free = snd_hwdep_dev_free, |
|---|
| 373 | 365 | .dev_register = snd_hwdep_dev_register, |
|---|
| 374 | 366 | .dev_disconnect = snd_hwdep_dev_disconnect, |
|---|