summaryrefslogtreecommitdiffstats
path: root/include/linux/can
diff options
context:
space:
mode:
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>2021-03-06 14:40:40 +0900
committerMarc Kleine-Budde <mkl@pengutronix.de>2021-03-30 11:14:45 +0200
commit1d7750760b70ba8b0e641146eee1b3a343d1b292 (patch)
tree18a32fdd433f6d66cdfbb486426fc652777426ed /include/linux/can
parentc25cc7993243fdc00ab7e608e3764819538015ab (diff)
downloadlinux-1d7750760b70ba8b0e641146eee1b3a343d1b292.tar.gz
linux-1d7750760b70ba8b0e641146eee1b3a343d1b292.tar.bz2
linux-1d7750760b70ba8b0e641146eee1b3a343d1b292.zip
can: bittiming: add CAN_KBPS, CAN_MBPS and CAN_MHZ macros
Add three macro to simplify the readability of big bit timing numbers: - CAN_KBPS: kilobits per second (one thousand) - CAN_MBPS: megabits per second (one million) - CAN_MHZ: megahertz per second (one million) Example: u32 bitrate_max = 8 * CAN_MBPS; struct can_clock clock = {.freq = 80 * CAN_MHZ}; instead of: u32 bitrate_max = 8000000; struct can_clock clock = {.freq = 80000000}; Apply the new macro to driver/net/can/dev/bittiming.c. Link: https://lore.kernel.org/r/20210306054040.76483-1-mailhol.vincent@wanadoo.fr Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'include/linux/can')
-rw-r--r--include/linux/can/bittiming.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/can/bittiming.h b/include/linux/can/bittiming.h
index 3c4cad7b52c0..ae7a3411167c 100644
--- a/include/linux/can/bittiming.h
+++ b/include/linux/can/bittiming.h
@@ -11,6 +11,14 @@
#define CAN_SYNC_SEG 1
+
+/* Kilobits and Megabits per second */
+#define CAN_KBPS 1000UL
+#define CAN_MBPS 1000000UL
+
+/* Megahertz */
+#define CAN_MHZ 1000000UL
+
/*
* struct can_tdc - CAN FD Transmission Delay Compensation parameters
*