Skip to content

Commit 8f5e71b

Browse files
committed
Merge tag 'linux-can-next-for-5.10-20201007' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next
Marc Kleine-Budde says: ==================== linux-can-next-for-5.10-20201007 The first 3 patches are by me and fix several warnings found when compiling the kernel with W=1. Lukas Bulwahn's patch adjusts the MAINTAINERS file, to accommodate the renaming of the mcp251xfd driver. Vincent Mailhol contributes 3 patches for the CAN networking layer. First error queue support is added the the CAN RAW protocol. The second patch converts the get_can_dlc() and get_canfd_dlc() in-Kernel-only macros from using __u8 to u8. The third patch adds a helper function to calculate the length of one bit in in multiple of time quanta. Oliver Hartkopp's patch add support for the ISO 15765-2:2016 transport protocol to the CAN stack. Three patches by Lad Prabhakar add documentation for various new rcar controllers to the device tree bindings of the rcar_can and rcan_canfd driver. Michael Walle's patch adds various processors to the flexcan driver binding documentation. The next two patches are by me and target the flexcan driver aswell. The remove the ack_grp and ack_bit from the fsl,stop-mode DT property and the driver, as they are not used anymore. As these are the last two arguments this change will not break existing device trees. The last three patches are by Srinivas Neeli and target the xilinx_can driver. The first one increases the lower limit for the bit rate prescaler to 2, the other two fix sparse and coverity findings. ==================== Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 3b8f56e + 164ab90 commit 8f5e71b

File tree

17 files changed

+1676
-39
lines changed

17 files changed

+1676
-39
lines changed

Documentation/devicetree/bindings/net/can/fsl-flexcan.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Required properties:
44

55
- compatible : Should be "fsl,<processor>-flexcan"
66

7+
where <processor> is imx8qm, imx6q, imx28, imx53, imx35, imx25, p1010,
8+
vf610, ls1021ar2, lx2160ar1, ls1028ar1.
9+
10+
The ls1028ar1 must be followed by lx2160ar1, e.g.
11+
- "fsl,ls1028ar1-flexcan", "fsl,lx2160ar1-flexcan"
12+
713
An implementation should also claim any of the following compatibles
814
that it is fully backwards compatible with:
915

@@ -25,12 +31,10 @@ Optional properties:
2531
endian.
2632

2733
- fsl,stop-mode: register bits of stop mode control, the format is
28-
<&gpr req_gpr req_bit ack_gpr ack_bit>.
34+
<&gpr req_gpr req_bit>.
2935
gpr is the phandle to general purpose register node.
3036
req_gpr is the gpr register offset of CAN stop request.
3137
req_bit is the bit offset of CAN stop request.
32-
ack_gpr is the gpr register offset of CAN stop acknowledge.
33-
ack_bit is the bit offset of CAN stop acknowledge.
3438

3539
- fsl,clk-source: Select the clock source to the CAN Protocol Engine (PE).
3640
It's SoC Implementation dependent. Refer to RM for detailed

Documentation/devicetree/bindings/net/can/rcar_can.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ Renesas R-Car CAN controller Device Tree Bindings
22
-------------------------------------------------
33

44
Required properties:
5-
- compatible: "renesas,can-r8a7743" if CAN controller is a part of R8A7743 SoC.
5+
- compatible: "renesas,can-r8a7742" if CAN controller is a part of R8A7742 SoC.
6+
"renesas,can-r8a7743" if CAN controller is a part of R8A7743 SoC.
67
"renesas,can-r8a7744" if CAN controller is a part of R8A7744 SoC.
78
"renesas,can-r8a7745" if CAN controller is a part of R8A7745 SoC.
89
"renesas,can-r8a77470" if CAN controller is a part of R8A77470 SoC.
910
"renesas,can-r8a774a1" if CAN controller is a part of R8A774A1 SoC.
1011
"renesas,can-r8a774b1" if CAN controller is a part of R8A774B1 SoC.
1112
"renesas,can-r8a774c0" if CAN controller is a part of R8A774C0 SoC.
13+
"renesas,can-r8a774e1" if CAN controller is a part of R8A774E1 SoC.
1214
"renesas,can-r8a7778" if CAN controller is a part of R8A7778 SoC.
1315
"renesas,can-r8a7779" if CAN controller is a part of R8A7779 SoC.
1416
"renesas,can-r8a7790" if CAN controller is a part of R8A7790 SoC.
@@ -37,8 +39,8 @@ Required properties:
3739
- pinctrl-0: pin control group to be used for this controller.
3840
- pinctrl-names: must be "default".
3941

