From patchwork Mon Jul 29 07:41:31 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: 13744507 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 1CB1DC3DA4A for ; Mon, 29 Jul 2024 07:43:49 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qeg14f0KbqEGucxcVmm1WXsFuu/G6EBq2QXT7ORiCag=; b=e8L3NA11QIYixqlyuZ+HD4qfh8 nGnm2Mc/K+0rXlrFB4xHLg4ftZHE9s+dZ7/Wvr6x3pKFFjH6Wz7GoeVsfUCE81wvp//nHnzgE7si5 nDmPwE0E/8JIAVIdzSKahXCo31UsQlRbFLX1sRCI5Sq/WKcZP6FdoqV0Z1QqGLZhC9Ov5bT95XHeH ORbBkRDllexMqjtXFqHEAWv4P4MGvpzMFIhlan+Q1fdQPamu+ED/CHno2M7NCMKd6ylgoHgy1/Cvz LJ/K99tHeRCkBMU1Q0MjO74Vq0M8xzNzCPwZvOruENhl0x9vcl8pW5s36WNDP/o5iNJoXU4zjwFr8 EkoxChYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYL2i-0000000AOir-3KIo; Mon, 29 Jul 2024 07:43:40 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYL19-0000000AOCo-0Hw2 for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 07:42:04 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3683329f787so1237366f8f.1 for ; Mon, 29 Jul 2024 00:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722238921; x=1722843721; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qeg14f0KbqEGucxcVmm1WXsFuu/G6EBq2QXT7ORiCag=; b=3eJuUQIh6YpKMoxAMn5A/NQmkWfIcXCD7GiQco4BmrlHt4GDHrWjHTfz4We4JUMMCs kjpYW9biphxTEGbKbkIaar1qG4/Fva8Uk5n2UnohTwAreZNuJfjQZq5Gvo+gx/Eh4JGk CG54vzLJGZHQqbBrEMZ6rAlyfomSxbdBQZNC2qxZzm6mA3tVWpFCSRbMzQEC8OoWNG+q lAmYhtgVSLRqdumTEgDnaCGA8HrV43h/3WNbusYxC2gTtUgLwNUjSkgilN2F9R1DuI6o YCOb33DTBVTFm6xrs8JQehlx/73coONe9Hs/wsIdfy1vaWKcPLrkODvU7n8LW9IyR+fu 6/hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722238921; x=1722843721; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qeg14f0KbqEGucxcVmm1WXsFuu/G6EBq2QXT7ORiCag=; b=sv9+FGv8NgcIk/3/cNENqHiNmZIsZH60fsXtZAWwFW1HrnW6gxW9rftzCiuHuF91K4 GdoxN9BSQKouJyrDANnxfYR1xx9aNqEtaDXWrF3RKXj9qBvebgU5ny3hxBC/xkHc2WJ0 PVLGNEHE1B8eNPsvxJw7ouakMfPRaBV51yiiElzz5eNpybkIoYcnMxJQ3lH8f9Zu+tZW rnmBxmgqRmOFEwk7oA3feUaYRJDvAfyVnXPeIvv9aFRXz2qB4jDSugkEBKoJ9dqn5d2K MqH7mzR/ZqZP4FuxGSXG7LysG3H37ifUkEJgjmVKHfKdIbeSrs4mtg1iNvpGCOtgCHsT Hxtw== X-Forwarded-Encrypted: i=1; AJvYcCX52ZvWsBdyP31OLRaH/A0uxDXNwj2EEOPu1zHLvXXnPk2PVmbpqLBLPK1BcxJCZivcGInKC+88gO8HCbO47IteLQBZDEnkDlYlrGsQJT202naFFAM= X-Gm-Message-State: AOJu0YwqHMSj3LAh1zzKCag14HtCENKeOSpSlJVRghMEn334sR8qxigB WxV9/dKR/zcBDEX4+Bvh7ZqGsTo0eoPs8E6ayZoqp94EBLOMDUEfp90OXH5V4T0= X-Google-Smtp-Source: AGHT+IG/CESAQDtsmDP2HTDQ8KiBa0jkwD+YkksDTOEwTebAs8MrvspRVYp81dFcTJcPrwx9mnhJyg== X-Received: by 2002:adf:e94c:0:b0:369:f662:109b with SMTP id ffacd0b85a97d-36b5cf23abbmr4360020f8f.27.1722238920931; Mon, 29 Jul 2024 00:42:00 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36863aa7sm11460879f8f.109.2024.07.29.00.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 00:42:00 -0700 (PDT) From: Markus Schneider-Pargmann 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 , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Christophe JAILLET , Michal Kubiak Cc: Vibhore Vardhan , Kevin Hilman , Dhruva Gole , Conor Dooley , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/7] can: m_can: Return ERR_PTR on error in allocation Date: Mon, 29 Jul 2024 09:41:31 +0200 Message-ID: <20240729074135.3850634-4-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240729074135.3850634-1-msp@baylibre.com> References: <20240729074135.3850634-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_004203_221352_E8B1FDDB X-CRM114-Status: GOOD ( 14.84 ) 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 --- 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 2e4ccf05e162..5b80a7d1f9a1 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2352,7 +2352,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")) @@ -2367,7 +2367,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); @@ -2376,7 +2376,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 d72fe771dfc7..05a01dfdbfbf 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 983ab80260dd..a5024e2cff8d 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 2f73bf3abad8..4c40b4447275 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)