Skip to content

Commit

Permalink
Bluetooth: btmtkuart: Improve exception handling in btmtuart_probe()
Browse files Browse the repository at this point in the history
Calls of the functions clk_disable_unprepare() and hci_free_dev()
were missing for the exception handling.
Thus add the missed function calls together with corresponding
jump targets.

Fixes: 0558256 ("Bluetooth: btmtkuart: add an implementation for clock osc property")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Chuhong Yuan authored and Marcel Holtmann committed May 29, 2020
1 parent feac90d commit 4803c54
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/bluetooth/btmtkuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ static int btmtkuart_probe(struct serdev_device *serdev)
if (btmtkuart_is_standalone(bdev)) {
err = clk_prepare_enable(bdev->osc);
if (err < 0)
return err;
goto err_hci_free_dev;

if (bdev->boot) {
gpiod_set_value_cansleep(bdev->boot, 1);
Expand All @@ -1028,10 +1028,8 @@ static int btmtkuart_probe(struct serdev_device *serdev)

/* Power on */
err = regulator_enable(bdev->vcc);
if (err < 0) {
clk_disable_unprepare(bdev->osc);
return err;
}
if (err < 0)
goto err_clk_disable_unprepare;

/* Reset if the reset-gpios is available otherwise the board
* -level design should be guaranteed.
Expand Down Expand Up @@ -1063,7 +1061,6 @@ static int btmtkuart_probe(struct serdev_device *serdev)
err = hci_register_dev(hdev);
if (err < 0) {
dev_err(&serdev->dev, "Can't register HCI device\n");
hci_free_dev(hdev);
goto err_regulator_disable;
}

Expand All @@ -1072,6 +1069,11 @@ static int btmtkuart_probe(struct serdev_device *serdev)
err_regulator_disable:
if (btmtkuart_is_standalone(bdev))
regulator_disable(bdev->vcc);
err_clk_disable_unprepare:
if (btmtkuart_is_standalone(bdev))
clk_disable_unprepare(bdev->osc);
err_hci_free_dev:
hci_free_dev(hdev);

return err;
}
Expand Down

0 comments on commit 4803c54

Please sign in to comment.