]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: wilc1000: Convert using devm_clk_get_optional_enabled() in wilc_bus_probe()
authorLi Zetao <lizetao1@huawei.com>
Tue, 3 Sep 2024 11:02:05 +0000 (19:02 +0800)
committerKalle Valo <kvalo@kernel.org>
Mon, 9 Sep 2024 12:30:04 +0000 (15:30 +0300)
Use devm_clk_get_optional_enabled() instead of devm_clk_get_optional() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/20240903110205.4127706-3-lizetao1@huawei.com
drivers/net/wireless/microchip/wilc1000/spi.c

index 5ff940c53ad9c06f792137957a82b013dbd5bea7..05b577b1068ea33bfc78f629277e2327823f0fac 100644 (file)
@@ -228,12 +228,11 @@ static int wilc_bus_probe(struct spi_device *spi)
        if (ret < 0)
                goto netdev_cleanup;
 
-       wilc->rtc_clk = devm_clk_get_optional(&spi->dev, "rtc");
+       wilc->rtc_clk = devm_clk_get_optional_enabled(&spi->dev, "rtc");
        if (IS_ERR(wilc->rtc_clk)) {
                ret = PTR_ERR(wilc->rtc_clk);
                goto netdev_cleanup;
        }
-       clk_prepare_enable(wilc->rtc_clk);
 
        dev_info(&spi->dev, "Selected CRC config: crc7=%s, crc16=%s\n",
                 enable_crc7 ? "on" : "off", enable_crc16 ? "on" : "off");
@@ -266,7 +265,6 @@ static int wilc_bus_probe(struct spi_device *spi)
        return 0;
 
 power_down:
-       clk_disable_unprepare(wilc->rtc_clk);
        wilc_wlan_power(wilc, false);
 netdev_cleanup:
        wilc_netdev_cleanup(wilc);
@@ -280,7 +278,6 @@ static void wilc_bus_remove(struct spi_device *spi)
        struct wilc *wilc = spi_get_drvdata(spi);
        struct wilc_spi *spi_priv = wilc->bus_data;
 
-       clk_disable_unprepare(wilc->rtc_clk);
        wilc_netdev_cleanup(wilc);
        kfree(spi_priv);
 }