Skip to content

Conversation

Copy link

Copilot AI commented Dec 1, 2025

API structures (function pointer tables) in driver code were unnecessarily consuming RAM. These structures are never modified at runtime and should be stored in ROM/Flash.

Changes

Converted 27 static API structures to static const across 24 driver files:

  • Emulation drivers (mspi, espi, bc12, eeprom, sensors)
  • Network drivers (ethernet, nsos, loopback, canbus)
  • Modem drivers (hl7800, hl78xx, wncm14a2a, ublox-sara-r4, sim7080, quectel-bg9x)
  • Peripheral drivers (spi, watchdog, dp, firmware/scmi)

Example change:

-static struct ethernet_api virtnet_api = {
+static const struct ethernet_api virtnet_api = {
    .iface_api.init = virtnet_if_init,
    .get_capabilities = virtnet_get_capabilities,
    .send = virtnet_send,
};

This aligns with existing patterns where similar API structures are already correctly marked const.

Original prompt

in driver code, look for all structs that should be static const to save ram


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update driver code to use static const for structs drivers: mark static API structures as const to save RAM Dec 1, 2025
Copilot finished work on behalf of kartben December 1, 2025 23:18
Copilot AI requested a review from kartben December 1, 2025 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants