Skip to content

Commit 8714652

Browse files
committed
Merge tag 'linux-can-next-for-5.4-20190814' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next
Marc Kleine-Budde says: ==================== pull-request: can-next 2019-08-14 this is a pull request for net-next/master consisting of 41 patches. The first two patches are for the kvaser_pciefd driver: Christer Beskow removes unnecessary code in the kvaser_pciefd_pwm_stop() function, YueHaibing removes the unused including of <linux/version.h>. In the next patch YueHaibing also removes the unused including of <linux/version.h> in the f81601 driver. In the ti_hecc driver the next 6 patches are by me and fix checkpatch warnings. YueHaibing's patch removes an unused variable in the ti_hecc_mailbox_read() function. The next 6 patches all target the xilinx_can driver. Anssi Hannula's patch fixes a chip start failure with an invalid bus. The patch by Venkatesh Yadav Abbarapu skips an error message in case of a deferred probe. The 3 patches by Appana Durga Kedareswara rao fix the RX and TX path for CAN-FD frames. Srinivas Neeli's patch fixes the bit timing calculations for CAN-FD. The next 12 patches are by me and several checkpatch warnings in the af_can, raw and bcm components. Thomas Gleixner provides a patch for the bcm, which switches the timer to HRTIMER_MODE_SOFT and removes the hrtimer_tasklet. Then 6 more patches by me for the gw component, which fix checkpatch warnings, followed by 2 patches by Oliver Hartkopp to add CAN-FD support. The vcan driver gets 3 patches by me, fixing checkpatch warnings. And finally a patch by Andre Hartmann to fix typos in CAN's netlink header. ====================
2 parents 8d73f8f + 3ca3c4a commit 8714652

File tree

12 files changed

+579
-533
lines changed

12 files changed

+579
-533
lines changed

drivers/net/can/kvaser_pciefd.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
#include <linux/kernel.h>
10-
#include <linux/version.h>
1110
#include <linux/module.h>
1211
#include <linux/device.h>
1312
#include <linux/pci.h>
@@ -643,20 +642,16 @@ static int kvaser_pciefd_bus_on(struct kvaser_pciefd_can *can)
643642

644643
static void kvaser_pciefd_pwm_stop(struct kvaser_pciefd_can *can)
645644
{
646-
int top, trigger;
645+
u8 top;
647646
u32 pwm_ctrl;
648647
unsigned long irq;
649648

650649
spin_lock_irqsave(&can->lock, irq);
651650
pwm_ctrl = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG);
652651
top = (pwm_ctrl >> KVASER_PCIEFD_KCAN_PWM_TOP_SHIFT) & 0xff;
653652

654-
trigger = (100 * top + 50) / 100;
655-
if (trigger < 0)
656-
trigger = 0;
657-
658-
pwm_ctrl = trigger & 0xff;
659-
pwm_ctrl |= (top & 0xff) << KVASER_PCIEFD_KCAN_PWM_TOP_SHIFT;
653+
/* Set duty cycle to zero */
654+
pwm_ctrl |= top;
660655
iowrite32(pwm_ctrl, can->reg_base + KVASER_PCIEFD_KCAN_PWM_REG);
661656
spin_unlock_irqrestore(&can->lock, irq);
662657
}

drivers/net/can/sja1000/f81601.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <linux/pci.h>
1515
#include <linux/can/dev.h>
1616
#include <linux/io.h>
17-
#include <linux/version.h>
1817

1918
#include "sja1000.h"
2019

drivers/net/can/ti_hecc.c

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ MODULE_VERSION(HECC_MODULE_VERSION);
4646
#define HECC_MAX_MAILBOXES 32 /* hardware mailboxes - do not change */
4747
#define MAX_TX_PRIO 0x3F /* hardware value - do not change */
4848

