From patchwork Fri Oct 11 13:16:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13832566 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 576AED0D78D for ; Fri, 11 Oct 2024 13:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iCNLKfw0M7WpUeLbjzkp9aabjUez3xfd1Cb1mml4nhQ=; b=FygiVWP0u1fKaFJi3hWlEfJsml B3WPl5DiIMmMp7Ku9Pde7cOXvha0d8AOXyE1x+o8ptDAUoDSqa4I1gqP4VyA9iWhiNQHZ2xP27s87 9ydiEYp2qWMAuAbo70oqTK8QumGXfPUbsHG26YNzOvhk8XgK6K8wEVWe2vgcmEL3uvxhLqidZeB41 MD1I6IHDiQoUEx+vBv4XD416sMnmm/k3b2uYhS1vzmsVmlFS1pI6620DaIy3Wnx5Cp/4U8Uidi/EU OsTRj9rsHokoKX4QblTvv+CnMXuMNjs6s1v6j6vvj/GhmNCsTyxYrx5m7BnNBfdmjmOaLnHJC8DoX 2Cy2BBUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szFda-0000000GRb5-3MjE; Fri, 11 Oct 2024 13:24:58 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szFWv-0000000GQ5I-2VlI for linux-arm-kernel@lists.infradead.org; Fri, 11 Oct 2024 13:18:06 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5c5b954c359so2402977a12.1 for ; Fri, 11 Oct 2024 06:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1728652684; x=1729257484; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iCNLKfw0M7WpUeLbjzkp9aabjUez3xfd1Cb1mml4nhQ=; b=lqwu80IeipUO8FjSdFCSVH0CcZcSoTT8J4OveoHKZfmPNLRMpGjQ5KQxx9uEX4ZsgC iffblGc1tcbUT6ISq21qP8YmjYSm54omMYpVX+WPK0UglVYzGEbt1tcaMeEz68N6yR4Z 9bT51KFTGW8yO/Fu4AFxpplpJPZ6ClYhmTKRPJbNKJt9bfOSWZysndbNx3r7FGxqeKqD c8VJL3VzcZu1OMUK+HvOkMd+mOiqlXzO59zZmpVA5tJm4d4rAdsZnVMQ+hIGgTdl6MVe VcfnQj2otPJPBhtceazXMWMNZYIixkPZIBM8X20XFE0vcfgeNNkrK2Bc19cL7Ius8g4T 1t+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728652684; x=1729257484; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iCNLKfw0M7WpUeLbjzkp9aabjUez3xfd1Cb1mml4nhQ=; b=vNcL9YDoNlDZZwuZGX0n40AQF6AR2Jv95brFjNjUmxXu/Ze1qzh9MnAlMVa17mzxvX 4uGQZN9pTRyDvDXhjpjgbISJKTKZbdldMofaBr7IjYjL9gzB1odzZ3pmC1BmJW2IxXhy jbGtXVYLWb8484hZ560drvtVIRgk8r8LLyVOF+zK89bh5p5x7HKoTGtnmB9gMA8XJLUx K1rK2edOpkBBQ2OoEYOYl5T47Qtpqgk/Devk5WwZDkX32pNBRGi826xohA6qdluwiApd CgaRxgMAs3w0dq8MBJNF/6Mx5sygLkfM3fJzfNAheCQQtUdt8AebpzryPrxl+EQ82gSI ck3A== X-Forwarded-Encrypted: i=1; AJvYcCUuTeRQJ3X7WOkab7ROvz3SuOpPhHRnaJ95jEXgMj7k6HimeEERyX6b7B0H4P/qXENjxlEotI04ESGDbnLi0WxZ@lists.infradead.org X-Gm-Message-State: AOJu0YyZsCnPJoFOKWQdR2Kg4ruN3v173HFAaVMyQCsY2ydXEKKESfZF zlBpOOq6K15DN4PNFq+kyPClZh+DjrzdpYtew0lVs49Y8JThnJQ9HGvpP8IQwDo= X-Google-Smtp-Source: AGHT+IFQfR6/BL+UbBnXcWXuHv+Bf9nvEzHpLlQPVU/JaI/HqDVV39oK5GhdoCm9/k00vv50syIxeA== X-Received: by 2002:a17:907:368d:b0:a77:c95e:9b1c with SMTP id a640c23a62f3a-a99b93c1e47mr236799766b.27.1728652683727; Fri, 11 Oct 2024 06:18:03 -0700 (PDT) Received: from localhost ([2001:4090:a244:83ae:2517:2666:43c9:d0d3]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80f29e5sm209874466b.204.2024.10.11.06.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 06:18:03 -0700 (PDT) From: Markus Schneider-Pargmann Date: Fri, 11 Oct 2024 15:16:41 +0200 Subject: [PATCH v3 4/9] can: m_can: Return ERR_PTR on error in allocation MIME-Version: 1.0 Message-Id: <20241011-topic-mcan-wakeup-source-v6-12-v3-4-9752c714ad12@baylibre.com> References: <20241011-topic-mcan-wakeup-source-v6-12-v3-0-9752c714ad12@baylibre.com> In-Reply-To: <20241011-topic-mcan-wakeup-source-v6-12-v3-0-9752c714ad12@baylibre.com> To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Matthias Schiffer , Vishal Mahaveer , Kevin Hilman , Dhruva Gole , Markus Schneider-Pargmann X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3461; i=msp@baylibre.com; h=from:subject:message-id; bh=Yb7+ZkGNEL4O326OlkJgvKGqwn2t7za2oUgItrtB1AA=; b=owGbwMvMwCGm0rPl0RXRdfaMp9WSGNI5VVODT7w+FxYs9OfegbtnYh7vX1my6OWWKDnLPY/Nf 0xWVrpm2lHKwiDGwSArpshy98PCd3Vy1xdErHvkCDOHlQlkCAMXpwBM5LAUwz/NpJMRi159XsZV +DXSxWhz1eH0V9azq04//uXl+jX/wLVzDL9ZFaferzTifqX/NYT/VLTz47fTH1ateGhbKPq+/0a Usx8rAA== X-Developer-Key: i=msp@baylibre.com; a=openpgp; fpr=BADD88DB889FDC3E8A3D5FE612FA6A01E0A45B41 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241011_061805_680631_3927E541 X-CRM114-Status: GOOD ( 15.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We have more detailed error values available, return them in the core driver and the calling drivers to return proper errors to callers. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Vincent Mailhol --- drivers/net/can/m_can/m_can.c | 6 +++--- drivers/net/can/m_can/m_can_pci.c | 4 ++-- drivers/net/can/m_can/m_can_platform.c | 4 ++-- drivers/net/can/m_can/tcan4x5x-core.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 29accadc20de7e9efa509f14209cc62e599f03bb..5ab0bb3f1c71e7dc4d6144f7b9e8f58d0e0303fe 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2355,7 +2355,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")) @@ -2370,7 +2370,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); @@ -2379,7 +2379,7 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, SET_NETDEV_DEV(net_dev, dev); m_can_of_parse_mram(class_dev, mram_config_vals); -out: + return class_dev; } EXPORT_SYMBOL_GPL(m_can_class_allocate_dev); diff --git a/drivers/net/can/m_can/m_can_pci.c b/drivers/net/can/m_can/m_can_pci.c index d72fe771dfc7aa768c728f817e67a87b49fd9974..05a01dfdbfbf18b74f796d2efc75e2be5cbb75ed 100644 --- a/drivers/net/can/m_can/m_can_pci.c +++ b/drivers/net/can/m_can/m_can_pci.c @@ -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); diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c index b832566efda042929486578fad1879c7ad4a0cff..40bd10f71f0e2fab847c40c5bd5f7d85d3d46712 100644 --- a/drivers/net/can/m_can/m_can_platform.c +++ b/drivers/net/can/m_can/m_can_platform.c @@ -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); diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index 2f73bf3abad889c222f15c39a3d43de1a1cf5fbb..4c40b444727585b30df33a897c398e35e7592fb2 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -375,8 +375,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)