Re: [PATCH] Video/UVC: Fix unaligned exceptions in uvc video driver.

From: Bryan Wu
Date: Sun Nov 09 2008 - 21:08:05 EST


On Sun, Nov 9, 2008 at 8:55 PM, Laurent Pinchart
<laurent.pinchart@xxxxxxxxx> wrote:
> Hi Bryan, Michael,
>
> Thanks for the patch.
>
> On Thursday 06 November 2008, Bryan Wu wrote:
>> From: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
>>
>> buffer can be odd aligned on some NOMMU machine such as Blackfin
>
> The comment is a bit misleading. Buffers can be odd-aligned independently off
> the machine type. The issue comes from machines that can't access unaligned
> memory. Something like "Fix access to unaligned memory" would be better.
>
>> Signed-off-by: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
>> Signed-off-by: Bryan Wu <cooloney@xxxxxxxxxx>
>> ---
>> drivers/media/video/uvc/uvc_driver.c | 37
>> +++++++++++++++++---------------- 1 files changed, 19 insertions(+), 18
>> deletions(-)
>>
>> diff --git a/drivers/media/video/uvc/uvc_driver.c
>> b/drivers/media/video/uvc/uvc_driver.c index d7ad060..9b4f469 100644
>> --- a/drivers/media/video/uvc/uvc_driver.c
>> +++ b/drivers/media/video/uvc/uvc_driver.c
>> @@ -31,6 +31,7 @@
>> #include <linux/videodev2.h>
>> #include <linux/vmalloc.h>
>> #include <linux/wait.h>
>> +#include <asm/unaligned.h>
>> #include <asm/atomic.h>
>>
>> #include <media/v4l2-common.h>
>> @@ -432,20 +433,20 @@ static int uvc_parse_format(struct uvc_device *dev,
>>
>> frame->bFrameIndex = buffer[3];
>> frame->bmCapabilities = buffer[4];
>> - frame->wWidth = le16_to_cpup((__le16 *)&buffer[5]);
>> - frame->wHeight = le16_to_cpup((__le16 *)&buffer[7]);
>> - frame->dwMinBitRate = le32_to_cpup((__le32 *)&buffer[9]);
>> - frame->dwMaxBitRate = le32_to_cpup((__le32 *)&buffer[13]);
>> + frame->wWidth = le16_to_cpu(get_unaligned((__le16 *) &buffer[5]));
>
> What about using get_unaligned_le16 and get_unaligned_le32 directly ? Lines
> would be shorter and could be kept behind the 80 columns limit more easily.
>
> Tell me if you want to resubmit or if I should make the modification myself
> (including the patch description).
>

I guess Michael will update this patch according to you review. Then
we will resubmit it.

Thanks a lot
-Bryan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/