From: Alan Tull <atull@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Moritz Fischer <moritz.fischer@ettus.com>,
Alan Tull <atull@kernel.org>,
linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org,
Tobias Klauser <tklauser@distanz.ch>
Subject: [PATCH 1/3] fpga altera-hps2fpga: disable/unprepare clock on error in alt_fpga_bridge_probe()
Date: Mon, 24 Apr 2017 16:34:20 -0500 [thread overview]
Message-ID: <20170424213422.3190-2-atull@kernel.org> (raw)
In-Reply-To: <20170424213422.3190-1-atull@kernel.org>
From: Tobias Klauser <tklauser@distanz.ch>
If either _alt_hps2fpga_enable_set() or fpga_bridge_register() fail in
alt_fpga_bridge_probe(), the clock remains enabled and prepared. Also,
in the error path for _alt_hps2fpga_enable_set() a call to
fpga_bridge_unregister() is made even though the bridge was not
registered yet.
Remove the unnecessary call to fpga_bridge_unregister() and call
clk_disable_unprepare() in both error paths in order to make sure the
clock gets properly disabled and unprepared.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Alan Tull <atull@kernel.org>
---
drivers/fpga/altera-hps2fpga.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c
index 4b354c7..3066b80 100644
--- a/drivers/fpga/altera-hps2fpga.c
+++ b/drivers/fpga/altera-hps2fpga.c
@@ -181,15 +181,18 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
(enable ? "enabling" : "disabling"));
ret = _alt_hps2fpga_enable_set(priv, enable);
- if (ret) {
- fpga_bridge_unregister(&pdev->dev);
- return ret;
- }
+ if (ret)
+ goto err;
}
}
- return fpga_bridge_register(dev, priv->name, &altera_hps2fpga_br_ops,
- priv);
+ ret = fpga_bridge_register(dev, priv->name, &altera_hps2fpga_br_ops,
+ priv);
+err:
+ if (ret)
+ clk_disable_unprepare(priv->clk);
+
+ return ret;
}
static int alt_fpga_bridge_remove(struct platform_device *pdev)
--
2.7.4
next prev parent reply other threads:[~2017-04-24 21:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-24 21:34 [PATCH 0/3] patches for fpga Alan Tull
2017-04-24 21:34 ` Alan Tull [this message]
2017-04-24 21:34 ` [PATCH 2/3] fpga: region: release FPGA region reference in error path Alan Tull
2017-04-24 21:34 ` [PATCH 3/3] fpga fr br: update supported version numbers Alan Tull
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=20170424213422.3190-2-atull@kernel.org \
--to=atull@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=moritz.fischer@ettus.com \
--cc=tklauser@distanz.ch \
/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