Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1621074 > unrolled thread
| Started by | Tobias Klauser <tklauser@distanz.ch> |
|---|---|
| First post | 2017-04-11 11:30 +0200 |
| Last post | 2017-04-11 17:00 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] fpga altera-hps2fpga: disable/unprepare clock on error in alt_fpga_bridge_probe() Tobias Klauser <tklauser@distanz.ch> - 2017-04-11 11:30 +0200
Re: [PATCH] fpga altera-hps2fpga: disable/unprepare clock on error in alt_fpga_bridge_probe() Moritz Fischer <mdf@kernel.org> - 2017-04-11 17:00 +0200
Re: [PATCH] fpga altera-hps2fpga: disable/unprepare clock on error in alt_fpga_bridge_probe() Alan Tull <atull@kernel.org> - 2017-04-11 17:00 +0200
| From | Tobias Klauser <tklauser@distanz.ch> |
|---|---|
| Date | 2017-04-11 11:30 +0200 |
| Subject | [PATCH] fpga altera-hps2fpga: disable/unprepare clock on error in alt_fpga_bridge_probe() |
| Message-ID | <tv0hz-543-1@gated-at.bofh.it> |
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>
---
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 4b354c79be31..3066b805f2d0 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.12.2
[toc] | [next] | [standalone]
| From | Moritz Fischer <mdf@kernel.org> |
|---|---|
| Date | 2017-04-11 17:00 +0200 |
| Subject | Re: [PATCH] fpga altera-hps2fpga: disable/unprepare clock on error in alt_fpga_bridge_probe() |
| Message-ID | <tv5qV-8me-3@gated-at.bofh.it> |
| In reply to | #1621074 |
On Tue, Apr 11, 2017 at 09:53:38AM -0500, Alan Tull wrote:
> On Tue, Apr 11, 2017 at 4:22 AM, Tobias Klauser <tklauser@distanz.ch> wrote:
>
> Hi Tobias,
>
> Thanks!
>
> > 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 4b354c79be31..3066b805f2d0 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.12.2
> >
> >
[toc] | [prev] | [next] | [standalone]
| From | Alan Tull <atull@kernel.org> |
|---|---|
| Date | 2017-04-11 17:00 +0200 |
| Message-ID | <tv5qV-8me-5@gated-at.bofh.it> |
| In reply to | #1621074 |
On Tue, Apr 11, 2017 at 4:22 AM, Tobias Klauser <tklauser@distanz.ch> wrote:
Hi Tobias,
Thanks!
> 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>
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 4b354c79be31..3066b805f2d0 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.12.2
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web