Skip to content

Commit 15fb7bb

Browse files
committed
drivers: Migrate leftover driver APIs to DEVICE_API
Upstream Zephyr (zephyrproject-rtos/zephyr#103802) moved device API structs into per-class iterable linker sections and made DEVICE_API_GET() assert that dev->api points inside the section for the requested API class. Any driver still declaring its API as a plain "static const struct <class>_driver_api" leaves the struct outside that section, so the newly added assert fires at runtime on the first subsystem call against the device. Declare the remaining sdk-nrf driver APIs with DEVICE_API() so their structs land in the correct iterable section: - bluetooth: controller: SoftDevice Controller HCI driver (bt_hci) - drivers: serial: uart_ipc (uart) - drivers: sensor: pmw3360, paw3212, bme68x_iaq, bh1749 (sensor) - drivers: gpio: gpio_hpf (gpio) - drivers: flash: flash_rpc controller (flash) - drivers: entropy: entropy_cc3xx (entropy) - subsys: uart_async_adapter (uart) Assisted-by: Cursor:Claude Opus 4.8 Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent 1095cb4 commit 15fb7bb

10 files changed

Lines changed: 10 additions & 10 deletions

File tree

drivers/entropy/entropy_cc3xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int entropy_cc3xx_rng_init(const struct device *dev)
8181
return 0;
8282
}
8383

84-
static const struct entropy_driver_api entropy_cc3xx_rng_api = {
84+
static DEVICE_API(entropy, entropy_cc3xx_rng_api) = {
8585
.get_entropy = entropy_cc3xx_rng_get_entropy
8686
};
8787

drivers/flash/flash_rpc/flash_rpc_controller.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static void flash_rpc_page_layout(const struct device *dev,
219219
}
220220
#endif
221221

222-
static const struct flash_driver_api flash_driver_rpc_api = {
222+
static DEVICE_API(flash, flash_driver_rpc_api) = {
223223
.read = flash_rpc_read,
224224
.write = flash_rpc_write,
225225
.erase = flash_rpc_erase,

drivers/gpio/gpio_hpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int gpio_hpf_port_toggle_bits(const struct device *port, gpio_port_pins_t
7474
return gpio_send(&msg);
7575
}
7676

77-
static const struct gpio_driver_api gpio_hpf_drv_api_funcs = {
77+
static DEVICE_API(gpio, gpio_hpf_drv_api_funcs) = {
7878
.pin_configure = gpio_hpf_pin_configure,
7979
.port_set_masked_raw = gpio_hpf_port_set_masked_raw,
8080
.port_set_bits_raw = gpio_hpf_port_set_bits_raw,

drivers/sensor/bh1749/bh1749.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static int bh1749_init(const struct device *dev)
292292
return 0;
293293
};
294294

295-
static const struct sensor_driver_api bh1749_driver_api = {
295+
static DEVICE_API(sensor, bh1749_driver_api) = {
296296
.sample_fetch = &bh1749_sample_fetch,
297297
.channel_get = &bh1749_channel_get,
298298
#ifdef CONFIG_BH1749_TRIGGER

drivers/sensor/bme68x_iaq/bme68x_iaq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ static int bme68x_channel_get(const struct device *dev,
685685
return result;
686686
}
687687

688-
static const struct sensor_driver_api bme68x_driver_api = {
688+
static DEVICE_API(sensor, bme68x_driver_api) = {
689689
.sample_fetch = &bme68x_sample_fetch,
690690
.channel_get = &bme68x_channel_get,
691691
.trigger_set = bme68x_trigger_set,

drivers/sensor/paw3212/paw3212.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ static int paw3212_attr_set(const struct device *dev, enum sensor_channel chan,
943943
return err;
944944
}
945945

946-
static const struct sensor_driver_api paw3212_driver_api = {
946+
static DEVICE_API(sensor, paw3212_driver_api) = {
947947
.sample_fetch = paw3212_sample_fetch,
948948
.channel_get = paw3212_channel_get,
949949
.trigger_set = paw3212_trigger_set,

drivers/sensor/pmw3360/pmw3360.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ static int pmw3360_attr_set(const struct device *dev, enum sensor_channel chan,
10351035
return err;
10361036
}
10371037

1038-
static const struct sensor_driver_api pmw3360_driver_api = {
1038+
static DEVICE_API(sensor, pmw3360_driver_api) = {
10391039
.sample_fetch = pmw3360_sample_fetch,
10401040
.channel_get = pmw3360_channel_get,
10411041
.trigger_set = pmw3360_trigger_set,

drivers/serial/uart_ipc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ int ipc_uart_init(const struct device *dev)
185185
return 0;
186186
}
187187

188-
static const struct uart_driver_api uart_ipc_api = {
188+
static DEVICE_API(uart, uart_ipc_api) = {
189189
.poll_in = ipc_uart_poll_in,
190190
.poll_out = ipc_uart_poll_out
191191
};

subsys/bluetooth/controller/hci_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ static int hci_driver_close(const struct device *dev)
15291529
return err;
15301530
}
15311531

1532-
static const struct bt_hci_driver_api hci_driver_api = {
1532+
static DEVICE_API(bt_hci, hci_driver_api) = {
15331533
.open = hci_driver_open,
15341534
.close = hci_driver_close,
15351535
.send = hci_driver_send,

subsys/uart_async_adapter/uart_async_adapter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ static void uart_irq_handler(const struct device *target_dev, void *context)
547547
LOG_DBG("irq_handler: Exit");
548548
}
549549

550-
const struct uart_driver_api uart_async_adapter_driver_api = {
550+
DEVICE_API(uart, uart_async_adapter_driver_api) = {
551551
/* Async interface */
552552
.callback_set = callback_set,
553553
.tx = tx,

0 commit comments

Comments
 (0)