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>
This commit is contained in:
Markus Schneider-Pargmann (TI.com) 2025-10-01 16:30:21 +02:00 committed by Marc Kleine-Budde
parent 04d5826b07
commit 148e125d4e
4 changed files with 9 additions and 9 deletions

View File

@ -2408,7 +2408,7 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
sizeof(mram_config_vals) / 4);
if (ret) {
dev_err(dev, "Could not get Message RAM configuration.");
goto out;
return ERR_PTR(ret);
}
if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source"))
@ -2423,7 +2423,7 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
net_dev = alloc_candev(sizeof_priv, tx_fifo_size);
if (!net_dev) {
dev_err(dev, "Failed to allocate CAN device");
goto out;
return ERR_PTR(-ENOMEM);
}
class_dev = netdev_priv(net_dev);
@ -2433,7 +2433,7 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
m_can_of_parse_mram(class_dev, mram_config_vals);
spin_lock_init(&class_dev->tx_handling_spinlock);
out:
return class_dev;
}
EXPORT_SYMBOL_GPL(m_can_class_allocate_dev);

View File

@ -111,8 +111,8 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
mcan_class = m_can_class_allocate_dev(&pci->dev,
sizeof(struct m_can_pci_priv));
if (!mcan_class)
return -ENOMEM;
if (IS_ERR(mcan_class))
return PTR_ERR(mcan_class);
priv = cdev_to_priv(mcan_class);

View File

@ -87,8 +87,8 @@ static int m_can_plat_probe(struct platform_device *pdev)
mcan_class = m_can_class_allocate_dev(&pdev->dev,
sizeof(struct m_can_plat_priv));
if (!mcan_class)
return -ENOMEM;
if (IS_ERR(mcan_class))
return PTR_ERR(mcan_class);
priv = cdev_to_priv(mcan_class);

View File

@ -416,8 +416,8 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
mcan_class = m_can_class_allocate_dev(&spi->dev,
sizeof(struct tcan4x5x_priv));
if (!mcan_class)
return -ENOMEM;
if (IS_ERR(mcan_class))
return PTR_ERR(mcan_class);
ret = m_can_check_mram_cfg(mcan_class, TCAN4X5X_MRAM_SIZE);
if (ret)