public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefan Seyfried <stefan.seyfried@googlemail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-bluetooth@vger.kernel.org,
	Jeremy Jackson <jerj@coplanar.net>,
	linux-bluetooth@vger.kernel.org
Subject: Re: btusb regression on commands unsupported by adapter
Date: Wed, 23 Dec 2009 14:51:19 +0100	[thread overview]
Message-ID: <20091223145119.3ef1651b@strolchi.home.s3e.de> (raw)
In-Reply-To: <1261173206.4041.89.camel@localhost.localdomain>

Hi Marcel,

On Fri, 18 Dec 2009 13:53:26 -0800
Marcel Holtmann <marcel@holtmann.org> wrote:
> > The question for kernel side is, regression, or corrected behaviour?
> 
> this is basically a bluetoothd issue. We should be reading the list of
> supported commands and then either issue or not issue this command. Feel
> free to write a patch for that.

This sounded like fun, and because I had nothing better to do, I wanted
to take a shot at that.

The result looks something like that (not to be applied,
whitespace-damaged!):

diff --git a/src/adapter.c b/src/adapter.c
index 2e43662..2690227 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2121,6 +2121,7 @@ int adapter_start(struct btd_adapter *adapter)
        struct hci_dev_info di;
        struct hci_version ver;
        uint8_t features[8];
+       uint8_t cmds[64];
        int dd, err;
        char mode[14], address[18];

@@ -2203,8 +2204,16 @@ int adapter_start(struct btd_adapter *adapter)
        }

 setup:
-       hci_send_cmd(dd, OGF_LINK_POLICY, OCF_READ_DEFAULT_LINK_POLICY,
-                                                               0, NULL);
+       if (hci_read_local_commands(dd, cmds, 1000) < 0) {
+               error("Can't read supported commands on %s: %s (%d)\n",
+                                       adapter->path, strerror(errno), errno);
+       }
+
+       /* bit 43 is "Read Default Link Policy Settings" command support */
+       if (cmds[5] & (1 << 3))
+               hci_send_cmd(dd, OGF_LINK_POLICY,
+                                       OCF_READ_DEFAULT_LINK_POLICY, 0, NULL);
+
        hci_close_dev(dd);

        adapter->current_cod = 0;


One question I faced was, if we should error out if
hci_read_local_commands fails? I'm generally against it since it might
introduce an 

But then I noticed that we are not even reading the answer to this
command (or is there no answer? would seem strange for a "read"
command), so I concluded that the best way to fix the problem would
probably be to just revert commit 8563b779 which added this command.

Is my conclusion correct or did I overlook something?

Have fun,

	seife
-- 
Stefan Seyfried

"Any ideas, John?"
"Well, surrounding them's out."

      reply	other threads:[~2009-12-23 13:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18 17:44 btusb regression on commands unsupported by adapter Jeremy Jackson
2009-12-18 21:53 ` Marcel Holtmann
2009-12-23 13:51   ` Stefan Seyfried [this message]

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=20091223145119.3ef1651b@strolchi.home.s3e.de \
    --to=stefan.seyfried@googlemail.com \
    --cc=jerj@coplanar.net \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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