Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1052437pxm; Wed, 23 Feb 2022 16:55:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuH5LSc2aA6HONbGKSU8ot2fdV3tOdgwvI5ihoTLPmcdtPPun9iao5g+cmz2Dfp5XuUumh X-Received: by 2002:a17:902:6b4a:b0:14d:474f:4904 with SMTP id g10-20020a1709026b4a00b0014d474f4904mr280868plt.122.1645664152001; Wed, 23 Feb 2022 16:55:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645664151; cv=none; d=google.com; s=arc-20160816; b=qGUFBEZbVOvbD3mo72RE7Bxvb3zC1LVWJEJGaBVtXX+Kos66V8ZlUTqFr23XLX4JZo r/MuQldtSgd7Ecmp1gNm1ywZ/+sgEGP/MUEz1av2B34dFwMfEpu5us3fUcT/2EumIT+0 PwdLqWY7KGdjsXvZj10En4LiaRaGw1QeUCwvlX9SiH2YFbmbGNn5apYuJH81vaNmkUrh PYoqXMWIdPsqDq1t4LBCikmRcgtf7aMr8ORFOGENhBbvmtIeJseOwDLe3AGpoQUNXC99 l8KWIn0hVEjO+ou2zR8Zwfxvz6f9ulYrUZRRiVODtx4Uwgvux4wrRz/MgBsbgytPYtWw clCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=alNyl1KfQO+V+SfyCQrXRZU0CihhZAB4Wnp96QyBXCk=; b=tRjbaNE0EauBeXelLzkosDWioPtdS8pTRNarf2E4Q5lRB80QBW/N1fApUv1vVxqQHb 30SNpbkgp/F3EN2mNOzrrx7PMbZu/nGFH5TQ10LshrXd7qg/eTQPrn3SIuaaHRR5l4K+ ll+8KQn5wHUeJ0/TL+mq0hjdgyNLf/UDcilo7M0vTbLa1Bbe9/ur6BGTDqs6FO+ARQ16 hCJENme1Du1j/3h/hSFSR5PxnF2rIhqjS/zDRajEGXDJH5wvUrXtVrsZVlpdkMFZVrBB 8A6Mvcj9Sm2p7R9s9s8CtxCJ2E60Ub5EB5+cXJOqGyxyh84i62mTWFgMXOQj8GrTcQ5b Yl7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ext.kapsi.fi header.s=20161220 header.b=0IsdVDps; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h7si1105533pgc.381.2022.02.23.16.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:55:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=fail header.i=@ext.kapsi.fi header.s=20161220 header.b=0IsdVDps; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CE299CF3A0; Wed, 23 Feb 2022 16:49:03 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241531AbiBWOYk (ORCPT + 99 others); Wed, 23 Feb 2022 09:24:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236675AbiBWOYj (ORCPT ); Wed, 23 Feb 2022 09:24:39 -0500 Received: from mailserv1.kapsi.fi (mailserv1.kapsi.fi [IPv6:2001:67c:1be8::25:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02012B1A87; Wed, 23 Feb 2022 06:24:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ext.kapsi.fi; s=20161220; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=alNyl1KfQO+V+SfyCQrXRZU0CihhZAB4Wnp96QyBXCk=; b=0IsdVDpsDh+adcMgpwSaRULTtn AzomItLdY/7BbevphqzhFBifn7pmtFalbvNVdPabj73MJSPouu7DgUTVKIHWwkEgT7yXikKTseuL/ VfIlFeKdcUIfyPe9HqzR+WdGWd65/CIG6VzC1uqvsAXQWaZKtV7YyXvDlfMP7JeRKmdh2fKeJIoVV aGTQAEWTgY1MI1p8/dRBok006vVn67cZ34ZmBPYWeDK8g8TdLJ8u1TKebLvUiU1NNwabudXK2Kt4n hO2wPBh4imuGtc2emHPDRN1GVguuj+PxU12fP7Z3RirP8ssXl7KOM41wDuJ8N/yJcYRhOPBTC9Xh/ EmfT6E/Q==; Received: from 201-31-196-88.dyn.estpak.ee ([88.196.31.201]:56813 helo=localhost) by mailserv1.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1nMsYm-0002Zi-Vl; Wed, 23 Feb 2022 16:24:07 +0200 Received: by localhost (sSMTP sendmail emulation); Wed, 23 Feb 2022 16:24:03 +0200 From: Mauri Sandberg To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sebastian Hesselbarth , "David S. Miller" , Jakub Kicinski , Mauri Sandberg , Andrew Lunn Date: Wed, 23 Feb 2022 16:23:37 +0200 Message-Id: <20220223142337.41757-1-maukka@ext.kapsi.fi> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221062441.2685-1-maukka@ext.kapsi.fi> References: <20220221062441.2685-1-maukka@ext.kapsi.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 88.196.31.201 X-SA-Exim-Mail-From: maukka@ext.kapsi.fi X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Subject: [PATCH v2] net: mv643xx_eth: process retval from of_get_mac_address X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on mailserv1.kapsi.fi) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Obtaining a MAC address may be deferred in cases when the MAC is stored in an NVMEM block, for example, and it may not be ready upon the first retrieval attempt and return EPROBE_DEFER. It is also possible that a port that does not rely on NVMEM has been already created when getting the defer request. Thus, also the resources allocated previously must be freed when doing a roll-back. Signed-off-by: Mauri Sandberg Cc: Andrew Lunn --- v1 -> v2 - escalate all error values from of_get_mac_address() - move mv643xx_eth_shared_of_remove() before mv643xx_eth_shared_of_probe() - release all resources potentially allocated for previous port nodes - update commit title and message --- drivers/net/ethernet/marvell/mv643xx_eth.c | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 105247582684..143ca8be5eb5 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -2704,6 +2704,16 @@ MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_ids); static struct platform_device *port_platdev[3]; +static void mv643xx_eth_shared_of_remove(void) +{ + int n; + + for (n = 0; n < 3; n++) { + platform_device_del(port_platdev[n]); + port_platdev[n] = NULL; + } +} + static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev, struct device_node *pnp) { @@ -2740,7 +2750,9 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev, return -EINVAL; } - of_get_mac_address(pnp, ppd.mac_addr); + ret = of_get_mac_address(pnp, ppd.mac_addr); + if (ret) + return ret; mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size); mv643xx_eth_property(pnp, "tx-sram-addr", ppd.tx_sram_addr); @@ -2804,21 +2816,13 @@ static int mv643xx_eth_shared_of_probe(struct platform_device *pdev) ret = mv643xx_eth_shared_of_add_port(pdev, pnp); if (ret) { of_node_put(pnp); + mv643xx_eth_shared_of_remove(); return ret; } } return 0; } -static void mv643xx_eth_shared_of_remove(void) -{ - int n; - - for (n = 0; n < 3; n++) { - platform_device_del(port_platdev[n]); - port_platdev[n] = NULL; - } -} #else static inline int mv643xx_eth_shared_of_probe(struct platform_device *pdev) { base-commit: cfb92440ee71adcc2105b0890bb01ac3cddb8507 -- 2.25.1