Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Johan Hedberg <johan.hedberg@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 03/12 v3] Bluetooth: Add hci_transaction_cmd_complete function
Date: Sat, 16 Feb 2013 23:19:08 +0100	[thread overview]
Message-ID: <1361053148.1583.5.camel@aeonflux> (raw)
In-Reply-To: <1360921920-14080-4-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> This function is used to process the HCI transaction state, including
> things like picking the next command to send, calling the complete
> callback for the current transaction and moving the next transaction
> from the queue (if any) to hdev->current_transaction.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
>  include/net/bluetooth/hci_core.h |    1 +
>  net/bluetooth/hci_core.c         |   65 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 5cd58f5..54efaa2 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -1062,6 +1062,7 @@ int hci_start_transaction(struct hci_dev *hdev);
>  int hci_complete_transaction(struct hci_dev *hdev,
>  			     void (*complete)(struct hci_dev *hdev,
>  					      __u16 last_cmd, int status));
> +bool hci_transaction_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status);
>  
>  int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param);
>  void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags);
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 0b289f3..8923a1f 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -2976,6 +2976,71 @@ static void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
>  	kfree_skb(skb);
>  }
>  
> +static void __transaction_next(struct hci_dev *hdev, u16 opcode, int status)
> +{
> +	struct hci_transaction *transaction;
> +
> +	transaction = hdev->current_transaction;
> +	if (!transaction)
> +		goto next_in_queue;
> +
> +	if (status || skb_queue_empty(&transaction->cmd_q)) {
> +		hdev->current_transaction = NULL;
> +
> +		/* We need to give up the transaction lock temporarily
> +		 * since the complete callback might trigger a deadlock
> +		 */
> +		hci_transaction_unlock(hdev);
> +		if (transaction->complete)
> +			transaction->complete(hdev, opcode, status);
> +		__transaction_free(transaction);
> +		hci_transaction_lock(hdev);
> +
> +		transaction = hdev->current_transaction;
> +	}

why do we need current_transaction again. Can we not just always use the
head of the list?

Regards

Marcel



  reply	other threads:[~2013-02-16 22:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-15  9:51 [PATCH 00/12 v3] Bluetooth: Asynchronous HCI transaction API Johan Hedberg
2013-02-15  9:51 ` [PATCH 01/12 v3] Bluetooth: Add initial hooks for HCI transaction support Johan Hedberg
2013-02-15  9:51 ` [PATCH 02/12 v3] Bluetooth: Add basic start/complete HCI transaction functions Johan Hedberg
2013-02-16 22:17   ` Marcel Holtmann
2013-02-18  7:43     ` Johan Hedberg
2013-02-18 12:47       ` Marcel Holtmann
2013-02-15  9:51 ` [PATCH 03/12 v3] Bluetooth: Add hci_transaction_cmd_complete function Johan Hedberg
2013-02-16 22:19   ` Marcel Holtmann [this message]
2013-02-18  7:46     ` Johan Hedberg
2013-02-15  9:51 ` [PATCH 04/12 v3] Bluetooth: Add hci_transaction_from_skb function Johan Hedberg
2013-02-15  9:51 ` [PATCH 05/12 v3] Bluetooth: Switch from hdev->cmd_q to using transactions Johan Hedberg
2013-02-16 22:22   ` Marcel Holtmann
2013-02-18  7:48     ` Johan Hedberg
2013-02-15  9:51 ` [PATCH 06/12 v3] Bluetooth: Remove unused hdev->cmd_q HCI command queue Johan Hedberg
2013-02-15  9:51 ` [PATCH 07/12 v3] Bluetooth: Fix mgmt powered indication by using a HCI transaction Johan Hedberg
2013-02-19 19:36   ` Andre Guedes
2013-02-15  9:51 ` [PATCH 08/12 v3] Bluetooth: Enable HCI transaction support cmd_status 0 Johan Hedberg
2013-02-15  9:51 ` [PATCH 09/12 v3] Bluetooth: Add HCI init sequence support for HCI transactions Johan Hedberg
2013-02-15  9:51 ` [PATCH 10/12 v3] Bluetooth: Convert hci_request to use " Johan Hedberg
2013-02-15  9:51 ` [PATCH 11/12 v3] Bluetooth: Remove unused hdev->init_last_cmd Johan Hedberg
2013-02-15  9:52 ` [PATCH 12/12 v3] Bluetooth: Remove empty HCI event handlers Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361053148.1583.5.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox