Device driver configuration and driver_data distinction.

Marcus Shawcroft <marcus.shawcroft@...>


The DEVICE_INIT() macro and associated driver framework provides for
each driver instance to have two data structures, the config structure
and the driver_data structure.

Documentation in docs/drivers/drivers.rst indicates that the
configuration structure is for read only, build time configured data,
while the driver_data structure is for dynamic state.

This design make sense from the perspective that the read only config
data *could* be const and placed in flash only, hence lowering
pressure on sram.

However, it is not possible to make a drivers config structure const
because include/device.h defines struct device_config with a non const
*config_info, hence passing a const config structure to DEVICE_INIT()
generates a diagnostic/error.

I can see no obvious reason why we do not define config_info as const
paving the way for device config information to move to flash.

The infrastructure around config_info was landed in:
commit c9ac95a43aa46e0714a8db10d4d8f940c952acaf
Author: Dirk Brandewie <dirk.j.brandewie(a)>

config_info was non const in this original commit.

Can anybody provide insight into why config_info should not be const?
Was this an oversight, or, by design, in the original implementation?


Join to automatically receive all group messages.