Skip to content

Commit

Permalink
drivers: can: Make zcan_frame const for sending
Browse files Browse the repository at this point in the history
For sending the zcan_frame can be const, because its only
copied to the registers.

Signed-off-by: Alexander Wachter <[email protected]>
  • Loading branch information
Alexander Wachter authored and galak committed Feb 28, 2019
1 parent 8aab2e7 commit b082644
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions drivers/can/stm32_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ static int can_stm32_init(struct device *dev)
return 0;
}

int can_stm32_send(struct device *dev, struct zcan_frame *msg, s32_t timeout,
can_tx_callback_t callback)
int can_stm32_send(struct device *dev, const struct zcan_frame *msg,
s32_t timeout, can_tx_callback_t callback)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
Expand Down
9 changes: 5 additions & 4 deletions include/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ typedef int (*can_configure_t)(struct device *dev, enum can_mode mode,
* @retval 0 If successful.
* @retval CAN_TX_* on failure.
*/
typedef int (*can_send_t)(struct device *dev, struct zcan_frame *msg,
typedef int (*can_send_t)(struct device *dev, const struct zcan_frame *msg,
s32_t timeout, can_tx_callback_t callback_isr);


Expand Down Expand Up @@ -313,10 +313,11 @@ struct can_driver_api {
};


__syscall int can_send(struct device *dev, struct zcan_frame *msg,
__syscall int can_send(struct device *dev, const struct zcan_frame *msg,
s32_t timeout, can_tx_callback_t callback_isr);

static inline int _impl_can_send(struct device *dev, struct zcan_frame *msg,
static inline int _impl_can_send(struct device *dev,
const struct zcan_frame *msg,
s32_t timeout, can_tx_callback_t callback_isr)
{
const struct can_driver_api *api = dev->driver_api;
Expand Down Expand Up @@ -344,7 +345,7 @@ static inline int _impl_can_send(struct device *dev, struct zcan_frame *msg,
* @retval -EIO General input / output error.
* @retval -EINVAL if length > 8.
*/
static inline int can_write(struct device *dev, u8_t *data, u8_t length,
static inline int can_write(struct device *dev, const u8_t *data, u8_t length,
u32_t id, enum can_rtr rtr, s32_t timeout)
{
struct zcan_frame msg;
Expand Down

0 comments on commit b082644

Please sign in to comment.