drivers: can: add support for getting the maximum supported bitrate

Add support for getting the maximum supported bitrate in bits/s for CAN
controller/transceiver combination and check that a requested bitrate is
within the supported range.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2022-03-01 12:45:21 +01:00 committed by Maureen Helm
commit 0bae208778
2 changed files with 60 additions and 4 deletions

View file

@ -22,7 +22,6 @@ static inline int z_vrfy_can_set_timing(const struct device *dev,
static inline int z_vrfy_can_get_core_clock(const struct device *dev,
uint32_t *rate)
{
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, get_core_clock));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(rate, sizeof(rate)));
@ -30,6 +29,16 @@ static inline int z_vrfy_can_get_core_clock(const struct device *dev,
}
#include <syscalls/can_get_core_clock_mrsh.c>
static inline int z_vrfy_can_get_max_bitrate(const struct device *dev,
uint32_t *max_bitrate)
{
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, get_max_bitrate));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(max_bitrate, sizeof(*max_bitrate)));
return z_impl_can_get_max_bitrate(dev, max_bitrate);
}
#include <syscalls/can_get_max_bitrate_mrsh.c>
static inline int z_vrfy_can_send(const struct device *dev,
const struct zcan_frame *frame,
k_timeout_t timeout,
@ -73,7 +82,6 @@ static inline int z_vrfy_can_add_rx_filter_msgq(const struct device *dev,
static inline void z_vrfy_can_remove_rx_filter(const struct device *dev, int filter_id)
{
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, remove_rx_filter));
z_impl_can_remove_rx_filter((const struct device *)dev, (int)filter_id);
@ -84,7 +92,6 @@ static inline
int z_vrfy_can_get_state(const struct device *dev, enum can_state *state,
struct can_bus_err_cnt *err_cnt)
{
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
if (state != NULL) {
@ -103,7 +110,6 @@ int z_vrfy_can_get_state(const struct device *dev, enum can_state *state,
static inline int z_vrfy_can_recover(const struct device *dev,
k_timeout_t timeout)
{
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
return z_impl_can_recover(dev, k_timeout_t timeout);