Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Andre Guedes <andre.guedes@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 6/6] Bluetooth: Support LE-Only discovery procedure
Date: Thu, 17 Nov 2011 09:59:38 +0900	[thread overview]
Message-ID: <1321491582.15441.557.camel@aeonflux> (raw)
In-Reply-To: <44EE3913-AD40-4EAC-A7AE-A2BC8812B186@openbossa.org>

Hi Andre,

> >>> And here, I have a serious problem with how the code is done. I realize
> >>> that from using hdev->flags this ends up this crappy, but this is not
> >>> how I wanna see things done.
> >>> 
> >>> What you are doing is this:
> >>> 
> >>> - We call a complete unrelated function anyway
> >>> - And if it fails with a specific error code then we call something
> >>> else instead
> >>> 
> >>> I think it becomes pretty obvious now that we should just have had
> >>> hdev->mgmt_flags that tell us with discovery procedure is running right
> >>> now. And thus we know how to cancel it.
> >> 
> >> I'm not sure this will help us in case we have a interleaved discovery
> >> running. My point is, even if we know what discovery procedure is running,
> >> we need to know what the controller is doing right now (inquiring or le
> >> scanning) so we can properly stop it, and, therefore, stop the ongoing
> >> discovery procedure. IOW, telling us we have a interleaved discovery
> >> running does not help us to decide the right function to call
> >> (hci_cancel_inquiry or hci_cancel_le_scan).
> >> 
> >> So, I think we need to check the controller flags (HCI_INQUIRY and
> >> HCI_LE_SCAN) in order to stop the ongoing discovery procedure properly.
> > 
> > I have nothing against separate flags. That makes fully sense. I have
> > something against weirdly calling one function and expecting it to error
> > out. Relying on an error is a bad idea. You want to keep track of what
> > is currently going on.
> 
> Ok, I agree with that too.
> 
> The way I see to fix that is we have something like we had before:
> 
> if (HCI_INQUIRY)
> 	hci_cancel_inquiry()
> else if (HCI_LE_SCAN)
> 	hci_cancel_le_scan()
> 
> The drawback, as you already pointed, is the double check of these
> flags.

there is nothing you can do about it actually. However with the changes
we are doing, the flags are internal. That is really important to me to
be able to move over to a proper userspace side API in the future that
does not rely on a magic bitmask.

And also it is in one place here so people can easily understand what
code is run with what dependency.

> But, as I said before, the flags checking in stop_discovery is to
> decide the right cancel helper function to call. The flag checking
> in hci_cancel_*() helper functions guarantees no cancel command is
> sent to the controller if there is no ongoing inquiry or le scan.
> The flag checking in stop_discovery() and hci_cancel_*() have
> different purposes.
> 
> Since hci_cancel_*() are helper functions and they can be reused in
> future by other parts of the code, I think it is a good idea we keep
> the flag checking internally. This way we don't rely on the programmer
> doing the proper checking before calling these helper functions.

I lost you here. I need to see this in code.

Regards

Marcel



  reply	other threads:[~2011-11-17  0:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11 22:50 [PATCH 0/6] LE-Only discovery procedure support Andre Guedes
2011-11-11 22:50 ` [PATCH 1/6] Bluetooth: Add hci_flags to struct hci_dev Andre Guedes
2011-11-11 23:09   ` Marcel Holtmann
2011-11-16 17:42     ` Andre Guedes
2011-11-16 21:44       ` Marcel Holtmann
2011-11-16 21:50         ` Andre Guedes
2011-11-11 22:50 ` [PATCH 2/6] Bluetooth: Add LE Set Scan Parameter Command Andre Guedes
2011-11-11 23:10   ` Marcel Holtmann
2011-11-11 22:50 ` [PATCH 3/6] Bluetooth: LE scan infra-structure Andre Guedes
2011-11-11 23:13   ` Marcel Holtmann
2011-11-18 23:04     ` Andre Guedes
2011-11-19  6:11       ` Marcel Holtmann
2011-11-21 17:24         ` Andre Guedes
2011-11-11 22:50 ` [PATCH 4/6] Bluetooth: Add 'eir_len' param to mgmt_device_found() Andre Guedes
2011-11-11 22:50 ` [PATCH 5/6] Bluetooth: Report LE devices Andre Guedes
2011-11-11 23:14   ` Marcel Holtmann
2011-11-23 20:15     ` Vinicius Costa Gomes
2011-11-11 22:50 ` [PATCH 6/6] Bluetooth: Support LE-Only discovery procedure Andre Guedes
2011-11-12  6:43   ` Marcel Holtmann
2011-11-16 20:25     ` Andre Guedes
2011-11-16 21:45       ` Marcel Holtmann
2011-11-16 22:41         ` Andre Guedes
2011-11-17  0:59           ` Marcel Holtmann [this message]
2011-11-12  9:54   ` Johan Hedberg
2011-11-16 21:04     ` Andre Guedes
2011-11-14 10:08   ` Andrei Emeltchenko
2011-11-16 20:36     ` Andre Guedes
2011-11-17  8:59       ` Andrei Emeltchenko
2011-11-17 16:40         ` Andre Guedes

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=1321491582.15441.557.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=andre.guedes@openbossa.org \
    --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