]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
scsi: cxlflash: Fix power-of-two validations
authorMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Fri, 7 Jul 2017 16:05:31 +0000 (13:05 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Fri, 14 Jul 2017 14:33:05 +0000 (11:33 -0300)
BugLink: http://bugs.launchpad.net/bugs/1702521
Validation statements to enforce assumptions about specific defines are not
being evaluated by the compiler due to the fact that they reside in a routine
that is not used. To activate them, call the routine as part of module
initialization. As an additional, related cleanup, remove the now-defunct
CXLFLASH_NUM_CMDS.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit cd41e18daf1a21fea5a195a5a74c97c6b183c15a)
Signed-off-by: Victor Aoqui <victora@linux.vnet.ibm.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
drivers/scsi/cxlflash/common.h
drivers/scsi/cxlflash/main.c

index 17aa74a83d39b1a7163432ee184ad38ee68a2061..455fd4dffac845d5a58a40479875be1b1ef962b1 100644 (file)
@@ -52,12 +52,6 @@ extern const struct file_operations cxlflash_cxl_fops;
                                   certain AFU errors */
 
 /* Command management definitions */
-#define CXLFLASH_NUM_CMDS      (2 * CXLFLASH_MAX_CMDS) /* Must be a pow2 for
-                                                          alignment and more
-                                                          efficient array
-                                                          index derivation
-                                                        */
-
 #define CXLFLASH_MAX_CMDS               256
 #define CXLFLASH_MAX_CMDS_PER_LUN       CXLFLASH_MAX_CMDS
 
@@ -71,6 +65,7 @@ extern const struct file_operations cxlflash_cxl_fops;
 static inline void check_sizes(void)
 {
        BUILD_BUG_ON_NOT_POWER_OF_2(CXLFLASH_NUM_FC_PORTS_PER_BANK);
+       BUILD_BUG_ON_NOT_POWER_OF_2(CXLFLASH_MAX_CMDS);
 }
 
 /* AFU defines a fixed size of 4K for command buffers (borrow 4K page define) */
index 3c4a83307e6e534c230aaabf0ccc1d658d636b9d..f5c952c953f71d007bab8adeb05a744ac5ce88df 100644 (file)
@@ -2847,6 +2847,7 @@ static struct pci_driver cxlflash_driver = {
  */
 static int __init init_cxlflash(void)
 {
+       check_sizes();
        cxlflash_list_init();
 
        return pci_register_driver(&cxlflash_driver);