Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: m_can: Return ERR_PTR on error in allocation

We have more detailed error values available, return them in the core
driver and the calling drivers to return proper errors to callers.

Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Reviewed-by: Kendall Willis <k-willis@ti.com>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
Link: https://patch.msgid.link/20251001-topic-mcan-wakeup-source-v6-12-v10-3-4ab508ac5d1e@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Markus Schneider-Pargmann (TI.com) and committed by
Marc Kleine-Budde
148e125d 04d5826b

+9 -9
+3 -3
drivers/net/can/m_can/m_can.c
··· 2408 2408 sizeof(mram_config_vals) / 4); 2409 2409 if (ret) { 2410 2410 dev_err(dev, "Could not get Message RAM configuration."); 2411 - goto out; 2411 + return ERR_PTR(ret); 2412 2412 } 2413 2413 2414 2414 if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source")) ··· 2423 2423 net_dev = alloc_candev(sizeof_priv, tx_fifo_size); 2424 2424 if (!net_dev) { 2425 2425 dev_err(dev, "Failed to allocate CAN device"); 2426 - goto out; 2426 + return ERR_PTR(-ENOMEM); 2427 2427 } 2428 2428 2429 2429 class_dev = netdev_priv(net_dev); ··· 2433 2433 2434 2434 m_can_of_parse_mram(class_dev, mram_config_vals); 2435 2435 spin_lock_init(&class_dev->tx_handling_spinlock); 2436 - out: 2436 + 2437 2437 return class_dev; 2438 2438 } 2439 2439 EXPORT_SYMBOL_GPL(m_can_class_allocate_dev);
+2 -2
drivers/net/can/m_can/m_can_pci.c
··· 111 111 112 112 mcan_class = m_can_class_allocate_dev(&pci->dev, 113 113 sizeof(struct m_can_pci_priv)); 114 - if (!mcan_class) 115 - return -ENOMEM; 114 + if (IS_ERR(mcan_class)) 115 + return PTR_ERR(mcan_class); 116 116 117 117 priv = cdev_to_priv(mcan_class); 118 118
+2 -2
drivers/net/can/m_can/m_can_platform.c
··· 87 87 88 88 mcan_class = m_can_class_allocate_dev(&pdev->dev, 89 89 sizeof(struct m_can_plat_priv)); 90 - if (!mcan_class) 91 - return -ENOMEM; 90 + if (IS_ERR(mcan_class)) 91 + return PTR_ERR(mcan_class); 92 92 93 93 priv = cdev_to_priv(mcan_class); 94 94
+2 -2
drivers/net/can/m_can/tcan4x5x-core.c
··· 416 416 417 417 mcan_class = m_can_class_allocate_dev(&spi->dev, 418 418 sizeof(struct tcan4x5x_priv)); 419 - if (!mcan_class) 420 - return -ENOMEM; 419 + if (IS_ERR(mcan_class)) 420 + return PTR_ERR(mcan_class); 421 421 422 422 ret = m_can_check_mram_cfg(mcan_class, TCAN4X5X_MRAM_SIZE); 423 423 if (ret)