Skip to content

Commit

Permalink
drivers: i3c: Place API into iterable section
Browse files Browse the repository at this point in the history
Add wrapper DEVICE_API macro to all i3c_driver_api instances.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt committed Nov 28, 2024
1 parent 8780d91 commit 7e7d087
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion drivers/i3c/i3c_cdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -3281,7 +3281,7 @@ static int cdns_i3c_bus_init(const struct device *dev)
return 0;
}

static struct i3c_driver_api api = {
static DEVICE_API(i3c, api) = {
.i2c_api.configure = cdns_i3c_i2c_api_configure,
.i2c_api.transfer = cdns_i3c_i2c_api_transfer,

Expand Down
10 changes: 10 additions & 0 deletions drivers/i3c/i3c_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ int i3c_attach_i3c_device(struct i3c_device_desc *target)
int status = 0;
struct i3c_device_desc *i3c_desc;

__ASSERT_NO_MSG(DEVICE_API_IS(i3c, target->bus));

/* check to see if the device has already been attached */
I3C_BUS_FOR_EACH_I3CDEV(target->bus, i3c_desc) {
if (i3c_desc == target) {
Expand Down Expand Up @@ -279,6 +281,8 @@ int i3c_reattach_i3c_device(struct i3c_device_desc *target, uint8_t old_dyn_addr
const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api;
int status = 0;

__ASSERT_NO_MSG(DEVICE_API_IS(i3c, target->bus));

if (!i3c_addr_slots_is_free(&data->attached_dev.addr_slots, target->dynamic_addr)) {
return -EINVAL;
}
Expand All @@ -303,6 +307,8 @@ int i3c_detach_i3c_device(struct i3c_device_desc *target)
const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api;
int status = 0;

__ASSERT_NO_MSG(DEVICE_API_IS(i3c, target->bus));

if (!sys_slist_is_empty(&data->attached_dev.devices.i3c)) {
if (!sys_slist_find_and_remove(&data->attached_dev.devices.i3c, &target->node)) {
return -EINVAL;
Expand All @@ -328,6 +334,8 @@ int i3c_attach_i2c_device(struct i3c_i2c_device_desc *target)
int status = 0;
struct i3c_i2c_device_desc *i3c_i2c_desc;

__ASSERT_NO_MSG(DEVICE_API_IS(i3c, target->bus));

/* check to see if the device has already been attached */
I3C_BUS_FOR_EACH_I2CDEV(target->bus, i3c_i2c_desc) {
if (i3c_i2c_desc == target) {
Expand Down Expand Up @@ -356,6 +364,8 @@ int i3c_detach_i2c_device(struct i3c_i2c_device_desc *target)
const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api;
int status = 0;

__ASSERT_NO_MSG(DEVICE_API_IS(i3c, target->bus));

if (!sys_slist_is_empty(&data->attached_dev.devices.i2c)) {
if (!sys_slist_find_and_remove(&data->attached_dev.devices.i2c, &target->node)) {
return -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/i3c/i3c_mcux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,7 @@ static int mcux_i3c_i2c_api_transfer(const struct device *dev,
return ret;
}

static const struct i3c_driver_api mcux_i3c_driver_api = {
static DEVICE_API(i3c, mcux_i3c_driver_api) = {
.i2c_api.configure = mcux_i3c_i2c_api_configure,
.i2c_api.transfer = mcux_i3c_i2c_api_transfer,
.i2c_api.recover_bus = mcux_i3c_recover_bus,
Expand Down
2 changes: 1 addition & 1 deletion drivers/i3c/i3c_npcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2963,7 +2963,7 @@ static int npcx_i3c_init(const struct device *dev)
return 0;
}

static const struct i3c_driver_api npcx_i3c_driver_api = {
static DEVICE_API(i3c, npcx_i3c_driver_api) = {
.configure = npcx_i3c_configure,
.config_get = npcx_i3c_config_get,

Expand Down
2 changes: 1 addition & 1 deletion drivers/i3c/i3c_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static int vnd_i3c_recover_bus(const struct device *dev)
return -ENOTSUP;
}

static const struct i3c_driver_api vnd_i3c_api = {
static DEVICE_API(i3c, vnd_i3c_api) = {
.configure = vnd_i3c_configure,
.config_get = vnd_i3c_config_get,
.recover_bus = vnd_i3c_recover_bus,
Expand Down

0 comments on commit 7e7d087

Please sign in to comment.