49-
/*
50-
* Important Note: TX mailbox configuration
49+
/* Important Note: TX mailbox configuration
5150
* TX mailboxes should be restricted to the number of SKB buffers to avoid
5251
* maintaining SKB buffers separately. TX mailboxes should be a power of 2
5352
* for the mailbox logic to work. Top mailbox numbers are reserved for RX
@@ -223,7 +222,7 @@ static inline u32 hecc_read_stamp(struct ti_hecc_priv *priv, u32 mbxno)
223222
}
224223

225224
static inline void hecc_write_mbx(struct ti_hecc_priv *priv, u32 mbxno,
226-
u32 reg, u32 val)
225+
u32 reg, u32 val)
227226
{
228227
__raw_writel(val, priv->mbx + mbxno * 0x10 + reg);
229228
}
@@ -244,13 +243,13 @@ static inline u32 hecc_read(struct ti_hecc_priv *priv, int reg)
244243
}
245244

246245
static inline void hecc_set_bit(struct ti_hecc_priv *priv, int reg,
247-
u32 bit_mask)
246+
u32 bit_mask)
248247
{
249248
hecc_write(priv, reg, hecc_read(priv, reg) | bit_mask);
250249
}
251250

252251
static inline void hecc_clear_bit(struct ti_hecc_priv *priv, int reg,
253-
u32 bit_mask)
252+
u32 bit_mask)
254253
{
255254
hecc_write(priv, reg, hecc_read(priv, reg) & ~bit_mask);
256255
}
@@ -272,8 +271,8 @@ static int ti_hecc_set_btc(struct ti_hecc_priv *priv)
272271
if (bit_timing->brp > 4)
273272
can_btc |= HECC_CANBTC_SAM;
274273
else
275-
netdev_warn(priv->ndev, "WARN: Triple"
276-
"sampling not set due to h/w limitations");
274+
netdev_warn(priv->ndev,
275+
"WARN: Triple sampling not set due to h/w limitations");
277276
}
278277
can_btc |= ((bit_timing->sjw - 1) & 0x3) << 8;
279278
can_btc |= ((bit_timing->brp - 1) & 0xFF) << 16;
@@ -309,8 +308,7 @@ static void ti_hecc_reset(struct net_device *ndev)
309308
/* Set change control request and wait till enabled */
310309
hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
311310

312-
/*
313-
* INFO: It has been observed that at times CCE bit may not be
311+
/* INFO: It has been observed that at times CCE bit may not be
314312
* set and hw seems to be ok even if this bit is not set so
315313
* timing out with a timing of 1ms to respect the specs
316314
*/
@@ -320,8 +318,7 @@ static void ti_hecc_reset(struct net_device *ndev)
320318
udelay(10);
321319
}
322320

323-
/*
324-
* Note: On HECC, BTC can be programmed only in initialization mode, so
321+
/* Note: On HECC, BTC can be programmed only in initialization mode, so
325322
* it is expected that the can bittiming parameters are set via ip
326323
* utility before the device is opened
327324
*/
@@ -330,13 +327,11 @@ static void ti_hecc_reset(struct net_device *ndev)
330327
/* Clear CCR (and CANMC register) and wait for CCE = 0 enable */
331328
hecc_write(priv, HECC_CANMC, 0);
332329

333-
/*
334-
* INFO: CAN net stack handles bus off and hence disabling auto-bus-on
330+
/* INFO: CAN net stack handles bus off and hence disabling auto-bus-on
335331
* hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_ABO);
336332
*/
337333

338-
/*
339-
* INFO: It has been observed that at times CCE bit may not be
334+
/* INFO: It has been observed that at times CCE bit may not be
340335
* set and hw seems to be ok even if this bit is not set so
341336
*/
342337
cnt = HECC_CCE_WAIT_COUNT;
@@ -369,7 +364,8 @@ static void ti_hecc_start(struct net_device *ndev)
369364
/* put HECC in initialization mode and set btc */
370365
ti_hecc_reset(ndev);
371366

372-
priv->tx_head = priv->tx_tail = HECC_TX_MASK;
367+
priv->tx_head = HECC_TX_MASK;
368+
priv->tx_tail = HECC_TX_MASK;
373369

