can: add helper function to get CAN bus state
Add a helper function to get the CAN bus state. Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
This commit is contained in:
parent
4cb375a812
commit
6cc5fdc0e9
2 changed files with 20 additions and 0 deletions
|
@ -27,6 +27,7 @@ extern int rtnl_link_can_str2ctrlmode(const char *);
|
|||
|
||||
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 *);
|
||||
|
|
|
@ -404,6 +404,25 @@ int rtnl_link_can_freq(struct rtnl_link *link, uint32_t *freq)
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue