Skip to content

Commit

Permalink
Merge tag 'linux-can-fixes-for-5.10-20201130' of git://git.kernel.org…
Browse files Browse the repository at this point in the history
…/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
pull-request: can 2020-11-30

The first patch is by me an target the tcan4x5x bindings for the m_can driver.
It fixes the error path in the tcan4x5x_can_probe() function.

The next two patches are by Jeroen Hofstee and makes the lost of arbitration
error counters of sja1000 and the sun4i drivers consistent with the other
drivers.

Zhang Qilong contributes two patch that clean up the error path in the c_can
and kvaser_pciefd drivers.

* tag 'linux-can-fixes-for-5.10-20201130' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can:
  can: kvaser_pciefd: kvaser_pciefd_open(): fix error handling
  can: c_can: c_can_power_up(): fix error handling
  can: sun4i_can: sun4i_can_err(): don't count arbitration lose as an error
  can: sja1000: sja1000_err(): don't count arbitration lose as an error
  can: m_can: tcan4x5x_can_probe(): fix error path: remove erroneous clk_disable_unprepare()
====================

Link: https://lore.kernel.org/r/20201130125307.218258-1-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Dec 1, 2020
2 parents a5e7402 + 13a84cf commit 237f977
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
18 changes: 14 additions & 4 deletions drivers/net/can/c_can/c_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,12 +1295,22 @@ int c_can_power_up(struct net_device *dev)
time_after(time_out, jiffies))
cpu_relax();

if (time_after(jiffies, time_out))
return -ETIMEDOUT;
if (time_after(jiffies, time_out)) {
ret = -ETIMEDOUT;
goto err_out;
}

ret = c_can_start(dev);
if (!ret)
c_can_irq_control(priv, true);
if (ret)
goto err_out;

c_can_irq_control(priv, true);

return 0;

err_out:
c_can_reset_ram(priv, false);
c_can_pm_runtime_put_sync(priv);

return ret;
}
Expand Down
4 changes: 3 additions & 1 deletion drivers/net/can/kvaser_pciefd.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,10 @@ static int kvaser_pciefd_open(struct net_device *netdev)
return err;

err = kvaser_pciefd_bus_on(can);
if (err)
if (err) {
close_candev(netdev);
return err;
}

return 0;
}
Expand Down
11 changes: 3 additions & 8 deletions drivers/net/can/m_can/tcan4x5x.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,18 +489,18 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
spi->bits_per_word = 32;
ret = spi_setup(spi);
if (ret)
goto out_clk;
goto out_m_can_class_free_dev;

priv->regmap = devm_regmap_init(&spi->dev, &tcan4x5x_bus,
&spi->dev, &tcan4x5x_regmap);
if (IS_ERR(priv->regmap)) {
ret = PTR_ERR(priv->regmap);
goto out_clk;
goto out_m_can_class_free_dev;
}

ret = tcan4x5x_power_enable(priv->power, 1);
if (ret)
goto out_clk;
goto out_m_can_class_free_dev;

ret = tcan4x5x_parse_config(mcan_class);
if (ret)
Expand All @@ -519,11 +519,6 @@ static int tcan4x5x_can_probe(struct spi_device *spi)

out_power:
tcan4x5x_power_enable(priv->power, 0);
out_clk:
if (!IS_ERR(mcan_class->cclk)) {
clk_disable_unprepare(mcan_class->cclk);
clk_disable_unprepare(mcan_class->hclk);
}
out_m_can_class_free_dev:
m_can_class_free_dev(mcan_class->net);
dev_err(&spi->dev, "Probe failed, err=%d\n", ret);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/can/sja1000/sja1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
netdev_dbg(dev, "arbitration lost interrupt\n");
alc = priv->read_reg(priv, SJA1000_ALC);
priv->can.can_stats.arbitration_lost++;
stats->tx_errors++;
cf->can_id |= CAN_ERR_LOSTARB;
cf->data[0] = alc & 0x1f;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/net/can/sun4i_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
netdev_dbg(dev, "arbitration lost interrupt\n");
alc = readl(priv->base + SUN4I_REG_STA_ADDR);
priv->can.can_stats.arbitration_lost++;
stats->tx_errors++;
if (likely(skb)) {
cf->can_id |= CAN_ERR_LOSTARB;
cf->data[0] = (alc >> 8) & 0x1f;
Expand Down

0 comments on commit 237f977

Please sign in to comment.