RFC: API Change: Flash #36485


Ermel, Dominik
 

Hello,

 

Within the RFC: https://github.com/zephyrproject-rtos/zephyr/issues/36485 I would like to propose a change,

to the flash API, regarding how the flash page information and size is obtained.

For that purpose I propose definition of following API calls:

int flash_get_page_info(const struct device *dev, off_t offset, struct flash_page_info *fpi);

ssize_t flash_get_page_count(const struct device *dev);

ssize_t flash_get_size(const struct device *dev);

 

and addition of following fields to flash_parameters structure, to store flags and size of the largest page on a device (max_page_size).

I am also adding first flag, FPF_NON_UNIFORM_LAYOUT, that allows to quickly check whether the flash device offers uniform layout.

 

In contrary to the flash_api_pages_layout call, enabled with CONFIG_FLASH_PAGE_LAYOUT, the new additions to the API are always present.

 

These additions allow quicker access to the flash size and the page count, while obtaining page information will depend on whether layout

is uniform or not and on how the driver implements the function.

The change simplifies access to flash information and allows to easily override the calls in “virtual” devices that could be stacked over the other.

 

The proposed change, to the code, is available here:  https://github.com/zephyrproject-rtos/zephyr/pull/36484

 

Here is PR that uses the changes to implement flash partition device, which is “virtual” device, and may be used in any functions that call flash API,

the same way a real device would be used: https://github.com/zephyrproject-rtos/zephyr/pull/36487

 

Best regards,

Dominik Ermel

Dominik ERMEL | Senior Software Engineer
M +48 505 071 130 | Kraków, Poland
nordicsemi.com | devzone.nordicsemi.com

Nordic_logo_signature

 

Join {devel@lists.zephyrproject.org to automatically receive all group messages.