X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=drivers%2Fieee1394%2Fvideo1394.c;h=77f58bc831353a048f8c08b1e6193696047a2c5f;hb=edf1fb213e5df03983b91bb050bdd2914465a843;hp=295d0f8c3d061513fbcfc76967deb7e1024626fd;hpb=bbe5d235ee201705530a7153b57e141cd77d818b;p=powerpc.git diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 295d0f8c3d..77f58bc831 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -28,7 +28,6 @@ * ENOTTY for unsupported ioctl request * */ -#include #include #include #include @@ -50,16 +49,16 @@ #include #include -#include "ieee1394.h" -#include "ieee1394_types.h" +#include "dma.h" +#include "highlevel.h" #include "hosts.h" +#include "ieee1394.h" #include "ieee1394_core.h" -#include "highlevel.h" -#include "video1394.h" +#include "ieee1394_hotplug.h" +#include "ieee1394_types.h" #include "nodemgr.h" -#include "dma.h" - #include "ohci1394.h" +#include "video1394.h" #define ISO_CHANNELS 64 @@ -130,7 +129,7 @@ struct file_ctx { #define DBGMSG(card, fmt, args...) \ printk(KERN_INFO "video1394_%d: " fmt "\n" , card , ## args) #else -#define DBGMSG(card, fmt, args...) +#define DBGMSG(card, fmt, args...) do {} while (0) #endif /* print general (card independent) information */ @@ -715,8 +714,8 @@ static inline unsigned video1394_buffer_state(struct dma_iso_ctx *d, return ret; } -static int __video1394_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) +static long video1394_ioctl(struct file *file, + unsigned int cmd, unsigned long arg) { struct file_ctx *ctx = (struct file_ctx *)file->private_data; struct ti_ohci *ohci = ctx->ohci; @@ -885,13 +884,14 @@ static int __video1394_ioctl(struct file *file, struct dma_iso_ctx *d; int next_prg; - if (copy_from_user(&v, argp, sizeof(v))) + if (unlikely(copy_from_user(&v, argp, sizeof(v)))) return -EFAULT; d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); - if (d == NULL) return -EFAULT; + if (unlikely(d == NULL)) + return -EFAULT; - if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) { + if (unlikely((v.buffer<0) || (v.buffer>=d->num_desc - 1))) { PRINT(KERN_ERR, ohci->host->id, "Buffer %d out of range",v.buffer); return -EINVAL; @@ -899,7 +899,7 @@ static int __video1394_ioctl(struct file *file, spin_lock_irqsave(&d->lock,flags); - if (d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED) { + if (unlikely(d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED)) { PRINT(KERN_ERR, ohci->host->id, "Buffer %d is already used",v.buffer); spin_unlock_irqrestore(&d->lock,flags); @@ -950,13 +950,14 @@ static int __video1394_ioctl(struct file *file, struct dma_iso_ctx *d; int i = 0; - if (copy_from_user(&v, argp, sizeof(v))) + if (unlikely(copy_from_user(&v, argp, sizeof(v)))) return -EFAULT; d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); - if (d == NULL) return -EFAULT; + if (unlikely(d == NULL)) + return -EFAULT; - if ((v.buffer<0) || (v.buffer>d->num_desc - 1)) { + if (unlikely((v.buffer<0) || (v.buffer>d->num_desc - 1))) { PRINT(KERN_ERR, ohci->host->id, "Buffer %d out of range",v.buffer); return -EINVAL; @@ -1009,7 +1010,7 @@ static int __video1394_ioctl(struct file *file, spin_unlock_irqrestore(&d->lock, flags); v.buffer=i; - if (copy_to_user(argp, &v, sizeof(v))) + if (unlikely(copy_to_user(argp, &v, sizeof(v)))) return -EFAULT; return 0; @@ -1157,15 +1158,6 @@ static int __video1394_ioctl(struct file *file, } } -static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - int err; - lock_kernel(); - err = __video1394_ioctl(file, cmd, arg); - unlock_kernel(); - return err; -} - /* * This maps the vmalloced and reserved buffer to user space. * @@ -1178,16 +1170,44 @@ static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long a static int video1394_mmap(struct file *file, struct vm_area_struct *vma) { struct file_ctx *ctx = (struct file_ctx *)file->private_data; - int res = -EINVAL; - lock_kernel(); if (ctx->current_ctx == NULL) { - PRINT(KERN_ERR, ctx->ohci->host->id, "Current iso context not set"); - } else - res = dma_region_mmap(&ctx->current_ctx->dma, file, vma); - unlock_kernel(); + PRINT(KERN_ERR, ctx->ohci->host->id, + "Current iso context not set"); + return -EINVAL; + } + + return dma_region_mmap(&ctx->current_ctx->dma, file, vma); +} + +static unsigned int video1394_poll(struct file *file, poll_table *pt) +{ + struct file_ctx *ctx; + unsigned int mask = 0; + unsigned long flags; + struct dma_iso_ctx *d; + int i; + + ctx = file->private_data; + d = ctx->current_ctx; + if (d == NULL) { + PRINT(KERN_ERR, ctx->ohci->host->id, + "Current iso context not set"); + return POLLERR; + } + + poll_wait(file, &d->waitq, pt); + + spin_lock_irqsave(&d->lock, flags); + for (i = 0; i < d->num_desc; i++) { + if (d->buffer_status[i] == VIDEO1394_BUFFER_READY) { + mask |= POLLIN | POLLRDNORM; + break; + } + } + spin_unlock_irqrestore(&d->lock, flags); - return res; + return mask; } static int video1394_open(struct inode *inode, struct file *file) @@ -1221,7 +1241,6 @@ static int video1394_release(struct inode *inode, struct file *file) struct list_head *lh, *next; u64 mask; - lock_kernel(); list_for_each_safe(lh, next, &ctx->context_list) { struct dma_iso_ctx *d; d = list_entry(lh, struct dma_iso_ctx, link); @@ -1242,7 +1261,6 @@ static int video1394_release(struct inode *inode, struct file *file) kfree(ctx); file->private_data = NULL; - unlock_kernel(); return 0; } @@ -1258,6 +1276,7 @@ static struct file_operations video1394_fops= #ifdef CONFIG_COMPAT .compat_ioctl = video1394_compat_ioctl, #endif + .poll = video1394_poll, .mmap = video1394_mmap, .open = video1394_open, .release = video1394_release