374370
/* Enable local and global acceptance mask registers */
375371
hecc_write(priv, HECC_CANGAM, HECC_SET_REG);
@@ -395,7 +391,7 @@ static void ti_hecc_start(struct net_device *ndev)
395391
} else {
396392
hecc_write(priv, HECC_CANMIL, 0);
397393
hecc_write(priv, HECC_CANGIM,
398-
HECC_CANGIM_DEF_MASK | HECC_CANGIM_I0EN);
394+
HECC_CANGIM_DEF_MASK | HECC_CANGIM_I0EN);
399395
}
400396
priv->can.state = CAN_STATE_ERROR_ACTIVE;
401397
}
@@ -429,7 +425,7 @@ static int ti_hecc_do_set_mode(struct net_device *ndev, enum can_mode mode)
429425
}
430426

431427
static int ti_hecc_get_berr_counter(const struct net_device *ndev,
432-
struct can_berr_counter *bec)
428+
struct can_berr_counter *bec)
433429
{
434430
struct ti_hecc_priv *priv = netdev_priv(ndev);
435431

@@ -439,8 +435,7 @@ static int ti_hecc_get_berr_counter(const struct net_device *ndev,
439435
return 0;
440436
}
441437

442-
/*
443-
* ti_hecc_xmit: HECC Transmit
438+
/* ti_hecc_xmit: HECC Transmit
444439
*
445440
* The transmit mailboxes start from 0 to HECC_MAX_TX_MBOX. In HECC the
446441
* priority of the mailbox for tranmission is dependent upon priority setting
@@ -478,8 +473,8 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev)
478473
spin_unlock_irqrestore(&priv->mbx_lock, flags);
479474
netif_stop_queue(ndev);
480475
netdev_err(priv->ndev,
481-
"BUG: TX mbx not ready tx_head=%08X, tx_tail=%08X\n",
482-
priv->tx_head, priv->tx_tail);
476+
"BUG: TX mbx not ready tx_head=%08X, tx_tail=%08X\n",
477+
priv->tx_head, priv->tx_tail);
483478
return NETDEV_TX_BUSY;
484479
}
485480
spin_unlock_irqrestore(&priv->mbx_lock, flags);
@@ -496,18 +491,18 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev)
496491
data = (cf->can_id & CAN_SFF_MASK) << 18;
497492
hecc_write_mbx(priv, mbxno, HECC_CANMID, data);
498493
hecc_write_mbx(priv, mbxno, HECC_CANMDL,
499-
be32_to_cpu(*(__be32 *)(cf->data)));
494+
be32_to_cpu(*(__be32 *)(cf->data)));
500495
if (cf->can_dlc > 4)
501496
hecc_write_mbx(priv, mbxno, HECC_CANMDH,
502-
be32_to_cpu(*(__be32 *)(cf->data + 4)));
497+
be32_to_cpu(*(__be32 *)(cf->data + 4)));
503498
else
504499
*(u32 *)(cf->data + 4) = 0;
505500
can_put_echo_skb(skb, ndev, mbxno);
506501

507502
spin_lock_irqsave(&priv->mbx_lock, flags);
508503
--priv->tx_head;
509504
if ((hecc_read(priv, HECC_CANME) & BIT(get_tx_head_mb(priv))) ||
510-
(priv->tx_head & HECC_TX_MASK) == HECC_TX_MASK) {
505+
(priv->tx_head & HECC_TX_MASK) == HECC_TX_MASK) {
511506
netif_stop_queue(ndev);
512507
}
513508
hecc_set_bit(priv, HECC_CANME, mbx_mask);
@@ -520,7 +515,8 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev)
520515
return NETDEV_TX_OK;
521516
}
522517

523-
static inline struct ti_hecc_priv *rx_offload_to_priv(struct can_rx_offload *offload)
518+
static inline
519+
struct ti_hecc_priv *rx_offload_to_priv(struct can_rx_offload *offload)
524520
{
525521
return container_of(offload, struct ti_hecc_priv, offload);
526522
}
@@ -530,18 +526,19 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
530526
u32 *timestamp, unsigned int mbxno)
531527
{
532528
struct ti_hecc_priv *priv = rx_offload_to_priv(offload);
533-
u32 data, mbx_mask;
529+
u32 data;
534530

535-
mbx_mask = BIT(mbxno);
536531
data = hecc_read_mbx(priv, mbxno, HECC_CANMID);
537532
if (data & HECC_CANMID_IDE)
538533
cf->can_id = (data & CAN_EFF_MASK) | CAN_EFF_FLAG;
539534
else
540535
cf->can_id = (data >> 18) & CAN_SFF_MASK;
536+
541537
data = hecc_read_mbx(priv, mbxno, HECC_CANMCF);
542538
if (data & HECC_CANMCF_RTR)
543539
cf->can_id |= CAN_RTR_FLAG;
544540
cf->can_dlc = get_can_dlc(data & 0xF);
541+
545542
data = hecc_read_mbx(priv, mbxno, HECC_CANMDL);
546543
*(__be32 *)(cf->data) = cpu_to_be32(data);
547544
if (cf->can_dlc > 4) {
@@ -555,7 +552,7 @@ static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
555552
}
556553

557554
static int ti_hecc_error(struct net_device *ndev, int int_status,
558-
int err_status)
555+
int err_status)
559556
{
560557
struct ti_hecc_priv *priv = netdev_priv(ndev);
561558
struct can_frame *cf;
@@ -567,7 +564,8 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
567564
if (!skb) {
568565
if (printk_ratelimit())
569566
netdev_err(priv->ndev,
570-
"ti_hecc_error: alloc_can_err_skb() failed\n");
567+
"%s: alloc_can_err_skb() failed\n",
568+
__func__);
571569
return -ENOMEM;
572570
}
573571

@@ -601,8 +599,7 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
601599
hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
602600
}
603601

604-
/*
605-
* Need to check busoff condition in error status register too to
602+
/* Need to check busoff condition in error status register too to
606603
* ensure warning interrupts don't hog the system
607604
*/
608605
if ((int_status & HECC_CANGIF_BOIF) || (err_status & HECC_CANES_BO)) {
@@ -656,15 +653,16 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
656653
unsigned long flags, rx_pending;
657654

658655
int_status = hecc_read(priv,
659-
(priv->use_hecc1int) ? HECC_CANGIF1 : HECC_CANGIF0);
656+
priv->use_hecc1int ?
657+
HECC_CANGIF1 : HECC_CANGIF0);
660658

661659
if (!int_status)
662660
return IRQ_NONE;
663661

664662
err_status = hecc_read(priv, HECC_CANES);
665663
if (err_status & (HECC_BUS_ERROR | HECC_CANES_BO |
666-
HECC_CANES_EP | HECC_CANES_EW))
667-
ti_hecc_error(ndev, int_status, err_status);
664+
HECC_CANES_EP | HECC_CANES_EW))
665+
ti_hecc_error(ndev, int_status, err_status);
668666

