From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: Pavan Savoy <pavan_savoy@sify.com>
Cc: Vitaly Wool <vitalywool@gmail.com>,
marcel@holtmann.org, linux-bluetooth@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] Bluetooth: btwilink driver
Date: Wed, 17 Nov 2010 14:52:48 -0200 [thread overview]
Message-ID: <20101117165248.GB21729@vigoh> (raw)
In-Reply-To: <AANLkTi=NH8gbW8iCKOQN0bmbL=nqewsZkUik+VkvWUgi@mail.gmail.com>
Hi Pavan,
* Pavan Savoy <pavan_savoy@sify.com> [2010-11-17 11:13:26 +0530]:
> On Wed, Nov 17, 2010 at 4:50 AM, Vitaly Wool <vitalywool@gmail.com> wrote:
> >>> + =A0 =A0 /* Registration with ST layer is successful,
> >>> + =A0 =A0 =A0* hardware is ready to accept commands from HCI core.
> >>> + =A0 =A0 =A0*/
> >>> + =A0 =A0 if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) {
> >>> + =A0 =A0 =A0 =A0 =A0 =A0 clear_bit(HCI_RUNNING, &hdev->flags);
> >>> + =A0 =A0 =A0 =A0 =A0 =A0 err =3D st_unregister(ST_BT);
> >>> + =A0 =A0 =A0 =A0 =A0 =A0 if (err)
> >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 BT_ERR("st_unregister() fai=
led with error %d", err);
> >>> + =A0 =A0 =A0 =A0 =A0 =A0 hst->st_write =3D NULL;
> >>> + =A0 =A0 }
> >>
> >>
> >> 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?
>=20
> Vitaly, Gustavo,
>=20
> I suppose I never understood HCI_RUNNING flag that way, as in an error
> check mechanism to avoid multiple hci0 ups.
>=20
> 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.
>=20
> 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 :(
>=20
> 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 ?
It does, but does it as test_and_set and then clear if error as we do in
other drivers.
--=20
Gustavo F. Padovan
http://profusion.mobi
WARNING: multiple messages have this Message-ID (diff)
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: Pavan Savoy <pavan_savoy@sify.com>
Cc: Vitaly Wool <vitalywool@gmail.com>,
marcel@holtmann.org, linux-bluetooth@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] Bluetooth: btwilink driver
Date: Wed, 17 Nov 2010 14:52:48 -0200 [thread overview]
Message-ID: <20101117165248.GB21729@vigoh> (raw)
In-Reply-To: <AANLkTi=NH8gbW8iCKOQN0bmbL=nqewsZkUik+VkvWUgi@mail.gmail.com>
Hi Pavan,
* Pavan Savoy <pavan_savoy@sify.com> [2010-11-17 11:13:26 +0530]:
> On Wed, Nov 17, 2010 at 4:50 AM, Vitaly Wool <vitalywool@gmail.com> 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 ?
It does, but does it as test_and_set and then clear if error as we do in
other drivers.
--
Gustavo F. Padovan
http://profusion.mobi
next prev parent reply other threads:[~2010-11-17 16:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 13:07 [PATCH v5] Bluetooth: btwilink driver pavan_savoy
2010-11-16 7:03 ` Pavan Savoy
2010-11-16 7:03 ` Pavan Savoy
2011-01-06 22:32 ` Jesper Juhl
2010-11-16 22:54 ` Gustavo F. Padovan
2010-11-16 23:20 ` Vitaly Wool
2010-11-16 23:20 ` Vitaly Wool
2010-11-17 5:43 ` Pavan Savoy
2010-11-17 5:43 ` Pavan Savoy
2010-11-17 16:52 ` Gustavo F. Padovan [this message]
2010-11-17 16:52 ` Gustavo F. Padovan
2010-11-18 5:18 ` Pavan Savoy
2010-11-18 5:18 ` Pavan Savoy
2010-11-17 5:34 ` Pavan Savoy
2010-11-17 5:34 ` Pavan Savoy
2010-11-17 16:50 ` Gustavo F. Padovan
2010-11-17 16:50 ` Gustavo F. Padovan
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=20101117165248.GB21729@vigoh \
--to=padovan@profusion.mobi \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=pavan_savoy@sify.com \
--cc=vitalywool@gmail.com \
/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.