Commit 5a1c7700 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: wavefront annotation

Both ALSA and OSS drivers + wavefront ioctl structure annotated.  NB:
both should be switched to generic firmware loading - as it is, they are
using a homegrown and rather ugly variant
parent 76ae908a
...@@ -554,8 +554,8 @@ typedef struct wf_patch_info { ...@@ -554,8 +554,8 @@ typedef struct wf_patch_info {
WF_{GET,SET}_CHANNEL above. WF_{GET,SET}_CHANNEL above.
*/ */
wavefront_any *hdrptr; /* user-space ptr to hdr bytes */ wavefront_any __user *hdrptr; /* user-space ptr to hdr bytes */
u16 *dataptr; /* actual sample data */ u16 __user *dataptr; /* actual sample data */
wavefront_any hdr; /* kernel-space copy of hdr bytes */ wavefront_any hdr; /* kernel-space copy of hdr bytes */
} wavefront_patch_info; } wavefront_patch_info;
......
...@@ -179,7 +179,7 @@ snd_wavefront_fx_ioctl (snd_hwdep_t *sdev, struct file *file, ...@@ -179,7 +179,7 @@ snd_wavefront_fx_ioctl (snd_hwdep_t *sdev, struct file *file,
acard = card->private_data; acard = card->private_data;
dev = &acard->wavefront; dev = &acard->wavefront;
if (copy_from_user (&r, (unsigned char *) arg, sizeof (wavefront_fx_info))) if (copy_from_user (&r, (void __user *)arg, sizeof (wavefront_fx_info)))
return -EFAULT; return -EFAULT;
switch (r.request) { switch (r.request) {
...@@ -201,7 +201,7 @@ snd_wavefront_fx_ioctl (snd_hwdep_t *sdev, struct file *file, ...@@ -201,7 +201,7 @@ snd_wavefront_fx_ioctl (snd_hwdep_t *sdev, struct file *file,
return -EIO; return -EIO;
} }
if (copy_from_user (page_data, if (copy_from_user (page_data,
(unsigned char *) r.data[3], (unsigned char __user *) r.data[3],
r.data[2])) r.data[2]))
return -EFAULT; return -EFAULT;
pd = page_data; pd = page_data;
......
...@@ -861,7 +861,7 @@ wavefront_freemem (snd_wavefront_t *dev) ...@@ -861,7 +861,7 @@ wavefront_freemem (snd_wavefront_t *dev)
static int static int
wavefront_send_sample (snd_wavefront_t *dev, wavefront_send_sample (snd_wavefront_t *dev,
wavefront_patch_info *header, wavefront_patch_info *header,
u16 *dataptr, u16 __user *dataptr,
int data_is_unsigned) int data_is_unsigned)
{ {
...@@ -876,7 +876,7 @@ wavefront_send_sample (snd_wavefront_t *dev, ...@@ -876,7 +876,7 @@ wavefront_send_sample (snd_wavefront_t *dev,
u16 sample_short; u16 sample_short;
u32 length; u32 length;
u16 *data_end = 0; u16 __user *data_end = 0;
unsigned int i; unsigned int i;
const unsigned int max_blksize = 4096/2; const unsigned int max_blksize = 4096/2;
unsigned int written; unsigned int written;
...@@ -1355,7 +1355,7 @@ wavefront_find_free_patch (snd_wavefront_t *dev) ...@@ -1355,7 +1355,7 @@ wavefront_find_free_patch (snd_wavefront_t *dev)
#endif #endif
static int static int
wavefront_load_patch (snd_wavefront_t *dev, const char *addr) wavefront_load_patch (snd_wavefront_t *dev, const char __user *addr)
{ {
wavefront_patch_info header; wavefront_patch_info header;
...@@ -1377,8 +1377,7 @@ wavefront_load_patch (snd_wavefront_t *dev, const char *addr) ...@@ -1377,8 +1377,7 @@ wavefront_load_patch (snd_wavefront_t *dev, const char *addr)
switch (header.subkey) { switch (header.subkey) {
case WF_ST_SAMPLE: /* sample or sample_header, based on patch->size */ case WF_ST_SAMPLE: /* sample or sample_header, based on patch->size */
if (copy_from_user ((unsigned char *) &header.hdr.s, if (copy_from_user (&header.hdr.s, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_sample))) sizeof (wavefront_sample)))
return -EFAULT; return -EFAULT;
...@@ -1386,8 +1385,7 @@ wavefront_load_patch (snd_wavefront_t *dev, const char *addr) ...@@ -1386,8 +1385,7 @@ wavefront_load_patch (snd_wavefront_t *dev, const char *addr)
case WF_ST_MULTISAMPLE: case WF_ST_MULTISAMPLE:
if (copy_from_user ((unsigned char *) &header.hdr.s, if (copy_from_user (&header.hdr.s, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_multisample))) sizeof (wavefront_multisample)))
return -EFAULT; return -EFAULT;
...@@ -1396,32 +1394,28 @@ wavefront_load_patch (snd_wavefront_t *dev, const char *addr) ...@@ -1396,32 +1394,28 @@ wavefront_load_patch (snd_wavefront_t *dev, const char *addr)
case WF_ST_ALIAS: case WF_ST_ALIAS:
if (copy_from_user ((unsigned char *) &header.hdr.a, if (copy_from_user (&header.hdr.a, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_alias))) sizeof (wavefront_alias)))
return -EFAULT; return -EFAULT;
return wavefront_send_alias (dev, &header); return wavefront_send_alias (dev, &header);
case WF_ST_DRUM: case WF_ST_DRUM:
if (copy_from_user ((unsigned char *) &header.hdr.d, if (copy_from_user (&header.hdr.d, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_drum))) sizeof (wavefront_drum)))
return -EFAULT; return -EFAULT;
return wavefront_send_drum (dev, &header); return wavefront_send_drum (dev, &header);
case WF_ST_PATCH: case WF_ST_PATCH:
if (copy_from_user ((unsigned char *) &header.hdr.p, if (copy_from_user (&header.hdr.p, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_patch))) sizeof (wavefront_patch)))
return -EFAULT; return -EFAULT;
return wavefront_send_patch (dev, &header); return wavefront_send_patch (dev, &header);
case WF_ST_PROGRAM: case WF_ST_PROGRAM:
if (copy_from_user ((unsigned char *) &header.hdr.pr, if (copy_from_user (&header.hdr.pr, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_program))) sizeof (wavefront_program)))
return -EFAULT; return -EFAULT;
...@@ -1627,6 +1621,7 @@ snd_wavefront_synth_ioctl (snd_hwdep_t *hw, struct file *file, ...@@ -1627,6 +1621,7 @@ snd_wavefront_synth_ioctl (snd_hwdep_t *hw, struct file *file,
snd_wavefront_t *dev; snd_wavefront_t *dev;
snd_wavefront_card_t *acard; snd_wavefront_card_t *acard;
wavefront_control wc; wavefront_control wc;
void __user *argp = (void __user *)arg;
card = (snd_card_t *) hw->card; card = (snd_card_t *) hw->card;
...@@ -1639,18 +1634,18 @@ snd_wavefront_synth_ioctl (snd_hwdep_t *hw, struct file *file, ...@@ -1639,18 +1634,18 @@ snd_wavefront_synth_ioctl (snd_hwdep_t *hw, struct file *file,
switch (cmd) { switch (cmd) {
case WFCTL_LOAD_SPP: case WFCTL_LOAD_SPP:
if (wavefront_load_patch (dev, (char *) arg) != 0) { if (wavefront_load_patch (dev, argp) != 0) {
return -EIO; return -EIO;
} }
break; break;
case WFCTL_WFCMD: case WFCTL_WFCMD:
if (copy_from_user (&wc, (void *) arg, sizeof (wc))) if (copy_from_user (&wc, argp, sizeof (wc)))
return -EFAULT; return -EFAULT;
if (wavefront_synth_control (acard, &wc) < 0) { if (wavefront_synth_control (acard, &wc) < 0) {
return -EIO; return -EIO;
} }
if (copy_to_user ((void *) arg, &wc, sizeof (wc))) if (copy_to_user (argp, &wc, sizeof (wc)))
return -EFAULT; return -EFAULT;
break; break;
......
...@@ -1011,7 +1011,7 @@ wavefront_send_sample (wavefront_patch_info *header, ...@@ -1011,7 +1011,7 @@ wavefront_send_sample (wavefront_patch_info *header,
UINT16 sample_short; UINT16 sample_short;
UINT32 length; UINT32 length;
UINT16 *data_end = 0; UINT16 __user *data_end = 0;
unsigned int i; unsigned int i;
const int max_blksize = 4096/2; const int max_blksize = 4096/2;
unsigned int written; unsigned int written;
...@@ -1024,11 +1024,11 @@ wavefront_send_sample (wavefront_patch_info *header, ...@@ -1024,11 +1024,11 @@ wavefront_send_sample (wavefront_patch_info *header,
int initial_skip = 0; int initial_skip = 0;
DPRINT (WF_DEBUG_LOAD_PATCH, "sample %sdownload for slot %d, " DPRINT (WF_DEBUG_LOAD_PATCH, "sample %sdownload for slot %d, "
"type %d, %d bytes from 0x%x\n", "type %d, %d bytes from %p\n",
header->size ? "" : "header ", header->size ? "" : "header ",
header->number, header->subkey, header->number, header->subkey,
header->size, header->size,
(int) header->dataptr); header->dataptr);
if (header->number == WAVEFRONT_FIND_FREE_SAMPLE_SLOT) { if (header->number == WAVEFRONT_FIND_FREE_SAMPLE_SLOT) {
int x; int x;
...@@ -1688,8 +1688,7 @@ wavefront_load_patch (const char __user *addr) ...@@ -1688,8 +1688,7 @@ wavefront_load_patch (const char __user *addr)
case WF_ST_MULTISAMPLE: case WF_ST_MULTISAMPLE:
if (copy_from_user((unsigned char *) &header.hdr.s, if (copy_from_user(&header.hdr.s, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof(wavefront_multisample))) sizeof(wavefront_multisample)))
return -EFAULT; return -EFAULT;
...@@ -1698,32 +1697,28 @@ wavefront_load_patch (const char __user *addr) ...@@ -1698,32 +1697,28 @@ wavefront_load_patch (const char __user *addr)
case WF_ST_ALIAS: case WF_ST_ALIAS:
if (copy_from_user((unsigned char *) &header.hdr.a, if (copy_from_user(&header.hdr.a, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_alias))) sizeof (wavefront_alias)))
return -EFAULT; return -EFAULT;
return wavefront_send_alias (&header); return wavefront_send_alias (&header);
case WF_ST_DRUM: case WF_ST_DRUM:
if (copy_from_user((unsigned char *) &header.hdr.d, if (copy_from_user(&header.hdr.d, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_drum))) sizeof (wavefront_drum)))
return -EFAULT; return -EFAULT;
return wavefront_send_drum (&header); return wavefront_send_drum (&header);
case WF_ST_PATCH: case WF_ST_PATCH:
if (copy_from_user((unsigned char *) &header.hdr.p, if (copy_from_user(&header.hdr.p, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_patch))) sizeof (wavefront_patch)))
return -EFAULT; return -EFAULT;
return wavefront_send_patch (&header); return wavefront_send_patch (&header);
case WF_ST_PROGRAM: case WF_ST_PROGRAM:
if (copy_from_user((unsigned char *) &header.hdr.pr, if (copy_from_user(&header.hdr.pr, header.hdrptr,
(unsigned char *) header.hdrptr,
sizeof (wavefront_program))) sizeof (wavefront_program)))
return -EFAULT; return -EFAULT;
...@@ -3002,7 +2997,7 @@ wffx_ioctl (wavefront_fx_info *r) ...@@ -3002,7 +2997,7 @@ wffx_ioctl (wavefront_fx_info *r)
return -(EINVAL); return -(EINVAL);
} }
if (copy_from_user(page_data, if (copy_from_user(page_data,
(unsigned char *)r->data[3], (unsigned char __user *)r->data[3],
r->data[2])) r->data[2]))
return -EFAULT; return -EFAULT;
pd = page_data; pd = page_data;
......
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