Commit 2e2cb285 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: cs46xx annotation

cs46xx annotated
parent 35a2f28e
......@@ -1717,7 +1717,7 @@ static irqreturn_t cs_interrupt(int irq, void *dev_id, struct pt_regs *regs)
/**********************************************************************/
static ssize_t cs_midi_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
static ssize_t cs_midi_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
{
struct cs_card *card = (struct cs_card *)file->private_data;
ssize_t ret;
......@@ -1762,7 +1762,7 @@ static ssize_t cs_midi_read(struct file *file, char *buffer, size_t count, loff_
}
static ssize_t cs_midi_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
static ssize_t cs_midi_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
{
struct cs_card *card = (struct cs_card *)file->private_data;
ssize_t ret;
......@@ -2037,7 +2037,7 @@ static void CopySamples(char *dst, char *src, int count, unsigned fmt,
*/
static unsigned cs_copy_to_user(
struct cs_state *s,
void *dest,
void __user *dest,
void *hwsrc,
unsigned cnt,
unsigned *copied)
......@@ -2046,8 +2046,8 @@ static unsigned cs_copy_to_user(
void *src = hwsrc; /* default to the standard destination buffer addr */
CS_DBGOUT(CS_FUNCTION, 6, printk(KERN_INFO
"cs_copy_to_user()+ fmt=0x%x cnt=%d dest=0x%.8x\n",
dmabuf->fmt,(unsigned)cnt,(unsigned)dest) );
"cs_copy_to_user()+ fmt=0x%x cnt=%d dest=%p\n",
dmabuf->fmt,(unsigned)cnt,dest) );
if(cnt > dmabuf->dmasize)
{
......@@ -2074,8 +2074,8 @@ static unsigned cs_copy_to_user(
if (copy_to_user(dest, src, cnt))
{
CS_DBGOUT(CS_FUNCTION, 2, printk(KERN_ERR
"cs46xx: cs_copy_to_user()- fault dest=0x%x src=0x%x cnt=%d\n",
(unsigned)dest,(unsigned)src,cnt) );
"cs46xx: cs_copy_to_user()- fault dest=%p src=%p cnt=%d\n",
dest,src,cnt) );
*copied = 0;
return -EFAULT;
}
......@@ -2087,7 +2087,7 @@ static unsigned cs_copy_to_user(
/* in this loop, dmabuf.count signifies the amount of data that is waiting to be copied to
the user's buffer. it is filled by the dma machine and drained by this loop. */
static ssize_t cs_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
{
struct cs_card *card = (struct cs_card *) file->private_data;
struct cs_state *state;
......@@ -2165,8 +2165,8 @@ static ssize_t cs_read(struct file *file, char *buffer, size_t count, loff_t *pp
CS_DBGOUT(CS_WAVE_READ, 2, printk(KERN_INFO
"_read() copy_to cnt=%d count=%d ", cnt,count) );
CS_DBGOUT(CS_WAVE_READ, 8, printk(KERN_INFO
" .dmasize=%d .count=%d buffer=0x%.8x ret=%d\n",
dmabuf->dmasize,dmabuf->count,(unsigned)buffer,ret) );
" .dmasize=%d .count=%d buffer=%p ret=%d\n",
dmabuf->dmasize,dmabuf->count,buffer,ret) );
if (cs_copy_to_user(state, buffer,
(void *)((unsigned)dmabuf->rawbuf + swptr), cnt, &copied))
......@@ -2196,7 +2196,7 @@ static ssize_t cs_read(struct file *file, char *buffer, size_t count, loff_t *pp
/* in this loop, dmabuf.count signifies the amount of data that is waiting to be dma to
the soundcard. it is drained by the dma machine and filled by this loop. */
static ssize_t cs_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
static ssize_t cs_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
{
struct cs_card *card = (struct cs_card *) file->private_data;
struct cs_state *state;
......@@ -2486,6 +2486,8 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
audio_buf_info abinfo;
count_info cinfo;
int val, valsave, mapped, ret;
void __user *argp = (void __user *)arg;
int __user *p = argp;
state = (struct cs_state *)card->states[0];
if(state)
......@@ -2507,7 +2509,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
switch (cmd)
{
case OSS_GETVERSION:
return put_user(SOUND_VERSION, (int *)arg);
return put_user(SOUND_VERSION, p);
case SNDCTL_DSP_RESET:
/* FIXME: spin_lock ? */
......@@ -2550,7 +2552,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
return 0;
case SNDCTL_DSP_SPEED: /* set sample rate */
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (val >= 0) {
if (file->f_mode & FMODE_READ) {
......@@ -2582,12 +2584,12 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
file->f_mode & FMODE_WRITE ? "DAC" : "",
file->f_mode & FMODE_READ ? "ADC" : "",
dmabuf->rate ) );
return put_user(dmabuf->rate, (int *)arg);
return put_user(dmabuf->rate, p);
}
return put_user(0, (int *)arg);
return put_user(0, p);
case SNDCTL_DSP_STEREO: /* set stereo or mono channel */
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (file->f_mode & FMODE_WRITE) {
state = (struct cs_state *)card->states[1];
......@@ -2637,7 +2639,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
dmabuf = &state->dmabuf;
if ((val = prog_dmabuf(state)))
return val;
return put_user(dmabuf->fragsize, (int *)arg);
return put_user(dmabuf->fragsize, p);
}
}
if (file->f_mode & FMODE_READ) {
......@@ -2648,16 +2650,16 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
if ((val = prog_dmabuf(state)))
return val;
return put_user(dmabuf->fragsize/dmabuf->divisor,
(int *)arg);
p);
}
}
return put_user(0, (int *)arg);
return put_user(0, p);
case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format*/
return put_user(AFMT_S16_LE | AFMT_U8, (int *)arg);
return put_user(AFMT_S16_LE | AFMT_U8, p);
case SNDCTL_DSP_SETFMT: /* Select sample format */
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(
"cs46xx: cs_ioctl() DSP_SETFMT %s %s %s %s\n",
......@@ -2730,14 +2732,14 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
if(dmabuf)
{
if(dmabuf->fmt & CS_FMT_16BIT)
return put_user(AFMT_S16_LE, (int *)arg);
return put_user(AFMT_S16_LE, p);
else
return put_user(AFMT_U8, (int *)arg);
return put_user(AFMT_U8, p);
}
return put_user(0, (int *)arg);
return put_user(0, p);
case SNDCTL_DSP_CHANNELS:
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (val != 0) {
if (file->f_mode & FMODE_WRITE) {
......@@ -2776,7 +2778,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
}
}
return put_user((dmabuf->fmt & CS_FMT_STEREO) ? 2 : 1,
(int *)arg);
p);
case SNDCTL_DSP_POST:
/*
......@@ -2793,7 +2795,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
dmabuf = &state->dmabuf;
if (dmabuf->subdivision)
return -EINVAL;
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (val != 1 && val != 2)
return -EINVAL;
......@@ -2807,7 +2809,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
dmabuf = &state->dmabuf;
if (dmabuf->subdivision)
return -EINVAL;
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (val != 1 && val != 2)
return -EINVAL;
......@@ -2817,7 +2819,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
return 0;
case SNDCTL_DSP_SETFRAGMENT:
if (get_user(val, (int *)arg))
if (get_user(val, p))
return -EFAULT;
if (file->f_mode & FMODE_WRITE) {
......@@ -2861,7 +2863,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
spin_unlock_irqrestore(&state->card->lock, flags);
return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
return copy_to_user(argp, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
}
return -ENODEV;
......@@ -2879,7 +2881,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
abinfo.fragstotal = dmabuf->numfrag;
abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
spin_unlock_irqrestore(&state->card->lock, flags);
return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
return copy_to_user(argp, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
}
return -ENODEV;
......@@ -2889,7 +2891,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
case SNDCTL_DSP_GETCAPS:
return put_user(DSP_CAP_REALTIME|DSP_CAP_TRIGGER|DSP_CAP_MMAP,
(int *)arg);
p);
case SNDCTL_DSP_GETTRIGGER:
val = 0;
......@@ -2915,10 +2917,10 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
}
}
CS_DBGOUT(CS_IOCTL, 2, printk("cs46xx: DSP_GETTRIGGER()- val=0x%x\n",val) );
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) {
state = (struct cs_state *)card->states[0];
......@@ -2961,7 +2963,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
cinfo.blocks = dmabuf->count/dmabuf->divisor >> dmabuf->fragshift;
cinfo.ptr = dmabuf->hwptr/dmabuf->divisor;
spin_unlock_irqrestore(&state->card->lock, flags);
if (copy_to_user((void *)arg, &cinfo, sizeof(cinfo)))
if (copy_to_user(argp, &cinfo, sizeof(cinfo)))
return -EFAULT;
return 0;
}
......@@ -2996,7 +2998,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
"cs46xx: GETOPTR bytes=%d blocks=%d ptr=%d\n",
cinfo.bytes,cinfo.blocks,cinfo.ptr) );
spin_unlock_irqrestore(&state->card->lock, flags);
if (copy_to_user((void *)arg, &cinfo, sizeof(cinfo)))
if (copy_to_user(argp, &cinfo, sizeof(cinfo)))
return -EFAULT;
return 0;
}
......@@ -3019,7 +3021,7 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
}
else
val = 0;
return put_user(val, (int *)arg);
return put_user(val, p);
case SOUND_PCM_READ_RATE:
if(file->f_mode & FMODE_READ)
......@@ -3029,9 +3031,9 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
if(state)
{
dmabuf = &state->dmabuf;
return put_user(dmabuf->rate, (int *)arg);
return put_user(dmabuf->rate, p);
}
return put_user(0, (int *)arg);
return put_user(0, p);
case SOUND_PCM_READ_CHANNELS:
......@@ -3043,9 +3045,9 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
{
dmabuf = &state->dmabuf;
return put_user((dmabuf->fmt & CS_FMT_STEREO) ? 2 : 1,
(int *)arg);
p);
}
return put_user(0, (int *)arg);
return put_user(0, p);
case SOUND_PCM_READ_BITS:
if(file->f_mode & FMODE_READ)
......@@ -3056,10 +3058,10 @@ static int cs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
{
dmabuf = &state->dmabuf;
return put_user((dmabuf->fmt & CS_FMT_16BIT) ?
AFMT_S16_LE : AFMT_U8, (int *)arg);
AFMT_S16_LE : AFMT_U8, p);
}
return put_user(0, (int *)arg);
return put_user(0, p);
case SNDCTL_DSP_MAPINBUF:
case SNDCTL_DSP_MAPOUTBUF:
......@@ -4164,6 +4166,7 @@ static int cs_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int
struct ac97_codec *codec = (struct ac97_codec *)file->private_data;
struct cs_card *card=NULL;
struct list_head *entry;
unsigned long __user *p = (long __user *)arg;
#if CSDEBUG_INTERFACE
int val;
......@@ -4178,25 +4181,25 @@ static int cs_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int
{
case SOUND_MIXER_CS_GETDBGMASK:
return put_user(cs_debugmask, (unsigned long *)arg);
return put_user(cs_debugmask, p);
case SOUND_MIXER_CS_GETDBGLEVEL:
return put_user(cs_debuglevel, (unsigned long *)arg);
return put_user(cs_debuglevel, p);
case SOUND_MIXER_CS_SETDBGMASK:
if (get_user(val, (unsigned long *)arg))
if (get_user(val, p))
return -EFAULT;
cs_debugmask = val;
return 0;
case SOUND_MIXER_CS_SETDBGLEVEL:
if (get_user(val, (unsigned long *)arg))
if (get_user(val, p))
return -EFAULT;
cs_debuglevel = val;
return 0;
case SOUND_MIXER_CS_APM:
if (get_user(val, (unsigned long *) arg))
if (get_user(val, p))
return -EFAULT;
if(val == CS_IOCTL_CMD_SUSPEND)
{
......
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