wilc1000: use devm_clk_get_optional()
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Fri, 6 Aug 2021 08:12:29 +0000 (11:12 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Sat, 21 Aug 2021 17:45:38 +0000 (20:45 +0300)
Use devm_clk_get_optional() for rtc clock: it simplifies a bit
the code.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210806081229.721731-4-claudiu.beznea@microchip.com
drivers/net/wireless/microchip/wilc1000/sdio.c
drivers/net/wireless/microchip/wilc1000/spi.c

index d1fd182bbbffffa7d4bbda5c4d61533552d37224..42e03a701ae165a64ff313262b1755def1185241 100644 (file)
@@ -146,12 +146,12 @@ static int wilc_sdio_probe(struct sdio_func *func,
        wilc->bus_data = sdio_priv;
        wilc->dev = &func->dev;
 
-       wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
-       if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
-               ret = -EPROBE_DEFER;
+       wilc->rtc_clk = devm_clk_get_optional(&func->card->dev, "rtc");
+       if (IS_ERR(wilc->rtc_clk)) {
+               ret = PTR_ERR(wilc->rtc_clk);
                goto dispose_irq;
-       } else if (!IS_ERR(wilc->rtc_clk))
-               clk_prepare_enable(wilc->rtc_clk);
+       }
+       clk_prepare_enable(wilc->rtc_clk);
 
        dev_info(&func->dev, "Driver Initializing success\n");
        return 0;
@@ -168,9 +168,7 @@ static void wilc_sdio_remove(struct sdio_func *func)
 {
        struct wilc *wilc = sdio_get_drvdata(func);
 
-       if (!IS_ERR(wilc->rtc_clk))
-               clk_disable_unprepare(wilc->rtc_clk);
-
+       clk_disable_unprepare(wilc->rtc_clk);
        wilc_netdev_cleanup(wilc);
 }
 
index 23d811b2b925c2f7e6084bfb8a30284b2df81a41..8b180c29d682fa1d466b8ccaee879fc7abaef8a0 100644 (file)
@@ -162,12 +162,12 @@ static int wilc_bus_probe(struct spi_device *spi)
        wilc->bus_data = spi_priv;
        wilc->dev_irq_num = spi->irq;
 
-       wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc");
-       if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
-               ret = -EPROBE_DEFER;
+       wilc->rtc_clk = devm_clk_get_optional(&spi->dev, "rtc");
+       if (IS_ERR(wilc->rtc_clk)) {
+               ret = PTR_ERR(wilc->rtc_clk);
                goto netdev_cleanup;
-       } else if (!IS_ERR(wilc->rtc_clk))
-               clk_prepare_enable(wilc->rtc_clk);
+       }
+       clk_prepare_enable(wilc->rtc_clk);
 
        return 0;
 
@@ -182,10 +182,9 @@ static int wilc_bus_remove(struct spi_device *spi)
 {
        struct wilc *wilc = spi_get_drvdata(spi);
 
-       if (!IS_ERR(wilc->rtc_clk))
-               clk_disable_unprepare(wilc->rtc_clk);
-
+       clk_disable_unprepare(wilc->rtc_clk);
        wilc_netdev_cleanup(wilc);
+
        return 0;
 }