From patchwork Mon Jul 25 15:10:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12928225 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 AF507C433EF for ; Mon, 25 Jul 2022 15:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I3uSU0aef648fZTiQk/5xP2Y0FTBnASit0F06wkATKg=; b=ev1N57E9YmGEeY Yra4OUJy81Hrf1Gs/QNTIQL2MhpL1SCrScViYH6p8iRydxGIgeaRWYh7kl4USsIDYg0cMWF4pspxy eRvfr351Nmd/B4Nh1X4k7u5Oeebzs4PUiGBC+ThAggVOpajJh70k0lFPo3lNEXnaxPPNNHvysoOgg PlHFEN2w370RGS0rZUpSiOOtWsxaqHEnq4c5jJhQliZXSb+8ovi2jiYalxyoelvqgD1cXNkqssmI3 UgxFBYlCgBGDvqJil0CgCuJ2PD1mUj+BH93Y0uDY2/Z41bzkfYZvm3Z7vbbwP+sIHZZCsVqbBiLZa EJTw6oaB+2Zl5rYWQ0Pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzyU-00FLtY-PF; Mon, 25 Jul 2022 15:26:28 +0000 Received: from mail-eopbgr130089.outbound.protection.outlook.com ([40.107.13.89] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzkF-00FG5l-L2 for linux-arm-kernel@lists.infradead.org; Mon, 25 Jul 2022 15:11:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RksUMukzD2qWaDHmSybo2oq31VA9T1GmNKue8iGV4ml56IDhoO1wbZjlPPjM2tgEGekNj2w+5dV1n+9vd03xy2D6PEq3mVTUBlmL8K1FJo2BPrl7cwwre31i3fiJkSZlss1IGCoJCf1Na1Jcr4rDB3vDSvFfu6I0KChqfgN+9Pd4S0zrpBHhbF+dDLHG0bS3HrLMGTT7k8ve6mWGeCV2xSGTHzu48OWrAp/wLYLFtdubwljwbvq8LC+NQpyNdBVntG3GFUbGXFXBx5sSyl0friuSAEOb4y09zSkYRD45zN3DVUKntr16CBZMEpUmeWP1DEi4VxLghJw9JUnEwsD1OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F39VOWHdbomM6yNOWWJ7eMkODFt7MS7bR17qY8C8kTQ=; b=dnrMksz37jeQ1QazZXnO35A47VSXkdd8mkmQqHFP1d7phKtA47Pxg9eDyjCRyb3GyR5/HHYebuX6cnabJFYX113RuioJvUmGMJ3pfpkj0+8D9b5ExxhPs3p7wRRKSuNkCgb9xuqjpIvMzZpEvPAm63pUr8zGcG4I1TTpplTLlwqaz0JgVv4KHQSWA7rhdd8l1rfGNg9sh2t+MX+HTTEM15pJakbP4qKtrA5GfBlZgJrz8minD/9RSSVDSZkMBesba1QIpSkf2MEVbZXOTLhB8NCsjKvGCW19y27KAoCYmhsnAhO7C7ld5iol7ZKqkd+cjNDjaCClCvu+K91LGmjEhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F39VOWHdbomM6yNOWWJ7eMkODFt7MS7bR17qY8C8kTQ=; b=KZf4plhVNCCSlpLgYf9xqFH13sHDZeCDkGjrEG2juhHMN9ORg2K+h9DViJ3dsWIkUIHh+3DKny+UlIIB5IwUz7q183d9JpZK0Iu2IGpMDgY+GYqSt43yaqZ5UQvvX6gxVr5Cji26NihqSdyhib1WjBDt76w5+4uejAlksDiqObQQhdmMgf2ngoNZ4P16BkRCBlWDJ7BJhx+vK2bL/nbsUfPRk4aZMz8Mf217NjD1G4Rp9k/0/J6ZN40jfer2hgd2d/WY4AqNJxpPcChA3I1+vRT509QpcH7ikfCWX/aE2te09QP9ACZb4uT15z0asLrC2+wbonv2ZgiDpkefqoAB/A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB7PR03MB3723.eurprd03.prod.outlook.com (2603:10a6:5:6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Mon, 25 Jul 2022 15:11:35 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::59ef:35d2:2f27:e98b]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::59ef:35d2:2f27:e98b%4]) with mapi id 15.20.5458.018; Mon, 25 Jul 2022 15:11:35 +0000 From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Camelia Groza , linux-kernel@vger.kernel.org (open list), Madalin Bucur , linux-arm-kernel@lists.infradead.org, Sean Anderson Subject: [PATCH v4 20/25] net: fman: Clean up error handling Date: Mon, 25 Jul 2022 11:10:34 -0400 Message-Id: <20220725151039.2581576-21-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220725151039.2581576-1-sean.anderson@seco.com> References: <20220725151039.2581576-1-sean.anderson@seco.com> X-ClientProxiedBy: CH0PR03CA0229.namprd03.prod.outlook.com (2603:10b6:610:e7::24) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a49599f8-d676-4921-e548-08da6e4ff6ca X-MS-TrafficTypeDiagnostic: DB7PR03MB3723:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lCXwuiQjvbbWP0CsWXQGW+L8337Jldga4Mur5e1V0Q82c66BOp/i1bOMy6VGr3RLuDkx90pv2IYA8kn2etyH+HDs67FNUeWMUVkzAC8jNsOWt5S85Zg8QAXerd2VnYsNTMMBtzNpB029qRaD4MK/9ypGXqwQuXVwbyVfMUmwdm54bJNfg2mX8PuLEjHxSJjYq+pAmMrXXSH+7h45rnb7yFIXXUH2EWCvtx05KW0kybbGFc+m2raEm/fH0KI6ErgaQ6IYtMYQZfzlyPKxle9yC4v/yHUeGG7E9I/9W0sIn20bTlh2+ygZhZ4Vbrs9AblrOMxzi1Hh+UDtsJRMusZ32eB1quPPSHM4ZQhKO0+HdoXqNiINBsFINgrCFnnMyNGC+Ly5CBInS0qA7iTM/LdbLt7t+pSSdjzu99a4ZDwvleeYM+dq4R7dsTTpnmsFbZ3MbFk1f6llZupPAwv85Rb1uW/1QT9JQMhC48bQXvyLHbgfMAyZ3DbiKl06ZjoEM+Uv5zHnxYQoVN/XbfXCm9yIrRHPnaw+ABTYjSOAg4TlnFxh6OWsV+xb/yWe2N5tiTeD2v2zLWpGNmBXoyDxH9xSQ3TghXV4ncah9JqwvNLxN9MMbCJdXWZtLsoi2EK9x1Yg8P6WoqGwLwrEutVBbX0u83AdRbAUFApOU+CTr3ALpmfgdcU7GhP7ASgS1LorttpDHQlFV9udhOgXnRat4z+aHF5Ecdb9znytLMI8Ju965k+l+7stRog/CtC+3IJuy9UHSOFKNXMn7lumtvBnjjXXZk42SvMfA9Nyw0TTh+eXEnQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(396003)(346002)(39850400004)(376002)(366004)(186003)(6512007)(2616005)(107886003)(66946007)(1076003)(316002)(5660300002)(44832011)(66556008)(4326008)(66476007)(8936002)(6506007)(7416002)(52116002)(54906003)(110136005)(26005)(8676002)(6486002)(2906002)(38350700002)(86362001)(83380400001)(38100700002)(36756003)(478600001)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Hiqi9/UjrdI7QDOU/bgBoqUEW+N8/H2kzOZdu8t5WNMaVK9f7zeDL32G151CYdRE6Lyrgv6UfBSHYkzSzydqFIB/y6DQLB0ASE+zY4yvGqR3TTMV3fZpOE1NX9J8PFT1jFp/pP/QjezuTXSnMr3FmLHRQ8mil/mgqXq1NLnKo9k7pEsOCQbYULuZCam9RElNqFxZG8bCs36e2EA6t775yg3k7yh6ocw9UPAGvq6tA7jbRKdQJC4Vg1pS23CupAiAqYzCH6DJ/pEkY1iZXyeRa63LEPhoi6cdPjXeDtkC1R0kSJ/BP+0DmTS/w79YgchVsKXgEub3wifnyipiLs5lXPb7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zITuR63sk+lX8ba6xGFX+wGLb/RcIHog+fE+B7sKuFIkw1s/zKZ/tjXPmFGi+q28x2Lxd7kmhIPHrEor4xUmuVLFSPCTxbES+wZ1T/wwOxPy4qIk1VEPSkuk7TNhC5lq8PihUKvFuU7n/cs/8uRkUHtmKI5FcZjU6NpMrJkRkwbE5/z+5xZylDo3i3s6fK/dsT8gHGuEfOY2YSg== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: a49599f8-d676-4921-e548-08da6e4ff6ca X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2022 15:11:34.9404 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 47yl723nG0ElJ6LY1L2b9xcu37aZg1dVZY5dAJwuWR1N4QhNDwZSAGZkga4mccraAIVrWw8ZDdJoosL4bchUGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR03MB3723 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220725_081143_730285_2221FAB4 X-CRM114-Status: GOOD ( 12.79 ) 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 This removes the _return label, since something like err = -EFOO; goto _return; can be replaced by the briefer return -EFOO; Additionally, this skips going to _return_of_node_put when dev_node has already been put (preventing a double put). Signed-off-by: Sean Anderson Acked-by: Camelia Groza --- (no changes since v1) drivers/net/ethernet/freescale/fman/mac.c | 43 ++++++++--------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c index 66a3742a862b..7b7526fd7da3 100644 --- a/drivers/net/ethernet/freescale/fman/mac.c +++ b/drivers/net/ethernet/freescale/fman/mac.c @@ -291,15 +291,11 @@ static int mac_probe(struct platform_device *_of_dev) init = of_device_get_match_data(dev); mac_dev = devm_kzalloc(dev, sizeof(*mac_dev), GFP_KERNEL); - if (!mac_dev) { - err = -ENOMEM; - goto _return; - } + if (!mac_dev) + return -ENOMEM; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) { - err = -ENOMEM; - goto _return; - } + if (!priv) + return -ENOMEM; /* Save private information */ mac_dev->priv = priv; @@ -312,8 +308,7 @@ static int mac_probe(struct platform_device *_of_dev) if (!dev_node) { dev_err(dev, "of_get_parent(%pOF) failed\n", mac_node); - err = -EINVAL; - goto _return_of_node_put; + return -EINVAL; } of_dev = of_find_device_by_node(dev_node); @@ -352,28 +347,24 @@ static int mac_probe(struct platform_device *_of_dev) err = devm_request_resource(dev, fman_get_mem_region(priv->fman), res); if (err) { dev_err_probe(dev, err, "could not request resource\n"); - goto _return_of_node_put; + return err; } mac_dev->vaddr = devm_ioremap(dev, res->start, resource_size(res)); if (!mac_dev->vaddr) { dev_err(dev, "devm_ioremap() failed\n"); - err = -EIO; - goto _return_of_node_put; + return -EIO; } mac_dev->vaddr_end = mac_dev->vaddr + resource_size(res); - if (!of_device_is_available(mac_node)) { - err = -ENODEV; - goto _return_of_node_put; - } + if (!of_device_is_available(mac_node)) + return -ENODEV; /* Get the cell-index */ err = of_property_read_u32(mac_node, "cell-index", &val); if (err) { dev_err(dev, "failed to read cell-index for %pOF\n", mac_node); - err = -EINVAL; - goto _return_of_node_put; + return -EINVAL; } priv->cell_index = (u8)val; @@ -387,15 +378,13 @@ static int mac_probe(struct platform_device *_of_dev) if (unlikely(nph < 0)) { dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n", mac_node); - err = nph; - goto _return_of_node_put; + return nph; } if (nph != ARRAY_SIZE(mac_dev->port)) { dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n", mac_node); - err = -EINVAL; - goto _return_of_node_put; + return -EINVAL; } for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { @@ -404,8 +393,7 @@ static int mac_probe(struct platform_device *_of_dev) if (!dev_node) { dev_err(dev, "of_parse_phandle(%pOF, fsl,fman-ports) failed\n", mac_node); - err = -EINVAL; - goto _return_of_node_put; + return -EINVAL; } of_dev = of_find_device_by_node(dev_node); @@ -465,7 +453,7 @@ static int mac_probe(struct platform_device *_of_dev) if (err < 0) { dev_err(dev, "mac_dev->init() = %d\n", err); of_node_put(mac_dev->phy_node); - goto _return_of_node_put; + return err; } /* pause frame autonegotiation enabled */ @@ -492,11 +480,10 @@ static int mac_probe(struct platform_device *_of_dev) priv->eth_dev = NULL; } - goto _return; + return err; _return_of_node_put: of_node_put(dev_node); -_return: return err; }