diff options
Diffstat (limited to 'drivers/ieee1394/video1394.c')
-rw-r--r-- | drivers/ieee1394/video1394.c | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 9bc65059cc69..598b19fc5989 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c | |||
@@ -714,8 +714,8 @@ static inline unsigned video1394_buffer_state(struct dma_iso_ctx *d, | |||
714 | return ret; | 714 | return ret; |
715 | } | 715 | } |
716 | 716 | ||
717 | static int __video1394_ioctl(struct file *file, | 717 | static long video1394_ioctl(struct file *file, |
718 | unsigned int cmd, unsigned long arg) | 718 | unsigned int cmd, unsigned long arg) |
719 | { | 719 | { |
720 | struct file_ctx *ctx = (struct file_ctx *)file->private_data; | 720 | struct file_ctx *ctx = (struct file_ctx *)file->private_data; |
721 | struct ti_ohci *ohci = ctx->ohci; | 721 | struct ti_ohci *ohci = ctx->ohci; |
@@ -884,13 +884,14 @@ static int __video1394_ioctl(struct file *file, | |||
884 | struct dma_iso_ctx *d; | 884 | struct dma_iso_ctx *d; |
885 | int next_prg; | 885 | int next_prg; |
886 | 886 | ||
887 | if (copy_from_user(&v, argp, sizeof(v))) | 887 | if (unlikely(copy_from_user(&v, argp, sizeof(v)))) |
888 | return -EFAULT; | 888 | return -EFAULT; |
889 | 889 | ||
890 | d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); | 890 | d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); |
891 | if (d == NULL) return -EFAULT; | 891 | if (unlikely(d == NULL)) |
892 | return -EFAULT; | ||
892 | 893 | ||
893 | if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) { | 894 | if (unlikely((v.buffer<0) || (v.buffer>=d->num_desc - 1))) { |
894 | PRINT(KERN_ERR, ohci->host->id, | 895 | PRINT(KERN_ERR, ohci->host->id, |
895 | "Buffer %d out of range",v.buffer); | 896 | "Buffer %d out of range",v.buffer); |
896 | return -EINVAL; | 897 | return -EINVAL; |
@@ -898,7 +899,7 @@ static int __video1394_ioctl(struct file *file, | |||
898 | 899 | ||
899 | spin_lock_irqsave(&d->lock,flags); | 900 | spin_lock_irqsave(&d->lock,flags); |
900 | 901 | ||
901 | if (d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED) { | 902 | if (unlikely(d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED)) { |
902 | PRINT(KERN_ERR, ohci->host->id, | 903 | PRINT(KERN_ERR, ohci->host->id, |
903 | "Buffer %d is already used",v.buffer); | 904 | "Buffer %d is already used",v.buffer); |
904 | spin_unlock_irqrestore(&d->lock,flags); | 905 | spin_unlock_irqrestore(&d->lock,flags); |
@@ -949,13 +950,14 @@ static int __video1394_ioctl(struct file *file, | |||
949 | struct dma_iso_ctx *d; | 950 | struct dma_iso_ctx *d; |
950 | int i = 0; | 951 | int i = 0; |
951 | 952 | ||
952 | if (copy_from_user(&v, argp, sizeof(v))) | 953 | if (unlikely(copy_from_user(&v, argp, sizeof(v)))) |
953 | return -EFAULT; | 954 | return -EFAULT; |
954 | 955 | ||
955 | d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); | 956 | d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); |
956 | if (d == NULL) return -EFAULT; | 957 | if (unlikely(d == NULL)) |
958 | return -EFAULT; | ||
957 | 959 | ||
958 | if ((v.buffer<0) || (v.buffer>d->num_desc - 1)) { | 960 | if (unlikely((v.buffer<0) || (v.buffer>d->num_desc - 1))) { |
959 | PRINT(KERN_ERR, ohci->host->id, | 961 | PRINT(KERN_ERR, ohci->host->id, |
960 | "Buffer %d out of range",v.buffer); | 962 | "Buffer %d out of range",v.buffer); |
961 | return -EINVAL; | 963 | return -EINVAL; |
@@ -1008,7 +1010,7 @@ static int __video1394_ioctl(struct file *file, | |||
1008 | spin_unlock_irqrestore(&d->lock, flags); | 1010 | spin_unlock_irqrestore(&d->lock, flags); |
1009 | 1011 | ||
1010 | v.buffer=i; | 1012 | v.buffer=i; |
1011 | if (copy_to_user(argp, &v, sizeof(v))) | 1013 | if (unlikely(copy_to_user(argp, &v, sizeof(v)))) |
1012 | return -EFAULT; | 1014 | return -EFAULT; |
1013 | 1015 | ||
1014 | return 0; | 1016 | return 0; |
@@ -1156,15 +1158,6 @@ static int __video1394_ioctl(struct file *file, | |||
1156 | } | 1158 | } |
1157 | } | 1159 | } |
1158 | 1160 | ||
1159 | static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
1160 | { | ||
1161 | int err; | ||
1162 | lock_kernel(); | ||
1163 | err = __video1394_ioctl(file, cmd, arg); | ||
1164 | unlock_kernel(); | ||
1165 | return err; | ||
1166 | } | ||
1167 | |||
1168 | /* | 1161 | /* |
1169 | * This maps the vmalloced and reserved buffer to user space. | 1162 | * This maps the vmalloced and reserved buffer to user space. |
1170 | * | 1163 | * |
@@ -1177,17 +1170,14 @@ static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long a | |||
1177 | static int video1394_mmap(struct file *file, struct vm_area_struct *vma) | 1170 | static int video1394_mmap(struct file *file, struct vm_area_struct *vma) |
1178 | { | 1171 | { |
1179 | struct file_ctx *ctx = (struct file_ctx *)file->private_data; | 1172 | struct file_ctx *ctx = (struct file_ctx *)file->private_data; |
1180 | int res = -EINVAL; | ||
1181 | 1173 | ||
1182 | lock_kernel(); | ||
1183 | if (ctx->current_ctx == NULL) { | 1174 | if (ctx->current_ctx == NULL) { |
1184 | PRINT(KERN_ERR, ctx->ohci->host->id, | 1175 | PRINT(KERN_ERR, ctx->ohci->host->id, |
1185 | "Current iso context not set"); | 1176 | "Current iso context not set"); |
1186 | } else | 1177 | return -EINVAL; |
1187 | res = dma_region_mmap(&ctx->current_ctx->dma, file, vma); | 1178 | } |
1188 | unlock_kernel(); | ||
1189 | 1179 | ||
1190 | return res; | 1180 | return dma_region_mmap(&ctx->current_ctx->dma, file, vma); |
1191 | } | 1181 | } |
1192 | 1182 | ||
1193 | static unsigned int video1394_poll(struct file *file, poll_table *pt) | 1183 | static unsigned int video1394_poll(struct file *file, poll_table *pt) |
@@ -1198,14 +1188,12 @@ static unsigned int video1394_poll(struct file *file, poll_table *pt) | |||
1198 | struct dma_iso_ctx *d; | 1188 | struct dma_iso_ctx *d; |
1199 | int i; | 1189 | int i; |
1200 | 1190 | ||
1201 | lock_kernel(); | ||
1202 | ctx = file->private_data; | 1191 | ctx = file->private_data; |
1203 | d = ctx->current_ctx; | 1192 | d = ctx->current_ctx; |
1204 | if (d == NULL) { | 1193 | if (d == NULL) { |
1205 | PRINT(KERN_ERR, ctx->ohci->host->id, | 1194 | PRINT(KERN_ERR, ctx->ohci->host->id, |
1206 | "Current iso context not set"); | 1195 | "Current iso context not set"); |
1207 | mask = POLLERR; | 1196 | return POLLERR; |
1208 | goto done; | ||
1209 | } | 1197 | } |
1210 | 1198 | ||
1211 | poll_wait(file, &d->waitq, pt); | 1199 | poll_wait(file, &d->waitq, pt); |
@@ -1218,8 +1206,6 @@ static unsigned int video1394_poll(struct file *file, poll_table *pt) | |||
1218 | } | 1206 | } |
1219 | } | 1207 | } |
1220 | spin_unlock_irqrestore(&d->lock, flags); | 1208 | spin_unlock_irqrestore(&d->lock, flags); |
1221 | done: | ||
1222 | unlock_kernel(); | ||
1223 | 1209 | ||
1224 | return mask; | 1210 | return mask; |
1225 | } | 1211 | } |
@@ -1255,7 +1241,6 @@ static int video1394_release(struct inode *inode, struct file *file) | |||
1255 | struct list_head *lh, *next; | 1241 | struct list_head *lh, *next; |
1256 | u64 mask; | 1242 | u64 mask; |
1257 | 1243 | ||
1258 | lock_kernel(); | ||
1259 | list_for_each_safe(lh, next, &ctx->context_list) { | 1244 | list_for_each_safe(lh, next, &ctx->context_list) { |
1260 | struct dma_iso_ctx *d; | 1245 | struct dma_iso_ctx *d; |
1261 | d = list_entry(lh, struct dma_iso_ctx, link); | 1246 | d = list_entry(lh, struct dma_iso_ctx, link); |
@@ -1276,7 +1261,6 @@ static int video1394_release(struct inode *inode, struct file *file) | |||
1276 | kfree(ctx); | 1261 | kfree(ctx); |
1277 | file->private_data = NULL; | 1262 | file->private_data = NULL; |
1278 | 1263 | ||
1279 | unlock_kernel(); | ||
1280 | return 0; | 1264 | return 0; |
1281 | } | 1265 | } |
1282 | 1266 | ||
@@ -1324,12 +1308,8 @@ static struct ieee1394_device_id video1394_id_table[] = { | |||
1324 | MODULE_DEVICE_TABLE(ieee1394, video1394_id_table); | 1308 | MODULE_DEVICE_TABLE(ieee1394, video1394_id_table); |
1325 | 1309 | ||
1326 | static struct hpsb_protocol_driver video1394_driver = { | 1310 | static struct hpsb_protocol_driver video1394_driver = { |
1327 | .name = "1394 Digital Camera Driver", | 1311 | .name = VIDEO1394_DRIVER_NAME, |
1328 | .id_table = video1394_id_table, | 1312 | .id_table = video1394_id_table, |
1329 | .driver = { | ||
1330 | .name = VIDEO1394_DRIVER_NAME, | ||
1331 | .bus = &ieee1394_bus_type, | ||
1332 | }, | ||
1333 | }; | 1313 | }; |
1334 | 1314 | ||
1335 | 1315 | ||