spi: spi-zynqmp-gqspi: fix clk_enable/disable imbalance issue
authorQuanyang Wang <quanyang.wang@windriver.com>
Fri, 16 Apr 2021 00:46:48 +0000 (08:46 +0800)
committerMark Brown <broonie@kernel.org>
Fri, 16 Apr 2021 12:44:12 +0000 (13:44 +0100)
commitc6bdae08012b2ca3e94f3a41ef4ca8cfe7c9ab6f
tree7fee454f1a97a88ce2d34314a25ec43a802bea67
parentc7ed5fd5fbb279a75a58cf641b873f57ef906ac7
spi: spi-zynqmp-gqspi: fix clk_enable/disable imbalance issue

The clks "pclk" and "ref_clk" are enabled twice during the probe. The
first time is in the function zynqmp_qspi_probe and the second time is
in zynqmp_qspi_setup_op which is called by devm_spi_register_controller.
Then calling zynqmp_qspi_remove (rmmod this module) to disable these clks
will trigger a warning as below:

[  309.124604] Unpreparing enabled qspi_ref
[  309.128641] WARNING: CPU: 1 PID: 537 at drivers/clk/clk.c:824 clk_core_unprepare+0x108/0x110

Since pm_runtime works now, clks can be enabled/disabled by calling
zynqmp_runtime_suspend/resume. So we don't need to enable these clks
explicitly in zynqmp_qspi_setup_op. Remove them to fix this issue.

And remove clk enabling/disabling in zynqmp_qspi_resume because there is
no spi transfer operation so enabling ref_clk is redundant meanwhile pclk
is not disabled for it is shared with other peripherals.

Furthermore replace clk_enable/disable with clk_prepare_enable and
clk_disable_unprepare in runtime_suspend/resume functions.

Fixes: 1c26372e5aa9 ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework")
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
Link: https://lore.kernel.org/r/20210416004652.2975446-2-quanyang.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-zynqmp-gqspi.c