On Wed, Nov 17, 2010 at 4:50 AM, Vitaly Wool <vitalywool@xxxxxxxxx> wrote: >>> + Â Â /* Registration with ST layer is successful, >>> + Â Â Â* hardware is ready to accept commands from HCI core. >>> + Â Â Â*/ >>> + Â Â if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) { >>> + Â Â Â Â Â Â clear_bit(HCI_RUNNING, &hdev->flags); >>> + Â Â Â Â Â Â err = st_unregister(ST_BT); >>> + Â Â Â Â Â Â if (err) >>> + Â Â Â Â Â Â Â Â Â Â BT_ERR("st_unregister() failed with error %d", err); >>> + Â Â Â Â Â Â hst->st_write = NULL; >>> + Â Â } >> >> >> What are you trying to do here? test_and_set_bit() result doesn't say >> nothing about error and you shall put test_and_set_bit should be in the >> beginning, to know if your device is already opened or not and then >> clear_bit if some error ocurrs during the function. >> > > Yeap, this piece of code beats me is well. Why is it an error if this > bit wasn't already set? Vitaly, Gustavo, I suppose I never understood HCI_RUNNING flag that way, as in an error check mechanism to avoid multiple hci0 ups. What I understood was that HCI_RUNNING suggested as to when hci0 was ready to be used. With this understanding, I wanted to make sure I downloaded the firmware for the chip before I proclaim to the world that the hci0 is ready to be used, as in HCI_RUNNING. For example, I didn't want my _send_frame to be called before I did the firmware download - since firmware download takes time - 45kb send/wait commands :( But I suppose I now understand - What I would rather do is test_bit in the beginning of function and do a set_bit at the end of function - does this make sense ? > ~Vitaly > -- > 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 > -- 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