diff mbox

sh_mobile_ceu_camera: Add physical address alignment checks V2

Message ID 20091211081006.16358.10589.sendpatchset@rxone.opensource.se (mailing list archive)
State RFC
Headers show

Commit Message

Magnus Damm Dec. 11, 2009, 8:10 a.m. UTC
None
diff mbox

Patch

--- 0010/drivers/media/video/sh_mobile_ceu_camera.c
+++ work/drivers/media/video/sh_mobile_ceu_camera.c	2009-12-11 16:52:19.000000000 +0900
@@ -339,7 +339,7 @@  static int sh_mobile_ceu_videobuf_prepar
 	}
 
 	vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3);
-	if (0 != vb->baddr && vb->bsize < vb->size) {
+	if (0 != vb->baddr && vb->bsize < vb->size && !(vb->width & 3)) {
 		ret = -EINVAL;
 		goto out;
 	}
@@ -348,6 +348,13 @@  static int sh_mobile_ceu_videobuf_prepar
 		ret = videobuf_iolock(vq, vb, NULL);
 		if (ret)
 			goto fail;
+
+		/* the physical address must be 32-bit aligned (USERPTR) */
+		if (videobuf_to_dma_contig(vb) & 3) {
+			ret = -EINVAL;
+			goto fail;
+		}
+
 		vb->state = VIDEOBUF_PREPARED;
 	}