Re: [PATCH 4/5] Bluetooth: hci_intel: Add intel_data_list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Loic,

> In the same way as a intel_data (hu) needs to access its corresponding
> intel_device (pdev). A intel_device may be required to access the
> intel_data. We need to maintain a list of current intel_data and
> protect it against concurrent access.
> 
> Signed-off-by: Loic Poulain <loic.poulain@xxxxxxxxx>
> ---
> drivers/bluetooth/hci_intel.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c
> index f855515..99f1307 100644
> --- a/drivers/bluetooth/hci_intel.c
> +++ b/drivers/bluetooth/hci_intel.c
> @@ -75,11 +75,16 @@ static LIST_HEAD(intel_device_list);
> static DEFINE_SPINLOCK(intel_device_list_lock);
> 
> struct intel_data {
> +	struct list_head list;

this is the private data associated with the hci_uart. I am not turning this into a list.

> 	struct sk_buff *rx_skb;
> 	struct sk_buff_head txq;
> 	unsigned long flags;
> +	struct hci_uart *hu;
> };
> 
> +static LIST_HEAD(intel_data_list);
> +static DEFINE_MUTEX(intel_data_list_lock);
> +
> static u8 intel_convert_speed(unsigned int speed)
> {
> 	switch (speed) {
> @@ -130,6 +135,24 @@ static struct intel_device *intel_device_get(struct hci_uart *hu)
> 	return NULL;
> }
> 
> +static struct intel_data *intel_data_get(struct intel_device *idev)
> +{
> +	struct list_head *p;
> +
> +	list_for_each(p, &intel_data_list) {
> +		struct intel_data *intel = list_entry(p, struct intel_data,
> +						      list);
> +
> +		/* tty device and pdev device should share the same parent
> +		 * which is the UART port.
> +		 */
> +		if (intel->hu->tty->dev->parent == idev->pdev->dev.parent)
> +			return intel;
> +	}
> +
> +	return NULL;
> +}
> +

You really need to come up with something else. intel_data is not a list. It is private data for hci_uart.

> static int intel_wait_booting(struct hci_uart *hu)
> {
> 	struct intel_data *intel = hu->priv;
> @@ -194,6 +217,11 @@ static int intel_open(struct hci_uart *hu)
> 	skb_queue_head_init(&intel->txq);
> 
> 	hu->priv = intel;
> +	intel->hu = hu;
> +
> +	mutex_lock(&intel_data_list_lock);
> +	list_add_tail(&intel->list, &intel_data_list);
> +	mutex_unlock(&intel_data_list_lock);
> 
> 	if (!intel_set_power(hu, true))
> 		set_bit(STATE_BOOTING, &intel->flags);
> @@ -209,6 +237,10 @@ static int intel_close(struct hci_uart *hu)
> 
> 	intel_set_power(hu, false);
> 
> +	mutex_lock(&intel_data_list_lock);
> +	list_del(&intel->list);
> +	mutex_unlock(&intel_data_list_lock);
> +
> 	skb_queue_purge(&intel->txq);
> 	kfree_skb(intel->rx_skb);
> 	kfree(intel);

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux