Re: [PATCH 08/16] Bluetooth: Fix stop_discovery()

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

 



Hi Gustavo,

On Wed, Jul 13, 2011 at 5:15 PM, Gustavo Padovan <padovan@xxxxxxxxxxxxxx> wrote:
>> @@ -963,6 +963,11 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
>>
>>       set_bit(HCI_INQUIRY, &hdev->flags);
>>
>> +     if (mgmt_has_pending_stop_discov(hdev->id)) {
>
> Isn't a new bit flag log HCI_INQUIRY_CANCEL better that this? First this has
> read a list, second it is a really ugly  function name.

A flag called HCI_CANCEL_DISCOV would be more appropriated since it
would be used to cancel the discovery procedure (inquiry/le scan).

My point is: I don't need a new flag to tell me the same information I already
have by checking for pending stop discovery command. IMO, traversing the
pending command list is not a issue today since it isn't that large.
If that list
becomes too large in future, then we'll have a bigger issue because lots of
mgmt commands do traversing the command pending list. In that case we
would need to come up with some optimization like pending list per hdev,
for instance.

Besides, I don't think mixing up mgmt layer and hci layer logic is a good
idea. The whole discovery procedure logic should go in mgmt layer, so no
discovery logic should be implemented in hci layer.

>> +             mgmt_cancel_discovery(hdev->id);
>
> Just call hci_send_cmd(HCI_OP_INQUIRY_CANCEL)

It would mix up mgmt and hci layer logic.

>
>> +             return;
>> +     }
>> +
>>       mgmt_discovering(hdev->id, 1);
>>  }
>>
>> @@ -1356,7 +1361,12 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
>>       hci_req_complete(hdev, HCI_OP_INQUIRY, status);
>>
>>       mgmt_discovering(hdev->id, 0);
>> +
>> +     hci_dev_lock(hdev);
>> +
>>       mgmt_start_discovery_complete(hdev->id);
>> +
>> +     hci_dev_unlock(hdev);
>>  }
>>
>>  static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
>> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
>> index e43940e..bbb0daa 100644
>> --- a/net/bluetooth/mgmt.c
>> +++ b/net/bluetooth/mgmt.c
>> @@ -1670,6 +1670,21 @@ static int cancel_inquiry(struct hci_dev *hdev)
>>       return hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL);
>>  }
>>
>> +int mgmt_cancel_discovery(u16 index)
>> +{
>> +     struct hci_dev *hdev;
>> +     int res = 0;
>> +
>> +     hdev = hci_dev_get(index);
>> +
>> +     if (test_bit(HCI_INQUIRY, &hdev->flags))
>> +             res = cancel_inquiry(hdev);
>> +
>> +     hci_dev_put(hdev);
>> +
>> +     return res;
>> +}
>> +
>>  static int stop_discovery(struct sock *sk, u16 index)
>>  {
>>       struct hci_dev *hdev;
>> @@ -1701,7 +1716,7 @@ static int stop_discovery(struct sock *sk, u16 index)
>>               goto failed;
>>       }
>
> You can check here with mgmt_pending_find() if the HCI_OP_INQUIRY_CANCEL was
> already issued or not. This simplifies code a bit.

Sorry, I didn't see what you mean here.

Regards,

Andre.
--
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