From patchwork Sun Oct 1 11:02:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 9979673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13AA860365 for ; Sun, 1 Oct 2017 11:03:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06E8628B77 for ; Sun, 1 Oct 2017 11:03:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFF2728B7F; Sun, 1 Oct 2017 11:03:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F73328B77 for ; Sun, 1 Oct 2017 11:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qW5kJXXbXqUGn8We1AnVMQXPPJ//ub664NAuaq4Jwis=; b=k5W77DoF+oGXuz+7FLvxzAkM86 OT7sa4tBIkiXF4ZpRo4dAb1V7zL2gt67WViB67bU6DAOjW4vnZIuMX/0Whf88fe+uFr8NftttyCwR Gz8t4mC6AtdCWOIwLGX007EnQHxc/0yZesderatmVVSKQrE1y3vVsifaC65aKlKFQbPfom5zk6Og/ 7EuEM1vGDFBqja6v49FddcZ1q53rbLKDfKCFMTAH1Ee5HmTjmwQV8Cp2UcOjqRUDNVUANDLGiLd5I 8fEDVk1OYt4+lssVc2FGlvnWXOKu7kb8gSDZYnkSF60VhhINerNJtaSFOtcM8BZ9zxAVlaEAYGAKY 8lSDOW3w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dyc27-0005x1-UX; Sun, 01 Oct 2017 11:03:40 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dyc14-0004vT-5h for linux-arm-kernel@lists.infradead.org; Sun, 01 Oct 2017 11:02:37 +0000 Received: by mail-wm0-x242.google.com with SMTP id b189so1874336wmd.2 for ; Sun, 01 Oct 2017 04:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/+eszXk8aFpWJrxTbJ/QkRiJ0VmXeFFSvgGJJzivwBw=; b=RNw+A1GNPME0UZmAnNxD+LCgQ5VVHuIx66Mpa1EDuj91lOO7lT7DhlD+C1LWnm0NTF xBAkDX30f1P6I619Mpq0znMZQN3GceQhtu0DtJFzUBaAuVGjlZ0W0FuIbvYy5luVVyuY RSE+bBFiJH8o/NLn2bLXz4kco2Uj6ORgWoBR8NYXt2oiLIqVxSq3hy3dH6TDjH5wdSsL 5DgCzZ3NvKoIRXvCvyNUBMqEiRyhVzbDVewwlXFv7ja6cloVWpcwFVUH2KGY9by49QHR VR6YhN8u9lI+n2ddAxDYh0LIRbtPLTcIiBqdUCQw5xPkA3vAM009AJWxUmkiQ2TRXyTL BZQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/+eszXk8aFpWJrxTbJ/QkRiJ0VmXeFFSvgGJJzivwBw=; b=L3SSJNMbvq5slpOCUgeuSoVJ69IfqszkI3/EKcJLQlJhAM/IKvp/TyS5Sr4ssc/WPb Zzo1ZrZHGT/pbKaKaDWCMEAAqorKKy6385dGBVCZNCq7yH7FRqlvlUk5ojRJsdY7I5EJ ICTS3O2DlFRRjklr06zVTFSQmFCbhQ54OOdYbqK6fle3J14GaclgxxDR7etJu76jXR4x srfycZIFG+aj5fEkF1Bi5GDWWzdeMb8NQM2V7bIZ3JtFTmkHDIdbsE/MpjugRG0wcWRR GMRHrJhZZnL7cCTO0G6TLFhOzhP+iUu3kKfbamaCoG18c6V9WYDU40AM8Rl/i6e9VeZH KrLw== X-Gm-Message-State: AHPjjUiW6NR1oUg9SihCDDNFg1tG1tVf4dLsw4MFw85zmEe43kwl5x+o 7s4Kr1vwiqSPIQiYEJuylJs= X-Google-Smtp-Source: AOwi7QAxjvryYq7EUUX55fp1WmgL+dPbac8f9m7wPjf24eXuZhdk1xEuwXHdH+1ua5WUyPqzZrKFhg== X-Received: by 10.80.241.92 with SMTP id z28mr16426598edl.294.1506855732060; Sun, 01 Oct 2017 04:02:12 -0700 (PDT) Received: from localhost.localdomain ([2001:470:9e39::48e]) by smtp.gmail.com with ESMTPSA id 26sm7404270eds.5.2017.10.01.04.02.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Oct 2017 04:02:11 -0700 (PDT) From: Jonas Gorski To: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.or Subject: [PATCH 1/6] bcm63xx_enet: correct clock usage Date: Sun, 1 Oct 2017 13:02:15 +0200 Message-Id: <20171001110220.27668-2-jonas.gorski@gmail.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20171001110220.27668-1-jonas.gorski@gmail.com> References: <20171001110220.27668-1-jonas.gorski@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171001_040234_454675_12EAA776 X-CRM114-Status: GOOD ( 12.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, "David S. Miller" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Check the return code of prepare_enable and change one last instance of enable only to prepare_enable. Also properly disable and release the clock in error paths and on remove for enetsw. Signed-off-by: Jonas Gorski --- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 31 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index c6221f04a748..a45ec97b5b1e 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c @@ -1773,7 +1773,9 @@ static int bcm_enet_probe(struct platform_device *pdev) ret = PTR_ERR(priv->mac_clk); goto out; } - clk_prepare_enable(priv->mac_clk); + ret = clk_prepare_enable(priv->mac_clk); + if (ret) + goto out_put_clk_mac; /* initialize default and fetch platform data */ priv->rx_ring_size = BCMENET_DEF_RX_DESC; @@ -1805,9 +1807,11 @@ static int bcm_enet_probe(struct platform_device *pdev) if (IS_ERR(priv->phy_clk)) { ret = PTR_ERR(priv->phy_clk); priv->phy_clk = NULL; - goto out_put_clk_mac; + goto out_disable_clk_mac; } - clk_prepare_enable(priv->phy_clk); + ret = clk_prepare_enable(priv->phy_clk); + if (ret) + goto out_put_clk_phy; } /* do minimal hardware init to be able to probe mii bus */ @@ -1900,13 +1904,16 @@ static int bcm_enet_probe(struct platform_device *pdev) out_uninit_hw: /* turn off mdc clock */ enet_writel(priv, 0, ENET_MIISC_REG); - if (priv->phy_clk) { + if (priv->phy_clk) clk_disable_unprepare(priv->phy_clk); + +out_put_clk_phy: + if (priv->phy_clk) clk_put(priv->phy_clk); - } -out_put_clk_mac: +out_disable_clk_mac: clk_disable_unprepare(priv->mac_clk); +out_put_clk_mac: clk_put(priv->mac_clk); out: free_netdev(dev); @@ -2748,7 +2755,9 @@ static int bcm_enetsw_probe(struct platform_device *pdev) ret = PTR_ERR(priv->mac_clk); goto out_unmap; } - clk_enable(priv->mac_clk); + ret = clk_prepare_enable(priv->mac_clk); + if (ret) + goto out_put_clk; priv->rx_chan = 0; priv->tx_chan = 1; @@ -2769,7 +2778,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev) ret = register_netdev(dev); if (ret) - goto out_put_clk; + goto out_disable_clk; netif_carrier_off(dev); platform_set_drvdata(pdev, dev); @@ -2778,6 +2787,9 @@ static int bcm_enetsw_probe(struct platform_device *pdev) return 0; +out_disable_clk: + clk_disable_unprepare(priv->mac_clk); + out_put_clk: clk_put(priv->mac_clk); @@ -2809,6 +2821,9 @@ static int bcm_enetsw_remove(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); release_mem_region(res->start, resource_size(res)); + clk_disable_unprepare(priv->mac_clk); + clk_put(priv->mac_clk); + free_netdev(dev); return 0; }