diff options
author | Dan Carpenter <error27@gmail.com> | 2010-10-20 02:58:30 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-11-09 16:31:49 -0500 |
commit | 4fc718a4b0cdf3803f370e323ea5252a3d76f52d (patch) | |
tree | 89cc20c45beb0359f09a894d32971bbfc6f172aa | |
parent | 08da782b1a58fd63199928176909e103477c933a (diff) |
Staging: sst: add some __user anotations
This silences all the sparse warnings in intel_sst_app_interface.c.
It was just a matter of adding __user annotations, I didn't find any
real bugs here. Quite a few of these were needed for stuff I added
earlier, sorry about that.
I removed a couple casts to (void *) that caused a warning like:
drivers/staging/intel_sst/intel_sst_app_interface.c:606:27:
warning: cast removes address space of expression
For example sst_drv_ctx->mailbox is already declared as
"void __iomem *mailbox" so casting it to void pointer isn't necessary
and it makes sparse complain because it removes the __user attribute.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/intel_sst/intel_sst_app_interface.c | 36 | ||||
-rw-r--r-- | drivers/staging/intel_sst/intel_sst_common.h | 4 |
2 files changed, 18 insertions, 22 deletions
diff --git a/drivers/staging/intel_sst/intel_sst_app_interface.c b/drivers/staging/intel_sst/intel_sst_app_interface.c index 834bb617524b..9618c7997461 100644 --- a/drivers/staging/intel_sst/intel_sst_app_interface.c +++ b/drivers/staging/intel_sst/intel_sst_app_interface.c | |||
@@ -392,7 +392,7 @@ static int snd_sst_fill_kernel_list(struct stream_info *stream, | |||
392 | { | 392 | { |
393 | struct sst_stream_bufs *stream_bufs; | 393 | struct sst_stream_bufs *stream_bufs; |
394 | unsigned long index, mmap_len; | 394 | unsigned long index, mmap_len; |
395 | unsigned char *bufp; | 395 | unsigned char __user *bufp; |
396 | unsigned long size, copied_size; | 396 | unsigned long size, copied_size; |
397 | int retval = 0, add_to_list = 0; | 397 | int retval = 0, add_to_list = 0; |
398 | static int sent_offset; | 398 | static int sent_offset; |
@@ -527,9 +527,7 @@ static int snd_sst_copy_userbuf_capture(struct stream_info *stream, | |||
527 | /* copy to user */ | 527 | /* copy to user */ |
528 | list_for_each_entry_safe(entry, _entry, | 528 | list_for_each_entry_safe(entry, _entry, |
529 | copy_to_list, node) { | 529 | copy_to_list, node) { |
530 | if (copy_to_user((void *) | 530 | if (copy_to_user(iovec[entry->iov_index].iov_base + entry->iov_offset, |
531 | iovec[entry->iov_index].iov_base + | ||
532 | entry->iov_offset, | ||
533 | kbufs->addr + entry->offset, | 531 | kbufs->addr + entry->offset, |
534 | entry->size)) { | 532 | entry->size)) { |
535 | /* Clean up the list and return error */ | 533 | /* Clean up the list and return error */ |
@@ -605,7 +603,7 @@ static int intel_sst_read_write(unsigned int str_id, char __user *buf, | |||
605 | buf, (int) count, (int) stream->status); | 603 | buf, (int) count, (int) stream->status); |
606 | 604 | ||
607 | stream->buf_type = SST_BUF_USER_STATIC; | 605 | stream->buf_type = SST_BUF_USER_STATIC; |
608 | iovec.iov_base = (void *)buf; | 606 | iovec.iov_base = buf; |
609 | iovec.iov_len = count; | 607 | iovec.iov_len = count; |
610 | nr_segs = 1; | 608 | nr_segs = 1; |
611 | 609 | ||
@@ -878,7 +876,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
878 | data->str_id = retval; | 876 | data->str_id = retval; |
879 | str_info = &sst_drv_ctx->streams[retval]; | 877 | str_info = &sst_drv_ctx->streams[retval]; |
880 | str_info->src = SST_DRV; | 878 | str_info->src = SST_DRV; |
881 | dest = (char *)arg + offsetof(struct snd_sst_params, stream_id); | 879 | dest = (char __user *)arg + offsetof(struct snd_sst_params, stream_id); |
882 | retval = copy_to_user(dest, &retval, sizeof(__u32)); | 880 | retval = copy_to_user(dest, &retval, sizeof(__u32)); |
883 | if (retval) | 881 | if (retval) |
884 | retval = -EFAULT; | 882 | retval = -EFAULT; |
@@ -947,7 +945,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
947 | pr_debug("sst: id:%d\n, vol:%d, ramp_dur:%d, ramp_type:%d\n", | 945 | pr_debug("sst: id:%d\n, vol:%d, ramp_dur:%d, ramp_type:%d\n", |
948 | get_vol.stream_id, get_vol.volume, | 946 | get_vol.stream_id, get_vol.volume, |
949 | get_vol.ramp_duration, get_vol.ramp_type); | 947 | get_vol.ramp_duration, get_vol.ramp_type); |
950 | if (copy_to_user((struct snd_sst_vol *)arg, | 948 | if (copy_to_user((struct snd_sst_vol __user *)arg, |
951 | &get_vol, sizeof(get_vol))) { | 949 | &get_vol, sizeof(get_vol))) { |
952 | retval = -EFAULT; | 950 | retval = -EFAULT; |
953 | break; | 951 | break; |
@@ -987,7 +985,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
987 | retval = -EIO; | 985 | retval = -EIO; |
988 | break; | 986 | break; |
989 | } | 987 | } |
990 | if (copy_to_user((struct snd_sst_get_stream_params *)arg, | 988 | if (copy_to_user((struct snd_sst_get_stream_params __user *)arg, |
991 | &get_params, sizeof(get_params))) { | 989 | &get_params, sizeof(get_params))) { |
992 | retval = -EFAULT; | 990 | retval = -EFAULT; |
993 | break; | 991 | break; |
@@ -1032,8 +1030,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
1032 | break; | 1030 | break; |
1033 | } | 1031 | } |
1034 | memcpy_fromio(&tstamp, | 1032 | memcpy_fromio(&tstamp, |
1035 | ((void *)(sst_drv_ctx->mailbox + SST_TIME_STAMP) | 1033 | sst_drv_ctx->mailbox + SST_TIME_STAMP + str_id * sizeof(tstamp), |
1036 | +(str_id * sizeof(tstamp))), | ||
1037 | sizeof(tstamp)); | 1034 | sizeof(tstamp)); |
1038 | time = tstamp.samples_rendered; | 1035 | time = tstamp.samples_rendered; |
1039 | freq = (unsigned long long) tstamp.sampling_frequency; | 1036 | freq = (unsigned long long) tstamp.sampling_frequency; |
@@ -1141,11 +1138,11 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
1141 | dbufs_local.output_bytes_produced = | 1138 | dbufs_local.output_bytes_produced = |
1142 | param.output_bytes_produced; | 1139 | param.output_bytes_produced; |
1143 | 1140 | ||
1144 | if (copy_from_user(&ibufs, param.ibufs, sizeof(ibufs))) { | 1141 | if (copy_from_user(&ibufs, (void __user *)param.ibufs, sizeof(ibufs))) { |
1145 | retval = -EFAULT; | 1142 | retval = -EFAULT; |
1146 | break; | 1143 | break; |
1147 | } | 1144 | } |
1148 | if (copy_from_user(&obufs, param.obufs, sizeof(obufs))) { | 1145 | if (copy_from_user(&obufs, (void __user *)param.obufs, sizeof(obufs))) { |
1149 | retval = -EFAULT; | 1146 | retval = -EFAULT; |
1150 | break; | 1147 | break; |
1151 | } | 1148 | } |
@@ -1157,7 +1154,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
1157 | goto free_iobufs; | 1154 | goto free_iobufs; |
1158 | } | 1155 | } |
1159 | 1156 | ||
1160 | if (copy_from_user(ibuf_tmp, ibufs.buff_entry, | 1157 | if (copy_from_user(ibuf_tmp, (void __user *)ibufs.buff_entry, |
1161 | ibufs.entries * sizeof(*ibuf_tmp))) { | 1158 | ibufs.entries * sizeof(*ibuf_tmp))) { |
1162 | retval = -EFAULT; | 1159 | retval = -EFAULT; |
1163 | goto free_iobufs; | 1160 | goto free_iobufs; |
@@ -1165,7 +1162,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
1165 | ibufs.buff_entry = ibuf_tmp; | 1162 | ibufs.buff_entry = ibuf_tmp; |
1166 | dbufs_local.ibufs = &ibufs; | 1163 | dbufs_local.ibufs = &ibufs; |
1167 | 1164 | ||
1168 | if (copy_from_user(obuf_tmp, obufs.buff_entry, | 1165 | if (copy_from_user(obuf_tmp, (void __user *)obufs.buff_entry, |
1169 | obufs.entries * sizeof(*obuf_tmp))) { | 1166 | obufs.entries * sizeof(*obuf_tmp))) { |
1170 | retval = -EFAULT; | 1167 | retval = -EFAULT; |
1171 | goto free_iobufs; | 1168 | goto free_iobufs; |
@@ -1179,7 +1176,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
1179 | goto free_iobufs; | 1176 | goto free_iobufs; |
1180 | } | 1177 | } |
1181 | 1178 | ||
1182 | dest = (char *)arg + offsetof(struct snd_sst_dbufs, input_bytes_consumed); | 1179 | dest = (char __user *)arg + offsetof(struct snd_sst_dbufs, input_bytes_consumed); |
1183 | if (copy_to_user(dest, | 1180 | if (copy_to_user(dest, |
1184 | &dbufs_local.input_bytes_consumed, | 1181 | &dbufs_local.input_bytes_consumed, |
1185 | sizeof(unsigned long long))) { | 1182 | sizeof(unsigned long long))) { |
@@ -1187,7 +1184,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) | |||
1187 | goto free_iobufs; | 1184 | goto free_iobufs; |
1188 | } | 1185 | } |
1189 | 1186 | ||
1190 | dest = (char *)arg + offsetof(struct snd_sst_dbufs, input_bytes_consumed); | 1187 | dest = (char __user *)arg + offsetof(struct snd_sst_dbufs, input_bytes_consumed); |
1191 | if (copy_to_user(dest, | 1188 | if (copy_to_user(dest, |
1192 | &dbufs_local.output_bytes_produced, | 1189 | &dbufs_local.output_bytes_produced, |
1193 | sizeof(unsigned long long))) { | 1190 | sizeof(unsigned long long))) { |
@@ -1210,7 +1207,7 @@ free_iobufs: | |||
1210 | break; | 1207 | break; |
1211 | 1208 | ||
1212 | case _IOC_NR(SNDRV_SST_STREAM_BYTES_DECODED): { | 1209 | case _IOC_NR(SNDRV_SST_STREAM_BYTES_DECODED): { |
1213 | unsigned long long *bytes = (unsigned long long *)arg; | 1210 | unsigned long long __user *bytes = (unsigned long long __user *)arg; |
1214 | struct snd_sst_tstamp tstamp = {0}; | 1211 | struct snd_sst_tstamp tstamp = {0}; |
1215 | 1212 | ||
1216 | pr_debug("sst: STREAM_BYTES_DECODED recieved!\n"); | 1213 | pr_debug("sst: STREAM_BYTES_DECODED recieved!\n"); |
@@ -1219,8 +1216,7 @@ free_iobufs: | |||
1219 | break; | 1216 | break; |
1220 | } | 1217 | } |
1221 | memcpy_fromio(&tstamp, | 1218 | memcpy_fromio(&tstamp, |
1222 | ((void *)(sst_drv_ctx->mailbox + SST_TIME_STAMP) | 1219 | sst_drv_ctx->mailbox + SST_TIME_STAMP + str_id * sizeof(tstamp), |
1223 | +(str_id * sizeof(tstamp))), | ||
1224 | sizeof(tstamp)); | 1220 | sizeof(tstamp)); |
1225 | if (copy_to_user(bytes, &tstamp.bytes_processed, | 1221 | if (copy_to_user(bytes, &tstamp.bytes_processed, |
1226 | sizeof(*bytes))) | 1222 | sizeof(*bytes))) |
@@ -1243,7 +1239,7 @@ free_iobufs: | |||
1243 | kfree(fw_info); | 1239 | kfree(fw_info); |
1244 | break; | 1240 | break; |
1245 | } | 1241 | } |
1246 | if (copy_to_user((struct snd_sst_dbufs *)arg, | 1242 | if (copy_to_user((struct snd_sst_dbufs __user *)arg, |
1247 | fw_info, sizeof(*fw_info))) { | 1243 | fw_info, sizeof(*fw_info))) { |
1248 | kfree(fw_info); | 1244 | kfree(fw_info); |
1249 | retval = -EFAULT; | 1245 | retval = -EFAULT; |
diff --git a/drivers/staging/intel_sst/intel_sst_common.h b/drivers/staging/intel_sst/intel_sst_common.h index 73a98c851e4a..bf0ead78bfae 100644 --- a/drivers/staging/intel_sst/intel_sst_common.h +++ b/drivers/staging/intel_sst/intel_sst_common.h | |||
@@ -231,8 +231,8 @@ struct stream_info { | |||
231 | spinlock_t pcm_lock; | 231 | spinlock_t pcm_lock; |
232 | bool mmapped; | 232 | bool mmapped; |
233 | unsigned int sg_index; /* current buf Index */ | 233 | unsigned int sg_index; /* current buf Index */ |
234 | unsigned char *cur_ptr; /* Current static bufs */ | 234 | unsigned char __user *cur_ptr; /* Current static bufs */ |
235 | struct snd_sst_buf_entry *buf_entry; | 235 | struct snd_sst_buf_entry __user *buf_entry; |
236 | struct sst_block data_blk; /* stream ops block */ | 236 | struct sst_block data_blk; /* stream ops block */ |
237 | struct sst_block ctrl_blk; /* stream control cmd block */ | 237 | struct sst_block ctrl_blk; /* stream control cmd block */ |
238 | enum snd_sst_buf_type buf_type; | 238 | enum snd_sst_buf_type buf_type; |