diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2020-10-16 18:03:59 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2021-01-29 09:31:58 +0100 |
commit | cf8ee6de2543a0fa6d9471ddbb7216464a9681a1 (patch) | |
tree | 869366f18211d4bdecbbafbee6013ae0e822c23e /drivers/net/can/spi | |
parent | dfe99ba29e6283d0533ca9bf5135c5a6c0f7a952 (diff) | |
download | linux-stable-cf8ee6de2543a0fa6d9471ddbb7216464a9681a1.tar.gz linux-stable-cf8ee6de2543a0fa6d9471ddbb7216464a9681a1.tar.bz2 linux-stable-cf8ee6de2543a0fa6d9471ddbb7216464a9681a1.zip |
can: mcp251xfd: mcp251xfd_probe(): use dev_err_probe() to simplify error handling
dev_err_probe() can reduce code size, uniform error handling and record the
defer probe reason etc., use it to simplify the code.
Link: https://lore.kernel.org/r/20210128104644.2982125-9-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/spi')
-rw-r--r-- | drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c index da5e8e416440..3c5b92911d46 100644 --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c @@ -2849,32 +2849,28 @@ static int mcp251xfd_probe(struct spi_device *spi) rx_int = devm_gpiod_get_optional(&spi->dev, "microchip,rx-int", GPIOD_IN); - if (PTR_ERR(rx_int) == -EPROBE_DEFER) - return -EPROBE_DEFER; - else if (IS_ERR(rx_int)) - return PTR_ERR(rx_int); + if (IS_ERR(rx_int)) + return dev_err_probe(&spi->dev, PTR_ERR(rx_int), + "Failed to get RX-INT!\n"); reg_vdd = devm_regulator_get_optional(&spi->dev, "vdd"); - if (PTR_ERR(reg_vdd) == -EPROBE_DEFER) - return -EPROBE_DEFER; - else if (PTR_ERR(reg_vdd) == -ENODEV) + if (PTR_ERR(reg_vdd) == -ENODEV) reg_vdd = NULL; else if (IS_ERR(reg_vdd)) - return PTR_ERR(reg_vdd); + return dev_err_probe(&spi->dev, PTR_ERR(reg_vdd), + "Failed to get VDD regulator!\n"); reg_xceiver = devm_regulator_get_optional(&spi->dev, "xceiver"); - if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER) - return -EPROBE_DEFER; - else if (PTR_ERR(reg_xceiver) == -ENODEV) + if (PTR_ERR(reg_xceiver) == -ENODEV) reg_xceiver = NULL; else if (IS_ERR(reg_xceiver)) - return PTR_ERR(reg_xceiver); + return dev_err_probe(&spi->dev, PTR_ERR(reg_xceiver), + "Failed to get Transceiver regulator!\n"); clk = devm_clk_get(&spi->dev, NULL); - if (IS_ERR(clk)) { - dev_err(&spi->dev, "No Oscillator (clock) defined.\n"); - return PTR_ERR(clk); - } + if (IS_ERR(clk)) + dev_err_probe(&spi->dev, PTR_ERR(clk), + "Failed to get Oscillator (clock)!\n"); freq = clk_get_rate(clk); /* Sanity check */ |