Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *   32bit -> 64bit ioctl wrapper for hwdep API
0004  *   Copyright (c) by Takashi Iwai <tiwai@suse.de>
0005  */
0006 
0007 /* This file is included from hwdep.c */
0008 
0009 #include <linux/compat.h>
0010 
0011 struct snd_hwdep_dsp_image32 {
0012     u32 index;
0013     unsigned char name[64];
0014     u32 image;  /* pointer */
0015     u32 length;
0016     u32 driver_data;
0017 } /* don't set packed attribute here */;
0018 
0019 static int snd_hwdep_dsp_load_compat(struct snd_hwdep *hw,
0020                      struct snd_hwdep_dsp_image32 __user *src)
0021 {
0022     struct snd_hwdep_dsp_image info = {};
0023     compat_caddr_t ptr;
0024 
0025     if (copy_from_user(&info, src, 4 + 64) ||
0026         get_user(ptr, &src->image) ||
0027         get_user(info.length, &src->length) ||
0028         get_user(info.driver_data, &src->driver_data))
0029         return -EFAULT;
0030     info.image = compat_ptr(ptr);
0031 
0032     return snd_hwdep_dsp_load(hw, &info);
0033 }
0034 
0035 enum {
0036     SNDRV_HWDEP_IOCTL_DSP_LOAD32   = _IOW('H', 0x03, struct snd_hwdep_dsp_image32)
0037 };
0038 
0039 static long snd_hwdep_ioctl_compat(struct file * file, unsigned int cmd,
0040                    unsigned long arg)
0041 {
0042     struct snd_hwdep *hw = file->private_data;
0043     void __user *argp = compat_ptr(arg);
0044     switch (cmd) {
0045     case SNDRV_HWDEP_IOCTL_PVERSION:
0046     case SNDRV_HWDEP_IOCTL_INFO:
0047     case SNDRV_HWDEP_IOCTL_DSP_STATUS:
0048         return snd_hwdep_ioctl(file, cmd, (unsigned long)argp);
0049     case SNDRV_HWDEP_IOCTL_DSP_LOAD32:
0050         return snd_hwdep_dsp_load_compat(hw, argp);
0051     }
0052     if (hw->ops.ioctl_compat)
0053         return hw->ops.ioctl_compat(hw, file, cmd, arg);
0054     return -ENOIOCTLCMD;
0055 }