Commit 099a47a2 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: rme9652 annotation

Annotated driver and ioctl structure used by it.
parent 2996867d
...@@ -76,7 +76,7 @@ struct _snd_hdsp_config_info { ...@@ -76,7 +76,7 @@ struct _snd_hdsp_config_info {
typedef struct _snd_hdsp_firmware hdsp_firmware_t; typedef struct _snd_hdsp_firmware hdsp_firmware_t;
struct _snd_hdsp_firmware { struct _snd_hdsp_firmware {
unsigned long *firmware_data; /* 24413 long words */ unsigned long __user *firmware_data; /* 24413 long words */
}; };
#define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW('H', 0x42, hdsp_firmware_t) #define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW('H', 0x42, hdsp_firmware_t)
......
...@@ -1250,9 +1250,9 @@ static inline void snd_hdsp_midi_write_byte (hdsp_t *hdsp, int id, int val) ...@@ -1250,9 +1250,9 @@ static inline void snd_hdsp_midi_write_byte (hdsp_t *hdsp, int id, int val)
{ {
/* the hardware already does the relevant bit-mask with 0xff */ /* the hardware already does the relevant bit-mask with 0xff */
if (id) { if (id) {
return hdsp_write(hdsp, HDSP_midiDataOut1, val); hdsp_write(hdsp, HDSP_midiDataOut1, val);
} else { } else {
return hdsp_write(hdsp, HDSP_midiDataOut0, val); hdsp_write(hdsp, HDSP_midiDataOut0, val);
} }
} }
...@@ -3834,7 +3834,7 @@ static char *hdsp_channel_buffer_location(hdsp_t *hdsp, ...@@ -3834,7 +3834,7 @@ static char *hdsp_channel_buffer_location(hdsp_t *hdsp,
} }
static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel, static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel,
snd_pcm_uframes_t pos, void *src, snd_pcm_uframes_t count) snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count)
{ {
hdsp_t *hdsp = _snd_pcm_substream_chip(substream); hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
char *channel_buf; char *channel_buf;
...@@ -3849,7 +3849,7 @@ static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel, ...@@ -3849,7 +3849,7 @@ static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel,
} }
static int snd_hdsp_capture_copy(snd_pcm_substream_t *substream, int channel, static int snd_hdsp_capture_copy(snd_pcm_substream_t *substream, int channel,
snd_pcm_uframes_t pos, void *dst, snd_pcm_uframes_t count) snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count)
{ {
hdsp_t *hdsp = _snd_pcm_substream_chip(substream); hdsp_t *hdsp = _snd_pcm_substream_chip(substream);
char *channel_buf; char *channel_buf;
...@@ -4531,10 +4531,11 @@ static int snd_hdsp_hwdep_dummy_op(snd_hwdep_t *hw, struct file *file) ...@@ -4531,10 +4531,11 @@ static int snd_hdsp_hwdep_dummy_op(snd_hwdep_t *hw, struct file *file)
static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int cmd, unsigned long arg) static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int cmd, unsigned long arg)
{ {
hdsp_t *hdsp = (hdsp_t *)hw->private_data; hdsp_t *hdsp = (hdsp_t *)hw->private_data;
void __user *argp = (void __user *)arg;
switch (cmd) { switch (cmd) {
case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: { case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: {
hdsp_peak_rms_t *peak_rms; hdsp_peak_rms_t __user *peak_rms;
int i; int i;
if (hdsp->io_type == H9652) { if (hdsp->io_type == H9652) {
...@@ -4542,38 +4543,38 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int ...@@ -4542,38 +4543,38 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
int doublespeed = 0; int doublespeed = 0;
if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
doublespeed = 1; doublespeed = 1;
peak_rms = (hdsp_peak_rms_t *)arg; peak_rms = (hdsp_peak_rms_t __user *)arg;
for (i = 0; i < 26; ++i) { for (i = 0; i < 26; ++i) {
if (!(doublespeed && (i & 4))) { if (!(doublespeed && (i & 4))) {
if (copy_to_user_fromio((void *)peak_rms->input_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-i*4, 4) != 0) if (copy_to_user_fromio((void __user *)peak_rms->input_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-i*4, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user_fromio((void *)peak_rms->playback_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-(doublespeed ? 14 : 26)*4-i*4, 4) != 0) if (copy_to_user_fromio((void __user *)peak_rms->playback_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user_fromio((void *)peak_rms->output_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-2*(doublespeed ? 14 : 26)*4-i*4, 4) != 0) if (copy_to_user_fromio((void __user *)peak_rms->output_peaks+i*4, hdsp->iobase+HDSP_9652_peakBase-2*(doublespeed ? 14 : 26)*4-i*4, 4) != 0)
return -EFAULT; return -EFAULT;
rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8) & 0xFFFFFF00; rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8) & 0xFFFFFF00;
rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8+4) & 0xFFFFFF00; rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+i*8+4) & 0xFFFFFF00;
rms_high += (rms_low >> 24); rms_high += (rms_low >> 24);
rms_low <<= 8; rms_low <<= 8;
if (copy_to_user((void *)peak_rms->input_rms+i*8, &rms_low, 4) != 0) if (copy_to_user((void __user *)peak_rms->input_rms+i*8, &rms_low, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->input_rms+i*8+4, &rms_high, 4) != 0) if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, &rms_high, 4) != 0)
return -EFAULT; return -EFAULT;
rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00; rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00; rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
rms_high += (rms_low >> 24); rms_high += (rms_low >> 24);
rms_low <<= 8; rms_low <<= 8;
if (copy_to_user((void *)peak_rms->playback_rms+i*8, &rms_low, 4) != 0) if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, &rms_low, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, &rms_high, 4) != 0) if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, &rms_high, 4) != 0)
return -EFAULT; return -EFAULT;
rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00; rms_low = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8) & 0xFFFFFF00;
rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00; rms_high = *(u32 *)(hdsp->iobase+HDSP_9652_rmsBase+2*(doublespeed ? 14 : 26)*8+i*8+4) & 0xFFFFFF00;
rms_high += (rms_low >> 24); rms_high += (rms_low >> 24);
rms_low <<= 8; rms_low <<= 8;
if (copy_to_user((void *)peak_rms->output_rms+i*8, &rms_low, 4) != 0) if (copy_to_user((void __user *)peak_rms->output_rms+i*8, &rms_low, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->output_rms+i*8+4, &rms_high, 4) != 0) if (copy_to_user((void __user *)peak_rms->output_rms+i*8+4, &rms_high, 4) != 0)
return -EFAULT; return -EFAULT;
} }
} }
...@@ -4586,25 +4587,25 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int ...@@ -4586,25 +4587,25 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus)
doublespeed = 1; doublespeed = 1;
m = (hdsp_9632_meters_t *)(hdsp->iobase+HDSP_9632_metersBase); m = (hdsp_9632_meters_t *)(hdsp->iobase+HDSP_9632_metersBase);
peak_rms = (hdsp_peak_rms_t *)arg; peak_rms = (hdsp_peak_rms_t __user *)arg;
for (i = 0, j = 0; i < 16; ++i, ++j) { for (i = 0, j = 0; i < 16; ++i, ++j) {
if (copy_to_user((void *)peak_rms->input_peaks+i*4, &(m->input_peak[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->input_peaks+i*4, &(m->input_peak[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->playback_peaks+i*4, &(m->playback_peak[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->playback_peaks+i*4, &(m->playback_peak[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->output_peaks+i*4, &(m->output_peak[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->output_peaks+i*4, &(m->output_peak[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->input_rms+i*8, &(m->input_rms_low[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->input_rms+i*8, &(m->input_rms_low[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->playback_rms+i*8, &(m->playback_rms_low[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, &(m->playback_rms_low[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->output_rms+i*8, &(m->output_rms_low[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->output_rms+i*8, &(m->output_rms_low[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->input_rms+i*8+4, &(m->input_rms_high[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, &(m->input_rms_high[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, &(m->playback_rms_high[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, &(m->playback_rms_high[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->output_rms+i*8+4, &(m->output_rms_high[j]), 4) != 0) if (copy_to_user((void __user *)peak_rms->output_rms+i*8+4, &(m->output_rms_high[j]), 4) != 0)
return -EFAULT; return -EFAULT;
if (doublespeed && i == 3) i += 4; if (doublespeed && i == 3) i += 4;
} }
...@@ -4614,25 +4615,25 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int ...@@ -4614,25 +4615,25 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
snd_printk("firmware needs to be uploaded to the card.\n"); snd_printk("firmware needs to be uploaded to the card.\n");
return -EINVAL; return -EINVAL;
} }
peak_rms = (hdsp_peak_rms_t *)arg; peak_rms = (hdsp_peak_rms_t __user *)arg;
for (i = 0; i < 26; ++i) { for (i = 0; i < 26; ++i) {
if (copy_to_user((void *)peak_rms->playback_peaks+i*4, (void *)hdsp->iobase+HDSP_playbackPeakLevel+i*4, 4) != 0) if (copy_to_user((void __user *)peak_rms->playback_peaks+i*4, (void *)hdsp->iobase+HDSP_playbackPeakLevel+i*4, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->input_peaks+i*4, (void *)hdsp->iobase+HDSP_inputPeakLevel+i*4, 4) != 0) if (copy_to_user((void __user *)peak_rms->input_peaks+i*4, (void *)hdsp->iobase+HDSP_inputPeakLevel+i*4, 4) != 0)
return -EFAULT; return -EFAULT;
} }
for (i = 0; i < 26; ++i) { for (i = 0; i < 26; ++i) {
if (copy_to_user((void *)peak_rms->playback_rms+i*8+4, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8, 4) != 0) if (copy_to_user((void __user *)peak_rms->playback_rms+i*8+4, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->playback_rms+i*8, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8+4, 4) != 0) if (copy_to_user((void __user *)peak_rms->playback_rms+i*8, (void *)hdsp->iobase+HDSP_playbackRmsLevel+i*8+4, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->input_rms+i*8+4, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8, 4) != 0) if (copy_to_user((void __user *)peak_rms->input_rms+i*8+4, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8, 4) != 0)
return -EFAULT; return -EFAULT;
if (copy_to_user((void *)peak_rms->input_rms+i*8, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8+4, 4) != 0) if (copy_to_user((void __user *)peak_rms->input_rms+i*8, (void *)hdsp->iobase+HDSP_inputRmsLevel+i*8+4, 4) != 0)
return -EFAULT; return -EFAULT;
} }
for (i = 0; i < 28; ++i) { for (i = 0; i < 28; ++i) {
if (copy_to_user((void *)peak_rms->output_peaks+i*4, (void *)hdsp->iobase+HDSP_outputPeakLevel+i*4, 4) != 0) if (copy_to_user((void __user *)peak_rms->output_peaks+i*4, (void *)hdsp->iobase+HDSP_outputPeakLevel+i*4, 4) != 0)
return -EFAULT; return -EFAULT;
} }
break; break;
...@@ -4680,7 +4681,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int ...@@ -4680,7 +4681,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp); info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp);
} }
spin_unlock_irqrestore(&hdsp->lock, flags); spin_unlock_irqrestore(&hdsp->lock, flags);
if (copy_to_user((void *)arg, &info, sizeof(info))) if (copy_to_user(argp, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
break; break;
} }
...@@ -4690,7 +4691,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int ...@@ -4690,7 +4691,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
if (hdsp->io_type != H9632) return -EINVAL; if (hdsp->io_type != H9632) return -EINVAL;
h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS; h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS;
h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS; h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS;
if (copy_to_user((void *)arg, &h9632_aeb, sizeof(h9632_aeb))) if (copy_to_user(argp, &h9632_aeb, sizeof(h9632_aeb)))
return -EFAULT; return -EFAULT;
break; break;
} }
...@@ -4706,14 +4707,14 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int ...@@ -4706,14 +4707,14 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
} }
hdsp_version.io_type = hdsp->io_type; hdsp_version.io_type = hdsp->io_type;
hdsp_version.firmware_rev = hdsp->firmware_rev; hdsp_version.firmware_rev = hdsp->firmware_rev;
if ((err = copy_to_user((void *)arg, &hdsp_version, sizeof(hdsp_version)))) { if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version)))) {
return -EFAULT; return -EFAULT;
} }
break; break;
} }
case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: { case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: {
hdsp_firmware_t *firmware; hdsp_firmware_t __user *firmware;
unsigned long *firmware_data; unsigned long __user *firmware_data;
int err; int err;
if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
...@@ -4721,7 +4722,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int ...@@ -4721,7 +4722,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
if (hdsp->io_type == Undefined) return -EINVAL; if (hdsp->io_type == Undefined) return -EINVAL;
snd_printk("initializing firmware upload\n"); snd_printk("initializing firmware upload\n");
firmware = (hdsp_firmware_t *)arg; firmware = (hdsp_firmware_t __user *)argp;
if (get_user(firmware_data, &firmware->firmware_data)) { if (get_user(firmware_data, &firmware->firmware_data)) {
return -EFAULT; return -EFAULT;
...@@ -4754,9 +4755,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int ...@@ -4754,9 +4755,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int
break; break;
} }
case SNDRV_HDSP_IOCTL_GET_MIXER: { case SNDRV_HDSP_IOCTL_GET_MIXER: {
hdsp_mixer_t *mixer; hdsp_mixer_t __user *mixer = (hdsp_mixer_t __user *)argp;
mixer = (hdsp_mixer_t *)arg;
if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE)) if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE))
return -EFAULT; return -EFAULT;
break; break;
......
...@@ -2011,7 +2011,7 @@ static char *rme9652_channel_buffer_location(rme9652_t *rme9652, ...@@ -2011,7 +2011,7 @@ static char *rme9652_channel_buffer_location(rme9652_t *rme9652,
} }
static int snd_rme9652_playback_copy(snd_pcm_substream_t *substream, int channel, static int snd_rme9652_playback_copy(snd_pcm_substream_t *substream, int channel,
snd_pcm_uframes_t pos, void *src, snd_pcm_uframes_t count) snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count)
{ {
rme9652_t *rme9652 = _snd_pcm_substream_chip(substream); rme9652_t *rme9652 = _snd_pcm_substream_chip(substream);
char *channel_buf; char *channel_buf;
...@@ -2028,7 +2028,7 @@ static int snd_rme9652_playback_copy(snd_pcm_substream_t *substream, int channel ...@@ -2028,7 +2028,7 @@ static int snd_rme9652_playback_copy(snd_pcm_substream_t *substream, int channel
} }
static int snd_rme9652_capture_copy(snd_pcm_substream_t *substream, int channel, static int snd_rme9652_capture_copy(snd_pcm_substream_t *substream, int channel,
snd_pcm_uframes_t pos, void *dst, snd_pcm_uframes_t count) snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count)
{ {
rme9652_t *rme9652 = _snd_pcm_substream_chip(substream); rme9652_t *rme9652 = _snd_pcm_substream_chip(substream);
char *channel_buf; char *channel_buf;
......
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