40-
Required properties for R8A774A1, R8A774B1, R8A774C0, R8A7795, R8A7796,
41-
R8A77965, R8A77990, and R8A77995:
42+
Required properties for R8A774A1, R8A774B1, R8A774C0, R8A774E1, R8A7795,
43+
R8A7796, R8A77965, R8A77990, and R8A77995:
4244
For the denoted SoCs, "clkp2" can be CANFD clock. This is a div6 clock and can
4345
be used by both CAN and CAN FD controller at the same time. It needs to be
4446
scaled to maximum frequency if any of these controllers use it. This is done

Documentation/devicetree/bindings/net/can/rcar_canfd.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Required properties:
77
- "renesas,r8a774a1-canfd" for R8A774A1 (RZ/G2M) compatible controller.
88
- "renesas,r8a774b1-canfd" for R8A774B1 (RZ/G2N) compatible controller.
99
- "renesas,r8a774c0-canfd" for R8A774C0 (RZ/G2E) compatible controller.
10+
- "renesas,r8a774e1-canfd" for R8A774E1 (RZ/G2H) compatible controller.
1011
- "renesas,r8a7795-canfd" for R8A7795 (R-Car H3) compatible controller.
1112
- "renesas,r8a7796-canfd" for R8A7796 (R-Car M3-W) compatible controller.
1213
- "renesas,r8a77965-canfd" for R8A77965 (R-Car M3-N) compatible controller.
@@ -32,8 +33,8 @@ The name of the child nodes are "channel0" and "channel1" respectively. Each
3233
child node supports the "status" property only, which is used to
3334
enable/disable the respective channel.
3435

35-
Required properties for R8A774A1, R8A774B1, R8A774C0, R8A7795, R8A7796,
36-
R8A77965, R8A77990, and R8A77995:
36+
Required properties for R8A774A1, R8A774B1, R8A774C0, R8A774E1, R8A7795,
37+
R8A7796, R8A77965, R8A77990, and R8A77995:
3738
In the denoted SoCs, canfd clock is a div6 clock and can be used by both CAN
3839
and CAN FD controller at the same time. It needs to be scaled to maximum
3940
frequency if any of these controllers use it. This is done using the below

MAINTAINERS

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,6 +3917,7 @@ F: include/net/netns/can.h
39173917
F: include/uapi/linux/can.h
39183918
F: include/uapi/linux/can/bcm.h
39193919
F: include/uapi/linux/can/gw.h
3920+
F: include/uapi/linux/can/isotp.h
39203921
F: include/uapi/linux/can/raw.h
39213922
F: net/can/
39223923

@@ -10680,14 +10681,14 @@ L: [email protected]
1068010681
S: Maintained
1068110682
F: drivers/hid/hid-mcp2221.c
1068210683

10683-
MCP25XXFD SPI-CAN NETWORK DRIVER
10684+
MCP251XFD SPI-CAN NETWORK DRIVER
1068410685
M: Marc Kleine-Budde <[email protected]>
1068510686
M: Manivannan Sadhasivam <[email protected]>
1068610687
R: Thomas Kopp <[email protected]>
1068710688
1068810689
S: Maintained
10689-
F: Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml
10690-
F: drivers/net/can/spi/mcp25xxfd/
10690+
F: Documentation/devicetree/bindings/net/can/microchip,mcp251xfd.yaml
10691+
F: drivers/net/can/spi/mcp251xfd/
1069110692

1069210693
MCP4018 AND MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVERS
1069310694
M: Peter Rosin <[email protected]>

