From 94199ec22e3e0381b17ac6bc5c2fcffe4db1540a Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Wed, 7 Mar 2007 13:19:49 -0800 Subject: zr364xx: Use kernel's byte-swapping function From: Trent Piepho Some code to swap bytes wasn't using the swab16() function that the kernel provides for this. Make use of it, which results in more efficient code. Signed-off-by: Trent Piepho Acked-by: Antoine Jacquet --- linux/drivers/media/video/zr364xx.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'linux/drivers/media') diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c index 43643ce84..88b1fec85 100644 --- a/linux/drivers/media/video/zr364xx.c +++ b/linux/drivers/media/video/zr364xx.c @@ -282,7 +282,7 @@ static unsigned char header3; static int read_frame(struct zr364xx_camera *cam, int framenum) { int i, n, temp, head, size, actual_length; - unsigned char *ptr = NULL, *jpeg, swap; + unsigned char *ptr = NULL, *jpeg; redo: /* hardware brightness */ @@ -313,12 +313,11 @@ static int read_frame(struct zr364xx_camera *cam, int framenum) } /* swap bytes if camera needs it */ - if (cam->method == METHOD0) - for (i = 0; i < BUFFER_SIZE; i += 2) { - swap = cam->buffer[i]; - cam->buffer[i] = cam->buffer[i + 1]; - cam->buffer[i + 1] = swap; - } + if (cam->method == METHOD0) { + u16 *buf = (u16*)cam->buffer; + for (i = 0; i < BUFFER_SIZE/2; i++) + swab16s(buf + i); + } /* write the JPEG header */ if (!head) { -- cgit v1.2.3