hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/can/dev.h
....@@ -82,15 +82,30 @@
8282 #endif
8383 };
8484
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
+
85100 /*
86101 * 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.
88103 *
89104 * To be used in the CAN netdriver receive path to ensure conformance with
90105 * ISO 11898-1 Chapter 8.4.2.3 (DLC field)
91106 */
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))
94109
95110 /* Check for outgoing skbs that have not been created by the CAN subsystem */
96111 static inline bool can_skb_headroom_valid(struct net_device *dev,
....@@ -108,7 +123,7 @@
108123
109124 skb->ip_summed = CHECKSUM_UNNECESSARY;
110125
111
- /* preform proper loopback on capable devices */
126
+ /* perform proper loopback on capable devices */
112127 if (dev->flags & IFF_ECHO)
113128 skb->pkt_type = PACKET_LOOPBACK;
114129 else
....@@ -201,9 +216,10 @@
201216 void can_change_state(struct net_device *dev, struct can_frame *cf,
202217 enum can_state tx_state, enum can_state rx_state);
203218
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);
207223 unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
208224 void can_free_echo_skb(struct net_device *dev, unsigned int idx);
209225