From patchwork Tue Jul 17 08:08:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 142115 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3359868ljj; Tue, 17 Jul 2018 01:08:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdSntMho2uT8R0P+Vkkt/GCGiyc1nV+RdIctwjxT6tbR4qnInXmYi7tZmQCQjJgn9R9IUNv X-Received: by 2002:a63:b047:: with SMTP id z7-v6mr588204pgo.335.1531814934030; Tue, 17 Jul 2018 01:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531814934; cv=none; d=google.com; s=arc-20160816; b=OOMfOyyLWB+VNNXqTVApvHf0TweZj4HRW+1acdwhZY9GB2KM3LWm+PZX2RtxyXBaIC hMPqJ9bMWN/Xgqvv5vKM2aaiNBnIJRZJ87ELZeCfqotb+uX6cANV8y6AVUIo+GKq1EPA wUiBXeVC2LWQ3j+a+iuqvhk40l7/xiRXOf/s+3/KlgY9LlpnxCrhWG/dTs87dUyOT0ju B9IbbbjS4HX0DByHkTsMNOVQH/N4AlJNLU72RNbsMQMXFSeo1ZWTf3/um/5h+Xj/3LE/ ZqiqRKAnFDJUohVVB27ZDQ/U21nNy6lXNurN4zNQTHNQp4ABrdutbtf9mZnOW2qGiFWt w4SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=P6YxmUpCcKbTgwIO3mE4/21tq21XyGLZfs4HTjiecrU=; b=T1JUGTg1R5exksel3jUVCbL5FCtpntkb/w1RaCqGfcqoDc2ZkQ8K0yq/9LECqrjs0V 0xjm6t+9s6x5B5LITzLzuTBbl1KekbmkZNKTGsExaspjrHJBAARhntHOeOEslNvb+R70 vXb46iaJfptUfox5n2gHatZpGhFGtPVupv1B9I1Jup66yAzsMsJiPYnK0/en9GY6de9M 3RSWabLsCrjD4AomKEbByKLeiQYBzC2LEs6dIQ4mgmU4PSy7ZAZ+F9Y2yLz7eZp9Bf4W HA3po9ulAQa4C4sKn+/B6r42VY2X52W86hulkJvFuGph3PxeQ+RaIe1re/FViYBxX2SU xlKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kb04lFx0; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1-v6si309442pll.493.2018.07.17.01.08.53; Tue, 17 Jul 2018 01:08:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kb04lFx0; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729717AbeGQIkP (ORCPT + 13 others); Tue, 17 Jul 2018 04:40:15 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:33691 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbeGQIkP (ORCPT ); Tue, 17 Jul 2018 04:40:15 -0400 Received: by mail-pl0-f65.google.com with SMTP id 6-v6so129355plb.0 for ; Tue, 17 Jul 2018 01:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P6YxmUpCcKbTgwIO3mE4/21tq21XyGLZfs4HTjiecrU=; b=kb04lFx0j4CS/qn9/VM3WkEvDsvEJ95CU4DecfazHDbkjUrcHtafayHrjT+mwA0Jjn FQ3jlc6edXE/0p5PPgYoD71LDORswjA7Q4OO6p2tgqO+j6nR82QD/ROwQ1UKyR+JT/ib IByl7mu4Jt2RhF4GykYmdchZJjbYQt7mBF/Iw= 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=P6YxmUpCcKbTgwIO3mE4/21tq21XyGLZfs4HTjiecrU=; b=gxxyno5wbHGLVFvKUogPXA3dgWeIfpIeQpXN2Fo+v1WMD8ueiCQS38LwhW+R6fgEcn dJ1cOm43UI4IRDGeMGS/9s0AH7rLR0XAzCG6jmQ1izERZ4oL/J51olZ0263a1KA/YofF JKmEjXAXe/R/0rDucRZBywqaHKgwDJJNJBm/VbcTQMEZXvX7kHa95H/o06Jca7MLBWjW 1qUgSemuNl+nqjUWLAqFJR8wcnsJBCpM2CKJCcqWOTtYTSeVu9Zdlf1WGLR7zU6SLahq GJXzhsNNlW07imFd2IbFQx2n3UfGghZvop7gASz2HqJRIk/+QqBl6KIJi7go+dLFg6jy dxXg== X-Gm-Message-State: AOUpUlFBhzanRwmsHLumqEGlAJMPSaXozxg/d+4+0FG84Bv0ohF3I7K8 mNTw7qWgDxPYYzrJHU9Pzv1IfFLQ2VU= X-Received: by 2002:a17:902:8f86:: with SMTP id z6-v6mr656171plo.38.1531814932423; Tue, 17 Jul 2018 01:08:52 -0700 (PDT) Received: from localhost.localdomain ([106.51.22.240]) by smtp.gmail.com with ESMTPSA id c85-v6sm2205083pfd.110.2018.07.17.01.08.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jul 2018 01:08:51 -0700 (PDT) From: Amit Pundir To: Greg KH , Stable Cc: Jonas Gorski , "David S . Miller" Subject: [PATCH for-4.14.y 4/5] bcm63xx_enet: correct clock usage Date: Tue, 17 Jul 2018 13:38:33 +0530 Message-Id: <1531814914-19191-5-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531814914-19191-1-git-send-email-amit.pundir@linaro.org> References: <1531814914-19191-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonas Gorski commit 9c86b846ce02f7e35d7234cf090b80553eba5389 upstream. 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 Signed-off-by: David S. Miller Signed-off-by: Amit Pundir --- Cherry-picked from lede tree https://git.lede-project.org/?p=source.git drivers/net/ethernet/broadcom/bcm63xx_enet.c | 31 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index 4f3845a58126..b7d8b6600be6 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 */ @@ -1901,13 +1905,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); @@ -2752,7 +2759,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; @@ -2773,7 +2782,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); @@ -2782,6 +2791,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); @@ -2813,6 +2825,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; }