All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: Ulisses Furquim <ulisses@profusion.mobi>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv3 1/2] Bluetooth: Fix registering hci with duplicate name
Date: Fri, 13 Apr 2012 21:39:21 +0300	[thread overview]
Message-ID: <CAMXE1-o8oPdPF6Ry1nFUcnHFUMXs8U_ghysKN3nhCeTsFFx7Mw@mail.gmail.com> (raw)
In-Reply-To: <CAA37ikaFf+=9yR_qa6_QFNjOxAf3DZ5D_R7kZ28ZycjuVaLSsg@mail.gmail.com>

Hi Ulisses,

On Fri, Apr 13, 2012 at 7:25 PM, Ulisses Furquim <ulisses@profusion.mobi> wrote:

> On Fri, Apr 13, 2012 at 8:21 AM, Andrei Emeltchenko
> <Andrei.Emeltchenko.news@gmail.com> wrote:
>>
>> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>>
>> When adding HCI devices hci_register_dev may assigns the same name
>> hciX for subsequently added HCI devices. Use bitmask to find free
>> device ID the same way as it is done in other subsystems.
>>
>> ...
>> [ 6958.381886] sysfs: cannot create duplicate filename
>>        '/devices/virtual/bluetooth/hci1
> Well, I don't like this bitmask approach, really. We used to have this
> list ordered and the code was doing that before we added the
> restriction of index 0 for AMP devices, I think.

I think it just was not tested enough.

> Using a bitmask looks
> overkill to me when we can probably modify the loop to find the first

This approach is used in many places when choosing device id, specifically
in network device code, so I just took it as I do not like to reinvent
the wheel.

> available ID. Marcel even suggested an approach with a pseudo code
> that seems to be the best way to go. Something along the lines of:
>
>        list_for_each(p, &hci_dev_list) {
>                if (list_entry(p, struct hci_dev, list)->id > id)
> /* just replacing != with > */
>                        break;
>                head = p; id++;
>        }
>
> We assume id starts with the number we'll try to add the new device
> and keep iterating until we find the proper place. The only difference
> is we start with 0 for BR/EDR and 1 for AMP devices. Then every
> hdev->id in the _ordered_ list <= to the id we want we increment id
> and move head. In the end we'll have id as the first available one and
> head is where you need to add hdev (before head) to the list to keep
> it ordered. Right? Does that work for you? Am I missing anything here?

Please better send a patch ;) Either way is OK for me.

Regards,
Andrei

  reply	other threads:[~2012-04-13 18:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13 10:06 [PATCHv2 0/2] Fixing device registration bugs Andrei Emeltchenko
2012-04-13 10:06 ` [PATCHv2 1/2] Bluetooth: Fix registering hci with duplicate name Andrei Emeltchenko
2012-04-13 10:06 ` [PATCHv2 2/2] Bluetooth: Fix debug printing unallocated name Andrei Emeltchenko
2012-04-13 11:21 ` [PATCHv3 0/2] Fixing device registration bugs Andrei Emeltchenko
2012-04-13 11:21   ` [PATCHv3 1/2] Bluetooth: Fix registering hci with duplicate name Andrei Emeltchenko
2012-04-13 16:25     ` Ulisses Furquim
2012-04-13 18:39       ` Andrei Emeltchenko [this message]
2012-04-13 20:05         ` Ulisses Furquim
2012-04-13 11:21   ` [PATCHv3 2/2] Bluetooth: Fix debug printing unallocated name Andrei Emeltchenko

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=CAMXE1-o8oPdPF6Ry1nFUcnHFUMXs8U_ghysKN3nhCeTsFFx7Mw@mail.gmail.com \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=ulisses@profusion.mobi \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.