669667
if (int_status & HECC_CANGIF_GMIF) {
670668
while (priv->tx_tail - priv->tx_head > 0) {
@@ -678,18 +676,19 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
678676
hecc_clear_bit(priv, HECC_CANME, mbx_mask);
679677
spin_unlock_irqrestore(&priv->mbx_lock, flags);
680678
stamp = hecc_read_stamp(priv, mbxno);
681-
stats->tx_bytes += can_rx_offload_get_echo_skb(&priv->offload,
682-
mbxno, stamp);
679+
stats->tx_bytes +=
680+
can_rx_offload_get_echo_skb(&priv->offload,
681+
mbxno, stamp);
683682
stats->tx_packets++;
684683
can_led_event(ndev, CAN_LED_EVENT_TX);
685684
--priv->tx_tail;
686685
}
687686

688687
/* restart queue if wrap-up or if queue stalled on last pkt */
689-
if (((priv->tx_head == priv->tx_tail) &&
690-
((priv->tx_head & HECC_TX_MASK) != HECC_TX_MASK)) ||
691-
(((priv->tx_tail & HECC_TX_MASK) == HECC_TX_MASK) &&
692-
((priv->tx_head & HECC_TX_MASK) == HECC_TX_MASK)))
688+
if ((priv->tx_head == priv->tx_tail &&
689+
((priv->tx_head & HECC_TX_MASK) != HECC_TX_MASK)) ||
690+
(((priv->tx_tail & HECC_TX_MASK) == HECC_TX_MASK) &&
691+
((priv->tx_head & HECC_TX_MASK) == HECC_TX_MASK)))
693692
netif_wake_queue(ndev);
694693

695694
/* offload RX mailboxes and let NAPI deliver them */
@@ -718,7 +717,7 @@ static int ti_hecc_open(struct net_device *ndev)
718717
int err;
719718

720719
err = request_irq(ndev->irq, ti_hecc_interrupt, IRQF_SHARED,
721-
ndev->name, ndev);
720+
ndev->name, ndev);
722721
if (err) {
723722
netdev_err(ndev, "error requesting interrupt\n");
724723
return err;
@@ -894,7 +893,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
894893
devm_can_led_init(ndev);
895894

896895
dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%u)\n",
897-
priv->base, (u32) ndev->irq);
896+
priv->base, (u32)ndev->irq);
898897

