spi: designware_spi: Disable and free clock when remove driver
authorLey Foon Tan <ley.foon.tan@intel.com>
Wed, 19 Sep 2018 08:27:19 +0000 (16:27 +0800)
committerJagan Teki <jagan@amarulasolutions.com>
Thu, 24 Oct 2019 19:18:32 +0000 (00:48 +0530)
Disable and free clock when remove driver.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Acked-by: Marek Vasut <marex@denx.de>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
drivers/spi/designware_spi.c

index 7d58cfae55e417d1766069111f2ab963d434e6dc..91e613e9cd65374c0220814421d407a3bcd17041 100644 (file)
@@ -518,8 +518,22 @@ 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;
+
+       ret = reset_release_bulk(&priv->resets);
+       if (ret)
+               return ret;
 
-       return reset_release_bulk(&priv->resets);
+#if CONFIG_IS_ENABLED(CLK)
+       ret = clk_disable(&priv->clk);
+       if (ret)
+               return ret;
+
+       ret = clk_free(&priv->clk);
+       if (ret)
+               return ret;
+#endif
+       return 0;
 }
 
 static const struct dm_spi_ops dw_spi_ops = {