Skip to content

Commit d2b0f70

Browse files
XenuIsWatchingnashif
authored andcommitted
drivers: i3c: add helper for if target is controller capable
Add the function, i3c_device_is_controller_capable, to determine if a target is controller capable. Signed-off-by: Ryan McClelland <[email protected]>
1 parent 93dc611 commit d2b0f70

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

drivers/i3c/i3c_common.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,7 @@ bool i3c_bus_has_sec_controller(const struct device *dev)
670670
SYS_SLIST_FOR_EACH_NODE(&data->attached_dev.devices.i3c, node) {
671671
struct i3c_device_desc *i3c_desc = CONTAINER_OF(node, struct i3c_device_desc, node);
672672

673-
if (I3C_BCR_DEVICE_ROLE(i3c_desc->bcr) ==
674-
I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE) {
673+
if (i3c_device_is_controller_capable(i3c_desc)) {
675674
return true;
676675
}
677676
}

include/zephyr/drivers/i3c.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,23 @@ static inline int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
17621762
== I3C_BCR_IBI_REQUEST_CAPABLE;
17631763
}
17641764

1765+
/**
1766+
* @brief Check if the target is controller capable
1767+
*
1768+
* This reads the BCR from the device descriptor struct to determine
1769+
* whether the target is controller capable
1770+
*
1771+
* Note that BCR must have been obtained from device and
1772+
* i3c_device_desc::bcr must be set.
1773+
*
1774+
* @return True if target is controller capable, false otherwise.
1775+
*/
1776+
static inline int i3c_device_is_controller_capable(struct i3c_device_desc *target)
1777+
{
1778+
return I3C_BCR_DEVICE_ROLE(target->bcr)
1779+
== I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE;
1780+
}
1781+
17651782
/** @} */
17661783

17671784
/**
@@ -2089,6 +2106,8 @@ int i3c_device_basic_info_get(struct i3c_device_desc *target);
20892106
* This reads the BCR from the device descriptor struct of all targets
20902107
* to determine whether a device is a secondary controller.
20912108
*
2109+
* @param dev Pointer to controller device driver instance.
2110+
*
20922111
* @return True if the bus has a secondary controller, false otherwise.
20932112
*/
20942113
bool i3c_bus_has_sec_controller(const struct device *dev);

0 commit comments

Comments
 (0)