Commit 746c771e authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: sonicvibes annotation

sonicvibes annotated
parent c0b6b657
......@@ -1042,6 +1042,7 @@ static int mixer_ioctl(struct sv_state *s, unsigned int cmd, unsigned long arg)
unsigned long flags;
int i, val;
unsigned char l, r, rl, rr;
int __user *p = (int __user *)arg;
VALIDATE_STATE(s);
if (cmd == SOUND_MIXER_INFO) {
......@@ -1050,7 +1051,7 @@ static int mixer_ioctl(struct sv_state *s, unsigned int cmd, unsigned long arg)
strlcpy(info.id, "SonicVibes", sizeof(info.id));
strlcpy(info.name, "S3 SonicVibes", sizeof(info.name));
info.modify_counter = s->mix.modcnt;
if (copy_to_user((void *)arg, &info, sizeof(info)))
if (copy_to_user((void __user *)arg, &info, sizeof(info)))
return -EFAULT;
return 0;
}
......@@ -1059,14 +1060,14 @@ static int mixer_ioctl(struct sv_state *s, unsigned int cmd, unsigned long arg)
memset(&info, 0, sizeof(info));
strlcpy(info.id, "SonicVibes", sizeof(info.id));
strlcpy(info.name, "S3 SonicVibes", sizeof(info.name));
if (copy_to_user((void *)arg, &info, sizeof(info)))
if (copy_to_user((void __user *)arg, &info, sizeof(info)))
return -EFAULT;
return 0;
}
if (cmd == OSS_GETVERSION)
return put_user(SOUND_VERSION, (int *)arg);
return put_user(SOUND_VERSION, p);
if (cmd == SOUND_MIXER_PRIVATE1) { /* SRS settings */
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
spin_lock_irqsave(&s->lock, flags);
if (val & 1) {
......@@ -1086,47 +1087,47 @@ static int mixer_ioctl(struct sv_state *s, unsigned int cmd, unsigned long arg)
r = rdindir(s, SV_CISRSCENTER);
spin_unlock_irqrestore(&s->lock, flags);
if (l & 0x80)
return put_user(0, (int *)arg);
return put_user(((4 - (l & 7)) << 2) | ((4 - (r & 7)) << 5) | 2, (int *)arg);
return put_user(0, p);
return put_user(((4 - (l & 7)) << 2) | ((4 - (r & 7)) << 5) | 2, p);
}
if (_IOC_TYPE(cmd) != 'M' || _SIOC_SIZE(cmd) != sizeof(int))
return -EINVAL;
if (_SIOC_DIR(cmd) == _SIOC_READ) {
switch (_IOC_NR(cmd)) {
case SOUND_MIXER_RECSRC: /* Arg contains a bit for each recording source */
return put_user(mixer_recmask(s), (int *)arg);
return put_user(mixer_recmask(s), p);
case SOUND_MIXER_DEVMASK: /* Arg contains a bit for each supported device */
for (val = i = 0; i < SOUND_MIXER_NRDEVICES; i++)
if (mixtable[i].type)
val |= 1 << i;
return put_user(val, (int *)arg);
return put_user(val, p);
case SOUND_MIXER_RECMASK: /* Arg contains a bit for each supported recording source */
for (val = i = 0; i < SOUND_MIXER_NRDEVICES; i++)
if (mixtable[i].rec)
val |= 1 << i;
return put_user(val, (int *)arg);
return put_user(val, p);
case SOUND_MIXER_STEREODEVS: /* Mixer channels supporting stereo */
for (val = i = 0; i < SOUND_MIXER_NRDEVICES; i++)
if (mixtable[i].type && mixtable[i].type != MT_4MUTEMONO)
val |= 1 << i;
return put_user(val, (int *)arg);
return put_user(val, p);
case SOUND_MIXER_CAPS:
return put_user(SOUND_CAP_EXCL_INPUT, (int *)arg);
return put_user(SOUND_CAP_EXCL_INPUT, p);
default:
i = _IOC_NR(cmd);
if (i >= SOUND_MIXER_NRDEVICES || !mixtable[i].type)
return -EINVAL;
#ifdef OSS_DOCUMENTED_MIXER_SEMANTICS
return return_mixval(s, i, (int *)arg);
return return_mixval(s, i, p);
#else /* OSS_DOCUMENTED_MIXER_SEMANTICS */
if (!volidx[i])
return -EINVAL;
return put_user(s->mix.vol[volidx[i]-1], (int *)arg);
return put_user(s->mix.vol[volidx[i]-1], p);
#endif /* OSS_DOCUMENTED_MIXER_SEMANTICS */
}
}
......@@ -1135,7 +1136,7 @@ static int mixer_ioctl(struct sv_state *s, unsigned int cmd, unsigned long arg)
s->mix.modcnt++;
switch (_IOC_NR(cmd)) {
case SOUND_MIXER_RECSRC: /* Arg contains a bit for each recording source */
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
i = hweight32(val);
if (i == 0)
......@@ -1160,7 +1161,7 @@ static int mixer_ioctl(struct sv_state *s, unsigned int cmd, unsigned long arg)
i = _IOC_NR(cmd);
if (i >= SOUND_MIXER_NRDEVICES || !mixtable[i].type)
return -EINVAL;
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
l = val & 0xff;
r = (val >> 8) & 0xff;
......@@ -1224,12 +1225,12 @@ static int mixer_ioctl(struct sv_state *s, unsigned int cmd, unsigned long arg)
}
spin_unlock_irqrestore(&s->lock, flags);
#ifdef OSS_DOCUMENTED_MIXER_SEMANTICS
return return_mixval(s, i, (int *)arg);
return return_mixval(s, i, p);
#else /* OSS_DOCUMENTED_MIXER_SEMANTICS */
if (!volidx[i])
return -EINVAL;
s->mix.vol[volidx[i]-1] = val;
return put_user(s->mix.vol[volidx[i]-1], (int *)arg);
return put_user(s->mix.vol[volidx[i]-1], p);
#endif /* OSS_DOCUMENTED_MIXER_SEMANTICS */
}
}
......@@ -1314,7 +1315,7 @@ static int drain_dac(struct sv_state *s, int nonblock)
/* --------------------------------------------------------------------- */
static ssize_t sv_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
static ssize_t sv_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
{
struct sv_state *s = (struct sv_state *)file->private_data;
DECLARE_WAITQUEUE(wait, current);
......@@ -1399,7 +1400,7 @@ static ssize_t sv_read(struct file *file, char *buffer, size_t count, loff_t *pp
return ret;
}
static ssize_t sv_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
static ssize_t sv_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
{
struct sv_state *s = (struct sv_state *)file->private_data;
DECLARE_WAITQUEUE(wait, current);
......@@ -1570,13 +1571,15 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
int count;
int val, mapped, ret;
unsigned char fmtm, fmtd;
void __user *argp = (void __user *)arg;
int __user *p = argp;
VALIDATE_STATE(s);
mapped = ((file->f_mode & FMODE_WRITE) && s->dma_dac.mapped) ||
((file->f_mode & FMODE_READ) && s->dma_adc.mapped);
switch (cmd) {
case OSS_GETVERSION:
return put_user(SOUND_VERSION, (int *)arg);
return put_user(SOUND_VERSION, p);
case SNDCTL_DSP_SYNC:
if (file->f_mode & FMODE_WRITE)
......@@ -1587,7 +1590,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
return 0;
case SNDCTL_DSP_GETCAPS:
return put_user(DSP_CAP_DUPLEX | DSP_CAP_REALTIME | DSP_CAP_TRIGGER | DSP_CAP_MMAP, (int *)arg);
return put_user(DSP_CAP_DUPLEX | DSP_CAP_REALTIME | DSP_CAP_TRIGGER | DSP_CAP_MMAP, p);
case SNDCTL_DSP_RESET:
if (file->f_mode & FMODE_WRITE) {
......@@ -1603,7 +1606,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
return 0;
case SNDCTL_DSP_SPEED:
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (val >= 0) {
if (file->f_mode & FMODE_READ) {
......@@ -1617,10 +1620,10 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
set_dac_rate(s, val);
}
}
return put_user((file->f_mode & FMODE_READ) ? s->rateadc : s->ratedac, (int *)arg);
return put_user((file->f_mode & FMODE_READ) ? s->rateadc : s->ratedac, p);
case SNDCTL_DSP_STEREO:
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
fmtd = 0;
fmtm = ~0;
......@@ -1644,7 +1647,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
return 0;
case SNDCTL_DSP_CHANNELS:
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (val != 0) {
fmtd = 0;
......@@ -1668,13 +1671,13 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
set_fmt(s, fmtm, fmtd);
}
return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (SV_CFMT_STEREO << SV_CFMT_CSHIFT)
: (SV_CFMT_STEREO << SV_CFMT_ASHIFT))) ? 2 : 1, (int *)arg);
: (SV_CFMT_STEREO << SV_CFMT_ASHIFT))) ? 2 : 1, p);
case SNDCTL_DSP_GETFMTS: /* Returns a mask */
return put_user(AFMT_S16_LE|AFMT_U8, (int *)arg);
return put_user(AFMT_S16_LE|AFMT_U8, p);
case SNDCTL_DSP_SETFMT: /* Selects ONE fmt*/
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (val != AFMT_QUERY) {
fmtd = 0;
......@@ -1698,7 +1701,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
set_fmt(s, fmtm, fmtd);
}
return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (SV_CFMT_16BIT << SV_CFMT_CSHIFT)
: (SV_CFMT_16BIT << SV_CFMT_ASHIFT))) ? AFMT_S16_LE : AFMT_U8, (int *)arg);
: (SV_CFMT_16BIT << SV_CFMT_ASHIFT))) ? AFMT_S16_LE : AFMT_U8, p);
case SNDCTL_DSP_POST:
return 0;
......@@ -1709,10 +1712,10 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
val |= PCM_ENABLE_INPUT;
if (file->f_mode & FMODE_WRITE && s->enable & SV_CENABLE_PE)
val |= PCM_ENABLE_OUTPUT;
return put_user(val, (int *)arg);
return put_user(val, p);
case SNDCTL_DSP_SETTRIGGER:
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (file->f_mode & FMODE_READ) {
if (val & PCM_ENABLE_INPUT) {
......@@ -1753,7 +1756,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
abinfo.fragstotal = s->dma_dac.numfrag;
abinfo.fragments = abinfo.bytes >> s->dma_dac.fragshift;
spin_unlock_irqrestore(&s->lock, flags);
return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
return copy_to_user(argp, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
case SNDCTL_DSP_GETISPACE:
if (!(file->f_mode & FMODE_READ))
......@@ -1770,7 +1773,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
abinfo.fragstotal = s->dma_adc.numfrag;
abinfo.fragments = abinfo.bytes >> s->dma_adc.fragshift;
spin_unlock_irqrestore(&s->lock, flags);
return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
return copy_to_user(argp, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
case SNDCTL_DSP_NONBLOCK:
file->f_flags |= O_NONBLOCK;
......@@ -1787,7 +1790,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
spin_unlock_irqrestore(&s->lock, flags);
if (count < 0)
count = 0;
return put_user(count, (int *)arg);
return put_user(count, p);
case SNDCTL_DSP_GETIPTR:
if (!(file->f_mode & FMODE_READ))
......@@ -1805,7 +1808,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
if (s->dma_adc.mapped)
s->dma_adc.count &= s->dma_adc.fragsize-1;
spin_unlock_irqrestore(&s->lock, flags);
if (copy_to_user((void *)arg, &cinfo, sizeof(cinfo)))
if (copy_to_user(argp, &cinfo, sizeof(cinfo)))
return -EFAULT;
return 0;
......@@ -1825,7 +1828,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
if (s->dma_dac.mapped)
s->dma_dac.count &= s->dma_dac.fragsize-1;
spin_unlock_irqrestore(&s->lock, flags);
if (copy_to_user((void *)arg, &cinfo, sizeof(cinfo)))
if (copy_to_user(argp, &cinfo, sizeof(cinfo)))
return -EFAULT;
return 0;
......@@ -1833,14 +1836,14 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
if (file->f_mode & FMODE_WRITE) {
if ((val = prog_dmabuf(s, 0)))
return val;
return put_user(s->dma_dac.fragsize, (int *)arg);
return put_user(s->dma_dac.fragsize, p);
}
if ((val = prog_dmabuf(s, 1)))
return val;
return put_user(s->dma_adc.fragsize, (int *)arg);
return put_user(s->dma_adc.fragsize, p);
case SNDCTL_DSP_SETFRAGMENT:
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (file->f_mode & FMODE_READ) {
s->dma_adc.ossfragshift = val & 0xffff;
......@@ -1868,7 +1871,7 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
if ((file->f_mode & FMODE_READ && s->dma_adc.subdivision) ||
(file->f_mode & FMODE_WRITE && s->dma_dac.subdivision))
return -EINVAL;
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (val != 1 && val != 2 && val != 4)
return -EINVAL;
......@@ -1879,15 +1882,15 @@ static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
return 0;
case SOUND_PCM_READ_RATE:
return put_user((file->f_mode & FMODE_READ) ? s->rateadc : s->ratedac, (int *)arg);
return put_user((file->f_mode & FMODE_READ) ? s->rateadc : s->ratedac, p);
case SOUND_PCM_READ_CHANNELS:
return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (SV_CFMT_STEREO << SV_CFMT_CSHIFT)
: (SV_CFMT_STEREO << SV_CFMT_ASHIFT))) ? 2 : 1, (int *)arg);
: (SV_CFMT_STEREO << SV_CFMT_ASHIFT))) ? 2 : 1, p);
case SOUND_PCM_READ_BITS:
return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (SV_CFMT_16BIT << SV_CFMT_CSHIFT)
: (SV_CFMT_16BIT << SV_CFMT_ASHIFT))) ? 16 : 8, (int *)arg);
: (SV_CFMT_16BIT << SV_CFMT_ASHIFT))) ? 16 : 8, p);
case SOUND_PCM_WRITE_FILTER:
case SNDCTL_DSP_SETSYNCRO:
......@@ -1992,7 +1995,7 @@ static /*const*/ struct file_operations sv_audio_fops = {
/* --------------------------------------------------------------------- */
static ssize_t sv_midi_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
static ssize_t sv_midi_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
{
struct sv_state *s = (struct sv_state *)file->private_data;
DECLARE_WAITQUEUE(wait, current);
......@@ -2055,7 +2058,7 @@ static ssize_t sv_midi_read(struct file *file, char *buffer, size_t count, loff_
return ret;
}
static ssize_t sv_midi_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
static ssize_t sv_midi_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
{
struct sv_state *s = (struct sv_state *)file->private_data;
DECLARE_WAITQUEUE(wait, current);
......@@ -2297,7 +2300,7 @@ static int sv_dmfm_ioctl(struct inode *inode, struct file *file, unsigned int cm
return 0;
case FM_IOCTL_PLAY_NOTE:
if (copy_from_user(&n, (void *)arg, sizeof(n)))
if (copy_from_user(&n, (void __user *)arg, sizeof(n)))
return -EFAULT;
if (n.voice >= 18)
return -EINVAL;
......@@ -2315,7 +2318,7 @@ static int sv_dmfm_ioctl(struct inode *inode, struct file *file, unsigned int cm
return 0;
case FM_IOCTL_SET_VOICE:
if (copy_from_user(&v, (void *)arg, sizeof(v)))
if (copy_from_user(&v, (void __user *)arg, sizeof(v)))
return -EFAULT;
if (v.voice >= 18)
return -EINVAL;
......@@ -2345,7 +2348,7 @@ static int sv_dmfm_ioctl(struct inode *inode, struct file *file, unsigned int cm
return 0;
case FM_IOCTL_SET_PARAMS:
if (copy_from_user(&p, (void *)arg, sizeof(p)))
if (copy_from_user(&p, (void *__user )arg, sizeof(p)))
return -EFAULT;
outb(0x08, s->iosynth);
outb((p.kbd_split & 1) << 6, s->iosynth+1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment