.. | .. |
---|
82 | 82 | #endif |
---|
83 | 83 | }; |
---|
84 | 84 | |
---|
| 85 | +#define CAN_SYNC_SEG 1 |
---|
| 86 | + |
---|
| 87 | +/* |
---|
| 88 | + * can_bit_time() - Duration of one bit |
---|
| 89 | + * |
---|
| 90 | + * Please refer to ISO 11898-1:2015, section 11.3.1.1 "Bit time" for |
---|
| 91 | + * additional information. |
---|
| 92 | + * |
---|
| 93 | + * Return: the number of time quanta in one bit. |
---|
| 94 | + */ |
---|
| 95 | +static inline unsigned int can_bit_time(const struct can_bittiming *bt) |
---|
| 96 | +{ |
---|
| 97 | + return CAN_SYNC_SEG + bt->prop_seg + bt->phase_seg1 + bt->phase_seg2; |
---|
| 98 | +} |
---|
| 99 | + |
---|
85 | 100 | /* |
---|
86 | 101 | * get_can_dlc(value) - helper macro to cast a given data length code (dlc) |
---|
87 | | - * to __u8 and ensure the dlc value to be max. 8 bytes. |
---|
| 102 | + * to u8 and ensure the dlc value to be max. 8 bytes. |
---|
88 | 103 | * |
---|
89 | 104 | * To be used in the CAN netdriver receive path to ensure conformance with |
---|
90 | 105 | * ISO 11898-1 Chapter 8.4.2.3 (DLC field) |
---|
91 | 106 | */ |
---|
92 | | -#define get_can_dlc(i) (min_t(__u8, (i), CAN_MAX_DLC)) |
---|
93 | | -#define get_canfd_dlc(i) (min_t(__u8, (i), CANFD_MAX_DLC)) |
---|
| 107 | +#define get_can_dlc(i) (min_t(u8, (i), CAN_MAX_DLC)) |
---|
| 108 | +#define get_canfd_dlc(i) (min_t(u8, (i), CANFD_MAX_DLC)) |
---|
94 | 109 | |
---|
95 | 110 | /* Check for outgoing skbs that have not been created by the CAN subsystem */ |
---|
96 | 111 | static inline bool can_skb_headroom_valid(struct net_device *dev, |
---|
.. | .. |
---|
108 | 123 | |
---|
109 | 124 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
---|
110 | 125 | |
---|
111 | | - /* preform proper loopback on capable devices */ |
---|
| 126 | + /* perform proper loopback on capable devices */ |
---|
112 | 127 | if (dev->flags & IFF_ECHO) |
---|
113 | 128 | skb->pkt_type = PACKET_LOOPBACK; |
---|
114 | 129 | else |
---|
.. | .. |
---|
201 | 216 | void can_change_state(struct net_device *dev, struct can_frame *cf, |
---|
202 | 217 | enum can_state tx_state, enum can_state rx_state); |
---|
203 | 218 | |
---|
204 | | -void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, |
---|
205 | | - unsigned int idx); |
---|
206 | | -struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr); |
---|
| 219 | +int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, |
---|
| 220 | + unsigned int idx); |
---|
| 221 | +struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, |
---|
| 222 | + u8 *len_ptr); |
---|
207 | 223 | unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx); |
---|
208 | 224 | void can_free_echo_skb(struct net_device *dev, unsigned int idx); |
---|
209 | 225 | |
---|