History

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 1d7750760b70 ("can: bittiming: add CAN_KBPS, CAN_MBPS and CAN_MHZ macros") [2] commit 26471d4a6cf8 ("units: Add SI metric prefix definitions")

Vincent Mailhol committed 4 years ago

Commit 330c6d31 parent 1fe5b014 files · +9 −13Browse files

Unified · Split

4 files
  1. drivers/net/can/dev/bittiming.c +3 −2
  2. drivers/net/can/usb/etas_es58x/es581_4.c +3 −2
  3. drivers/net/can/usb/etas_es58x/es58x_fd.c +3 −2
  4. include/linux/can/bittiming.h +0 −7
drivers/net/can/dev/bittiming.c+3−2
@@ -4,6 +4,7 @@ · 3 unmodified lines
4 * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>4 * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
5 */5 */
6 6
7#include <linux/units.h>
7#include <linux/can/dev.h>8#include <linux/can/dev.h>
8 9
9#ifdef CONFIG_CAN_CALC_BITTIMING10#ifdef CONFIG_CAN_CALC_BITTIMING
@@ -81,9 +82,9 @@ int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, · 71 unmodified lines
81 if (bt->sample_point) {82 if (bt->sample_point) {
82 sample_point_nominal = bt->sample_point;83 sample_point_nominal = bt->sample_point;
83 } else {84 } else {
84 if (bt->bitrate > 800 * CAN_KBPS)85 if (bt->bitrate > 800 * KILO /* BPS */)
85 sample_point_nominal = 750;86 sample_point_nominal = 750;
86 else if (bt->bitrate > 500 * CAN_KBPS)87 else if (bt->bitrate > 500 * KILO /* BPS */)
87 sample_point_nominal = 800;88 sample_point_nominal = 800;
88 else89 else
89 sample_point_nominal = 875;90 sample_point_nominal = 875;
drivers/net/can/usb/etas_es58x/es581_4.c+3−2
@@ -10,6 +10,7 @@ · 9 unmodified lines
10 */10 */
11 11
12#include <linux/kernel.h>12#include <linux/kernel.h>
13#include <linux/units.h>
13#include <asm/unaligned.h>14#include <asm/unaligned.h>
14 15
15#include "es58x_core.h"16#include "es58x_core.h"
@@ -469,8 +470,8 @@ const struct es58x_parameters es581_4_param = { · 453 unmodified lines
469 .bittiming_const = &es581_4_bittiming_const,470 .bittiming_const = &es581_4_bittiming_const,
470 .data_bittiming_const = NULL,471 .data_bittiming_const = NULL,
471 .tdc_const = NULL,472 .tdc_const = NULL,
472 .bitrate_max = 1 * CAN_MBPS,473 .bitrate_max = 1 * MEGA /* BPS */,
473 .clock = {.freq = 50 * CAN_MHZ},474 .clock = {.freq = 50 * MEGA /* Hz */},
474 .ctrlmode_supported = CAN_CTRLMODE_CC_LEN8_DLC,475 .ctrlmode_supported = CAN_CTRLMODE_CC_LEN8_DLC,
475 .tx_start_of_frame = 0xAFAF,476 .tx_start_of_frame = 0xAFAF,
476 .rx_start_of_frame = 0xFAFA,477 .rx_start_of_frame = 0xFAFA,
drivers/net/can/usb/etas_es58x/es58x_fd.c+3−2
@@ -12,6 +12,7 @@ · 11 unmodified lines
12 */12 */
13 13
14#include <linux/kernel.h>14#include <linux/kernel.h>
15#include <linux/units.h>
15#include <asm/unaligned.h>16#include <asm/unaligned.h>
16 17
17#include "es58x_core.h"18#include "es58x_core.h"
@@ -522,8 +523,8 @@ const struct es58x_parameters es58x_fd_param = { · 504 unmodified lines
522 * Mbps work in an optimal environment but are not recommended523 * Mbps work in an optimal environment but are not recommended
523 * for production environment.524 * for production environment.
524 */525 */
525 .bitrate_max = 8 * CAN_MBPS,526 .bitrate_max = 8 * MEGA /* BPS */,
526 .clock = {.freq = 80 * CAN_MHZ},527 .clock = {.freq = 80 * MEGA /* Hz */},
527 .ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY |528 .ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY |
528 CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO |529 CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO |
529 CAN_CTRLMODE_CC_LEN8_DLC | CAN_CTRLMODE_TDC_AUTO,530 CAN_CTRLMODE_CC_LEN8_DLC | CAN_CTRLMODE_TDC_AUTO,
include/linux/can/bittiming.h+0−7
@@ -12,13 +12,6 @@ · 11 unmodified lines
12#define CAN_SYNC_SEG 112#define CAN_SYNC_SEG 1
13 13
14 14
15/* Kilobits and Megabits per second */
16#define CAN_KBPS 1000UL
17#define CAN_MBPS 1000000UL
18
19/* Megahertz */
20#define CAN_MHZ 1000000UL
21
22#define CAN_CTRLMODE_TDC_MASK \15#define CAN_CTRLMODE_TDC_MASK \
23 (CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL)16 (CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL)
24 17

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t