899898
return 0;
900899

drivers/net/can/vcan.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/*
2-
* vcan.c - Virtual CAN interface
1+
/* vcan.c - Virtual CAN interface
32
*
43
* Copyright (c) 2002-2017 Volkswagen Group Electronic Research
54
* All rights reserved.
@@ -39,6 +38,8 @@
3938
*
4039
*/
4140

41+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
42+
4243
#include <linux/module.h>
4344
#include <linux/init.h>
4445
#include <linux/netdevice.h>
@@ -57,9 +58,7 @@ MODULE_LICENSE("Dual BSD/GPL");
5758
MODULE_AUTHOR("Urs Thuermann <[email protected]>");
5859
MODULE_ALIAS_RTNL_LINK(DRV_NAME);
5960

60-
61-
/*
62-
* CAN test feature:
61+
/* CAN test feature:
6362
* Enable the echo on driver level for testing the CAN core echo modes.
6463
* See Documentation/networking/can.rst for details.
6564
*/
@@ -68,7 +67,6 @@ static bool echo; /* echo testing. Default: 0 (Off) */
6867
module_param(echo, bool, 0444);
6968
MODULE_PARM_DESC(echo, "Echo sent frames (for testing). Default: 0 (Off)");
7069

71-
7270
static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
7371
{
7472
struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
@@ -101,10 +99,8 @@ static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev)
10199

102100
if (!echo) {
103101
/* no echo handling available inside this driver */
104-
105102
if (loop) {
106-
/*
107-
* only count the packets here, because the
103+
/* only count the packets here, because the
108104
* CAN core already did the echo for us
109105
*/
110106
stats->rx_packets++;
@@ -117,7 +113,6 @@ static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev)
117113
/* perform standard echo handling for CAN network interfaces */
118114

119115
if (loop) {
120-
121116
skb = can_create_echo_skb(skb);
122117
if (!skb)
123118
return NETDEV_TX_OK;
@@ -173,10 +168,10 @@ static struct rtnl_link_ops vcan_link_ops __read_mostly = {
173168

174169
static __init int vcan_init_module(void)
175170
{
176-
pr_info("vcan: Virtual CAN interface driver\n");
171+
pr_info("Virtual CAN interface driver\n");
177172

178173
if (echo)
179-
printk(KERN_INFO "vcan: enabled echo on driver level.\n");
174+
pr_info("enabled echo on driver level.\n");
180175

181176
return rtnl_link_register(&vcan_link_ops);
182177
}

0 commit comments

Comments
 (0)