Skip to content

Conversation

Copy link

Copilot AI commented Dec 1, 2025

API callback structures and USB/DAP descriptors in subsys/ are defined as mutable globals despite containing only function pointers and constant configuration data that never change at runtime.

Changes

Modified 30 files to add static const to 36 struct definitions:

USB device classes (9 files)

  • usbd_class_api structs: mctp_usb, msc, dfu, uac2, hid, loopback, cdc_acm, tracing
  • USB descriptors: dfu_mode_desc, string_descr, func_desc

Backend APIs (8 files)

  • Coredump: logging, in_memory, intel_adsp_mem_window, flash_partition
  • Logging multidomain: log_backend_ipc_service, log_link_ipc_service, log_multidomain_link
  • DAP: dap_func_api + descriptor macro

Bluetooth (8 files)

  • Audio: ascs_iso_ops, broadcast_sink_iso_ops, unicast_client_iso_ops, broadcast_source_iso_ops, bap_stream_ops
  • Classic: goep_rfcomm_ops, bip_rfcomm_ops, bip_l2cap_ops, tg/ct_bip_transport_ops

Other subsystems (5 files)

  • Settings: settings_nvs_itf, settings_zms_itf
  • Filesystem: ffa_op_callbacks
  • Emul: ap_emul_api
  • Network L2: any_api
// Before
struct usbd_class_api mctp_usb_class_api = {
    .request = mctp_usb_class_request,
    .enable = mctp_usb_class_enable,
};

// After
static const struct usbd_class_api mctp_usb_class_api = {
    .request = mctp_usb_class_request,
    .enable = mctp_usb_class_enable,
};

Excluded

Structures with runtime-mutable fields were intentionally not changed:

  • Network packet filter rules (sys_slist nodes, locks)
  • SMP transport (k_work, k_fifo)
  • MCUmgr group registrations (list nodes)
Original prompt

in subsys 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 structs to static const in subsys code Make subsys API/descriptor structs static const to save RAM Dec 1, 2025
Copilot AI requested a review from kartben December 1, 2025 23:29
Copilot finished work on behalf of kartben December 1, 2025 23:29
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