summaryrefslogtreecommitdiff
path: root/drivers/scsi/cxlflash
diff options
context:
space:
mode:
authorMatthew R. Ochs <mrochs@linux.vnet.ibm.com>2017-04-12 22:15:11 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2017-04-14 05:55:41 +0300
commitcd41e18daf1a21fea5a195a5a74c97c6b183c15a (patch)
treee8eea2682d954857e4cba7555d1637a254f9cfbb /drivers/scsi/cxlflash
parent50b787f7235efbd074bbdf4315e0cc261d85b4d7 (diff)
downloadlinux-cd41e18daf1a21fea5a195a5a74c97c6b183c15a.tar.xz
scsi: cxlflash: Fix power-of-two validations
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>
Diffstat (limited to 'drivers/scsi/cxlflash')
-rw-r--r--drivers/scsi/cxlflash/common.h7
-rw-r--r--drivers/scsi/cxlflash/main.c1
2 files changed, 2 insertions, 6 deletions
diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h
index 17aa74a83d39..455fd4dffac8 100644
--- a/drivers/scsi/cxlflash/common.h
+++ b/drivers/scsi/cxlflash/common.h
@@ -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) */
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 3c4a83307e6e..f5c952c953f7 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -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);