From patchwork Tue Oct 15 19:15:58 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: 13837014 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 6E37ED1F9C5 for ; Tue, 15 Oct 2024 19:26:02 +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=I+gZxIafqFrR6BMcHIhEjszPUzk8N9qpO7jS8LguSsI=; b=yKxcWseEM/M83pwpro5FMzcOsc PB9+n1Op1HNC2fgW5TPDkjFvNkVK8MyFrFoLVjI0eo82EKCBQw3muY0FUX3D1vXq4zpiFD6cV+p4L ekTLYlSHqbRlPFZg0Bn6XefF/Fz2kVXHhMZKgKcjtxSaVpszJA61Iecl7Rvfn/wuhgNVYYBPxlqa8 KT/cel/29XIhMzZ312NQlwZFUblwS2MHqggY8yyMfOAU1aVJz1z3fi6MVbhESF8JjmVrMgL0Gj4EM hCOW3EHXhlOad0tpimv/LiJ0B3+o7ARNrarOeig00y0Ja+V+MBWYYRZkOSCLa51+FTpIZik8vLmH2 tBLBtiFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0nAz-00000009O5r-3bFZ; Tue, 15 Oct 2024 19:25:49 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0n2s-00000009MWF-10zB for linux-arm-kernel@bombadil.infradead.org; Tue, 15 Oct 2024 19:17:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=I+gZxIafqFrR6BMcHIhEjszPUzk8N9qpO7jS8LguSsI=; b=oWOZFTl7E/L/IwCRTDWjaxQvqV S6GuTyQDUBDQzFZAHKRdWiX3v7Q4/YAx8aytK5PrEML6swMqs8ItulffROExgEx7pA44aCqPyw4ES v/N/s/KBm4MNhm71vlscFjt3huJ6h8gxWDirNjnIAv5uKJqmOPV+tzn/DoaxeVc/9xpvPNAAEyJlK M9wt7LzEH6i0Ao2WRNtj5WISzxvSpCCjgMgM/7unaiXPy8n5qIAOq5M2ViY8Ukbzo7XOY3hJBk5+9 jyQSRyOw/3FjMAn1c2UUf5wa+Iw6AvdWXlEKVWNZu7s+kqqScpPF8Wv2WPahsgoKATIWBIzcKem8R AH3cuZmw==; Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0n2j-00000006dfj-1lTk for linux-arm-kernel@lists.infradead.org; Tue, 15 Oct 2024 19:17:21 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a93c1cc74fdso946006266b.3 for ; Tue, 15 Oct 2024 12:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729019834; x=1729624634; 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=I+gZxIafqFrR6BMcHIhEjszPUzk8N9qpO7jS8LguSsI=; b=FVgKiZiaC3/CI1sWGs/2gUslsqOCwQgQ5oCrynV462PwiqPbweb998SSx6IJyZPvLC 93E27/cin1aVowOaqLsLxKFY/EpKr0MDBxlyUn8LgdWoc3NaTkn+p6R6zrlEDIPx7W83 DCBmMIo3FZMrFi4yVPn7RrFtlqGo5dMkB0YJUKbTuBF3I6a2SwT5AlNRRfnsLBt1FC5C shuCLosv/f1unQq3IMSQPexrGMhr4ESDm32OMHjnUNWrXJOs3kZfhsvW0ZyPamMjTzLV zgkTxmTZHUE7I9zhNFna8Yd/mx4nW8Txz5O9OFz4FAKZgKMIqXnLVnRlvJpgmOCLB/Js T6dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729019834; x=1729624634; 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=I+gZxIafqFrR6BMcHIhEjszPUzk8N9qpO7jS8LguSsI=; b=BnDS/7icSHUPnUSqaKsNjPglTLvKVbjn7yyMaLYW/HByDIv2ZC6UsZUabV35KXQvrD on8gpIMsx5Ih2a+c61VuClAzNGqWy2Gk2gCnP95eRdWiW6Hmy5M1h/X5j7+cTWQndH0J F97ZcXOmS1iPle1c1KIvq3sL1ftTSYmEQdldYdTfPlFCLU8JaqRLCLNE5bR3cmDuqWM4 nOlt/Z0/+GS4pv0Et+7+UDAsP32G4oq5AnZ0F4bl3RL70BIAhlnWiZtCTZti8NvfqeEr UlpGzZ6f57XyOfaLwWxLqlah7uZVv44C9c3VzB3XejV/pBl3SPhRqKHRyX5DvDLV712g nVzg== X-Forwarded-Encrypted: i=1; AJvYcCWUxcGrykA95pdwrtvED991tIag8jcEh7F10vSd+mPCuCoTvec7MS5eH0evCYJoFJ3gBE87kTEpIAOLNnv/Kirs@lists.infradead.org X-Gm-Message-State: AOJu0YxVG8A+hLDpYMflq0wtVi5uaWrrQ+QqPv+Nzz81zu/QQN4CHi2L dDXPWYOok05Y/PPBWBvxt83tCKiiLMOeEif7Qv9kbJYy0FczqV5YB0g7W+BV0v8= X-Google-Smtp-Source: AGHT+IEnWhyoMdkPWKAnqSZfQ5E35xloBUwyytezjQk7zjPCXojeRmRve/u2bGJ3yuGwNR720ej3zA== X-Received: by 2002:a17:907:f1c7:b0:a99:8a0e:8710 with SMTP id a640c23a62f3a-a99e3b5b167mr1064453866b.14.1729019834109; Tue, 15 Oct 2024 12:17:14 -0700 (PDT) Received: from localhost ([2001:4090:a244:83ae:2517:2666:43c9:d0d3]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a2988c57asm101052866b.204.2024.10.15.12.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 12:17:13 -0700 (PDT) From: Markus Schneider-Pargmann Date: Tue, 15 Oct 2024 21:15:58 +0200 Subject: [PATCH v4 4/9] can: m_can: Return ERR_PTR on error in allocation MIME-Version: 1.0 Message-Id: <20241015-topic-mcan-wakeup-source-v6-12-v4-4-fdac1d1e7aa6@baylibre.com> References: <20241015-topic-mcan-wakeup-source-v6-12-v4-0-fdac1d1e7aa6@baylibre.com> In-Reply-To: <20241015-topic-mcan-wakeup-source-v6-12-v4-0-fdac1d1e7aa6@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 , Simon Horman , Vincent MAILHOL , Markus Schneider-Pargmann X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3520; i=msp@baylibre.com; h=from:subject:message-id; bh=FuSyoKzeygeLVHKVCKFUjItYDNK1CDXLTHh7H2UiD20=; b=owGbwMvMwCGm0rPl0RXRdfaMp9WSGNL59k/z2Lj1No/cl7I9t1MUPx1QXZx7ecckPVFvB4mmI 2vai37N7ShlYRDjYJAVU2S5+2Hhuzq56wsi1j1yhJnDygQyhIGLUwAmsnEtI8MuIZcVy569Tdhl d/vE54mpLC8EmrNF9zk++LzZc6pH01NORoZbyw0ily0ubKg1lLGYPcPCO03OcfI1x4lTduVd3MI WEsUIAA== 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-20241015_201718_538303_95461296 X-CRM114-Status: GOOD ( 15.64 ) 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. Reviewed-by: Vincent Mailhol Signed-off-by: Markus Schneider-Pargmann --- 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 d427645a5b3baf7d0a648e3b008d7d7de7f23374..5a4e0ad07e9ecc82de5f1f606707f3380d3679fc 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)