Skip to content

Commit

Permalink
scsi: cxlflash: Fix power-of-two validations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Matthew R. Ochs authored and Martin K. Petersen committed Apr 14, 2017
1 parent 50b787f commit cd41e18
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
7 changes: 1 addition & 6 deletions drivers/scsi/cxlflash/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) */
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/cxlflash/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cd41e18

Please sign in to comment.