diff mbox

sh_mobile_ceu_camera: Add physical address alignment checks

Message ID 20091209130712.32292.81708.sendpatchset@rxone.opensource.se (mailing list archive)
State Changes Requested
Headers show

Commit Message

Magnus Damm Dec. 9, 2009, 1:07 p.m. UTC
None
diff mbox

Patch

--- 0001/drivers/media/video/sh_mobile_ceu_camera.c
+++ work/drivers/media/video/sh_mobile_ceu_camera.c	2009-12-09 17:16:47.000000000 +0900
@@ -278,9 +278,14 @@  static int sh_mobile_ceu_capture(struct 
 
 	phys_addr_top = videobuf_to_dma_contig(pcdev->active);
 	ceu_write(pcdev, CDAYR, phys_addr_top);
+	if (phys_addr_top & 3)
+		return -EINVAL;
+
 	if (pcdev->is_interlaced) {
 		phys_addr_bottom = phys_addr_top + icd->user_width;
 		ceu_write(pcdev, CDBYR, phys_addr_bottom);
+		if (phys_addr_bottom & 3)
+			return -EINVAL;
 	}
 
 	switch (icd->current_fmt->fourcc) {
@@ -288,13 +293,16 @@  static int sh_mobile_ceu_capture(struct 
 	case V4L2_PIX_FMT_NV21:
 	case V4L2_PIX_FMT_NV16:
 	case V4L2_PIX_FMT_NV61:
-		phys_addr_top += icd->user_width *
-			icd->user_height;
+		phys_addr_top += icd->user_width * icd->user_height;
 		ceu_write(pcdev, CDACR, phys_addr_top);
+		if (phys_addr_top & 3)
+			return -EINVAL;
+
 		if (pcdev->is_interlaced) {
-			phys_addr_bottom = phys_addr_top +
-				icd->user_width;
+			phys_addr_bottom = phys_addr_top + icd->user_width;
 			ceu_write(pcdev, CDBCR, phys_addr_bottom);
+			if (phys_addr_bottom & 3)
+				return -EINVAL;
 		}
 	}