Add a helper function to get the CAN bus state.
Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
extern int rtnl_link_can_restart(struct rtnl_link *);
extern int rtnl_link_can_freq(struct rtnl_link *, uint32_t *);
+extern int rtnl_link_can_state(struct rtnl_link *, uint32_t *);
extern int rtnl_link_can_berr_rx(struct rtnl_link *);
extern int rtnl_link_can_berr_tx(struct rtnl_link *);
return 0;
}
+/**
+ * Get CAN state
+ * @arg link Link object
+ * @arg state CAN bus state
+ * @return 0 on success or a negative error code
+ */
+int rtnl_link_can_state(struct rtnl_link *link, uint32_t *state)
+{
+ struct can_info *ci = link->l_info;
+
+ IS_CAN_LINK_ASSERT(link);
+ if (!state)
+ return -NLE_INVAL;
+
+ *state = ci->ci_state;
+
+ return 0;
+}
+
/**
* Get CAN RX bus error count
* @arg link Link object