drivers/net/can/c_can/c_can.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ enum reg {
8181
C_CAN_FUNCTION_REG,
8282
};
8383

84-
static const u16 reg_map_c_can[] = {
84+
static const u16 __maybe_unused reg_map_c_can[] = {
8585
[C_CAN_CTRL_REG] = 0x00,
8686
[C_CAN_STS_REG] = 0x02,
8787
[C_CAN_ERR_CNT_REG] = 0x04,
@@ -121,7 +121,7 @@ static const u16 reg_map_c_can[] = {
121121
[C_CAN_MSGVAL2_REG] = 0xB2,
122122
};
123123

124-
static const u16 reg_map_d_can[] = {
124+
static const u16 __maybe_unused reg_map_d_can[] = {
125125
[C_CAN_CTRL_REG] = 0x00,
126126
[C_CAN_CTRL_EX_REG] = 0x02,
127127
[C_CAN_STS_REG] = 0x04,

drivers/net/can/dev.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ EXPORT_SYMBOL_GPL(can_len2dlc);
6060

6161
#ifdef CONFIG_CAN_CALC_BITTIMING
6262
#define CAN_CALC_MAX_ERROR 50 /* in one-tenth of a percent */
63-
#define CAN_CALC_SYNC_SEG 1
6463

6564
/* Bit-timing calculation derived from:
6665
*
@@ -86,8 +85,8 @@ can_update_sample_point(const struct can_bittiming_const *btc,
8685
int i;
8786

8887
for (i = 0; i <= 1; i++) {
89-
tseg2 = tseg + CAN_CALC_SYNC_SEG -
90-
(sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) /
88+
tseg2 = tseg + CAN_SYNC_SEG -
89+
(sample_point_nominal * (tseg + CAN_SYNC_SEG)) /
9190
1000 - i;
9291
tseg2 = clamp(tseg2, btc->tseg2_min, btc->tseg2_max);
9392
tseg1 = tseg - tseg2;
@@ -96,8 +95,8 @@ can_update_sample_point(const struct can_bittiming_const *btc,
9695
tseg2 = tseg - tseg1;
9796
}
9897

99-
sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) /
100-
(tseg + CAN_CALC_SYNC_SEG);
98+
sample_point = 1000 * (tseg + CAN_SYNC_SEG - tseg2) /
99+
(tseg + CAN_SYNC_SEG);
101100
sample_point_error = abs(sample_point_nominal - sample_point);
102101

103102
if (sample_point <= sample_point_nominal &&
@@ -145,7 +144,7 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
145144
/* tseg even = round down, odd = round up */
146145
for (tseg = (btc->tseg1_max + btc->tseg2_max) * 2 + 1;
147146
tseg >= (btc->tseg1_min + btc->tseg2_min) * 2; tseg--) {
148-
tsegall = CAN_CALC_SYNC_SEG + tseg / 2;
147+
tsegall = CAN_SYNC_SEG + tseg / 2;
149148

150149
/* Compute all possible tseg choices (tseg=tseg1+tseg2) */
151150
brp = priv->clock.freq / (tsegall * bt->bitrate) + tseg % 2;
@@ -223,7 +222,7 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
223222

224223
/* real bitrate */
225224
bt->bitrate = priv->clock.freq /
226-
(bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2));
225+
(bt->brp * (CAN_SYNC_SEG + tseg1 + tseg2));
227226

228227
return 0;
229228
}

drivers/net/can/flexcan.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,6 @@ struct flexcan_stop_mode {
333333
struct regmap *gpr;
334334
u8 req_gpr;
335335
u8 req_bit;
336-
u8 ack_gpr;
337-
u8 ack_bit;
338336
};
339337

340338
struct flexcan_priv {
@@ -1847,14 +1845,14 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
18471845
struct device_node *gpr_np;
18481846
struct flexcan_priv *priv;
18491847
phandle phandle;
1850-
u32 out_val[5];
1848+
u32 out_val[3];
18511849
int ret;
18521850

18531851
if (!np)
18541852
return -EINVAL;
18551853

18561854
/* stop mode property format is:
1857-
* <&gpr req_gpr req_bit ack_gpr ack_bit>.
1855+
* <&gpr req_gpr>.
18581856
*/
18591857
ret = of_property_read_u32_array(np, "fsl,stop-mode", out_val,
18601858
ARRAY_SIZE(out_val));
@@ -1880,13 +1878,10 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
18801878

18811879
priv->stm.req_gpr = out_val[1];
18821880
priv->stm.req_bit = out_val[2];
1883-
priv->stm.ack_gpr = out_val[3];
1884-
priv->stm.ack_bit = out_val[4];
18851881

18861882
dev_dbg(&pdev->dev,
1887-
"gpr %s req_gpr=0x02%x req_bit=%u ack_gpr=0x02%x ack_bit=%u\n",
1888-
gpr_np->full_name, priv->stm.req_gpr, priv->stm.req_bit,
1889-
priv->stm.ack_gpr, priv->stm.ack_bit);
1883+
"gpr %s req_gpr=0x02%x req_bit=%u\n",
1884+
gpr_np->full_name, priv->stm.req_gpr, priv->stm.req_bit);
18901885

18911886
device_set_wakeup_capable(&pdev->dev, true);
18921887

drivers/net/can/softing/softing_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,9 @@ static void softing_card_shutdown(struct softing *card)
447447
{
448448
int fw_up = 0;
449449

450-
if (mutex_lock_interruptible(&card->fw.lock))
450+
if (mutex_lock_interruptible(&card->fw.lock)) {
451451
/* return -ERESTARTSYS */;
452+
}
452453
fw_up = card->fw.up;
453454
card->fw.up = 0;
454455

drivers/net/can/xilinx_can.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static const struct can_bittiming_const xcan_bittiming_const_canfd2 = {
259259
.tseg2_min = 1,
260260
.tseg2_max = 128,
261261
.sjw_max = 128,
262-
.brp_min = 1,
262+
.brp_min = 2,
263263
.brp_max = 256,
264264
.brp_inc = 1,
265265
};
@@ -272,7 +272,7 @@ static struct can_bittiming_const xcan_data_bittiming_const_canfd2 = {
272272
.tseg2_min = 1,
273273
.tseg2_max = 16,
274274
.sjw_max = 16,
275-
.brp_min = 1,
275+
.brp_min = 2,
276276
.brp_max = 256,
277277
.brp_inc = 1,
278278
};
@@ -1369,9 +1369,13 @@ static irqreturn_t xcan_interrupt(int irq, void *dev_id)
13691369
static void xcan_chip_stop(struct net_device *ndev)
13701370
{
13711371
struct xcan_priv *priv = netdev_priv(ndev);
1372+
int ret;
13721373

13731374
/* Disable interrupts and leave the can in configuration mode */
1374-
set_reset_mode(ndev);
1375+
ret = set_reset_mode(ndev);
1376+
if (ret < 0)
1377+
netdev_dbg(ndev, "set_reset_mode() Failed\n");
1378+
13751379
priv->can.state = CAN_STATE_STOPPED;
13761380
}
13771381

@@ -1667,7 +1671,7 @@ static int xcan_probe(struct platform_device *pdev)
16671671
void __iomem *addr;
16681672
int ret;
16691673
int rx_max, tx_max;
1670-
int hw_tx_max, hw_rx_max;
1674+
u32 hw_tx_max = 0, hw_rx_max = 0;
16711675
const char *hw_tx_max_property;
16721676

16731677
/* Get the virtual base address for the device */
@@ -1720,7 +1724,7 @@ static int xcan_probe(struct platform_device *pdev)
17201724
*/
17211725
if (!(devtype->flags & XCAN_FLAG_TX_MAILBOXES) &&
17221726
(devtype->flags & XCAN_FLAG_TXFEMP))
1723-
tx_max = min(hw_tx_max, 2);
1727+
tx_max = min(hw_tx_max, 2U);
17241728
else
17251729
tx_max = 1;
17261730

include/linux/can/dev.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,30 @@ struct can_priv {
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,

0 commit comments

Comments
 (0)