Skip to content

Commit

Permalink
can: rcar_canfd: Improve error messages
Browse files Browse the repository at this point in the history
Improve printed error messages:
  - Replace numerical error codes by mnemotechnic error codes, to
    improve the user experience in case of errors,
  - Drop parentheses around printed numbers, cfr.
    Documentation/process/coding-style.rst,
  - Drop printing of an error message in case of out-of-memory, as the
    core memory allocation code already takes care of this.

Suggested-by: Vincent Mailhol <[email protected]>
Signed-off-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Reviewed-by: Vincent Mailhol <[email protected]>
Link: https://lore.kernel.org/all/4162cc46f72257ec191007675933985b6df394b9.1679414936.git.geert+renesas@glider.be
[mkl: use colon instead of comma]
Signed-off-by: Marc Kleine-Budde <[email protected]>
  • Loading branch information
geertu authored and marckleinebudde committed Mar 24, 2023
1 parent a0340df commit 33eced4
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions drivers/net/can/rcar/rcar_canfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,13 +1424,13 @@ static int rcar_canfd_open(struct net_device *ndev)
/* Peripheral clock is already enabled in probe */
err = clk_prepare_enable(gpriv->can_clk);
if (err) {
netdev_err(ndev, "failed to enable CAN clock, error %d\n", err);
netdev_err(ndev, "failed to enable CAN clock: %pe\n", ERR_PTR(err));
goto out_phy;
}

err = open_candev(ndev);
if (err) {
netdev_err(ndev, "open_candev() failed, error %d\n", err);
netdev_err(ndev, "open_candev() failed: %pe\n", ERR_PTR(err));
goto out_can_clock;
}

Expand Down Expand Up @@ -1731,10 +1731,9 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
int err = -ENODEV;

ndev = alloc_candev(sizeof(*priv), RCANFD_FIFO_DEPTH);
if (!ndev) {
dev_err(dev, "alloc_candev() failed\n");
if (!ndev)
return -ENOMEM;
}

priv = netdev_priv(ndev);

ndev->netdev_ops = &rcar_canfd_netdev_ops;
Expand Down Expand Up @@ -1777,8 +1776,8 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
rcar_canfd_channel_err_interrupt, 0,
irq_name, priv);
if (err) {
dev_err(dev, "devm_request_irq CH Err(%d) failed, error %d\n",
err_irq, err);
dev_err(dev, "devm_request_irq CH Err %d failed: %pe\n",
err_irq, ERR_PTR(err));
goto fail;
}
irq_name = devm_kasprintf(dev, GFP_KERNEL, "canfd.ch%d_trx",
Expand All @@ -1791,8 +1790,8 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
rcar_canfd_channel_tx_interrupt, 0,
irq_name, priv);
if (err) {
dev_err(dev, "devm_request_irq Tx (%d) failed, error %d\n",
tx_irq, err);
dev_err(dev, "devm_request_irq Tx %d failed: %pe\n",
tx_irq, ERR_PTR(err));
goto fail;
}
}
Expand Down Expand Up @@ -1823,7 +1822,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
gpriv->ch[priv->channel] = priv;
err = register_candev(ndev);
if (err) {
dev_err(dev, "register_candev() failed, error %d\n", err);
dev_err(dev, "register_candev() failed: %pe\n", ERR_PTR(err));
goto fail_candev;
}
dev_info(dev, "device registered (channel %u)\n", priv->channel);
Expand Down Expand Up @@ -1967,16 +1966,16 @@ static int rcar_canfd_probe(struct platform_device *pdev)
rcar_canfd_channel_interrupt, 0,
"canfd.ch_int", gpriv);
if (err) {
dev_err(dev, "devm_request_irq(%d) failed, error %d\n",
ch_irq, err);
dev_err(dev, "devm_request_irq %d failed: %pe\n",
ch_irq, ERR_PTR(err));
goto fail_dev;
}

err = devm_request_irq(dev, g_irq, rcar_canfd_global_interrupt,
0, "canfd.g_int", gpriv);
if (err) {
dev_err(dev, "devm_request_irq(%d) failed, error %d\n",
g_irq, err);
dev_err(dev, "devm_request_irq %d failed: %pe\n",
g_irq, ERR_PTR(err));
goto fail_dev;
}
} else {
Expand All @@ -1985,17 +1984,17 @@ static int rcar_canfd_probe(struct platform_device *pdev)
"canfd.g_recc", gpriv);

if (err) {
dev_err(dev, "devm_request_irq(%d) failed, error %d\n",
g_recc_irq, err);
dev_err(dev, "devm_request_irq %d failed: %pe\n",
g_recc_irq, ERR_PTR(err));
goto fail_dev;
}

err = devm_request_irq(dev, g_err_irq,
rcar_canfd_global_err_interrupt, 0,
"canfd.g_err", gpriv);
if (err) {
dev_err(dev, "devm_request_irq(%d) failed, error %d\n",
g_err_irq, err);
dev_err(dev, "devm_request_irq %d failed: %pe\n",
g_err_irq, ERR_PTR(err));
goto fail_dev;
}
}
Expand All @@ -2012,14 +2011,14 @@ static int rcar_canfd_probe(struct platform_device *pdev)
/* Enable peripheral clock for register access */
err = clk_prepare_enable(gpriv->clkp);
if (err) {
dev_err(dev, "failed to enable peripheral clock, error %d\n",
err);
dev_err(dev, "failed to enable peripheral clock: %pe\n",
ERR_PTR(err));
goto fail_reset;
}

err = rcar_canfd_reset_controller(gpriv);
if (err) {
dev_err(dev, "reset controller failed\n");
dev_err(dev, "reset controller failed: %pe\n", ERR_PTR(err));
goto fail_clk;
}

Expand Down

0 comments on commit 33eced4

Please sign in to comment.