From: Claudiu Beznea <claudiu.beznea@microchip.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <robh+dt@kernel.org>,
<nicolas.ferre@microchip.com>, <linux@armlinux.org.uk>,
<paul.walmsley@sifive.com>, <palmer@dabbelt.com>
Cc: <yash.shah@sifive.com>, <netdev@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-riscv@lists.infradead.org>,
Claudiu Beznea <claudiu.beznea@microchip.com>
Subject: [PATCH 3/7] net: macb: unprepare clocks in case of failure
Date: Fri, 4 Dec 2020 14:34:17 +0200 [thread overview]
Message-ID: <1607085261-25255-4-git-send-email-claudiu.beznea@microchip.com> (raw)
In-Reply-To: <1607085261-25255-1-git-send-email-claudiu.beznea@microchip.com>
Unprepare clocks in case of any failure in fu540_c000_clk_init().
Fixes: c218ad559020 ("macb: Add support for SiFive FU540-C000")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
drivers/net/ethernet/cadence/macb_main.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index b23e986ac6dc..29d144690b3b 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4406,8 +4406,10 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
return err;
mgmt = devm_kzalloc(&pdev->dev, sizeof(*mgmt), GFP_KERNEL);
- if (!mgmt)
- return -ENOMEM;
+ if (!mgmt) {
+ err = -ENOMEM;
+ goto err_disable_clocks;
+ }
init.name = "sifive-gemgxl-mgmt";
init.ops = &fu540_c000_ops;
@@ -4418,16 +4420,29 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
mgmt->hw.init = &init;
*tx_clk = devm_clk_register(&pdev->dev, &mgmt->hw);
- if (IS_ERR(*tx_clk))
- return PTR_ERR(*tx_clk);
+ if (IS_ERR(*tx_clk)) {
+ err = PTR_ERR(*tx_clk);
+ goto err_disable_clocks;
+ }
err = clk_prepare_enable(*tx_clk);
- if (err)
+ if (err) {
dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n", err);
- else
+ goto err_disable_clocks;
+ } else {
dev_info(&pdev->dev, "Registered clk switch '%s'\n", init.name);
+ }
return 0;
+
+err_disable_clocks:
+ clk_disable_unprepare(*tx_clk);
+ clk_disable_unprepare(*hclk);
+ clk_disable_unprepare(*pclk);
+ clk_disable_unprepare(*rx_clk);
+ clk_disable_unprepare(*tsu_clk);
+
+ return err;
}
static int fu540_c000_init(struct platform_device *pdev)
--
2.7.4
next prev parent reply other threads:[~2020-12-04 12:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 12:34 [PATCH 0/7] net: macb: add support for sama7g5 Claudiu Beznea
2020-12-04 12:34 ` [PATCH 1/7] net: macb: add userio bits as platform configuration Claudiu Beznea
2020-12-05 14:30 ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 2/7] net: macb: add capability to not set the clock rate Claudiu Beznea
2020-12-05 14:32 ` Andrew Lunn
2020-12-04 12:34 ` Claudiu Beznea [this message]
2020-12-05 14:30 ` [PATCH 3/7] net: macb: unprepare clocks in case of failure Andrew Lunn
2020-12-07 9:26 ` Claudiu.Beznea
2020-12-04 12:34 ` [PATCH 4/7] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
2020-12-05 14:32 ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 5/7] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
2020-12-05 14:32 ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 6/7] net: macb: add support for sama7g5 gem interface Claudiu Beznea
2020-12-05 14:33 ` Andrew Lunn
2020-12-04 12:34 ` [PATCH 7/7] net: macb: add support for sama7g5 emac interface Claudiu Beznea
2020-12-05 14:33 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1607085261-25255-4-git-send-email-claudiu.beznea@microchip.com \
--to=claudiu.beznea@microchip.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh+dt@kernel.org \
--cc=yash.shah@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).