All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] spi: designware_spi: Disable and free clock when remove driver
@ 2018-09-07  7:42 Ley Foon Tan
  2018-09-07  8:49 ` Marek Vasut
  0 siblings, 1 reply; 2+ messages in thread
From: Ley Foon Tan @ 2018-09-07  7:42 UTC (permalink / raw)
  To: u-boot

Disable and free clock when remove driver.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
---
 drivers/spi/designware_spi.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index 5cca414..f4d36cf 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -516,8 +516,20 @@ static int dw_spi_set_mode(struct udevice *bus, uint mode)
 static int dw_spi_remove(struct udevice *bus)
 {
 	struct dw_spi_priv *priv = dev_get_priv(bus);
+	int ret;
 
-	return reset_release_bulk(&priv->resets);
+	ret = reset_release_bulk(&priv->resets);
+	if (ret)
+		return ret;
+
+#if CONFIG_IS_ENABLED(CLK)
+	ret = clk_disable(&priv->clk);
+	if (ret)
+		return ret;
+
+	ret = clk_free(&priv->clk);
+#endif
+	return ret;
 }
 
 static const struct dm_spi_ops dw_spi_ops = {
-- 
2.2.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] spi: designware_spi: Disable and free clock when remove driver
  2018-09-07  7:42 [U-Boot] [PATCH] spi: designware_spi: Disable and free clock when remove driver Ley Foon Tan
@ 2018-09-07  8:49 ` Marek Vasut
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Vasut @ 2018-09-07  8:49 UTC (permalink / raw)
  To: u-boot

On 09/07/2018 09:42 AM, Ley Foon Tan wrote:
> Disable and free clock when remove driver.
> 
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
>  drivers/spi/designware_spi.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
> index 5cca414..f4d36cf 100644
> --- a/drivers/spi/designware_spi.c
> +++ b/drivers/spi/designware_spi.c
> @@ -516,8 +516,20 @@ static int dw_spi_set_mode(struct udevice *bus, uint mode)
>  static int dw_spi_remove(struct udevice *bus)
>  {
>  	struct dw_spi_priv *priv = dev_get_priv(bus);
> +	int ret;
>  
> -	return reset_release_bulk(&priv->resets);
> +	ret = reset_release_bulk(&priv->resets);
> +	if (ret)
> +		return ret;
> +
> +#if CONFIG_IS_ENABLED(CLK)
> +	ret = clk_disable(&priv->clk);
> +	if (ret)
> +		return ret;
> +
> +	ret = clk_free(&priv->clk);
> +#endif

With CONFIG_CLK = n, you basically get

ret = reset_release_bulk();
if (ret)
  return ret;

return ret;

Just check the return value from clk_free() with if (ret) and then
finally return 0;


ret = reset_release_bulk();
if (ret)
  return ret;

#if ....
ret = clk_...
if (ret)
  return ret;
...
#endif

return 0;

> +	return ret;
>  }
>  
>  static const struct dm_spi_ops dw_spi_ops = {
> 


-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-07  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07  7:42 [U-Boot] [PATCH] spi: designware_spi: Disable and free clock when remove driver Ley Foon Tan
2018-09-07  8:49 ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.