cciss: add BUILD_BUG_ON() for catching bad CommandList_struct alignment
authorJens Axboe <jens.axboe@oracle.com>
Fri, 27 Feb 2009 19:14:20 +0000 (20:14 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 24 Mar 2009 11:35:16 +0000 (12:35 +0100)
The hardware requires 64-bit alignment of commands, so add a build bug
check for that. The recent commit 8a3173de4ab4cdacc43675dc5c077f9a5bf17f5f
didn't change the size of the command, but other additions/changes may and
thus break badly at runtime.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
drivers/block/cciss.c

index 4f9b6d7..5d0e135 100644 (file)
@@ -3898,6 +3898,13 @@ static struct pci_driver cciss_pci_driver = {
  */
 static int __init cciss_init(void)
 {
+       /*
+        * The hardware requires that commands are aligned on a 64-bit
+        * boundary. Given that we use pci_alloc_consistent() to allocate an
+        * array of them, the size must be a multiple of 8 bytes.
+        */
+       BUILD_BUG_ON(sizeof(CommandList_struct) % 8);
+
        printk(KERN_INFO DRIVER_NAME "\n");
 
        /* Register for our PCI devices */