diff options
author | Daniel Drake <ddrake@brontes3d.com> | 2006-10-18 16:37:14 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2006-12-07 15:31:04 -0500 |
commit | 3c21cfc4babaf4d20384f6f70def308e9b945159 (patch) | |
tree | a5bedb18e8df5fd6349f35053d55b3701aa025bf | |
parent | c1c9c7cd9f33ad6ff4407638060fe2730560bd56 (diff) |
video1394: small optimizations to frame retrieval codepath
Add some GCC branch prediction optimizations to unlikely error/safety
conditions in the ioctl handling code commonly called during an application's
capture loop.
Signed-off-by: Daniel Drake <ddrake@brontes3d.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r-- | drivers/ieee1394/video1394.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 9bc65059cc69..776b6618e80e 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c | |||
@@ -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; |