aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2018-03-17 06:05:44 -0400
committerMark Brown <broonie@kernel.org>2018-03-18 20:57:42 -0400
commit7c2861a6fb2c502d7b7aa85415e178f3c527a468 (patch)
tree7a825cd1d21d5f2a5e82e39abdf003b0aaabb1df
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
spi: jcore: disable ref_clk after getting its rate
The driver does not disable ref_clk on remove. According to the comment, the only reason to enable the clock is to get its rate. So, it should be safe to disable clk just after that. By the way, clk_prepare_enable() looks to be more appropriate than clk_enable() here. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-jcore.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/spi/spi-jcore.c b/drivers/spi/spi-jcore.c
index dafed6280df3..702fe573a47b 100644
--- a/drivers/spi/spi-jcore.c
+++ b/drivers/spi/spi-jcore.c
@@ -184,10 +184,11 @@ static int jcore_spi_probe(struct platform_device *pdev)
184 */ 184 */
185 clock_freq = 50000000; 185 clock_freq = 50000000;
186 clk = devm_clk_get(&pdev->dev, "ref_clk"); 186 clk = devm_clk_get(&pdev->dev, "ref_clk");
187 if (!IS_ERR_OR_NULL(clk)) { 187 if (!IS_ERR(clk)) {
188 if (clk_enable(clk) == 0) 188 if (clk_prepare_enable(clk) == 0) {
189 clock_freq = clk_get_rate(clk); 189 clock_freq = clk_get_rate(clk);
190 else 190 clk_disable_unprepare(clk);
191 } else
191 dev_warn(&pdev->dev, "could not enable ref_clk\n"); 192 dev_warn(&pdev->dev, "could not enable ref_clk\n");
192 } 193 }
193 hw->clock_freq = clock_freq; 194 hw->clock_freq = clock_freq;
@@ -198,10 +199,8 @@ static int jcore_spi_probe(struct platform_device *pdev)
198 199
199 /* Register our spi controller */ 200 /* Register our spi controller */
200 err = devm_spi_register_master(&pdev->dev, master); 201 err = devm_spi_register_master(&pdev->dev, master);
201 if (err) { 202 if (err)
202 clk_disable(clk);
203 goto exit; 203 goto exit;
204 }
205 204
206 return 0; 205 return 0;
207 206