Skip to content

Commit 2de33a2

Browse files
andy-shevVudentz
authored andcommitted
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. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 07a9342 commit 2de33a2

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

drivers/bluetooth/hci_bcm.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,17 +1068,17 @@ static struct clk *bcm_get_txco(struct device *dev)
10681068
struct clk *clk;
10691069

10701070
/* New explicit name */
1071-
clk = devm_clk_get(dev, "txco");
1072-
if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER)
1071+
clk = devm_clk_get_optional(dev, "txco");
1072+
if (clk)
10731073
return clk;
10741074

10751075
/* Deprecated name */
1076-
clk = devm_clk_get(dev, "extclk");
1077-
if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER)
1076+
clk = devm_clk_get_optional(dev, "extclk");
1077+
if (clk)
10781078
return clk;
10791079

10801080
/* Original code used no name at all */
1081-
return devm_clk_get(dev, NULL);
1081+
return devm_clk_get_optional(dev, NULL);
10821082
}
10831083

10841084
static int bcm_get_resources(struct bcm_device *dev)
@@ -1093,21 +1093,12 @@ static int bcm_get_resources(struct bcm_device *dev)
10931093
return 0;
10941094

10951095
dev->txco_clk = bcm_get_txco(dev->dev);
1096-
1097-
/* Handle deferred probing */
1098-
if (dev->txco_clk == ERR_PTR(-EPROBE_DEFER))
1099-
return PTR_ERR(dev->txco_clk);
1100-
1101-
/* Ignore all other errors as before */
11021096
if (IS_ERR(dev->txco_clk))
1103-
dev->txco_clk = NULL;
1104-
1105-
dev->lpo_clk = devm_clk_get(dev->dev, "lpo");
1106-
if (dev->lpo_clk == ERR_PTR(-EPROBE_DEFER))
1107-
return PTR_ERR(dev->lpo_clk);
1097+
return PTR_ERR(dev->txco_clk);
11081098

1099+
dev->lpo_clk = devm_clk_get_optional(dev->dev, "lpo");
11091100
if (IS_ERR(dev->lpo_clk))
1110-
dev->lpo_clk = NULL;
1101+
return PTR_ERR(dev->lpo_clk);
11111102

11121103
/* Check if we accidentally fetched the lpo clock twice */
11131104
if (dev->lpo_clk && clk_is_match(dev->lpo_clk, dev->txco_clk)) {

0 commit comments

Comments
 (0)