]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
can: m_can: Return ERR_PTR on error in allocation
authorMarkus Schneider-Pargmann (TI.com) <msp@baylibre.com>
Wed, 1 Oct 2025 14:30:21 +0000 (16:30 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 17 Oct 2025 09:02:28 +0000 (11:02 +0200)
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>
drivers/net/can/m_can/m_can.c
drivers/net/can/m_can/m_can_pci.c
drivers/net/can/m_can/m_can_platform.c
drivers/net/can/m_can/tcan4x5x-core.c

index f00bdec3246a130a2854de93529c90827cd175aa..10b5862b488018fc10b139d8717c0bb6155f3eb3 100644 (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);
index 9ad7419f88f83016e93667f4847fe536eca39ad1..eb31ed1f964491ab41c7811be317706a09951390 100644 (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);
 
index 4a412add2b8d36bc6eae68f6914f14d637e8cbdf..56da411878af0185ff9cc512e325137428a68255 100644 (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);
 
index 39b0b5277b11f5cf86137528e7ebea93a6d29c80..31cc9d0abd45360de8700d0a0270af8d3e42967d 100644 (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)