Skip to contentSkip to conversation

Bluetooth: hci_bcm: Use the devm_clk_get_optional() helper

PATCH Applied Andy Shevchenko 2 participants 2 messages Nov 8, 2024 – Nov 11, 2024 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_bcm: Use the devm_clk_get_optional() helper

Use devm_clk_get_optional() instead of hand writing it. This saves some LoC and improves the semantic.

---
 drivers/bluetooth/hci_bcm.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
drivers/bluetooth/hci_bcm.c +8 -17
index 89d4c2224546..521b785f2908 100644
@@ -1068,17 +1068,17 @@ static struct clk *bcm_get_txco(struct device *dev)
 	struct clk *clk;
 
 	/* New explicit name */
-	clk = devm_clk_get(dev, "txco");
-	if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER)
+	clk = devm_clk_get_optional(dev, "txco");
+	if (clk)
 		return clk;
 
 	/* Deprecated name */
-	clk = devm_clk_get(dev, "extclk");
-	if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER)
+	clk = devm_clk_get_optional(dev, "extclk");
+	if (clk)
 		return clk;
 
 	/* Original code used no name at all */
-	return devm_clk_get(dev, NULL);
+	return devm_clk_get_optional(dev, NULL);
 }
 
 static int bcm_get_resources(struct bcm_device *dev)
@@ -1093,21 +1093,12 @@ static int bcm_get_resources(struct bcm_device *dev)
 		return 0;
 
 	dev->txco_clk = bcm_get_txco(dev->dev);
-
-	/* Handle deferred probing */
-	if (dev->txco_clk == ERR_PTR(-EPROBE_DEFER))
+	if (IS_ERR(dev->txco_clk))
 		return PTR_ERR(dev->txco_clk);
 
-	/* Ignore all other errors as before */
-	if (IS_ERR(dev->txco_clk))
-		dev->txco_clk = NULL;
-
-	dev->lpo_clk = devm_clk_get(dev->dev, "lpo");
-	if (dev->lpo_clk == ERR_PTR(-EPROBE_DEFER))
-		return PTR_ERR(dev->lpo_clk);
-
+	dev->lpo_clk = devm_clk_get_optional(dev->dev, "lpo");
 	if (IS_ERR(dev->lpo_clk))
-		dev->lpo_clk = NULL;
+		return PTR_ERR(dev->lpo_clk);
 
 	/* Check if we accidentally fetched the lpo clock twice */
 	if (dev->lpo_clk && clk_is_match(dev->lpo_clk, dev->txco_clk)) {
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#1 lore raw
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 7 lines · On Fri, 8 Nov 2024 17:33:49 +0200 you wrote:

Use devm_clk_get_optional() instead of hand writing it. This saves some LoC and improves the semantic.

---
 drivers/bluetooth/hci_bcm.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

Here is the summary with links:
- [v1,1/1] Bluetooth: hci_bcm: Use the devm_clk_get_optional() helper

    https://git.kernel.org/bluetooth/bluetooth-next/c/42e8e5c1092b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html