Commit 6f7fe3ef authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: maestro annotation

maestro annotated
parent b6aef039
...@@ -2026,6 +2026,8 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar ...@@ -2026,6 +2026,8 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar
{ {
int i, val=0; int i, val=0;
unsigned long flags; unsigned long flags;
void __user *argp = (void __user *)arg;
int __user *p = argp;
VALIDATE_CARD(card); VALIDATE_CARD(card);
if (cmd == SOUND_MIXER_INFO) { if (cmd == SOUND_MIXER_INFO) {
...@@ -2034,7 +2036,7 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar ...@@ -2034,7 +2036,7 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar
strlcpy(info.id, card_names[card->card_type], sizeof(info.id)); strlcpy(info.id, card_names[card->card_type], sizeof(info.id));
strlcpy(info.name, card_names[card->card_type], sizeof(info.name)); strlcpy(info.name, card_names[card->card_type], sizeof(info.name));
info.modify_counter = card->mix.modcnt; info.modify_counter = card->mix.modcnt;
if (copy_to_user((void *)arg, &info, sizeof(info))) if (copy_to_user(argp, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
...@@ -2043,12 +2045,12 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar ...@@ -2043,12 +2045,12 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
strlcpy(info.id, card_names[card->card_type], sizeof(info.id)); strlcpy(info.id, card_names[card->card_type], sizeof(info.id));
strlcpy(info.name, card_names[card->card_type], sizeof(info.name)); strlcpy(info.name, card_names[card->card_type], sizeof(info.name));
if (copy_to_user((void *)arg, &info, sizeof(info))) if (copy_to_user(argp, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
if (cmd == OSS_GETVERSION) if (cmd == OSS_GETVERSION)
return put_user(SOUND_VERSION, (int *)arg); return put_user(SOUND_VERSION, p);
if (_IOC_TYPE(cmd) != 'M' || _IOC_SIZE(cmd) != sizeof(int)) if (_IOC_TYPE(cmd) != 'M' || _IOC_SIZE(cmd) != sizeof(int))
return -EINVAL; return -EINVAL;
...@@ -2098,7 +2100,7 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar ...@@ -2098,7 +2100,7 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar
break; break;
} }
return put_user(val,(int *)arg); return put_user(val, p);
} }
if (_IOC_DIR(cmd) != (_IOC_WRITE|_IOC_READ)) if (_IOC_DIR(cmd) != (_IOC_WRITE|_IOC_READ))
...@@ -2106,7 +2108,7 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar ...@@ -2106,7 +2108,7 @@ static int mixer_ioctl(struct ess_card *card, unsigned int cmd, unsigned long ar
card->mix.modcnt++; card->mix.modcnt++;
if (get_user(val, (int *)arg)) if (get_user(val, p))
return -EFAULT; return -EFAULT;
switch (_IOC_NR(cmd)) { switch (_IOC_NR(cmd)) {
...@@ -2262,7 +2264,7 @@ comb_stereo(unsigned char *real_buffer,unsigned char *tmp_buffer, int offset, ...@@ -2262,7 +2264,7 @@ comb_stereo(unsigned char *real_buffer,unsigned char *tmp_buffer, int offset,
to be copied to the user's buffer. it is filled by the interrupt to be copied to the user's buffer. it is filled by the interrupt
handler and drained by this loop. */ handler and drained by this loop. */
static ssize_t static ssize_t
ess_read(struct file *file, char *buffer, size_t count, loff_t *ppos) ess_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
{ {
struct ess_state *s = (struct ess_state *)file->private_data; struct ess_state *s = (struct ess_state *)file->private_data;
ssize_t ret; ssize_t ret;
...@@ -2361,7 +2363,7 @@ ess_read(struct file *file, char *buffer, size_t count, loff_t *ppos) ...@@ -2361,7 +2363,7 @@ ess_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
} }
static ssize_t static ssize_t
ess_write(struct file *file, const char *buffer, size_t count, loff_t *ppos) ess_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
{ {
struct ess_state *s = (struct ess_state *)file->private_data; struct ess_state *s = (struct ess_state *)file->private_data;
ssize_t ret; ssize_t ret;
...@@ -2539,6 +2541,8 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2539,6 +2541,8 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
count_info cinfo; count_info cinfo;
int val, mapped, ret; int val, mapped, ret;
unsigned char fmtm, fmtd; unsigned char fmtm, fmtd;
void __user *argp = (void __user *)arg;
int __user *p = argp;
/* printk("maestro: ess_ioctl: cmd %d\n", cmd);*/ /* printk("maestro: ess_ioctl: cmd %d\n", cmd);*/
...@@ -2547,7 +2551,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2547,7 +2551,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
((file->f_mode & FMODE_READ) && s->dma_adc.mapped); ((file->f_mode & FMODE_READ) && s->dma_adc.mapped);
switch (cmd) { switch (cmd) {
case OSS_GETVERSION: case OSS_GETVERSION:
return put_user(SOUND_VERSION, (int *)arg); return put_user(SOUND_VERSION, p);
case SNDCTL_DSP_SYNC: case SNDCTL_DSP_SYNC:
if (file->f_mode & FMODE_WRITE) if (file->f_mode & FMODE_WRITE)
...@@ -2559,7 +2563,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2559,7 +2563,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
return 0; return 0;
case SNDCTL_DSP_GETCAPS: 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: case SNDCTL_DSP_RESET:
if (file->f_mode & FMODE_WRITE) { if (file->f_mode & FMODE_WRITE) {
...@@ -2575,7 +2579,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2575,7 +2579,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
return 0; return 0;
case SNDCTL_DSP_SPEED: case SNDCTL_DSP_SPEED:
if (get_user(val, (int *)arg)) if (get_user(val, p))
return -EFAULT; return -EFAULT;
if (val >= 0) { if (val >= 0) {
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
...@@ -2589,10 +2593,10 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2589,10 +2593,10 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
set_dac_rate(s, val); 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: case SNDCTL_DSP_STEREO:
if (get_user(val, (int *)arg)) if (get_user(val, p))
return -EFAULT; return -EFAULT;
fmtd = 0; fmtd = 0;
fmtm = ~0; fmtm = ~0;
...@@ -2616,7 +2620,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2616,7 +2620,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
return 0; return 0;
case SNDCTL_DSP_CHANNELS: case SNDCTL_DSP_CHANNELS:
if (get_user(val, (int *)arg)) if (get_user(val, p))
return -EFAULT; return -EFAULT;
if (val != 0) { if (val != 0) {
fmtd = 0; fmtd = 0;
...@@ -2640,13 +2644,13 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2640,13 +2644,13 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
set_fmt(s, fmtm, fmtd); set_fmt(s, fmtm, fmtd);
} }
return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (ESS_FMT_STEREO << ESS_ADC_SHIFT) return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (ESS_FMT_STEREO << ESS_ADC_SHIFT)
: (ESS_FMT_STEREO << ESS_DAC_SHIFT))) ? 2 : 1, (int *)arg); : (ESS_FMT_STEREO << ESS_DAC_SHIFT))) ? 2 : 1, p);
case SNDCTL_DSP_GETFMTS: /* Returns a mask */ case SNDCTL_DSP_GETFMTS: /* Returns a mask */
return put_user(AFMT_U8|AFMT_S16_LE, (int *)arg); return put_user(AFMT_U8|AFMT_S16_LE, p);
case SNDCTL_DSP_SETFMT: /* Selects ONE fmt*/ case SNDCTL_DSP_SETFMT: /* Selects ONE fmt*/
if (get_user(val, (int *)arg)) if (get_user(val, p))
return -EFAULT; return -EFAULT;
if (val != AFMT_QUERY) { if (val != AFMT_QUERY) {
fmtd = 0; fmtd = 0;
...@@ -2678,7 +2682,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2678,7 +2682,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
: (ESS_FMT_16BIT << ESS_DAC_SHIFT))) ? : (ESS_FMT_16BIT << ESS_DAC_SHIFT))) ?
AFMT_S16_LE : AFMT_S16_LE :
AFMT_U8, AFMT_U8,
(int *)arg); p);
case SNDCTL_DSP_POST: case SNDCTL_DSP_POST:
return 0; return 0;
...@@ -2689,10 +2693,10 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2689,10 +2693,10 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
val |= PCM_ENABLE_INPUT; val |= PCM_ENABLE_INPUT;
if ((file->f_mode & FMODE_WRITE) && (s->enable & DAC_RUNNING)) if ((file->f_mode & FMODE_WRITE) && (s->enable & DAC_RUNNING))
val |= PCM_ENABLE_OUTPUT; val |= PCM_ENABLE_OUTPUT;
return put_user(val, (int *)arg); return put_user(val, p);
case SNDCTL_DSP_SETTRIGGER: case SNDCTL_DSP_SETTRIGGER:
if (get_user(val, (int *)arg)) if (get_user(val, p))
return -EFAULT; return -EFAULT;
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
if (val & PCM_ENABLE_INPUT) { if (val & PCM_ENABLE_INPUT) {
...@@ -2724,7 +2728,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2724,7 +2728,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
abinfo.fragstotal = s->dma_dac.numfrag; abinfo.fragstotal = s->dma_dac.numfrag;
abinfo.fragments = abinfo.bytes >> s->dma_dac.fragshift; abinfo.fragments = abinfo.bytes >> s->dma_dac.fragshift;
spin_unlock_irqrestore(&s->lock, flags); 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: case SNDCTL_DSP_GETISPACE:
if (!(file->f_mode & FMODE_READ)) if (!(file->f_mode & FMODE_READ))
...@@ -2738,7 +2742,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2738,7 +2742,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
abinfo.fragstotal = s->dma_adc.numfrag; abinfo.fragstotal = s->dma_adc.numfrag;
abinfo.fragments = abinfo.bytes >> s->dma_adc.fragshift; abinfo.fragments = abinfo.bytes >> s->dma_adc.fragshift;
spin_unlock_irqrestore(&s->lock, flags); 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: case SNDCTL_DSP_NONBLOCK:
file->f_flags |= O_NONBLOCK; file->f_flags |= O_NONBLOCK;
...@@ -2753,7 +2757,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2753,7 +2757,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
ess_update_ptr(s); ess_update_ptr(s);
val = s->dma_dac.count; val = s->dma_dac.count;
spin_unlock_irqrestore(&s->lock, flags); spin_unlock_irqrestore(&s->lock, flags);
return put_user(val, (int *)arg); return put_user(val, p);
case SNDCTL_DSP_GETIPTR: case SNDCTL_DSP_GETIPTR:
if (!(file->f_mode & FMODE_READ)) if (!(file->f_mode & FMODE_READ))
...@@ -2768,7 +2772,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2768,7 +2772,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
if (s->dma_adc.mapped) if (s->dma_adc.mapped)
s->dma_adc.count &= s->dma_adc.fragsize-1; s->dma_adc.count &= s->dma_adc.fragsize-1;
spin_unlock_irqrestore(&s->lock, flags); 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 -EFAULT;
return 0; return 0;
...@@ -2785,7 +2789,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2785,7 +2789,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
if (s->dma_dac.mapped) if (s->dma_dac.mapped)
s->dma_dac.count &= s->dma_dac.fragsize-1; s->dma_dac.count &= s->dma_dac.fragsize-1;
spin_unlock_irqrestore(&s->lock, flags); 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 -EFAULT;
return 0; return 0;
...@@ -2793,14 +2797,14 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2793,14 +2797,14 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
if (file->f_mode & FMODE_WRITE) { if (file->f_mode & FMODE_WRITE) {
if ((val = prog_dmabuf(s, 0))) if ((val = prog_dmabuf(s, 0)))
return val; 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))) if ((val = prog_dmabuf(s, 1)))
return val; return val;
return put_user(s->dma_adc.fragsize, (int *)arg); return put_user(s->dma_adc.fragsize, p);
case SNDCTL_DSP_SETFRAGMENT: case SNDCTL_DSP_SETFRAGMENT:
if (get_user(val, (int *)arg)) if (get_user(val, p))
return -EFAULT; return -EFAULT;
M_printk("maestro: SETFRAGMENT: %0x\n",val); M_printk("maestro: SETFRAGMENT: %0x\n",val);
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
...@@ -2829,7 +2833,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2829,7 +2833,7 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
if ((file->f_mode & FMODE_READ && s->dma_adc.subdivision) || if ((file->f_mode & FMODE_READ && s->dma_adc.subdivision) ||
(file->f_mode & FMODE_WRITE && s->dma_dac.subdivision)) (file->f_mode & FMODE_WRITE && s->dma_dac.subdivision))
return -EINVAL; return -EINVAL;
if (get_user(val, (int *)arg)) if (get_user(val, p))
return -EFAULT; return -EFAULT;
if (val != 1 && val != 2 && val != 4) if (val != 1 && val != 2 && val != 4)
return -EINVAL; return -EINVAL;
...@@ -2840,15 +2844,15 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u ...@@ -2840,15 +2844,15 @@ static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
return 0; return 0;
case SOUND_PCM_READ_RATE: 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: case SOUND_PCM_READ_CHANNELS:
return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (ESS_FMT_STEREO << ESS_ADC_SHIFT) return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (ESS_FMT_STEREO << ESS_ADC_SHIFT)
: (ESS_FMT_STEREO << ESS_DAC_SHIFT))) ? 2 : 1, (int *)arg); : (ESS_FMT_STEREO << ESS_DAC_SHIFT))) ? 2 : 1, p);
case SOUND_PCM_READ_BITS: case SOUND_PCM_READ_BITS:
return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (ESS_FMT_16BIT << ESS_ADC_SHIFT) return put_user((s->fmt & ((file->f_mode & FMODE_READ) ? (ESS_FMT_16BIT << ESS_ADC_SHIFT)
: (ESS_FMT_16BIT << ESS_DAC_SHIFT))) ? 16 : 8, (int *)arg); : (ESS_FMT_16BIT << ESS_DAC_SHIFT))) ? 16 : 8, p);
case SOUND_PCM_WRITE_FILTER: case SOUND_PCM_WRITE_FILTER:
case SNDCTL_DSP_SETSYNCRO: case SNDCTL_DSP_SETSYNCRO:
......
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