host: libbladeRF: Replace BLADERF_FLASH_NUM_PAGES
The BLADERF_FLASH_NUM_PAGES macro was replaced with data from the device's flash architecture structure (e.g. dev->flash_arch->num_pages). Functions with new parameters include: - spi_flash.c: check_page_access() - bladeRF device handle
This commit is contained in:
parent
03edb51ee4
commit
bc06d86ea3
2 changed files with 7 additions and 10 deletions
|
|
@ -110,10 +110,6 @@
|
|||
/** SPI flash 64KiB erase block size, in bytes */
|
||||
#define BLADERF_FLASH_EB_SIZE (64 * 1024)
|
||||
|
||||
/** Size of the SPI flash, in pages */
|
||||
#define BLADERF_FLASH_NUM_PAGES \
|
||||
(BLADERF_FLASH_TOTAL_SIZE / BLADERF_FLASH_PAGE_SIZE)
|
||||
|
||||
/** Size of the SPI flash, in 64KiB erase blocks */
|
||||
#define BLADERF_FLASH_NUM_EBS (BLADERF_FLASH_TOTAL_SIZE / BLADERF_FLASH_EB_SIZE)
|
||||
|
||||
|
|
|
|||
|
|
@ -49,15 +49,16 @@ static inline int check_eb_access(uint32_t erase_block, uint32_t count)
|
|||
}
|
||||
}
|
||||
|
||||
static inline int check_page_access(uint32_t page, uint32_t count)
|
||||
static inline int check_page_access(struct bladerf *dev,
|
||||
uint32_t page, uint32_t count)
|
||||
{
|
||||
if (page >= BLADERF_FLASH_NUM_PAGES) {
|
||||
if (page >= dev->flash_arch->num_pages) {
|
||||
log_debug("Invalid page: %u\n", page);
|
||||
return BLADERF_ERR_INVAL;
|
||||
} else if (count > BLADERF_FLASH_NUM_PAGES) {
|
||||
} else if (count > dev->flash_arch->num_pages) {
|
||||
log_debug("Invalid number of pages: %u\n", count);
|
||||
return BLADERF_ERR_INVAL;
|
||||
} else if ((page + count) > BLADERF_FLASH_NUM_PAGES) {
|
||||
} else if ((page + count) > dev->flash_arch->num_pages) {
|
||||
log_debug("Requested operation extends past end of flash: "
|
||||
"page=%u, count=%u\n", page, count);
|
||||
return BLADERF_ERR_INVAL;
|
||||
|
|
@ -80,7 +81,7 @@ int spi_flash_erase(struct bladerf *dev, uint32_t erase_block, uint32_t count)
|
|||
int spi_flash_read(struct bladerf *dev, uint8_t *buf,
|
||||
uint32_t page, uint32_t count)
|
||||
{
|
||||
int status = check_page_access(page, count);
|
||||
int status = check_page_access(dev, page, count);
|
||||
|
||||
if (status == 0) {
|
||||
status = dev->backend->read_flash_pages(dev, buf, page, count);
|
||||
|
|
@ -92,7 +93,7 @@ int spi_flash_read(struct bladerf *dev, uint8_t *buf,
|
|||
int spi_flash_write(struct bladerf *dev, const uint8_t *buf,
|
||||
uint32_t page, uint32_t count)
|
||||
{
|
||||
int status = check_page_access(page, count);
|
||||
int status = check_page_access(dev, page, count);
|
||||
|
||||
if (status == 0) {
|
||||
status = dev->backend->write_flash_pages(dev, buf, page, count);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue