Commit 330c6d3b authored by Vincent Mailhol's avatar Vincent Mailhol Committed by Marc Kleine-Budde

can: bittiming: replace CAN units with the generic ones from linux/units.h

In [1], we introduced a set of units in linux/can/bittiming.h. Since
then, generic SI prefixes were added to linux/units.h in [2]. Those
new prefixes can perfectly replace CAN specific ones.

This patch replaces all occurrences of the CAN units with their
corresponding prefix (from linux/units) and the unit (as a comment)
according to below table.

 CAN units	SI metric prefix (from linux/units) + unit (as a comment)
 ------------------------------------------------------------------------
 CAN_KBPS	KILO /* BPS */
 CAN_MBPS	MEGA /* BPS */
 CAM_MHZ	MEGA /* Hz */

The definition are then removed from linux/can/bittiming.h

[1] commit 1d775076 ("can: bittiming: add CAN_KBPS, CAN_MBPS and
CAN_MHZ macros")

[2] commit 26471d4a ("units: Add SI metric prefix definitions")

Link: https://lore.kernel.org/all/20211124014536.782550-1-mailhol.vincent@wanadoo.frSuggested-by: default avatarJimmy Assarsson <extja@kvaser.com>
Suggested-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 1fe5b012
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com> * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
*/ */
#include <linux/units.h>
#include <linux/can/dev.h> #include <linux/can/dev.h>
#ifdef CONFIG_CAN_CALC_BITTIMING #ifdef CONFIG_CAN_CALC_BITTIMING
...@@ -81,9 +82,9 @@ int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, ...@@ -81,9 +82,9 @@ int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
if (bt->sample_point) { if (bt->sample_point) {
sample_point_nominal = bt->sample_point; sample_point_nominal = bt->sample_point;
} else { } else {
if (bt->bitrate > 800 * CAN_KBPS) if (bt->bitrate > 800 * KILO /* BPS */)
sample_point_nominal = 750; sample_point_nominal = 750;
else if (bt->bitrate > 500 * CAN_KBPS) else if (bt->bitrate > 500 * KILO /* BPS */)
sample_point_nominal = 800; sample_point_nominal = 800;
else else
sample_point_nominal = 875; sample_point_nominal = 875;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/units.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include "es58x_core.h" #include "es58x_core.h"
...@@ -469,8 +470,8 @@ const struct es58x_parameters es581_4_param = { ...@@ -469,8 +470,8 @@ const struct es58x_parameters es581_4_param = {
.bittiming_const = &es581_4_bittiming_const, .bittiming_const = &es581_4_bittiming_const,
.data_bittiming_const = NULL, .data_bittiming_const = NULL,
.tdc_const = NULL, .tdc_const = NULL,
.bitrate_max = 1 * CAN_MBPS, .bitrate_max = 1 * MEGA /* BPS */,
.clock = {.freq = 50 * CAN_MHZ}, .clock = {.freq = 50 * MEGA /* Hz */},
.ctrlmode_supported = CAN_CTRLMODE_CC_LEN8_DLC, .ctrlmode_supported = CAN_CTRLMODE_CC_LEN8_DLC,
.tx_start_of_frame = 0xAFAF, .tx_start_of_frame = 0xAFAF,
.rx_start_of_frame = 0xFAFA, .rx_start_of_frame = 0xFAFA,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/units.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include "es58x_core.h" #include "es58x_core.h"
...@@ -522,8 +523,8 @@ const struct es58x_parameters es58x_fd_param = { ...@@ -522,8 +523,8 @@ const struct es58x_parameters es58x_fd_param = {
* Mbps work in an optimal environment but are not recommended * Mbps work in an optimal environment but are not recommended
* for production environment. * for production environment.
*/ */
.bitrate_max = 8 * CAN_MBPS, .bitrate_max = 8 * MEGA /* BPS */,
.clock = {.freq = 80 * CAN_MHZ}, .clock = {.freq = 80 * MEGA /* Hz */},
.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY | .ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO | CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO |
CAN_CTRLMODE_CC_LEN8_DLC | CAN_CTRLMODE_TDC_AUTO, CAN_CTRLMODE_CC_LEN8_DLC | CAN_CTRLMODE_TDC_AUTO,
......
...@@ -12,13 +12,6 @@ ...@@ -12,13 +12,6 @@
#define CAN_SYNC_SEG 1 #define CAN_SYNC_SEG 1
/* Kilobits and Megabits per second */
#define CAN_KBPS 1000UL
#define CAN_MBPS 1000000UL
/* Megahertz */
#define CAN_MHZ 1000000UL
#define CAN_CTRLMODE_TDC_MASK \ #define CAN_CTRLMODE_TDC_MASK \
(CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL) (CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment