diff mbox series

[3/3] Bluetooth: hci_qca: Refactor error handling in qca_suspend()

Message ID 20200605114552.3.Ib9b5e6e81ea31cdc964cd0562ef4985a6c6c5154@changeid (mailing list archive)
State Accepted
Delegated to: Marcel Holtmann
Headers show
Series | expand

Commit Message

Matthias Kaehlcke June 5, 2020, 6:46 p.m. UTC
If waiting for IBS sleep times out jump to the error handler, this is
easier to read than multiple 'if' branches and a fall through to the
error handler.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---

 drivers/bluetooth/hci_qca.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Abhishek Pandit-Subedi June 5, 2020, 8:46 p.m. UTC | #1
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>

On Fri, Jun 5, 2020 at 11:46 AM Matthias Kaehlcke <mka@chromium.org> wrote:
>
> If waiting for IBS sleep times out jump to the error handler, this is
> easier to read than multiple 'if' branches and a fall through to the
> error handler.
>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
>
>  drivers/bluetooth/hci_qca.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 90ffd8ca1fb0d..cf76f128e9834 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -2109,18 +2109,16 @@ static int __maybe_unused qca_suspend(struct device *dev)
>         /* Wait for HCI_IBS_SLEEP_IND sent by device to indicate its Tx is going
>          * to sleep, so that the packet does not wake the system later.
>          */
> -
>         ret = wait_event_interruptible_timeout(qca->suspend_wait_q,
>                         qca->rx_ibs_state == HCI_IBS_RX_ASLEEP,
>                         msecs_to_jiffies(IBS_BTSOC_TX_IDLE_TIMEOUT_MS));
> -
> -       if (ret > 0) {
> -               qca_wq_serial_tx_clock_vote_off(&qca->ws_tx_vote_off);
> -               return 0;
> +       if (ret == 0) {
> +               ret = -ETIMEDOUT;
> +               goto error;
>         }
>
> -       if (ret == 0)
> -               ret = -ETIMEDOUT;
> +       qca_wq_serial_tx_clock_vote_off(&qca->ws_tx_vote_off);
> +       return 0;
>
>  error:
>         clear_bit(QCA_SUSPENDING, &qca->flags);
> --
> 2.27.0.278.ge193c7cf3a9-goog
>
Marcel Holtmann June 8, 2020, 8:14 a.m. UTC | #2
Hi Matthias,

> If waiting for IBS sleep times out jump to the error handler, this is
> easier to read than multiple 'if' branches and a fall through to the
> error handler.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> 
> drivers/bluetooth/hci_qca.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel
diff mbox series

Patch

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 90ffd8ca1fb0d..cf76f128e9834 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -2109,18 +2109,16 @@  static int __maybe_unused qca_suspend(struct device *dev)
 	/* Wait for HCI_IBS_SLEEP_IND sent by device to indicate its Tx is going
 	 * to sleep, so that the packet does not wake the system later.
 	 */
-
 	ret = wait_event_interruptible_timeout(qca->suspend_wait_q,
 			qca->rx_ibs_state == HCI_IBS_RX_ASLEEP,
 			msecs_to_jiffies(IBS_BTSOC_TX_IDLE_TIMEOUT_MS));
-
-	if (ret > 0) {
-		qca_wq_serial_tx_clock_vote_off(&qca->ws_tx_vote_off);
-		return 0;
+	if (ret == 0) {
+		ret = -ETIMEDOUT;
+		goto error;
 	}
 
-	if (ret == 0)
-		ret = -ETIMEDOUT;
+	qca_wq_serial_tx_clock_vote_off(&qca->ws_tx_vote_off);
+	return 0;
 
 error:
 	clear_bit(QCA_SUSPENDING, &qca->flags);