Skip to content

Commit 4f01392

Browse files
Matthew MacovskyKyle Kearney
authored andcommitted
Replace power function with bit shift
1 parent 8fd1a50 commit 4f01392

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ enum qspif_default_instructions {
113113
QSPIF_ULBPR = 0x98, // Clears all write-protection bits in the Block-Protection register
114114
};
115115

116-
// Local Function
117-
static int local_math_power(int base, int exp);
118-
119116
// General QSPI instructions
120117
#define QSPIF_INST_WSR1 0x01 // Write status register 1
121118
#define QSPIF_INST_RSR1 0x05 // Read status register 1
@@ -882,7 +879,7 @@ int QSPIFBlockDevice::_sfdp_detect_page_size(uint8_t *basic_param_table_ptr, int
882879
if (basic_param_table_size > QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE) {
883880
// Page Size is specified by 4 Bits (N), calculated by 2^N
884881
int page_to_power_size = ((int)basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE]) >> 4;
885-
page_size = local_math_power(2, page_to_power_size);
882+
page_size = 1 << page_to_power_size;
886883
tr_debug("Detected Page Size: %d", page_size);
887884
} else {
888885
tr_debug("Using Default Page Size: %d", page_size);
@@ -1610,17 +1607,3 @@ qspi_status_t QSPIFBlockDevice::_qspi_write_status_registers(uint8_t *reg_buffer
16101607

16111608
return QSPI_STATUS_OK;
16121609
}
1613-
1614-
/*********************************************/
1615-
/************** Local Functions **************/
1616-
/*********************************************/
1617-
static int local_math_power(int base, int exp)
1618-
{
1619-
// Integer X^Y function, used to calculate size fields given in 2^N format
1620-
int result = 1;
1621-
while (exp) {
1622-
result *= base;
1623-
exp--;
1624-
}
1625-
return result;
1626-
}

0 commit comments

Comments
 (0)