Hi Andrei, On Mon, Apr 16, 2012 at 7:07 PM, Ulisses Furquim <ulisses@xxxxxxxxxxxxxx> wrote: > Hi Andrei, > > On Mon, Apr 16, 2012 at 6:44 PM, Andrei Emeltchenko > <andrei.emeltchenko.news@xxxxxxxxx> wrote: >> Hi Ulisses, >> >> Ulisses Furquim <ulisses@xxxxxxxxxxxxxx> написал(а): >> >>>When adding HCI devices hci_register_dev assigns the same name >>>hci1 for subsequently added AMP devices. >>> >>>... >>>[ 6958.381886] sysfs: cannot create duplicate filename >>> '/devices/virtual/bluetooth/hci1 >>>... >>> >>>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 device and 1 for AMP devices (thus AMP >>>devices will never receive register as index 0). Then every hdev->id in >>>the _ordered_ list <= to the id we want we increment id and move the >>>variable head. In the end we'll have id as the first available one and >>>head is where you need to add hdev after to keep the list ordered. >>> >>>Reported-by: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx> >>>Signed-off-by: Ulisses Furquim <ulisses@xxxxxxxxxxxxxx> >>>--- >>> >>>Andrei, it'd be good if you could test it with AMP and add a tested-by >>>as well, please. >>> >>>Thanks. >>> >>>--- >>> net/bluetooth/hci_core.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>>diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c >>>index c4dc263..f24d3d8 100644 >>>--- a/net/bluetooth/hci_core.c >>>+++ b/net/bluetooth/hci_core.c >>>@@ -1754,7 +1754,7 @@ int hci_register_dev(struct hci_dev *hdev) >>> >>> /* Find first available device id */ >>> list_for_each(p, &hci_dev_list) { >>>- if (list_entry(p, struct hci_dev, list)->id != id) >>>+ if (list_entry(p, struct hci_dev, list)->id > id) >>> break; >>> head = p; id++; >> >> Without testing I feel that it would not work. If you register first AMP then bredr it would have the same id. > > Hmm. First AMP will receive id 1, right? The first bredr will be tried > with id 0 and find the id 1 already there and break the loop and > insert hci0 before hci1 in the list, right? I still think it'll work. Now that I think, I see a problem, but different than you said. It's easily fixed, though. list_for_each(p, &hci_dev_list) { int nid = list_entry(p, struct hci_dev, list)->id; if (nid > id) break; if (nid == id) id++; head = p; } Now we solve the problem of adding first bredr and then an AMP device which had to result in hci0 and then hci1, but with the previous code was resulting in hci0 and hci2. Please, if you could test it'd be great. Thanks, Regards, -- Ulisses Furquim ProFUSION embedded systems http://profusion.mobi Mobile: +55 19 9250 0942 Skype: ulissesffs -- 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