Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH 2/7] Bluetooth: Add LE connect support
From: Ville Tervo @ 2010-10-12 12:50 UTC (permalink / raw)
  To: ext Gustavo F. Padovan; +Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org
In-Reply-To: <20101007163619.GB4893@vigoh>

On Thu, Oct 07, 2010 at 06:36:20PM +0200, ext Gustavo F. Padovan wrote:
> Hi Ville,
> 
> * Marcel Holtmann <marcel@holtmann.org> [2010-10-07 12:58:09 +0200]:
> 
> > Hi Ville,
> > 
> > > Add logic to create LE connections.
> 
> 
> Could you be more verbose on the commit message, that way people can
> understand better what you are doing in the patch. ;) 

Sure. 

> 
> > > 
> > > Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
> > > ---
> > >  include/net/bluetooth/hci.h      |    1 +
> > >  include/net/bluetooth/hci_core.h |    6 ++-
> > >  net/bluetooth/hci_conn.c         |   38 ++++++++++++++-
> > >  net/bluetooth/hci_event.c        |  100 +++++++++++++++++++++++++++++++++++++-
> > >  4 files changed, 141 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > > index b86aed5..b326240 100644
> > > --- a/include/net/bluetooth/hci.h
> > > +++ b/include/net/bluetooth/hci.h
> > > @@ -162,6 +162,7 @@ enum {
> > >  #define SCO_LINK	0x00
> > >  #define ACL_LINK	0x01
> > >  #define ESCO_LINK	0x02
> > > +#define LE_LINK		0x03
> > 
> > this is not a value defined by the specification, while the others are.
> > And some functions match these to HCI event. So if wanna do it like
> > this, then using something like 0x80 is better.
> 
> A comment in the code saying that is also a good ideia.

Done

-- 
VIlle

^ permalink raw reply

* Re: [PATCH 2/7] Bluetooth: Add LE connect support
From: Ville Tervo @ 2010-10-12 12:50 UTC (permalink / raw)
  To: ext Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1286449089.6145.91.camel@aeonflux>

Hi Marcel,

Thanks for the review. Could you  comments on hci_connect?

On Thu, Oct 07, 2010 at 12:58:09PM +0200, ext Marcel Holtmann wrote:
> Hi Ville,
> 
> > Add logic to create LE connections.
> > 
> > Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
> > ---
> >  include/net/bluetooth/hci.h      |    1 +
> >  include/net/bluetooth/hci_core.h |    6 ++-
> >  net/bluetooth/hci_conn.c         |   38 ++++++++++++++-
> >  net/bluetooth/hci_event.c        |  100 +++++++++++++++++++++++++++++++++++++-
> >  4 files changed, 141 insertions(+), 4 deletions(-)
> > 
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index b86aed5..b326240 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -162,6 +162,7 @@ enum {
> >  #define SCO_LINK	0x00
> >  #define ACL_LINK	0x01
> >  #define ESCO_LINK	0x02
> > +#define LE_LINK		0x03
> 
> this is not a value defined by the specification, while the others are.
> And some functions match these to HCI event. So if wanna do it like
> this, then using something like 0x80 is better.

Done with some explanation why 0x80 is used.

> >  /* LMP features */
> >  #define LMP_3SLOT	0x01
> > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> > index ebec8c9..89f4b10 100644
> > --- a/include/net/bluetooth/hci_core.h
> > +++ b/include/net/bluetooth/hci_core.h
> > @@ -170,6 +170,7 @@ struct hci_conn {
> >  	bdaddr_t	 dst;
> >  	__u16		 handle;
> >  	__u16		 state;
> > +	__u16		 le_state;
> 
> I don't see the need for a separate state here. The LE link is different
> from an ACL link and also from a SCO link. We will create a new hci_conn
> for each type of link.

I removed le_state completely.

> >  	__u8             mode;
> >  	__u8		 type;
> >  	__u8		 out;
> > @@ -203,6 +204,7 @@ struct hci_conn {
> >  	struct hci_dev	*hdev;
> >  	void		*l2cap_data;
> >  	void		*sco_data;
> > +	void		*le_data;
> >  	void		*priv;
> 
> What is the use of le_data here?

No use. Some left over earlier version.

> >  	struct hci_conn	*link;
> > @@ -272,7 +274,7 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
> >  {
> >  	struct hci_conn_hash *h = &hdev->conn_hash;
> >  	list_add(&c->list, &h->list);
> > -	if (c->type == ACL_LINK)
> > +	if (c->type == ACL_LINK || c->type == LE_LINK)
> >  		h->acl_num++;
> >  	else
> >  		h->sco_num++;
> > @@ -282,7 +284,7 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
> >  {
> >  	struct hci_conn_hash *h = &hdev->conn_hash;
> >  	list_del(&c->list);
> > -	if (c->type == ACL_LINK)
> > +	if (c->type == ACL_LINK || c->type == LE_LINK)
> >  		h->acl_num--;
> >  	else
> >  		h->sco_num--;
> 
> I would assume that counting LE connection separately would be way
> better. We could have ACL link to one device and LE link to another.

Done

> > diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> > index 145993f..cb41d64 100644
> > --- a/net/bluetooth/hci_conn.c
> > +++ b/net/bluetooth/hci_conn.c
> > @@ -45,6 +45,27 @@
> >  #include <net/bluetooth/bluetooth.h>
> >  #include <net/bluetooth/hci_core.h>
> >  
> > +void hci_le_connect(struct hci_conn *conn)
> > +{
> > +	struct hci_dev *hdev = conn->hdev;
> > +	struct hci_cp_le_create_conn cp;
> > +
> > +	conn->le_state = BT_CONNECT;
> > +	conn->out = 1;
> > +
> > +	memset(&cp, 0, sizeof(cp));
> > +	cp.scan_interval = cpu_to_le16(0x0004);
> > +	cp.scan_window = cpu_to_le16(0x0004);
> > +	bacpy(&cp.peer_addr, &conn->dst);
> > +	cp.conn_interval_min = cpu_to_le16(0x0008);
> > +	cp.conn_interval_max = cpu_to_le16(0x0100);
> > +	cp.supervision_timeout = cpu_to_le16(0x0064);
> > +	cp.min_ce_len = cpu_to_le16(0x0001);
> > +	cp.max_ce_len = cpu_to_le16(0xffff);
> > +
> > +	hci_send_cmd(hdev, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
> > +}
> > +
> >  void hci_acl_connect(struct hci_conn *conn)
> >  {
> >  	struct hci_dev *hdev = conn->hdev;
> > @@ -365,15 +386,30 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
> >  }
> >  EXPORT_SYMBOL(hci_get_route);
> >  
> > -/* Create SCO or ACL connection.
> > +/* Create SCO, ACL or LE connection.
> >   * Device _must_ be locked */
> >  struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type)
> >  {
> >  	struct hci_conn *acl;
> >  	struct hci_conn *sco;
> > +	struct hci_conn *le;
> >  
> >  	BT_DBG("%s dst %s", hdev->name, batostr(dst));
> >  
> > +	if (type == LE_LINK) {
> > +		le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
> > +
> > +		if (!le)
> > +			le = hci_conn_add(hdev, LE_LINK, dst);
> > +
> > +		if (!le)
> > +			return NULL;
> > +
> > +		hci_le_connect(le);
> > +
> > +		return le;
> > +	}
> > +
> >  	if (!(acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst))) {
> >  		if (!(acl = hci_conn_add(hdev, ACL_LINK, dst)))
> >  			return NULL;
> 
> No liking it this much. We might have to re-think on how to do things
> here.

Could you eloborate which part you dislike? I'm leaving this currently like it was.

> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index d3c68de..0b979ae 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
> > @@ -868,6 +868,44 @@ static void hci_cc_le_set_scan(struct hci_dev *hdev, struct sk_buff *skb)
> >  	hci_req_complete(hdev, status);
> >  }
> >  
> > +static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
> > +{
> > +	struct hci_cp_le_create_conn *cp;
> > +	struct hci_conn *conn;
> > +
> > +	BT_DBG("%s status 0x%x", hdev->name, status);
> > +
> > +	cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN);
> > +	if (!cp)
> > +		return;
> > +
> > +	hci_dev_lock(hdev);
> > +
> > +	conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->peer_addr);
> > +
> > +	BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->peer_addr),
> > +		conn);
> > +
> > +	if (status) {
> > +		if (conn && conn->le_state == BT_CONNECT) {
> > +			conn->le_state = BT_CLOSED;
> > +			hci_proto_connect_cfm(conn, status);
> > +			hci_conn_del(conn);
> > +		}
> > +	} else {
> > +		if (!conn) {
> > +			conn = hci_conn_add(hdev, LE_LINK, &cp->peer_addr);
> > +			if (conn) {
> > +				conn->out = 1;
> > +				conn->link_mode |= HCI_LM_MASTER;
> > +			} else
> > +				BT_ERR("No memory for new connection");
> > +		}
> > +	}
> > +
> > +	hci_dev_unlock(hdev);
> > +}
> 
> Do we have the master/slave association with LE?

Yes. But it cannot be changed like in legacy bluetooth connection. conn->out
and conn->link_mode |= HCI_LM_MASTER are redutant information. I removed
conn->link_mode setting.

> >  static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
> >  {
> >  	__u8 status = *((__u8 *) skb->data);
> > @@ -1069,7 +1107,10 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
> >  
> >  	conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
> >  	if (conn) {
> > -		conn->state = BT_CLOSED;
> > +		if (conn->type == LE_LINK)
> > +			conn->le_state = BT_CLOSED;
> > +		else
> > +			conn->state = BT_CLOSED;
> 
> If we would just use conn->state then this should not be needed.
>  
> >  		hci_proto_disconn_cfm(conn, ev->reason);
> >  		hci_conn_del(conn);
> > @@ -1430,6 +1471,10 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
> >  		hci_cs_exit_sniff_mode(hdev, ev->status);
> >  		break;
> >  
> > +	case HCI_OP_LE_CREATE_CONN:
> > +		hci_cs_le_create_conn(hdev, ev->status);
> > +		break;
> > +
> >  	default:
> >  		BT_DBG("%s opcode 0x%x", hdev->name, opcode);
> >  		break;
> > @@ -1875,6 +1920,55 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_
> >  	hci_dev_unlock(hdev);
> >  }
> >  
> > +static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
> > +{
> > +	struct hci_ev_le_conn_complete *ev = (void *) skb->data;
> > +	struct hci_conn *conn;
> > +
> > +	BT_DBG("%s status %d", hdev->name, ev->status);
> > +
> > +	hci_dev_lock(hdev);
> > +
> > +	conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &ev->bdaddr);
> > +
> > +	if (!conn)
> > +		goto unlock;
> 
> The empty line between conn assignment and check should be removed.

Done

> 
> > +
> > +	if (ev->status) {
> > +		hci_proto_connect_cfm(conn, ev->status);
> > +		conn->le_state = BT_CLOSED;
> > +		hci_conn_del(conn);
> > +		goto unlock;
> > +	}
> > +
> > +	conn->handle = __le16_to_cpu(ev->handle);
> > +	conn->le_state = BT_CONNECTED;
> > +
> > +	hci_conn_hold_device(conn);
> > +	hci_conn_add_sysfs(conn);
> > +
> > +	hci_proto_connect_cfm(conn, ev->status);
> > +unlock:
> > +	hci_dev_unlock(hdev);
> 
> And here you should have an empty line between the label and the last
> statement before the label.

Done

> > +}
> > +
> > +static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
> > +{
> > +	struct hci_ev_le_meta *le_ev = (void *) skb->data;
> > +	__u8 event = le_ev->subevent;
> 
> Why?
> 
> > +
> > +	skb_pull(skb, sizeof(*le_ev));
> > +
> > +	switch (event) {
> 
> Using le_ev->subevent would be just fine here.

Done

> > +	case HCI_EV_LE_CONN_COMPLETE:
> > +		hci_le_conn_complete_evt(hdev, skb);
> > +		break;
> > +
> > +	default:
> > +		break;
> > +	}
> > +}
> > +
> >  void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
> >  {
> >  	struct hci_event_hdr *hdr = (void *) skb->data;
> > @@ -2011,6 +2105,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
> >  		hci_remote_host_features_evt(hdev, skb);
> >  		break;
> >  
> > +	case HCI_EV_LE_META:
> > +		hci_le_meta_evt(hdev, skb);
> > +		break;
> > +
> >  	default:
> >  		BT_DBG("%s event 0x%x", hdev->name, event);
> >  		break;
> 

-- 
Ville

^ permalink raw reply

* Re: Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Johan Hedberg @ 2010-10-12 10:15 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikapHztx_w9mWxotJBuofYHnxMExd88V+8ng40E@mail.gmail.com>

Hi Jose,

On Tue, Oct 12, 2010, Jose Antonio Santos Cadenas wrote:
> >> On Tue, Oct 12, 2010, Jose Antonio Santos Cadenas wrote:
> >>> I'm sorry but I can't connect to the IRC rigth now. Nevertheless, I
> >>> think that I've found the issues:
> >>>
> >>> - The iochannel should be unrefereed when the watcher is explicitly removed
> >>
> >> Yes, though do you need to have a reference at all? As long as you have
> >> the GLib watch callback GLib itself holds a reference, so if you don't
> >> need one just remove chan->echo_chan and do an unref after calling
> >> add_watch.
> >
> > Sorry I've forgot this one. Gonna solve it.
> 
> Solved, I've removed the chan->echo_chan attribute and directly unref
> the io_channel once the watcher is set.

Thanks. The patches have now been pushed upstream.

Johan

^ permalink raw reply

* Re: Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Jose Antonio Santos Cadenas @ 2010-10-12 10:10 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas, linux-bluetooth; +Cc: Johan Hedberg
In-Reply-To: <AANLkTikPOQm0MBQVL7Ax=v8nfp5wJCY+W5=9Fqn384Ur@mail.gmail.com>

2010/10/12 Jose Antonio Santos Cadenas <santoscadenas@gmail.com>:
> 2010/10/12 Johan Hedberg <johan.hedberg@gmail.com>:
>> Hi Jose,
>>
>> On Tue, Oct 12, 2010, Jose Antonio Santos Cadenas wrote:
>>> I'm sorry but I can't connect to the IRC rigth now. Nevertheless, I
>>> think that I've found the issues:
>>>
>>> - The iochannel should be unrefereed when the watcher is explicitly removed
>>
>> Yes, though do you need to have a reference at all? As long as you have
>> the GLib watch callback GLib itself holds a reference, so if you don't
>> need one just remove chan->echo_chan and do an unref after calling
>> add_watch.
>
> Sorry I've forgot this one. Gonna solve it.

Solved, I've removed the chan->echo_chan attribute and directly unref
the io_channel once the watcher is set.

>
>>
>>> - The commit message s/paramter/parameter
>>>
>>> Are there any more?
>>
>> s/Imcoming/Incoming/
>> s/DBus/D-Bus/
>>
>> And the following doesn't make much sense to me:
>>
>> "Delete all channels DBus interface when the instance is removed"
>>
>> Could you rephrase it somehow, maybe by putting most of it in the
>> message body instead of the summary line. Is it trying to say "Delete
>> the D-Bus interfaces of all channels"? The summary line shouldn't be too
>> complex. You can just say "Fix D-Bus channel removal when removing
>> instances" and then in the message body do the more detailed
>> explanation.
>>
>> Johan
>>
>

^ permalink raw reply

* Re: Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Jose Antonio Santos Cadenas @ 2010-10-12 10:02 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas, linux-bluetooth; +Cc: Johan Hedberg
In-Reply-To: <20101012093531.GA22165@jh-x301>

2010/10/12 Johan Hedberg <johan.hedberg@gmail.com>:
> Hi Jose,
>
> On Tue, Oct 12, 2010, Jose Antonio Santos Cadenas wrote:
>> I'm sorry but I can't connect to the IRC rigth now. Nevertheless, I
>> think that I've found the issues:
>>
>> - The iochannel should be unrefereed when the watcher is explicitly removed
>
> Yes, though do you need to have a reference at all? As long as you have
> the GLib watch callback GLib itself holds a reference, so if you don't
> need one just remove chan->echo_chan and do an unref after calling
> add_watch.

Sorry I've forgot this one. Gonna solve it.

>
>> - The commit message s/paramter/parameter
>>
>> Are there any more?
>
> s/Imcoming/Incoming/
> s/DBus/D-Bus/
>
> And the following doesn't make much sense to me:
>
> "Delete all channels DBus interface when the instance is removed"
>
> Could you rephrase it somehow, maybe by putting most of it in the
> message body instead of the summary line. Is it trying to say "Delete
> the D-Bus interfaces of all channels"? The summary line shouldn't be too
> complex. You can just say "Fix D-Bus channel removal when removing
> instances" and then in the message body do the more detailed
> explanation.
>
> Johan
>

^ permalink raw reply

* Re: Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Jose Antonio Santos Cadenas @ 2010-10-12  9:57 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas, linux-bluetooth
In-Reply-To: <20101012093531.GA22165@jh-x301>

Hi,

2010/10/12 Johan Hedberg <johan.hedberg@gmail.com>:
> Hi Jose,
>
> On Tue, Oct 12, 2010, Jose Antonio Santos Cadenas wrote:
>> I'm sorry but I can't connect to the IRC rigth now. Nevertheless, I
>> think that I've found the issues:
>>
>> - The iochannel should be unrefereed when the watcher is explicitly removed
>
> Yes, though do you need to have a reference at all? As long as you have
> the GLib watch callback GLib itself holds a reference, so if you don't
> need one just remove chan->echo_chan and do an unref after calling
> add_watch.
>
>> - The commit message s/paramter/parameter
>>
>> Are there any more?
>
> s/Imcoming/Incoming/

Solved this one

> s/DBus/D-Bus/
>
> And the following doesn't make much sense to me:
>
> "Delete all channels DBus interface when the instance is removed"
>
> Could you rephrase it somehow, maybe by putting most of it in the
> message body instead of the summary line. Is it trying to say "Delete
> the D-Bus interfaces of all channels"? The summary line shouldn't be too
> complex. You can just say "Fix D-Bus channel removal when removing
> instances" and then in the message body do the more detailed
> explanation.

I've changed the commit message and added an explanation. I hope now is clearer.

>
> Johan
>

Regards.

Jose.

^ permalink raw reply

* Re: [PATCH 4/4] Fix possible use of uninitialized variables
From: Johan Hedberg @ 2010-10-12  9:39 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1286870891-5862-4-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Tue, Oct 12, 2010, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> 
> Using uninitialized value "hi" and "flags" in call to function
> "OBEX_ObjectAddHeader".
> ---
>  src/obex.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)

And this one has also been pushed upstream. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 3/4] Fix dead statement
From: Johan Hedberg @ 2010-10-12  9:39 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1286870891-5862-3-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Tue, Oct 12, 2010, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> 
> Cannot reach dead statement "(*os->driver->close)(object);"
> ---
>  src/obex.c |    8 +-------
>  1 files changed, 1 insertions(+), 7 deletions(-)

This one is also upstream.

Johan

^ permalink raw reply

* Re: [PATCH 2/4] Fix possible NULL pointer deference
From: Johan Hedberg @ 2010-10-12  9:38 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1286870891-5862-2-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Tue, Oct 12, 2010, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> 
> Variable "transfer" tracked as NULL was passed to function
> "transfer_unregister" that dereferences it.
> ---
>  client/session.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)

Pushed upstream. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 1/4] Fix possible NULL pointer deference
From: Johan Hedberg @ 2010-10-12  9:38 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1286870891-5862-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Tue, Oct 12, 2010, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> 
> Variable "os->driver" tracked as NULL.
> ---
>  src/obex.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)

Pushed upstream. Thanks.

Johan

^ permalink raw reply

* Re: Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Johan Hedberg @ 2010-10-12  9:35 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas; +Cc: linux-bluetooth
In-Reply-To: <AANLkTik8k84qwMM3nHc4z2gVWm6Vo0HaLME2PEcwMyeg@mail.gmail.com>

Hi Jose,

On Tue, Oct 12, 2010, Jose Antonio Santos Cadenas wrote:
> I'm sorry but I can't connect to the IRC rigth now. Nevertheless, I
> think that I've found the issues:
> 
> - The iochannel should be unrefereed when the watcher is explicitly removed

Yes, though do you need to have a reference at all? As long as you have
the GLib watch callback GLib itself holds a reference, so if you don't
need one just remove chan->echo_chan and do an unref after calling
add_watch.

> - The commit message s/paramter/parameter
> 
> Are there any more?

s/Imcoming/Incoming/
s/DBus/D-Bus/

And the following doesn't make much sense to me:

"Delete all channels DBus interface when the instance is removed"

Could you rephrase it somehow, maybe by putting most of it in the
message body instead of the summary line. Is it trying to say "Delete
the D-Bus interfaces of all channels"? The summary line shouldn't be too
complex. You can just say "Fix D-Bus channel removal when removing
instances" and then in the message body do the more detailed
explanation.

Johan

^ permalink raw reply

* [PATCH 4/4] Fix possible use of uninitialized variables
From: Luiz Augusto von Dentz @ 2010-10-12  8:08 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1286870891-5862-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

Using uninitialized value "hi" and "flags" in call to function
"OBEX_ObjectAddHeader".
---
 src/obex.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index 41ba558..3e9f5b6 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -670,6 +670,9 @@ add_header:
 	case OBEX_HDR_APPARAM:
 		flags =  0;
 		break;
+	default:
+		error("read(): unkown header type %u", hi);
+		return -EIO;
 	}
 
 	OBEX_ObjectAddHeader(obex, obj, hi, hd, len, flags);
-- 
1.7.1


^ permalink raw reply related

* [PATCH 3/4] Fix dead statement
From: Luiz Augusto von Dentz @ 2010-10-12  8:08 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1286870891-5862-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

Cannot reach dead statement "(*os->driver->close)(object);"
---
 src/obex.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index 8d12f8f..41ba558 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -882,7 +882,7 @@ int obex_get_stream_start(struct obex_session *os, const char *filename)
 								&size, &err);
 	if (object == NULL) {
 		error("open(%s): %s (%d)", filename, strerror(-err), -err);
-		goto fail;
+		return err;
 	}
 
 	os->object = object;
@@ -893,12 +893,6 @@ int obex_get_stream_start(struct obex_session *os, const char *filename)
 		os->buf = g_malloc0(os->tx_mtu);
 
 	return 0;
-
-fail:
-	if (object)
-		os->driver->close(object);
-
-	return err;
 }
 
 int obex_put_stream_start(struct obex_session *os, const char *filename)
-- 
1.7.1


^ permalink raw reply related

* [PATCH 2/4] Fix possible NULL pointer deference
From: Luiz Augusto von Dentz @ 2010-10-12  8:08 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1286870891-5862-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

Variable "transfer" tracked as NULL was passed to function
"transfer_unregister" that dereferences it.
---
 client/session.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/client/session.c b/client/session.c
index 7539a97..ce3432d 100644
--- a/client/session.c
+++ b/client/session.c
@@ -1274,10 +1274,8 @@ int session_send(struct session_data *session, const char *filename,
 
 	transfer = transfer_register(session, filename, targetname, NULL,
 					NULL);
-	if (transfer == NULL) {
-		err = -EINVAL;
-		goto fail;
-	}
+	if (transfer == NULL)
+		return -EINVAL;
 
 	/* Transfer should start if it is the first in the pending list */
 	if (transfer != session->pending->data)
-- 
1.7.1


^ permalink raw reply related

* [PATCH 1/4] Fix possible NULL pointer deference
From: Luiz Augusto von Dentz @ 2010-10-12  8:08 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

Variable "os->driver" tracked as NULL.
---
 src/obex.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index 92d3b5c..8d12f8f 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -589,7 +589,9 @@ static int obex_read_stream(struct obex_session *os, obex_t *obex,
 	os->buf = g_realloc(os->buf, os->pending + size);
 	memcpy(os->buf + os->pending, buffer, size);
 	os->pending += size;
-	if (os->object == NULL) {
+
+	/* only write if both object and driver are valid */
+	if (os->object == NULL || os->driver == NULL) {
 		DBG("Stored %u bytes into temporary buffer", os->pending);
 		return 0;
 	}
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH] Bluetooth: TI_ST bluetooth driver
From: Pavan Savoy @ 2010-10-12  4:19 UTC (permalink / raw)
  To: linux-bluetooth, marcel; +Cc: greg, linux-kernel, Pavan Savoy
In-Reply-To: <1286814803-6740-1-git-send-email-pavan_savoy@ti.com>

On Mon, Oct 11, 2010 at 12:33 PM,  <pavan_savoy@ti.com> wrote:
> From: Pavan Savoy <pavan_savoy@ti.com>
>
> Gustavo, Marcel,
>
> I have taken care of most of the comments which you provided.
> Couple of them like usage of goto's, I didn't handle since
> I am not doing much error handling repeatedly there.
>
> I have also removed the 2 states like _REGISTERED, _RUNNING which
> were not required and the flags associated with it.
> I have taken care of other style comments.
>
> Please review and provide your comments,

Marcel,
I hope you find some time to provide comments.


Thanks,
Pavan

> -- patch description --
>
> This is the bluetooth protocol driver for the TI WiLink7 chipsets.
> Texas Instrument's WiLink chipsets combine wireless technologies
> like BT, FM, GPS and WLAN onto a single chip.
>
> This Bluetooth driver works on top of the TI_ST shared transport
> line discipline driver which also allows other drivers like
> FM V4L2 and GPS character driver to make use of the same UART interface.
>
> Kconfig and Makefile modifications to enable the Bluetooth
> driver for Texas Instrument's WiLink 7 chipset.
>
> Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
> ---
> =C2=A0drivers/bluetooth/Kconfig =C2=A0 =C2=A0| =C2=A0 10 +
> =C2=A0drivers/bluetooth/Makefile =C2=A0 | =C2=A0 =C2=A01 +
> =C2=A0drivers/bluetooth/btwilink.c | =C2=A0455 ++++++++++++++++++++++++++=
++++++++++++++++
> =C2=A03 files changed, 466 insertions(+), 0 deletions(-)
> =C2=A0create mode 100644 drivers/bluetooth/btwilink.c
>
> diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
> index 02deef4..e0d67dd 100644
> --- a/drivers/bluetooth/Kconfig
> +++ b/drivers/bluetooth/Kconfig
> @@ -219,4 +219,14 @@ config BT_ATH3K
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Say Y here to compile support for "Athe=
ros firmware download driver"
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0into the kernel or say M to compile it =
as module (ath3k).
>
> +config BT_WILINK
> + =C2=A0 =C2=A0 =C2=A0 tristate "BlueZ bluetooth driver for TI ST"
> + =C2=A0 =C2=A0 =C2=A0 depends on TI_ST
> + =C2=A0 =C2=A0 =C2=A0 help
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 This enables the Bluetooth driver for Texas=
 Instrument's BT/FM/GPS
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 combo devices. This makes use of shared tra=
nsport line discipline
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 core driver to communicate with the BT core=
 of the combo chip.
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 Say Y here to compile support for Texas Ins=
trument's WiLink7 driver
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 into the kernel or say M to compile it as m=
odule.
> =C2=A0endmenu
> diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
> index 71bdf13..5351b62 100644
> --- a/drivers/bluetooth/Makefile
> +++ b/drivers/bluetooth/Makefile
> @@ -28,3 +28,4 @@ hci_uart-$(CONFIG_BT_HCIUART_BCSP) =C2=A0 =C2=A0+=3D hc=
i_bcsp.o
> =C2=A0hci_uart-$(CONFIG_BT_HCIUART_LL) =C2=A0 =C2=A0 =C2=A0 +=3D hci_ll.o
> =C2=A0hci_uart-$(CONFIG_BT_HCIUART_ATH3K) =C2=A0 =C2=A0+=3D hci_ath.o
> =C2=A0hci_uart-objs =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:=3D $(hci_uart-y)
> +obj-$(CONFIG_BT_WILINK) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:=3D btwilink.o
> diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
> new file mode 100644
> index 0000000..e0bde79
> --- /dev/null
> +++ b/drivers/bluetooth/btwilink.c
> @@ -0,0 +1,455 @@
> +/*
> + * =C2=A0Texas Instrument's Bluetooth Driver For Shared Transport.
> + *
> + * =C2=A0Bluetooth Driver acts as interface between HCI CORE and
> + * =C2=A0TI Shared Transport Layer.
> + *
> + * =C2=A0Copyright (C) 2009-2010 Texas Instruments
> + * =C2=A0Author: Raja Mani <raja_mani@ti.com>
> + * =C2=A0 =C2=A0 Pavan Savoy <pavan_savoy@ti.com>
> + *
> + * =C2=A0This program is free software; you can redistribute it and/or m=
odify
> + * =C2=A0it under the terms of the GNU General Public License version 2 =
as
> + * =C2=A0published by the Free Software Foundation.
> + *
> + * =C2=A0This program is distributed in the hope that it will be useful,
> + * =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =C2=A0See =
the
> + * =C2=A0GNU General Public License for more details.
> + *
> + * =C2=A0You should have received a copy of the GNU General Public Licen=
se
> + * =C2=A0along with this program; if not, write to the Free Software
> + * =C2=A0Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA =C2=A0=
02111-1307 =C2=A0USA
> + *
> + */
> +
> +#include <linux/platform_device.h>
> +#include <net/bluetooth/bluetooth.h>
> +#include <net/bluetooth/hci_core.h>
> +
> +#include <linux/ti_wilink_st.h>
> +
> +/* Bluetooth Driver Version */
> +#define VERSION =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "1.0"
> +
> +/* Defines number of seconds to wait for reg completion
> + * callback getting called from ST (in case,registration
> + * with ST returns PENDING status)
> + */
> +#define BT_REGISTER_TIMEOUT =C2=A0 6000 =C2=A0 =C2=A0 /* 6 sec */
> +
> +/**
> + * struct ti_st - BT driver operation structure
> + * @hdev: hci device pointer which binds to bt driver
> + * @flags: used locally,to maintain various BT driver status
> + * @streg_cbdata: to hold ST registration callback status
> + * @st_write: write function pointer of ST driver
> + * @wait_for_btdrv_reg_completion - completion sync between ti_st_open
> + * =C2=A0 =C2=A0 and ti_st_registration_completion_cb.
> + */
> +struct ti_st {
> + =C2=A0 =C2=A0 =C2=A0 struct hci_dev *hdev;
> + =C2=A0 =C2=A0 =C2=A0 char streg_cbdata;
> + =C2=A0 =C2=A0 =C2=A0 long (*st_write) (struct sk_buff *);
> + =C2=A0 =C2=A0 =C2=A0 struct completion wait_for_btdrv_reg_completion;
> +};
> +
> +static int reset;
> +
> +/* Increments HCI counters based on pocket ID (cmd,acl,sco) */
> +static inline void ti_st_tx_complete(struct ti_st *hst, int pkt_type)
> +{
> + =C2=A0 =C2=A0 =C2=A0 struct hci_dev *hdev;
> + =C2=A0 =C2=A0 =C2=A0 hdev =3D hst->hdev;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Update HCI stat counters */
> + =C2=A0 =C2=A0 =C2=A0 switch (pkt_type) {
> + =C2=A0 =C2=A0 =C2=A0 case HCI_COMMAND_PKT:
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hdev->stat.cmd_tx++;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> +
> + =C2=A0 =C2=A0 =C2=A0 case HCI_ACLDATA_PKT:
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hdev->stat.acl_tx++;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> +
> + =C2=A0 =C2=A0 =C2=A0 case HCI_SCODATA_PKT:
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hdev->stat.sco_tx++;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> + =C2=A0 =C2=A0 =C2=A0 }
> +}
> +
> +/* ------- Interfaces to Shared Transport ------ */
> +
> +/* Called by ST layer to indicate protocol registration completion
> + * status.ti_st_open() function will wait for signal from this
> + * API when st_register() function returns ST_PENDING.
> + */
> +static void st_registration_completion_cb(void *priv_data, char data)
> +{
> + =C2=A0 =C2=A0 =C2=A0 struct ti_st *lhst =3D (struct ti_st *)priv_data;
> + =C2=A0 =C2=A0 =C2=A0 /* ti_st_open() function needs value of 'data' to =
know
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* the registration status(success/fail),So h=
ave a back
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* up of it.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 lhst->streg_cbdata =3D data;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Got a feedback from ST for BT driver registrati=
on
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* request.Wackup ti_st_open() function to co=
ntinue
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* it's open operation.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 complete(&lhst->wait_for_btdrv_reg_completion);
> +}
> +
> +/* Called by Shared Transport layer when receive data is
> + * available */
> +static long st_receive(void *priv_data, struct sk_buff *skb)
> +{
> + =C2=A0 =C2=A0 =C2=A0 int err;
> + =C2=A0 =C2=A0 =C2=A0 struct ti_st *lhst =3D (struct ti_st *)priv_data;
> +
> + =C2=A0 =C2=A0 =C2=A0 if (skb =3D=3D NULL) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Invalid SKB re=
ceived from ST");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EFAULT;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 if (!lhst) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree_skb(skb);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Invalid ti_st =
memory,freeing SKB");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EFAULT;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 skb->dev =3D (struct net_device *)lhst->hdev;
> + =C2=A0 =C2=A0 =C2=A0 /* Forward skb to HCI CORE layer */
> + =C2=A0 =C2=A0 =C2=A0 err =3D hci_recv_frame(skb);
> + =C2=A0 =C2=A0 =C2=A0 if (err) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree_skb(skb);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Unable to push=
 skb to HCI CORE(%d),freeing SKB",
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 err);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return err;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 lhst->hdev->stat.byte_rx +=3D skb->len;
> + =C2=A0 =C2=A0 =C2=A0 return 0;
> +}
> +
> +/* ------- Interfaces to HCI layer ------ */
> +
> +/* Called from HCI core to initialize the device */
> +static int ti_st_open(struct hci_dev *hdev)
> +{
> + =C2=A0 =C2=A0 =C2=A0 static struct st_proto_s ti_st_proto;
> + =C2=A0 =C2=A0 =C2=A0 unsigned long timeleft;
> + =C2=A0 =C2=A0 =C2=A0 struct ti_st *hst;
> + =C2=A0 =C2=A0 =C2=A0 int err;
> + =C2=A0 =C2=A0 =C2=A0 err =3D 0;
> +
> + =C2=A0 =C2=A0 =C2=A0 BT_DBG("%s %p", hdev->name, hdev);
> + =C2=A0 =C2=A0 =C2=A0 hst =3D hdev->driver_data;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Populate BT driver info required by ST */
> + =C2=A0 =C2=A0 =C2=A0 memset(&ti_st_proto, 0, sizeof(ti_st_proto));
> +
> + =C2=A0 =C2=A0 =C2=A0 /* BT driver ID */
> + =C2=A0 =C2=A0 =C2=A0 ti_st_proto.type =3D ST_BT;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Receive function which called from ST */
> + =C2=A0 =C2=A0 =C2=A0 ti_st_proto.recv =3D st_receive;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Callback to be called when registration is pend=
ing */
> + =C2=A0 =C2=A0 =C2=A0 ti_st_proto.reg_complete_cb =3D st_registration_co=
mpletion_cb;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* send in the hst to be received at registration =
complete callback
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* and during st's receive
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 ti_st_proto.priv_data =3D hst;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Register with ST layer */
> + =C2=A0 =C2=A0 =C2=A0 err =3D st_register(&ti_st_proto);
> + =C2=A0 =C2=A0 =C2=A0 if (err =3D=3D -EINPROGRESS) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Prepare wait-for-co=
mpletion handler data structures.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* Needed to sync=
ronize this and st_registration_completion_cb()
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* functions.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 init_completion(&hst->=
wait_for_btdrv_reg_completion);
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Reset ST registrati=
on callback status flag , this value
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* will be update=
d in ti_st_registration_completion_cb()
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* function whene=
ver it called from ST driver.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hst->streg_cbdata =3D =
-EINPROGRESS;
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* ST is busy with oth=
er protocol registration(may be busy with
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* firmware downl=
oad).So,Wait till the registration callback
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* (passed as a a=
rgument to st_register() function) getting
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* called from ST=
.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_DBG(" %s waiting fo=
r reg completion signal from ST",
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 __func__);
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 timeleft =3D
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 wait_for_completion_timeout
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 (&hst->wait_for_btdrv_reg_completion,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0msecs_to_jiffies(BT_REGISTER_TIMEOUT));
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!timeleft) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 BT_ERR("Timeout(%d sec),didn't get reg"
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "completion =
signal from ST",
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_REGISTER_=
TIMEOUT / 1000);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 return -ETIMEDOUT;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Is ST registration =
callback called with ERROR value? */
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (hst->streg_cbdata =
!=3D 0) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 BT_ERR("ST reg completion CB called with invalid"
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "status %d",=
 hst->streg_cbdata);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 return -EAGAIN;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 err =3D 0;
> + =C2=A0 =C2=A0 =C2=A0 } else if (err =3D=3D -1) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("st_register fa=
iled %d", err);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EAGAIN;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Do we have proper ST write function? */
> + =C2=A0 =C2=A0 =C2=A0 if (ti_st_proto.write !=3D NULL) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* We need this pointe=
r for sending any Bluetooth pkts */
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hst->st_write =3D ti_s=
t_proto.write;
> + =C2=A0 =C2=A0 =C2=A0 } else {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("failed to get =
ST write func pointer");
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Undo registration w=
ith ST */
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 err =3D st_unregister(=
ST_BT);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (err < 0)
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 BT_ERR("st_unregister failed %d", err);
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hst->st_write =3D NULL=
;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EAGAIN;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Registration with ST layer is completed success=
fully,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* now chip is ready to accept commands from =
HCI CORE.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* Mark HCI Device flag as RUNNING
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 set_bit(HCI_RUNNING, &hdev->flags);
> + =C2=A0 =C2=A0 =C2=A0 return err;
> +}
> +
> +/* Close device */
> +static int ti_st_close(struct hci_dev *hdev)
> +{
> + =C2=A0 =C2=A0 =C2=A0 int err =3D 0;
> + =C2=A0 =C2=A0 =C2=A0 struct ti_st *hst;
> +
> + =C2=A0 =C2=A0 =C2=A0 hst =3D hdev->driver_data;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Clear HCI device RUNNING flag */
> + =C2=A0 =C2=A0 =C2=A0 if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)=
)
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("HCI not RUNNIN=
G?");
> +
> + =C2=A0 =C2=A0 =C2=A0 /* continue to unregister from transport */
> + =C2=A0 =C2=A0 =C2=A0 err =3D st_unregister(ST_BT);
> + =C2=A0 =C2=A0 =C2=A0 if (err !=3D 0) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hst->st_write =3D NULL=
;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("st_unregister =
failed %d", err);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EBUSY;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 hst->st_write =3D NULL;
> + =C2=A0 =C2=A0 =C2=A0 return err;
> +}
> +
> +/* Called from HCI CORE , Sends frames to Shared Transport */
> +static int ti_st_send_frame(struct sk_buff *skb)
> +{
> + =C2=A0 =C2=A0 =C2=A0 struct hci_dev *hdev;
> + =C2=A0 =C2=A0 =C2=A0 struct ti_st *hst;
> + =C2=A0 =C2=A0 =C2=A0 long len;
> +
> + =C2=A0 =C2=A0 =C2=A0 if (skb =3D=3D NULL) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Invalid skb re=
ceived from HCI CORE");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENOMEM;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 hdev =3D (struct hci_dev *)skb->dev;
> + =C2=A0 =C2=A0 =C2=A0 if (!hdev) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("SKB received f=
or invalid HCI Device (hdev=3DNULL)");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENODEV;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 if (!test_bit(HCI_RUNNING, &hdev->flags)) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Device is not =
running");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EBUSY;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 hst =3D (struct ti_st *)hdev->driver_data;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Prepend skb with frame type */
> + =C2=A0 =C2=A0 =C2=A0 memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1)=
;
> +
> + =C2=A0 =C2=A0 =C2=A0 BT_DBG(" %s: type %d len %d", hdev->name, bt_cb(sk=
b)->pkt_type,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 skb->len);
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Insert skb to shared transport layer's transmit=
 queue.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* Freeing skb memory is taken care in shared=
 transport layer,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* so don't free skb memory here.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 if (!hst->st_write) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree_skb(skb);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR(" Can't write t=
o ST, st_write null?");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EAGAIN;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 len =3D hst->st_write(skb);
> + =C2=A0 =C2=A0 =C2=A0 if (len < 0) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree_skb(skb);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR(" ST write fail=
ed (%ld)", len);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EAGAIN;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 /* ST accepted our skb. So, Go ahead and do rest *=
/
> + =C2=A0 =C2=A0 =C2=A0 hdev->stat.byte_tx +=3D len;
> + =C2=A0 =C2=A0 =C2=A0 ti_st_tx_complete(hst, bt_cb(skb)->pkt_type);
> +
> + =C2=A0 =C2=A0 =C2=A0 return 0;
> +}
> +
> +static void ti_st_destruct(struct hci_dev *hdev)
> +{
> + =C2=A0 =C2=A0 =C2=A0 if (!hdev) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Destruct calle=
d with invalid HCI Device"
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "(hdev=3DNULL)");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 BT_DBG("%s", hdev->name);
> +
> + =C2=A0 =C2=A0 =C2=A0 /* free ti_st memory */
> + =C2=A0 =C2=A0 =C2=A0 if (hdev->driver_data !=3D NULL)
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree(hdev->driver_dat=
a);
> +
> + =C2=A0 =C2=A0 =C2=A0 return;
> +}
> +
> +/* Creates new HCI device */
> +static int ti_st_register_dev(struct ti_st *hst)
> +{
> + =C2=A0 =C2=A0 =C2=A0 struct hci_dev *hdev;
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Initialize and register HCI device */
> + =C2=A0 =C2=A0 =C2=A0 hdev =3D hci_alloc_dev();
> + =C2=A0 =C2=A0 =C2=A0 if (!hdev) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Can't allocate=
 HCI device");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENOMEM;
> + =C2=A0 =C2=A0 =C2=A0 }
> + =C2=A0 =C2=A0 =C2=A0 BT_DBG(" HCI device allocated. hdev=3D %p", hdev);
> +
> + =C2=A0 =C2=A0 =C2=A0 hst->hdev =3D hdev;
> + =C2=A0 =C2=A0 =C2=A0 hdev->bus =3D HCI_UART;
> + =C2=A0 =C2=A0 =C2=A0 hdev->driver_data =3D hst;
> + =C2=A0 =C2=A0 =C2=A0 hdev->open =3D ti_st_open;
> + =C2=A0 =C2=A0 =C2=A0 hdev->close =3D ti_st_close;
> + =C2=A0 =C2=A0 =C2=A0 hdev->flush =3D NULL;
> + =C2=A0 =C2=A0 =C2=A0 hdev->send =3D ti_st_send_frame;
> + =C2=A0 =C2=A0 =C2=A0 hdev->destruct =3D ti_st_destruct;
> + =C2=A0 =C2=A0 =C2=A0 hdev->owner =3D THIS_MODULE;
> +
> + =C2=A0 =C2=A0 =C2=A0 if (reset)
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 set_bit(HCI_QUIRK_NO_R=
ESET, &hdev->quirks);
> +
> + =C2=A0 =C2=A0 =C2=A0 if (hci_register_dev(hdev) < 0) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Can't register=
 HCI device");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hci_free_dev(hdev);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENODEV;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 BT_DBG(" HCI device registered. hdev=3D %p", hdev)=
;
> + =C2=A0 =C2=A0 =C2=A0 return 0;
> +}
> +
> +
> +static int bt_ti_probe(struct platform_device *pdev)
> +{
> + =C2=A0 =C2=A0 =C2=A0 int err;
> + =C2=A0 =C2=A0 =C2=A0 static struct ti_st *hst;
> + =C2=A0 =C2=A0 =C2=A0 err =3D 0;
> +
> + =C2=A0 =C2=A0 =C2=A0 BT_DBG(" Bluetooth Driver Version %s", VERSION);
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Allocate local resource memory */
> + =C2=A0 =C2=A0 =C2=A0 hst =3D kzalloc(sizeof(struct ti_st), GFP_KERNEL);
> + =C2=A0 =C2=A0 =C2=A0 if (!hst) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Can't allocate=
 control structure");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENFILE;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 /* Expose "hciX" device to user space */
> + =C2=A0 =C2=A0 =C2=A0 err =3D ti_st_register_dev(hst);
> + =C2=A0 =C2=A0 =C2=A0 if (err) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Release local resou=
rce memory */
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree(hst);
> +
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("Unable to expo=
se hci0 device(%d)", err);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return err;
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> + =C2=A0 =C2=A0 =C2=A0 dev_set_drvdata(&pdev->dev, hst);
> + =C2=A0 =C2=A0 =C2=A0 return err;
> +}
> +
> +static int bt_ti_remove(struct platform_device *pdev)
> +{
> + =C2=A0 =C2=A0 =C2=A0 struct ti_st *hst;
> +
> + =C2=A0 =C2=A0 =C2=A0 hst =3D dev_get_drvdata(&pdev->dev);
> + =C2=A0 =C2=A0 =C2=A0 /* Deallocate local resource's memory =C2=A0*/
> + =C2=A0 =C2=A0 =C2=A0 if (hst) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct hci_dev *hdev =
=3D hst->hdev;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (hdev =3D=3D NULL) =
{
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 BT_ERR("Invalid hdev memory");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 kfree(hst);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 ti_st_close(hdev);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 hci_unregister_dev(hdev);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 /* Free HCI device memory */
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 hci_free_dev(hdev);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> + =C2=A0 =C2=A0 =C2=A0 }
> + =C2=A0 =C2=A0 =C2=A0 return 0;
> +}
> +
> +static struct platform_driver bt_ti_driver =3D {
> + =C2=A0 =C2=A0 =C2=A0 .probe =3D bt_ti_probe,
> + =C2=A0 =C2=A0 =C2=A0 .remove =3D bt_ti_remove,
> + =C2=A0 =C2=A0 =C2=A0 .driver =3D {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .name =3D "ti_st_bluet=
ooth",
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .owner =3D THIS_MODULE=
,
> + =C2=A0 =C2=A0 =C2=A0 },
> +};
> +
> +/* ------- Module Init/Exit interfaces ------ */
> +static int __init bt_drv_init(void)
> +{
> + =C2=A0 =C2=A0 =C2=A0 long ret =3D 0;
> + =C2=A0 =C2=A0 =C2=A0 ret =3D platform_driver_register(&bt_ti_driver);
> + =C2=A0 =C2=A0 =C2=A0 if (ret !=3D 0) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BT_ERR("bt_ti platform=
 drv registration failed");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -1;
> + =C2=A0 =C2=A0 =C2=A0 }
> + =C2=A0 =C2=A0 =C2=A0 return 0;
> +}
> +
> +static void __exit bt_drv_exit(void)
> +{
> + =C2=A0 =C2=A0 =C2=A0 platform_driver_unregister(&bt_ti_driver);
> +}
> +
> +module_init(bt_drv_init);
> +module_exit(bt_drv_exit);
> +
> +/* ------ Module Info ------ */
> +
> +module_param(reset, bool, 0644);
> +MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
> +MODULE_AUTHOR("Raja Mani <raja_mani@ti.com>");
> +MODULE_DESCRIPTION("Bluetooth Driver for TI Shared Transport" VERSION);
> +MODULE_VERSION(VERSION);
> +MODULE_LICENSE("GPL");
> --
> 1.6.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply

* Bluez UCD support
From: Viswanathan Sankararam @ 2010-10-11 23:37 UTC (permalink / raw)
  To: linux-bluetooth

All,

Does the Bluez stack support UCD which is part of the bluetooth 3.0
specification?

Thanks

^ permalink raw reply

* Re: Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Jose Antonio Santos Cadenas @ 2010-10-11 23:23 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas, linux-bluetooth
In-Reply-To: <AANLkTik8k84qwMM3nHc4z2gVWm6Vo0HaLME2PEcwMyeg@mail.gmail.com>

Hi,

2010/10/12 Jose Antonio Santos Cadenas <santoscadenas@gmail.com>:
> Hi,
>
> 2010/10/11 Johan Hedberg <johan.hedberg@gmail.com>:
>> Hi,
>>
>> On Mon, Oct 11, 2010, Jose Antonio Santos Cadenas wrote:
>>> The following changes since commit 646f0c7e6b557c5413825ce7b04bee52bf0129e8:
>>>
>>>   Move remote name and version requests to hciops (2010-10-10 22:44:25 +0100)
>>>
>>> are available in the git repository at:
>>>   git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
>>>
>>> José Antonio Santos Cadenas (6):
>>>       Remove mdl_conn from struct hdp_channel
>>>       Remove app paramter from hdp_establish_mcl, it is not needed
>>>       Imcoming connection in control channel should be ERTM
>>>       Fix multiple emission of main channel property signal.
>>>       Return MCAP_MDL_BUSY when health channel can't be created
>>>       Implement callback for responding echo petitions
>>>
>>> Santiago Carot-Nemesio (6):
>>>       Add a new function to create channels
>>>       Process request of of echo channels creation
>>>       Correctly notify the deletion of the reliable data channel
>>>       Add extra checks for avoid notifiying incoming echo channels
>>>       Delete all channels DBus interface when the instance is removed
>>>       Check first reliable configuration during channel creation
>>>
>>>  health/hdp.c       |  249 +++++++++++++++++++++++++++++++++++----------------
>>>  health/hdp_types.h |    3 +-
>>>  health/hdp_util.c  |    3 -
>>>  health/hdp_util.h  |    1 -
>>>  health/mcap.c      |    1 +
>>>  5 files changed, 174 insertions(+), 83 deletions(-)
>>
>> Could you try to ping me on IRC when possible so we can solve a few
>> issues with these patches. It seems e.g. that you're doing GIOChannel
>> reference counting incorrectly in one place. There are also some english
>> language errors in the commit messages that would be good to fix (let's
>> see if you can spot them yourselves, otherwise I'll point them out when
>> we go over the other issues ;)
>
> I'm sorry but I can't connect to the IRC rigth now. Nevertheless, I
> think that I've found the issues:
>
> - The iochannel should be unrefereed when the watcher is explicitly removed
> - The commit message s/paramter/parameter
>
> Are there any more?
>
> I will solve them in half an hour.

I've rebased the branch with the changes that I described before. I've
also fixed an other issue related with the mdep checks, now a macro is
used to make the code more readable and easy to mantain.

Regards.

Jose.

^ permalink raw reply

* Re: Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Jose Antonio Santos Cadenas @ 2010-10-11 22:25 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas, linux-bluetooth
In-Reply-To: <20101011213154.GA12131@jh-x301>

Hi,

2010/10/11 Johan Hedberg <johan.hedberg@gmail.com>:
> Hi,
>
> On Mon, Oct 11, 2010, Jose Antonio Santos Cadenas wrote:
>> The following changes since commit 646f0c7e6b557c5413825ce7b04bee52bf0129e8:
>>
>>   Move remote name and version requests to hciops (2010-10-10 22:44:25 +0100)
>>
>> are available in the git repository at:
>>   git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
>>
>> José Antonio Santos Cadenas (6):
>>       Remove mdl_conn from struct hdp_channel
>>       Remove app paramter from hdp_establish_mcl, it is not needed
>>       Imcoming connection in control channel should be ERTM
>>       Fix multiple emission of main channel property signal.
>>       Return MCAP_MDL_BUSY when health channel can't be created
>>       Implement callback for responding echo petitions
>>
>> Santiago Carot-Nemesio (6):
>>       Add a new function to create channels
>>       Process request of of echo channels creation
>>       Correctly notify the deletion of the reliable data channel
>>       Add extra checks for avoid notifiying incoming echo channels
>>       Delete all channels DBus interface when the instance is removed
>>       Check first reliable configuration during channel creation
>>
>>  health/hdp.c       |  249 +++++++++++++++++++++++++++++++++++----------------
>>  health/hdp_types.h |    3 +-
>>  health/hdp_util.c  |    3 -
>>  health/hdp_util.h  |    1 -
>>  health/mcap.c      |    1 +
>>  5 files changed, 174 insertions(+), 83 deletions(-)
>
> Could you try to ping me on IRC when possible so we can solve a few
> issues with these patches. It seems e.g. that you're doing GIOChannel
> reference counting incorrectly in one place. There are also some english
> language errors in the commit messages that would be good to fix (let's
> see if you can spot them yourselves, otherwise I'll point them out when
> we go over the other issues ;)

I'm sorry but I can't connect to the IRC rigth now. Nevertheless, I
think that I've found the issues:

- The iochannel should be unrefereed when the watcher is explicitly removed
- The commit message s/paramter/parameter

Are there any more?

I will solve them in half an hour.

>
> Johan
>

Jose.

^ permalink raw reply

* Re: Pull request git://gitorious.org/~vudentz/bluez/vudentzs-clone.git for-upstream
From: Johan Hedberg @ 2010-10-11 21:36 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikWCgaXMyRZcpKAsZq19-NzPD_U7YpA=_cFtFQX@mail.gmail.com>

Hi Luiz,

On Mon, Oct 11, 2010, Luiz Augusto von Dentz wrote:
> The following changes since commit 646f0c7e6b557c5413825ce7b04bee52bf0129e8:
> 
>   Move remote name and version requests to hciops (2010-10-10 22:44:25 +0100)
> 
> are available in the git repository at:
>   git://gitorious.org/~vudentz/bluez/vudentzs-clone.git for-upstream
> 
> Luiz Augusto von Dentz (8):
>       Fix not always signalling new streams when acting as a sink
>       Fix not replying an error in case of endpoint request timeout
>       Add source if the device attempt to configure a stream with a local sink
>       Make use of avdtp category when setting errors
>       Fix blocking on setconf confirmation callback
>       Fix blocking on setconf indication callback
>       Fix blocking when calling endpoint on hsp/hfp connection
>       Remove unused code
> 
>  audio/a2dp.c   |  239 ++++++++++++++++++++++++++++++++++++++++----------------
>  audio/avdtp.c  |  117 ++++++++++++++++++----------
>  audio/avdtp.h  |   19 +++--
>  audio/media.c  |   54 +++++--------
>  audio/sink.c   |    4 +-
>  audio/source.c |    4 +-
>  6 files changed, 281 insertions(+), 156 deletions(-)

Thanks. The patches have been pushed upstream.

Johan

^ permalink raw reply

* Re: Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Johan Hedberg @ 2010-10-11 21:31 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas; +Cc: linux-bluetooth
In-Reply-To: <AANLkTi=Ogzb3kUX7O4fz-w9gNpU9PCyTFo0GnhfePjC6@mail.gmail.com>

Hi,

On Mon, Oct 11, 2010, Jose Antonio Santos Cadenas wrote:
> The following changes since commit 646f0c7e6b557c5413825ce7b04bee52bf0129e8:
> 
>   Move remote name and version requests to hciops (2010-10-10 22:44:25 +0100)
> 
> are available in the git repository at:
>   git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
> 
> José Antonio Santos Cadenas (6):
>       Remove mdl_conn from struct hdp_channel
>       Remove app paramter from hdp_establish_mcl, it is not needed
>       Imcoming connection in control channel should be ERTM
>       Fix multiple emission of main channel property signal.
>       Return MCAP_MDL_BUSY when health channel can't be created
>       Implement callback for responding echo petitions
> 
> Santiago Carot-Nemesio (6):
>       Add a new function to create channels
>       Process request of of echo channels creation
>       Correctly notify the deletion of the reliable data channel
>       Add extra checks for avoid notifiying incoming echo channels
>       Delete all channels DBus interface when the instance is removed
>       Check first reliable configuration during channel creation
> 
>  health/hdp.c       |  249 +++++++++++++++++++++++++++++++++++----------------
>  health/hdp_types.h |    3 +-
>  health/hdp_util.c  |    3 -
>  health/hdp_util.h  |    1 -
>  health/mcap.c      |    1 +
>  5 files changed, 174 insertions(+), 83 deletions(-)

Could you try to ping me on IRC when possible so we can solve a few
issues with these patches. It seems e.g. that you're doing GIOChannel
reference counting incorrectly in one place. There are also some english
language errors in the commit messages that would be good to fix (let's
see if you can spot them yourselves, otherwise I'll point them out when
we go over the other issues ;)

Johan

^ permalink raw reply

* [PATCH] Bluetooth: TI_ST bluetooth driver
From: pavan_savoy @ 2010-10-11 16:33 UTC (permalink / raw)
  To: linux-bluetooth, marcel; +Cc: greg, linux-kernel, Pavan Savoy

From: Pavan Savoy <pavan_savoy@ti.com>

Gustavo, Marcel,

I have taken care of most of the comments which you provided.
Couple of them like usage of goto's, I didn't handle since
I am not doing much error handling repeatedly there.

I have also removed the 2 states like _REGISTERED, _RUNNING which
were not required and the flags associated with it.
I have taken care of other style comments.

Please review and provide your comments,

-- patch description --

This is the bluetooth protocol driver for the TI WiLink7 chipsets.
Texas Instrument's WiLink chipsets combine wireless technologies
like BT, FM, GPS and WLAN onto a single chip.

This Bluetooth driver works on top of the TI_ST shared transport
line discipline driver which also allows other drivers like
FM V4L2 and GPS character driver to make use of the same UART interface.

Kconfig and Makefile modifications to enable the Bluetooth
driver for Texas Instrument's WiLink 7 chipset.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
---
 drivers/bluetooth/Kconfig    |   10 +
 drivers/bluetooth/Makefile   |    1 +
 drivers/bluetooth/btwilink.c |  455 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 466 insertions(+), 0 deletions(-)
 create mode 100644 drivers/bluetooth/btwilink.c

diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 02deef4..e0d67dd 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -219,4 +219,14 @@ config BT_ATH3K
 	  Say Y here to compile support for "Atheros firmware download driver"
 	  into the kernel or say M to compile it as module (ath3k).
 
+config BT_WILINK
+	tristate "BlueZ bluetooth driver for TI ST"
+	depends on TI_ST
+	help
+	  This enables the Bluetooth driver for Texas Instrument's BT/FM/GPS
+	  combo devices. This makes use of shared transport line discipline
+	  core driver to communicate with the BT core of the combo chip.
+
+	  Say Y here to compile support for Texas Instrument's WiLink7 driver
+	  into the kernel or say M to compile it as module.
 endmenu
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index 71bdf13..5351b62 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -28,3 +28,4 @@ hci_uart-$(CONFIG_BT_HCIUART_BCSP)	+= hci_bcsp.o
 hci_uart-$(CONFIG_BT_HCIUART_LL)	+= hci_ll.o
 hci_uart-$(CONFIG_BT_HCIUART_ATH3K)	+= hci_ath.o
 hci_uart-objs				:= $(hci_uart-y)
+obj-$(CONFIG_BT_WILINK)			:= btwilink.o
diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
new file mode 100644
index 0000000..e0bde79
--- /dev/null
+++ b/drivers/bluetooth/btwilink.c
@@ -0,0 +1,455 @@
+/*
+ *  Texas Instrument's Bluetooth Driver For Shared Transport.
+ *
+ *  Bluetooth Driver acts as interface between HCI CORE and
+ *  TI Shared Transport Layer.
+ *
+ *  Copyright (C) 2009-2010 Texas Instruments
+ *  Author: Raja Mani <raja_mani@ti.com>
+ *	Pavan Savoy <pavan_savoy@ti.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <linux/platform_device.h>
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+
+#include <linux/ti_wilink_st.h>
+
+/* Bluetooth Driver Version */
+#define VERSION               "1.0"
+
+/* Defines number of seconds to wait for reg completion
+ * callback getting called from ST (in case,registration
+ * with ST returns PENDING status)
+ */
+#define BT_REGISTER_TIMEOUT   6000	/* 6 sec */
+
+/**
+ * struct ti_st - BT driver operation structure
+ * @hdev: hci device pointer which binds to bt driver
+ * @flags: used locally,to maintain various BT driver status
+ * @streg_cbdata: to hold ST registration callback status
+ * @st_write: write function pointer of ST driver
+ * @wait_for_btdrv_reg_completion - completion sync between ti_st_open
+ *	and ti_st_registration_completion_cb.
+ */
+struct ti_st {
+	struct hci_dev *hdev;
+	char streg_cbdata;
+	long (*st_write) (struct sk_buff *);
+	struct completion wait_for_btdrv_reg_completion;
+};
+
+static int reset;
+
+/* Increments HCI counters based on pocket ID (cmd,acl,sco) */
+static inline void ti_st_tx_complete(struct ti_st *hst, int pkt_type)
+{
+	struct hci_dev *hdev;
+	hdev = hst->hdev;
+
+	/* Update HCI stat counters */
+	switch (pkt_type) {
+	case HCI_COMMAND_PKT:
+		hdev->stat.cmd_tx++;
+		break;
+
+	case HCI_ACLDATA_PKT:
+		hdev->stat.acl_tx++;
+		break;
+
+	case HCI_SCODATA_PKT:
+		hdev->stat.sco_tx++;
+		break;
+	}
+}
+
+/* ------- Interfaces to Shared Transport ------ */
+
+/* Called by ST layer to indicate protocol registration completion
+ * status.ti_st_open() function will wait for signal from this
+ * API when st_register() function returns ST_PENDING.
+ */
+static void st_registration_completion_cb(void *priv_data, char data)
+{
+	struct ti_st *lhst = (struct ti_st *)priv_data;
+	/* ti_st_open() function needs value of 'data' to know
+	 * the registration status(success/fail),So have a back
+	 * up of it.
+	 */
+	lhst->streg_cbdata = data;
+
+	/* Got a feedback from ST for BT driver registration
+	 * request.Wackup ti_st_open() function to continue
+	 * it's open operation.
+	 */
+	complete(&lhst->wait_for_btdrv_reg_completion);
+}
+
+/* Called by Shared Transport layer when receive data is
+ * available */
+static long st_receive(void *priv_data, struct sk_buff *skb)
+{
+	int err;
+	struct ti_st *lhst = (struct ti_st *)priv_data;
+
+	if (skb == NULL) {
+		BT_ERR("Invalid SKB received from ST");
+		return -EFAULT;
+	}
+
+	if (!lhst) {
+		kfree_skb(skb);
+		BT_ERR("Invalid ti_st memory,freeing SKB");
+		return -EFAULT;
+	}
+
+	skb->dev = (struct net_device *)lhst->hdev;
+	/* Forward skb to HCI CORE layer */
+	err = hci_recv_frame(skb);
+	if (err) {
+		kfree_skb(skb);
+		BT_ERR("Unable to push skb to HCI CORE(%d),freeing SKB",
+				err);
+		return err;
+	}
+
+	lhst->hdev->stat.byte_rx += skb->len;
+	return 0;
+}
+
+/* ------- Interfaces to HCI layer ------ */
+
+/* Called from HCI core to initialize the device */
+static int ti_st_open(struct hci_dev *hdev)
+{
+	static struct st_proto_s ti_st_proto;
+	unsigned long timeleft;
+	struct ti_st *hst;
+	int err;
+	err = 0;
+
+	BT_DBG("%s %p", hdev->name, hdev);
+	hst = hdev->driver_data;
+
+	/* Populate BT driver info required by ST */
+	memset(&ti_st_proto, 0, sizeof(ti_st_proto));
+
+	/* BT driver ID */
+	ti_st_proto.type = ST_BT;
+
+	/* Receive function which called from ST */
+	ti_st_proto.recv = st_receive;
+
+	/* Callback to be called when registration is pending */
+	ti_st_proto.reg_complete_cb = st_registration_completion_cb;
+
+	/* send in the hst to be received at registration complete callback
+	 * and during st's receive
+	 */
+	ti_st_proto.priv_data = hst;
+
+	/* Register with ST layer */
+	err = st_register(&ti_st_proto);
+	if (err == -EINPROGRESS) {
+		/* Prepare wait-for-completion handler data structures.
+		 * Needed to syncronize this and st_registration_completion_cb()
+		 * functions.
+		 */
+		init_completion(&hst->wait_for_btdrv_reg_completion);
+
+		/* Reset ST registration callback status flag , this value
+		 * will be updated in ti_st_registration_completion_cb()
+		 * function whenever it called from ST driver.
+		 */
+		hst->streg_cbdata = -EINPROGRESS;
+
+		/* ST is busy with other protocol registration(may be busy with
+		 * firmware download).So,Wait till the registration callback
+		 * (passed as a argument to st_register() function) getting
+		 * called from ST.
+		 */
+		BT_DBG(" %s waiting for reg completion signal from ST",
+				__func__);
+
+		timeleft =
+			wait_for_completion_timeout
+			(&hst->wait_for_btdrv_reg_completion,
+			 msecs_to_jiffies(BT_REGISTER_TIMEOUT));
+		if (!timeleft) {
+			BT_ERR("Timeout(%d sec),didn't get reg"
+					"completion signal from ST",
+					BT_REGISTER_TIMEOUT / 1000);
+			return -ETIMEDOUT;
+		}
+
+		/* Is ST registration callback called with ERROR value? */
+		if (hst->streg_cbdata != 0) {
+			BT_ERR("ST reg completion CB called with invalid"
+					"status %d", hst->streg_cbdata);
+			return -EAGAIN;
+		}
+		err = 0;
+	} else if (err == -1) {
+		BT_ERR("st_register failed %d", err);
+		return -EAGAIN;
+	}
+
+	/* Do we have proper ST write function? */
+	if (ti_st_proto.write != NULL) {
+		/* We need this pointer for sending any Bluetooth pkts */
+		hst->st_write = ti_st_proto.write;
+	} else {
+		BT_ERR("failed to get ST write func pointer");
+
+		/* Undo registration with ST */
+		err = st_unregister(ST_BT);
+		if (err < 0)
+			BT_ERR("st_unregister failed %d", err);
+
+		hst->st_write = NULL;
+		return -EAGAIN;
+	}
+
+	/* Registration with ST layer is completed successfully,
+	 * now chip is ready to accept commands from HCI CORE.
+	 * Mark HCI Device flag as RUNNING
+	 */
+	set_bit(HCI_RUNNING, &hdev->flags);
+	return err;
+}
+
+/* Close device */
+static int ti_st_close(struct hci_dev *hdev)
+{
+	int err = 0;
+	struct ti_st *hst;
+
+	hst = hdev->driver_data;
+
+	/* Clear HCI device RUNNING flag */
+	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+		BT_ERR("HCI not RUNNING?");
+
+	/* continue to unregister from transport */
+	err = st_unregister(ST_BT);
+	if (err != 0) {
+		hst->st_write = NULL;
+		BT_ERR("st_unregister failed %d", err);
+		return -EBUSY;
+	}
+
+	hst->st_write = NULL;
+	return err;
+}
+
+/* Called from HCI CORE , Sends frames to Shared Transport */
+static int ti_st_send_frame(struct sk_buff *skb)
+{
+	struct hci_dev *hdev;
+	struct ti_st *hst;
+	long len;
+
+	if (skb == NULL) {
+		BT_ERR("Invalid skb received from HCI CORE");
+		return -ENOMEM;
+	}
+
+	hdev = (struct hci_dev *)skb->dev;
+	if (!hdev) {
+		BT_ERR("SKB received for invalid HCI Device (hdev=NULL)");
+		return -ENODEV;
+	}
+
+	if (!test_bit(HCI_RUNNING, &hdev->flags)) {
+		BT_ERR("Device is not running");
+		return -EBUSY;
+	}
+
+	hst = (struct ti_st *)hdev->driver_data;
+
+	/* Prepend skb with frame type */
+	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
+
+	BT_DBG(" %s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type,
+			skb->len);
+
+	/* Insert skb to shared transport layer's transmit queue.
+	 * Freeing skb memory is taken care in shared transport layer,
+	 * so don't free skb memory here.
+	 */
+	if (!hst->st_write) {
+		kfree_skb(skb);
+		BT_ERR(" Can't write to ST, st_write null?");
+		return -EAGAIN;
+	}
+
+	len = hst->st_write(skb);
+	if (len < 0) {
+		kfree_skb(skb);
+		BT_ERR(" ST write failed (%ld)", len);
+		return -EAGAIN;
+	}
+
+	/* ST accepted our skb. So, Go ahead and do rest */
+	hdev->stat.byte_tx += len;
+	ti_st_tx_complete(hst, bt_cb(skb)->pkt_type);
+
+	return 0;
+}
+
+static void ti_st_destruct(struct hci_dev *hdev)
+{
+	if (!hdev) {
+		BT_ERR("Destruct called with invalid HCI Device"
+				"(hdev=NULL)");
+		return;
+	}
+
+	BT_DBG("%s", hdev->name);
+
+	/* free ti_st memory */
+	if (hdev->driver_data != NULL)
+		kfree(hdev->driver_data);
+
+	return;
+}
+
+/* Creates new HCI device */
+static int ti_st_register_dev(struct ti_st *hst)
+{
+	struct hci_dev *hdev;
+
+	/* Initialize and register HCI device */
+	hdev = hci_alloc_dev();
+	if (!hdev) {
+		BT_ERR("Can't allocate HCI device");
+		return -ENOMEM;
+	}
+	BT_DBG(" HCI device allocated. hdev= %p", hdev);
+
+	hst->hdev = hdev;
+	hdev->bus = HCI_UART;
+	hdev->driver_data = hst;
+	hdev->open = ti_st_open;
+	hdev->close = ti_st_close;
+	hdev->flush = NULL;
+	hdev->send = ti_st_send_frame;
+	hdev->destruct = ti_st_destruct;
+	hdev->owner = THIS_MODULE;
+
+	if (reset)
+		set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
+
+	if (hci_register_dev(hdev) < 0) {
+		BT_ERR("Can't register HCI device");
+		hci_free_dev(hdev);
+		return -ENODEV;
+	}
+
+	BT_DBG(" HCI device registered. hdev= %p", hdev);
+	return 0;
+}
+
+
+static int bt_ti_probe(struct platform_device *pdev)
+{
+	int err;
+	static struct ti_st *hst;
+	err = 0;
+
+	BT_DBG(" Bluetooth Driver Version %s", VERSION);
+
+	/* Allocate local resource memory */
+	hst = kzalloc(sizeof(struct ti_st), GFP_KERNEL);
+	if (!hst) {
+		BT_ERR("Can't allocate control structure");
+		return -ENFILE;
+	}
+
+	/* Expose "hciX" device to user space */
+	err = ti_st_register_dev(hst);
+	if (err) {
+		/* Release local resource memory */
+		kfree(hst);
+
+		BT_ERR("Unable to expose hci0 device(%d)", err);
+		return err;
+	}
+
+	dev_set_drvdata(&pdev->dev, hst);
+	return err;
+}
+
+static int bt_ti_remove(struct platform_device *pdev)
+{
+	struct ti_st *hst;
+
+	hst = dev_get_drvdata(&pdev->dev);
+	/* Deallocate local resource's memory  */
+	if (hst) {
+		struct hci_dev *hdev = hst->hdev;
+		if (hdev == NULL) {
+			BT_ERR("Invalid hdev memory");
+			kfree(hst);
+		} else {
+			ti_st_close(hdev);
+			hci_unregister_dev(hdev);
+			/* Free HCI device memory */
+			hci_free_dev(hdev);
+		}
+	}
+	return 0;
+}
+
+static struct platform_driver bt_ti_driver = {
+	.probe = bt_ti_probe,
+	.remove = bt_ti_remove,
+	.driver = {
+		.name = "ti_st_bluetooth",
+		.owner = THIS_MODULE,
+	},
+};
+
+/* ------- Module Init/Exit interfaces ------ */
+static int __init bt_drv_init(void)
+{
+	long ret = 0;
+	ret = platform_driver_register(&bt_ti_driver);
+	if (ret != 0) {
+		BT_ERR("bt_ti platform drv registration failed");
+		return -1;
+	}
+	return 0;
+}
+
+static void __exit bt_drv_exit(void)
+{
+	platform_driver_unregister(&bt_ti_driver);
+}
+
+module_init(bt_drv_init);
+module_exit(bt_drv_exit);
+
+/* ------ Module Info ------ */
+
+module_param(reset, bool, 0644);
+MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
+MODULE_AUTHOR("Raja Mani <raja_mani@ti.com>");
+MODULE_DESCRIPTION("Bluetooth Driver for TI Shared Transport" VERSION);
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
-- 
1.6.5

^ permalink raw reply related

* Pull request git://gitorious.org/~vudentz/bluez/vudentzs-clone.git for-upstream
From: Luiz Augusto von Dentz @ 2010-10-11 13:09 UTC (permalink / raw)
  To: linux-bluetooth

The following changes since commit 646f0c7e6b557c5413825ce7b04bee52bf0129e8:

  Move remote name and version requests to hciops (2010-10-10 22:44:25 +0100)

are available in the git repository at:
  git://gitorious.org/~vudentz/bluez/vudentzs-clone.git for-upstream

Luiz Augusto von Dentz (8):
      Fix not always signalling new streams when acting as a sink
      Fix not replying an error in case of endpoint request timeout
      Add source if the device attempt to configure a stream with a local sink
      Make use of avdtp category when setting errors
      Fix blocking on setconf confirmation callback
      Fix blocking on setconf indication callback
      Fix blocking when calling endpoint on hsp/hfp connection
      Remove unused code

 audio/a2dp.c   |  239 ++++++++++++++++++++++++++++++++++++++++----------------
 audio/avdtp.c  |  117 ++++++++++++++++++----------
 audio/avdtp.h  |   19 +++--
 audio/media.c  |   54 +++++--------
 audio/sink.c   |    4 +-
 audio/source.c |    4 +-
 6 files changed, 281 insertions(+), 156 deletions(-)

-- 
Luiz Augusto von Dentz
Computer Engineer

^ permalink raw reply

* Re: [PATCH 6/6] This patch adds support for using the ST-Ericsson CG2900
From: Par-Gunnar Hjalmdahl @ 2010-10-11 13:00 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth, linux-kernel, linus.walleij, Pavan Savoy
In-Reply-To: <1286270443.17473.62.camel@aeonflux>

Thanks for your comments Marcel,

Sorry for not answering to your mail earlier. I've been on a business
trip whole last week where I just did not have the possibility to
answer.

We are currently working on a new version of our driver, both the MFD
and the Bluetooth part, where we address the comments that we have so
far received. Hopefully I will able to send it later this week.

As answer to last mail: yes, we will change our debug system to be
reuse existing functionality in the Kernel.

/P-G

2010/10/5 Marcel Holtmann <marcel@holtmann.org>:
> Hi Par-Gunnar,
>
>> This patch adds support for using the ST-Ericsson CG2900
>> =A0connectivity controller as a driver for the BlueZ Bluetooth
>> =A0stack.
>> =A0This patch registers as a driver into the BlueZ framework and, when
>> =A0opened by BlueZ, it registers as user for bt_cmd, bt_acl, and bt_evt
>> =A0channels.
>>
>> Signed-off-by: Par-Gunnar Hjalmdahl <par-gunnar.p.hjalmdahl@stericsson.c=
om>
>> ---
>> =A0drivers/bluetooth/Kconfig =A0 =A0 =A0| =A0 =A07 +
>> =A0drivers/bluetooth/Makefile =A0 =A0 | =A0 =A02 +
>> =A0drivers/bluetooth/cg2900_hci.c | =A0896 +++++++++++++++++++++++++++++=
+++++++++++
>> =A03 files changed, 905 insertions(+), 0 deletions(-)
>> =A0create mode 100644 drivers/bluetooth/cg2900_hci.c
>>
>> diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
>> index 02deef4..9ca8d69 100644
>> --- a/drivers/bluetooth/Kconfig
>> +++ b/drivers/bluetooth/Kconfig
>> @@ -219,4 +219,11 @@ config BT_ATH3K
>> =A0 =A0 =A0 =A0 Say Y here to compile support for "Atheros firmware down=
load driver"
>> =A0 =A0 =A0 =A0 into the kernel or say M to compile it as module (ath3k)=
.
>>
>> +config BT_CG2900
>> + =A0 =A0 tristate "ST-Ericsson CG2900 driver"
>> + =A0 =A0 depends on MFD_CG2900 && BT
>> + =A0 =A0 help
>> + =A0 =A0 =A0 Select if ST-Ericsson CG2900 Connectivity controller shall=
 be used as
>> + =A0 =A0 =A0 Bluetooth controller for BlueZ.
>> +
>> =A0endmenu
>> diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
>> index 71bdf13..a479c16 100644
>> --- a/drivers/bluetooth/Makefile
>> +++ b/drivers/bluetooth/Makefile
>> @@ -19,6 +19,8 @@ obj-$(CONFIG_BT_ATH3K) =A0 =A0 =A0 =A0 =A0 =A0 =A0+=3D=
 ath3k.o
>> =A0obj-$(CONFIG_BT_MRVL) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0+=3D btmrvl.o
>> =A0obj-$(CONFIG_BT_MRVL_SDIO) =A0 +=3D btmrvl_sdio.o
>>
>> +obj-$(CONFIG_BT_CG2900) =A0 =A0 =A0 =A0 =A0 =A0 =A0+=3D cg2900_hci.o
>> +
>
> Please sort this after ath3k and before btmvrl config.
>
> And for the name either just use cg2900 if it uniquely identifies the
> Bluetooth chip used in the combo or use btcg2900.o as module name if it
> is the name of the combo module.
>
> We clearly moved into the direction of either unique hardware names
> without bt prefix or we have the bt prefix in front of it. The fully
> generic term hci will be phased out of the driver names.
>

I can change the name to btcg2900.o since the whole chip is called
cg2900 and this file is just for the BT part of it.
I will also sort it correctly into the file.

>> =A0btmrvl-y =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :=3D btmrvl_main.o
>> =A0btmrvl-$(CONFIG_DEBUG_FS) =A0 =A0+=3D btmrvl_debugfs.o
>>
>> diff --git a/drivers/bluetooth/cg2900_hci.c b/drivers/bluetooth/cg2900_h=
ci.c
>> new file mode 100644
>> index 0000000..de1ada8
>> --- /dev/null
>> +++ b/drivers/bluetooth/cg2900_hci.c
>> @@ -0,0 +1,896 @@
>> +/*
>> + * drivers/bluetooth/cg2900_hci.c
>> + *
>> + * Copyright (C) ST-Ericsson SA 2010
>> + * Authors:
>> + * Par-Gunnar Hjalmdahl (par-gunnar.p.hjalmdahl@stericsson.com) for
>> ST-Ericsson.
>> + * Henrik Possung (henrik.possung@stericsson.com) for ST-Ericsson.
>> + * Josef Kindberg (josef.kindberg@stericsson.com) for ST-Ericsson.
>> + * Dariusz Szymszak (dariusz.xd.szymczak@stericsson.com) for ST-Ericsso=
n.
>> + * Kjell Andersson (kjell.k.andersson@stericsson.com) for ST-Ericsson.
>> + * License terms: =A0GNU General Public License (GPL), version 2
>> + *
>> + * Linux Bluetooth HCI H:4 Driver for ST-Ericsson CG2900 connectivity
>> controller
>> + * towards the BlueZ Bluetooth stack.
>> + */
>
> Drop the filename in this header and don't bother with the description
> towards BlueZ or Bluetooth subsystem. That is clear from the location of
> the file.
>
> Also what is up with the "for ST-Ericsson"?
>

OK regarding the header comments. We have been instructed to use "for
ST-Ericsson" when writing author name. Is that a problem?

>> +
>> +#include <linux/module.h>
>> +#include <linux/types.h>
>> +#include <linux/skbuff.h>
>> +#include <asm/byteorder.h>
>> +#include <net/bluetooth/bluetooth.h>
>> +#include <net/bluetooth/hci.h>
>> +#include <net/bluetooth/hci_core.h>
>> +
>> +#include <linux/workqueue.h>
>> +#include <linux/wait.h>
>> +#include <linux/time.h>
>> +#include <linux/jiffies.h>
>> +#include <linux/sched.h>
>> +#include <linux/timer.h>
>> +
>> +#include <linux/mfd/cg2900.h>
>> +#include <mach/cg2900_devices.h>
>> +
>> +/* module_param declared in cg2900_core.c */
>> +extern int cg2900_debug_level;
>> +
>> +#define NAME =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "CG2900 HCI"
>> +
>> +/* Debug defines */
>> +#define CG2900_DBG_DATA(fmt, arg...) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 \
>> +do { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
>> + =A0 =A0 if (cg2900_debug_level >=3D 25) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 \
>> + =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_DEBUG NAME " %s: " fmt "\n" , __fu=
nc__ , ## arg); \
>> +} while (0)
>> +
>> +#define CG2900_DBG(fmt, arg...) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0\
>> +do { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
>> + =A0 =A0 if (cg2900_debug_level >=3D 20) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 \
>> + =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_DEBUG NAME " %s: " fmt "\n" , __fu=
nc__ , ## arg); \
>> +} while (0)
>> +
>> +#define CG2900_INFO(fmt, arg...) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 \
>> +do { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
>> + =A0 =A0 if (cg2900_debug_level >=3D 10) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 \
>> + =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_INFO NAME ": " fmt "\n" , ## arg);=
 \
>> +} while (0)
>> +
>> +#define CG2900_ERR(fmt, arg...) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
>> +do { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
>> + =A0 =A0 if (cg2900_debug_level >=3D 1) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0\
>> + =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR NAME " %s: " fmt "\n" , __func=
__ , ## arg); \
>> +} while (0)
>
> Remove all this debug stuff. Use BT_DBG, BT_ERR etc.

OK

>
>> +#define CG2900_SET_STATE(__name, __var, __new_state) =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 \
>> +do { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
>> + =A0 =A0 CG2900_DBG("New %s: 0x%X", __name, (uint32_t)__new_state); =A0=
 =A0 =A0\
>> + =A0 =A0 __var =3D __new_state; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
>> +} while (0)
>
> What is this for? Please don't do that. It just obfuscates the code.
>

Is it OK to use inline functions instead of defines? It's pretty
useful to be able to printout when changing state.
So something like:

static inline void set_reset_state(enum reset_state new_state)
{
  BT_DBG("New reset state: %x", new_state);
  hci_info->reset_state =3D new_state;
}

>> +/* HCI device type */
>> +#define HCI_CG2900 =A0 =A0 =A0 =A0 =A0 HCI_VIRTUAL
>
> This is the wrong type. Don't do that. And don't create a new define for
> it. Use the standard types. I assume that HCI_UART is most likely what
> you want here.
>

The problem here is that the physical transport used is not shown for
this module. It is handled with the CG2900 MFD driver. But I guess I
could expose the type through an API function.

>> +/* Wait for 5 seconds for a response to our requests */
>> +#define RESP_TIMEOUT =A0 =A0 =A0 =A0 5000
>> +
>> +/* State-setting defines */
>> +#define SET_RESET_STATE(__hci_reset_new_state) \
>> + =A0 =A0 CG2900_SET_STATE("reset_state", hci_info->reset_state, \
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0__hci_reset_new_state)
>> +#define SET_ENABLE_STATE(__hci_enable_new_state) \
>> + =A0 =A0 CG2900_SET_STATE("enable_state", hci_info->enable_state, \
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0__hci_enable_new_state)
>
> Don't do this. It is just highly obfuscating the code flow.
>

As stated above, is it OK to use static inline functions instead?

>> +/* Bluetooth error codes */
>> +#define HCI_ERR_NO_ERROR =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 0x00
>> +#define HCI_ERR_CMD_DISALLOWED =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 0x0C
>> +
>> +/**
>> + * enum reset_state - RESET-states of the HCI driver.
>> + *
>> + * @RESET_IDLE: =A0 =A0 =A0 =A0 =A0 =A0 =A0No reset in progress.
>> + * @RESET_ACTIVATED: Reset in progress.
>> + * @RESET_UNREGISTERED: =A0 =A0 =A0hdev is unregistered.
>> + */
>> +
>> +enum reset_state {
>> + =A0 =A0 RESET_IDLE,
>> + =A0 =A0 RESET_ACTIVATED,
>> + =A0 =A0 RESET_UNREGISTERED
>> +};
>> +
>> +/**
>> + * enum enable_state - ENABLE-states of the HCI driver.
>> + *
>> + * @ENABLE_IDLE: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 The HCI driver=
 is loaded but not opened.
>> + * @ENABLE_WAITING_BT_ENABLED_CC: =A0 =A0The HCI driver is waiting for =
a command
>> + * =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
complete event from the BT chip as a
>> + * =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
response to a BT Enable (true) command.
>> + * @ENABLE_BT_ENABLED: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 The =
BT chip is enabled.
>> + * @ENABLE_WAITING_BT_DISABLED_CC: =A0 The HCI driver is waiting for a =
command
>> + * =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
complete event from the BT chip as a
>> + * =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
response to a BT Enable (false) command.
>> + * @ENABLE_BT_DISABLED: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0The =
BT chip is disabled.
>> + * @ENABLE_BT_ERROR: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 The HCI driver is =
in a bad state, some
>> + * =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
thing has failed and is not expected to
>> + * =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
work properly.
>> + */
>> +enum enable_state {
>> + =A0 =A0 ENABLE_IDLE,
>> + =A0 =A0 ENABLE_WAITING_BT_ENABLED_CC,
>> + =A0 =A0 ENABLE_BT_ENABLED,
>> + =A0 =A0 ENABLE_WAITING_BT_DISABLED_CC,
>> + =A0 =A0 ENABLE_BT_DISABLED,
>> + =A0 =A0 ENABLE_BT_ERROR
>> +};
>> +
>> +/**
>> + * struct hci_info - Specifies HCI driver private data.
>> + *
>> + * This type specifies CG2900 HCI driver private data.
>> + *
>> + * @bt_cmd: =A0 =A0 =A0 =A0 =A0Device structure for BT command channel.
>> + * @bt_evt: =A0 =A0 =A0 =A0 =A0Device structure for BT event channel.
>> + * @bt_acl: =A0 =A0 =A0 =A0 =A0Device structure for BT ACL channel.
>> + * @hdev: =A0 =A0 =A0 =A0 =A0 =A0Device structure for HCI device.
>> + * @reset_state: =A0 =A0 Device enum for HCI driver reset state.
>> + * @enable_state: =A0 =A0Device enum for HCI driver BT enable state.
>> + */
>> +struct hci_info {
>> + =A0 =A0 struct cg2900_device =A0 =A0*bt_cmd;
>> + =A0 =A0 struct cg2900_device =A0 =A0*bt_evt;
>> + =A0 =A0 struct cg2900_device =A0 =A0*bt_acl;
>> + =A0 =A0 struct hci_dev =A0 =A0 =A0 =A0 =A0*hdev;
>> + =A0 =A0 enum reset_state =A0 =A0 =A0 =A0reset_state;
>> + =A0 =A0 enum enable_state =A0 =A0 =A0 enable_state;
>> +};
>> +
>> +/**
>> + * struct dev_info - Specifies private data used when receiving
>> callbacks from CPD.
>> + *
>> + * @hdev: =A0 =A0 =A0 =A0 =A0 =A0Device structure for HCI device.
>> + * @hci_data_type: =A0 Type of data according to BlueZ.
>> + */
>> +struct dev_info {
>> + =A0 =A0 struct hci_dev =A0*hdev;
>> + =A0 =A0 u8 =A0 =A0 =A0 =A0 =A0 =A0 =A0hci_data_type;
>> +};
>> +
>> +/* Variables where LSB and MSB for bt_enable command is stored */
>> +static u16 bt_enable_cmd;
>> +
>> +static struct hci_info *hci_info;
>> +
>> +/*
>> + * hci_wait_queue - Main Wait Queue in HCI driver.
>> + */
>> +static DECLARE_WAIT_QUEUE_HEAD(hci_wait_queue);
>> +
>> +/* Internal function declarations */
>> +static int register_to_bluez(void);
>
> Don't use bluez in kernel code. Just use bluetooth or bt.
>

OK

>> +/* Internal functions */
>> +
>> +/**
>> + * remove_bt_users() - Unregister and remove any existing BT users.
>> + * @info: =A0 =A0HCI driver info structure.
>> + */
>> +static void remove_bt_users(struct hci_info *info)
>> +{
>> + =A0 =A0 if (info->bt_cmd) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 kfree(info->bt_cmd->user_data);
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_cmd->user_data =3D NULL;
>> + =A0 =A0 =A0 =A0 =A0 =A0 cg2900_deregister_user(info->bt_cmd);
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_cmd =3D NULL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (info->bt_evt) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 kfree(info->bt_evt->user_data);
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_evt->user_data =3D NULL;
>> + =A0 =A0 =A0 =A0 =A0 =A0 cg2900_deregister_user(info->bt_evt);
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_evt =3D NULL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (info->bt_acl) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 kfree(info->bt_acl->user_data);
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_acl->user_data =3D NULL;
>> + =A0 =A0 =A0 =A0 =A0 =A0 cg2900_deregister_user(info->bt_acl);
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_acl =3D NULL;
>> + =A0 =A0 }
>> +}
>> +
>> +/**
>> + * hci_read_cb() - Callback for handling data received from CG2900 driv=
er.
>> + * @dev: =A0 =A0 Device receiving data.
>> + * @skb: =A0 =A0 Buffer with data coming from device.
>> + */
>> +static void hci_read_cb(struct cg2900_device *dev, struct sk_buff *skb)
>> +{
>> + =A0 =A0 int err =3D 0;
>> + =A0 =A0 struct dev_info *dev_info;
>> + =A0 =A0 struct hci_event_hdr *evt;
>> + =A0 =A0 struct hci_ev_cmd_complete *cmd_complete;
>> + =A0 =A0 struct hci_ev_cmd_status *cmd_status;
>> + =A0 =A0 u8 status;
>> +
>> + =A0 =A0 if (!skb) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for skb");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (!dev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("dev =3D=3D NULL");
>> + =A0 =A0 =A0 =A0 =A0 =A0 goto fin_free_skb;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 dev_info =3D (struct dev_info *)dev->user_data;
>> +
>> + =A0 =A0 if (!dev_info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("dev_info =3D=3D NULL");
>> + =A0 =A0 =A0 =A0 =A0 =A0 goto fin_free_skb;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 evt =3D (struct hci_event_hdr *)skb->data;
>> + =A0 =A0 cmd_complete =3D (struct hci_ev_cmd_complete *)(skb->data + si=
zeof(*evt));
>> + =A0 =A0 cmd_status =3D (struct hci_ev_cmd_status *)(skb->data + sizeof=
(*evt));
>> +
>> + =A0 =A0 /*
>> + =A0 =A0 =A0* Check if HCI Driver it self is expecting a Command Comple=
te packet
>> + =A0 =A0 =A0* from the chip after a BT Enable command.
>> + =A0 =A0 =A0*/
>> + =A0 =A0 if ((hci_info->enable_state =3D=3D ENABLE_WAITING_BT_ENABLED_C=
C ||
>> + =A0 =A0 =A0 =A0 =A0hci_info->enable_state =3D=3D ENABLE_WAITING_BT_DIS=
ABLED_CC) &&
>> + =A0 =A0 =A0 =A0 hci_info->bt_evt->h4_channel =3D=3D dev->h4_channel &&
>> + =A0 =A0 =A0 =A0 evt->evt =3D=3D HCI_EV_CMD_COMPLETE &&
>> + =A0 =A0 =A0 =A0 le16_to_cpu(cmd_complete->opcode) =3D=3D bt_enable_cmd=
) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 /*
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* This is the command complete event for
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* the HCI_Cmd_VS_Bluetooth_Enable.
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* Check result and update state.
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* The BT chip is enabled/disabled. Either i=
t was enabled/
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* disabled now (status NO_ERROR) or it was =
already enabled/
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* disabled (assuming status CMD_DISALLOWED =
is already enabled/
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* disabled).
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
>> + =A0 =A0 =A0 =A0 =A0 =A0 status =3D *(skb->data + sizeof(*evt) + sizeof=
(*cmd_complete));
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (status !=3D HCI_ERR_NO_ERROR &&
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 status !=3D HCI_ERR_CMD_DISALLOWED) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Could not enable/d=
isable BT core (0x%X)",
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0status)=
;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SET_ENABLE_STATE(ENABLE_BT_ERR=
OR);
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto fin_free_skb;
>> + =A0 =A0 =A0 =A0 =A0 =A0 }
>> +
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (hci_info->enable_state =3D=3D ENABLE_WAITI=
NG_BT_ENABLED_CC) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SET_ENABLE_STATE(ENABLE_BT_ENA=
BLED);
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG2900_INFO("BT core is enable=
d");
>> + =A0 =A0 =A0 =A0 =A0 =A0 } else {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SET_ENABLE_STATE(ENABLE_BT_DIS=
ABLED);
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG2900_INFO("BT core is disabl=
ed");
>> + =A0 =A0 =A0 =A0 =A0 =A0 }
>> +
>> + =A0 =A0 =A0 =A0 =A0 =A0 /* Wake up whom ever is waiting for this resul=
t. */
>> + =A0 =A0 =A0 =A0 =A0 =A0 wake_up_interruptible(&hci_wait_queue);
>> + =A0 =A0 =A0 =A0 =A0 =A0 goto fin_free_skb;
>> + =A0 =A0 } else if ((hci_info->enable_state =3D=3D ENABLE_WAITING_BT_DI=
SABLED_CC ||
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 hci_info->enable_state =3D=3D ENABLE_W=
AITING_BT_ENABLED_CC) &&
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0hci_info->bt_evt->h4_channel =3D=3D dev=
->h4_channel &&
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0evt->evt =3D=3D HCI_EV_CMD_STATUS &&
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0le16_to_cpu(cmd_status->opcode) =3D=3D =
bt_enable_cmd) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 /*
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* Clear the status events since the Bluez i=
s not expecting
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* them.
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_DBG("HCI Driver received Command Status=
(for "
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"BT enable): 0x%X", cmd=
_status->status);
>> + =A0 =A0 =A0 =A0 =A0 =A0 /*
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* This is the command status event for
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* the HCI_Cmd_VS_Bluetooth_Enable.
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* Just free the packet.
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
>> + =A0 =A0 =A0 =A0 =A0 =A0 goto fin_free_skb;
>> + =A0 =A0 } else {
>> + =A0 =A0 =A0 =A0 =A0 =A0 bt_cb(skb)->pkt_type =3D dev_info->hci_data_ty=
pe;
>> + =A0 =A0 =A0 =A0 =A0 =A0 skb->dev =3D (struct net_device *)dev_info->hd=
ev;
>> + =A0 =A0 =A0 =A0 =A0 =A0 /* Update BlueZ stats */
>> + =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hdev->stat.byte_rx +=3D skb->len;
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (bt_cb(skb)->pkt_type =3D=3D HCI_ACLDATA_PK=
T)
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hdev->stat.acl_rx++;
>> + =A0 =A0 =A0 =A0 =A0 =A0 else
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hdev->stat.evt_rx++;
>> +
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_DBG_DATA("Data receive %d bytes", skb->=
len);
>> +
>> + =A0 =A0 =A0 =A0 =A0 =A0 /* Provide BlueZ with received frame*/
>> + =A0 =A0 =A0 =A0 =A0 =A0 err =3D hci_recv_frame(skb);
>> + =A0 =A0 =A0 =A0 =A0 =A0 /* If err, skb have been freed in hci_recv_fra=
me() */
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (err)
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Failed in supplyin=
g packet to BlueZ (%d)",
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0err);
>> + =A0 =A0 }
>> +
>> + =A0 =A0 return;
>> +
>> +fin_free_skb:
>> + =A0 =A0 kfree_skb(skb);
>> +}
>> +
>> +/**
>> + * hci_reset_cb() - Callback for handling reset from CG2900 driver.
>> + * @dev: =A0 =A0 CPD device resetting.
>> + */
>> +static void hci_reset_cb(struct cg2900_device *dev)
>> +{
>> + =A0 =A0 int err;
>> + =A0 =A0 struct hci_dev *hdev;
>> + =A0 =A0 struct dev_info *dev_info;
>> + =A0 =A0 struct hci_info *info;
>> +
>> + =A0 =A0 CG2900_INFO("BluezDriver: hci_reset_cb");
>> +
>> + =A0 =A0 if (!dev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for dev");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 dev_info =3D (struct dev_info *)dev->user_data;
>> + =A0 =A0 if (!dev_info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for dev_info");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 hdev =3D dev_info->hdev;
>> + =A0 =A0 if (!hdev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for hdev");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 info =3D (struct hci_info *)hdev->driver_data;
>> + =A0 =A0 if (!info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for driver_data");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 switch (dev_info->hci_data_type) {
>> +
>> + =A0 =A0 case HCI_EVENT_PKT:
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_evt =3D NULL;
>> + =A0 =A0 =A0 =A0 =A0 =A0 break;
>> +
>> + =A0 =A0 case HCI_COMMAND_PKT:
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_cmd =3D NULL;
>> + =A0 =A0 =A0 =A0 =A0 =A0 break;
>> +
>> + =A0 =A0 case HCI_ACLDATA_PKT:
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_acl =3D NULL;
>> + =A0 =A0 =A0 =A0 =A0 =A0 break;
>> +
>> + =A0 =A0 default:
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Unknown HCI data type:%d",
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_info->hci_data_type=
);
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 SET_RESET_STATE(RESET_ACTIVATED);
>> +
>> + =A0 =A0 /* Free userdata as device info structure will be freed by CG2=
900
>> + =A0 =A0 =A0* when this callback returns */
>> + =A0 =A0 kfree(dev->user_data);
>> + =A0 =A0 dev->user_data =3D NULL;
>> +
>> + =A0 =A0 /*
>> + =A0 =A0 =A0* Continue to deregister hdev if all channels has been rese=
t else
>> + =A0 =A0 =A0* return.
>> + =A0 =A0 =A0*/
>> + =A0 =A0 if (info->bt_evt || info->bt_cmd || info->bt_acl)
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> +
>> + =A0 =A0 /*
>> + =A0 =A0 =A0* Deregister HCI device. Close and Destruct functions shoul=
d
>> + =A0 =A0 =A0* in turn be called by BlueZ.
>> + =A0 =A0 =A0*/
>> + =A0 =A0 CG2900_INFO("Deregister HCI device");
>> + =A0 =A0 err =3D hci_unregister_dev(hdev);
>> + =A0 =A0 if (err)
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Can not deregister HCI device! (%d=
)", err);
>> + =A0 =A0 =A0 =A0 =A0 =A0 /*
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* Now we are in trouble. Try to register a =
new hdev
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* anyway even though this will cost some me=
mory.
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
>> +
>> + =A0 =A0 wait_event_interruptible_timeout(hci_wait_queue,
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (RESET_UNREGIS=
TERED =3D=3D hci_info->reset_state),
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 msecs_to_jiffi=
es(RESP_TIMEOUT));
>> + =A0 =A0 if (RESET_UNREGISTERED !=3D hci_info->reset_state)
>> + =A0 =A0 =A0 =A0 =A0 =A0 /*
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* Now we are in trouble. Try to register a =
new hdev
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* anyway even though this will cost some me=
mory.
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Timeout expired. Could not deregis=
ter HCI device");
>> +
>> + =A0 =A0 /* Init and register hdev */
>> + =A0 =A0 CG2900_INFO("Register HCI device");
>> + =A0 =A0 err =3D register_to_bluez();
>> + =A0 =A0 if (err)
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("HCI Device registration error (%d)=
.", err);
>> +}
>> +
>> +/*
>> + * struct cg2900_cb - Specifies callback structure for CG2900 user.
>> + *
>> + * @read_cb: Callback function called when data is received from
>> + * =A0 =A0 =A0 =A0 =A0 the controller.
>> + * @reset_cb: =A0 =A0 =A0 =A0Callback function called when the controll=
er has been reset.
>> + */
>> +static struct cg2900_callbacks cg2900_cb =3D {
>> + =A0 =A0 .read_cb =3D hci_read_cb,
>> + =A0 =A0 .reset_cb =3D hci_reset_cb
>> +};
>> +
>> +/**
>> + * open_from_hci() - Open HCI interface.
>> + * @hdev: =A0 =A0HCI device being opened.
>> + *
>> + * BlueZ callback function for opening HCI interface to device.
>> + *
>> + * Returns:
>> + * =A0 0 if there is no error.
>> + * =A0 -EINVAL if NULL pointer is supplied.
>> + * =A0 -EOPNOTSUPP if supplied packet type is not supported.
>> + * =A0 -EBUSY if device is already opened.
>> + * =A0 -EACCES if opening of channels failed.
>> + */
>> +static int open_from_hci(struct hci_dev *hdev)
>> +{
>> + =A0 =A0 struct hci_info *info;
>> + =A0 =A0 struct dev_info *dev_info;
>> + =A0 =A0 struct sk_buff *enable_cmd;
>> + =A0 =A0 int err;
>> +
>> + =A0 =A0 CG2900_INFO("Open ST-Ericsson connectivity HCI driver");
>> +
>> + =A0 =A0 if (!hdev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for hdev");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 info =3D (struct hci_info *)hdev->driver_data;
>> + =A0 =A0 if (!info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for driver_data");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (test_and_set_bit(HCI_RUNNING, &(hdev->flags))) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Device already opened!");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EBUSY;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (!(info->bt_cmd)) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_cmd =3D cg2900_register_user(CG2900_B=
T_CMD,
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&cg2900_cb);
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (info->bt_cmd) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info =3D kmalloc(sizeof(*d=
ev_info), GFP_KERNEL);
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev_info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hdev=
 =3D hdev;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hci_=
data_type =3D HCI_COMMAND_PKT;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 info->bt_cmd->user_data =3D de=
v_info;
>> + =A0 =A0 =A0 =A0 =A0 =A0 } else {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Couldn't register =
CG2900_BT_CMD to CG2900");
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D -EACCES;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto handle_error;
>> + =A0 =A0 =A0 =A0 =A0 =A0 }
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (!(info->bt_evt)) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_evt =3D cg2900_register_user(CG2900_B=
T_EVT,
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&cg2900_cb);
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (info->bt_evt) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info =3D kmalloc(sizeof(*d=
ev_info), GFP_KERNEL);
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev_info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hdev=
 =3D hdev;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hci_=
data_type =3D HCI_EVENT_PKT;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 info->bt_evt->user_data =3D de=
v_info;
>> + =A0 =A0 =A0 =A0 =A0 =A0 } else {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Couldn't register =
CG2900_BT_EVT to CG2900");
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D -EACCES;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto handle_error;
>> + =A0 =A0 =A0 =A0 =A0 =A0 }
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (!(info->bt_acl)) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 info->bt_acl =3D cg2900_register_user(CG2900_B=
T_ACL,
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&cg2900_cb);
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (info->bt_acl) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info =3D kmalloc(sizeof(*d=
ev_info), GFP_KERNEL);
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev_info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hdev=
 =3D hdev;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_info->hci_=
data_type =3D HCI_ACLDATA_PKT;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 info->bt_acl->user_data =3D de=
v_info;
>> + =A0 =A0 =A0 =A0 =A0 =A0 } else {
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Couldn't register =
CG2900_BT_ACL to CG2900");
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D -EACCES;
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto handle_error;
>> + =A0 =A0 =A0 =A0 =A0 =A0 }
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (info->reset_state =3D=3D RESET_ACTIVATED)
>> + =A0 =A0 =A0 =A0 =A0 =A0 SET_RESET_STATE(RESET_IDLE);
>> +
>> + =A0 =A0 /*
>> + =A0 =A0 =A0* Call platform specific function that returns the chip dep=
endent
>> + =A0 =A0 =A0* bt enable(true) HCI command.
>> + =A0 =A0 =A0* If NULL is returned, then no bt_enable command should be =
sent to the
>> + =A0 =A0 =A0* chip.
>> + =A0 =A0 =A0*/
>> + =A0 =A0 enable_cmd =3D cg2900_devices_get_bt_enable_cmd(&bt_enable_cmd=
, true);
>> + =A0 =A0 if (!enable_cmd) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 /* The chip is enabled by default */
>> + =A0 =A0 =A0 =A0 =A0 =A0 SET_ENABLE_STATE(ENABLE_BT_ENABLED);
>> + =A0 =A0 =A0 =A0 =A0 =A0 return 0;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 /* Set the HCI state before sending command to chip. */
>> + =A0 =A0 SET_ENABLE_STATE(ENABLE_WAITING_BT_ENABLED_CC);
>> +
>> + =A0 =A0 /* Send command to chip */
>> + =A0 =A0 cg2900_write(info->bt_cmd, enable_cmd);
>> +
>> + =A0 =A0 /*
>> + =A0 =A0 =A0* Wait for callback to receive command complete and then wa=
ke us up
>> + =A0 =A0 =A0* again.
>> + =A0 =A0 =A0*/
>> + =A0 =A0 wait_event_interruptible_timeout(hci_wait_queue,
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (info->enable_=
state =3D=3D ENABLE_BT_ENABLED),
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 msecs_to_jiffi=
es(RESP_TIMEOUT));
>> + =A0 =A0 /* Check the current state to se that it worked. */
>> + =A0 =A0 if (info->enable_state !=3D ENABLE_BT_ENABLED) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Could not enable BT core (%d)", in=
fo->enable_state);
>> + =A0 =A0 =A0 =A0 =A0 =A0 err =3D -EACCES;
>> + =A0 =A0 =A0 =A0 =A0 =A0 SET_ENABLE_STATE(ENABLE_BT_DISABLED);
>> + =A0 =A0 =A0 =A0 =A0 =A0 goto handle_error;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 return 0;
>> +
>> +handle_error:
>> + =A0 =A0 remove_bt_users(info);
>> + =A0 =A0 clear_bit(HCI_RUNNING, &(hdev->flags));
>> + =A0 =A0 return err;
>> +
>> +}
>> +
>> +/**
>> + * flush_from_hci() - Flush HCI interface.
>> + * @hdev: =A0 =A0HCI device being flushed.
>> + *
>> + * Returns:
>> + * =A0 0 if there is no error.
>> + * =A0 -EINVAL if NULL pointer is supplied.
>> + */
>> +static int flush_from_hci(struct hci_dev *hdev)
>> +{
>> + =A0 =A0 CG2900_INFO("flush_from_hci");
>> +
>> + =A0 =A0 if (!hdev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for hdev");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 return 0;
>> +}
>> +
>> +/**
>> + * close_from_hci() - Close HCI interface.
>> + * @hdev: =A0 =A0HCI device being closed.
>> + *
>> + * BlueZ callback function for closing HCI interface.
>> + * It flushes the interface first.
>> + *
>> + * Returns:
>> + * =A0 0 if there is no error.
>> + * =A0 -EINVAL if NULL pointer is supplied.
>> + * =A0 -EOPNOTSUPP if supplied packet type is not supported.
>> + * =A0 -EBUSY if device is not opened.
>> + */
>> +static int close_from_hci(struct hci_dev *hdev)
>> +{
>> + =A0 =A0 struct hci_info *info =3D NULL;
>> + =A0 =A0 struct sk_buff *enable_cmd;
>> +
>> + =A0 =A0 CG2900_INFO("close_from_hci");
>> +
>> + =A0 =A0 if (!hdev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for hdev");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 info =3D (struct hci_info *)hdev->driver_data;
>> + =A0 =A0 if (!info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for driver_data");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Device already closed!");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EBUSY;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 flush_from_hci(hdev);
>> +
>> + =A0 =A0 /* Do not do this if there is an reset ongoing */
>> + =A0 =A0 if (hci_info->reset_state =3D=3D RESET_ACTIVATED)
>> + =A0 =A0 =A0 =A0 =A0 =A0 goto remove_users;
>> +
>> + =A0 =A0 /*
>> + =A0 =A0 =A0* Get the chip dependent BT Enable HCI command. The command=
 parameter
>> + =A0 =A0 =A0* shall be set to false to disable the BT core.
>> + =A0 =A0 =A0* If NULL is returned, then no BT Enable command should be =
sent to the
>> + =A0 =A0 =A0* chip.
>> + =A0 =A0 =A0*/
>> + =A0 =A0 enable_cmd =3D cg2900_devices_get_bt_enable_cmd(&bt_enable_cmd=
, false);
>> + =A0 =A0 if (!enable_cmd) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 /*
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* The chip is enabled by default and we sho=
uld not disable it.
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
>> + =A0 =A0 =A0 =A0 =A0 =A0 SET_ENABLE_STATE(ENABLE_BT_ENABLED);
>> + =A0 =A0 =A0 =A0 =A0 =A0 goto remove_users;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 /* Set the HCI state before sending command to chip */
>> + =A0 =A0 SET_ENABLE_STATE(ENABLE_WAITING_BT_DISABLED_CC);
>> +
>> + =A0 =A0 /* Send command to chip */
>> + =A0 =A0 cg2900_write(info->bt_cmd, enable_cmd);
>> +
>> + =A0 =A0 /*
>> + =A0 =A0 =A0* Wait for callback to receive command complete and then wa=
ke us up
>> + =A0 =A0 =A0* again.
>> + =A0 =A0 =A0*/
>> + =A0 =A0 wait_event_interruptible_timeout(hci_wait_queue,
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (info->enable_=
state =3D=3D ENABLE_BT_DISABLED),
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 msecs_to_jiffi=
es(RESP_TIMEOUT));
>> + =A0 =A0 /* Check the current state to se that it worked. */
>> + =A0 =A0 if (info->enable_state !=3D ENABLE_BT_DISABLED) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Could not disable BT core.");
>> + =A0 =A0 =A0 =A0 =A0 =A0 SET_ENABLE_STATE(ENABLE_BT_ENABLED);
>> + =A0 =A0 }
>> +
>> +remove_users:
>> + =A0 =A0 /* Finally deregister all users and free allocated data */
>> + =A0 =A0 remove_bt_users(info);
>> + =A0 =A0 return 0;
>> +}
>> +
>> +/**
>> + * send_from_hci() - Send packet to device.
>> + * @skb: =A0 =A0 sk buffer to be sent.
>> + *
>> + * BlueZ callback function for sending sk buffer.
>> + *
>> + * Returns:
>> + * =A0 0 if there is no error.
>> + * =A0 -EINVAL if NULL pointer is supplied.
>> + * =A0 -EOPNOTSUPP if supplied packet type is not supported.
>> + * =A0 Error codes from cg2900_write.
>> + */
>> +static int send_from_hci(struct sk_buff *skb)
>> +{
>> + =A0 =A0 struct hci_dev *hdev;
>> + =A0 =A0 struct hci_info *info;
>> + =A0 =A0 int err =3D 0;
>> +
>> + =A0 =A0 if (!skb) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for skb");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 hdev =3D (struct hci_dev *)(skb->dev);
>> + =A0 =A0 if (!hdev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for hdev");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 info =3D (struct hci_info *)hdev->driver_data;
>> + =A0 =A0 if (!info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for info");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 /* Update BlueZ stats */
>> + =A0 =A0 hdev->stat.byte_tx +=3D skb->len;
>> +
>> + =A0 =A0 CG2900_DBG_DATA("Data transmit %d bytes", skb->len);
>> +
>> + =A0 =A0 switch (bt_cb(skb)->pkt_type) {
>> + =A0 =A0 case HCI_COMMAND_PKT:
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_DBG("Sending HCI_COMMAND_PKT");
>> + =A0 =A0 =A0 =A0 =A0 =A0 err =3D cg2900_write(info->bt_cmd, skb);
>> + =A0 =A0 =A0 =A0 =A0 =A0 hdev->stat.cmd_tx++;
>> + =A0 =A0 =A0 =A0 =A0 =A0 break;
>> + =A0 =A0 case HCI_ACLDATA_PKT:
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_DBG("Sending HCI_ACLDATA_PKT");
>> + =A0 =A0 =A0 =A0 =A0 =A0 err =3D cg2900_write(info->bt_acl, skb);
>> + =A0 =A0 =A0 =A0 =A0 =A0 hdev->stat.acl_tx++;
>> + =A0 =A0 =A0 =A0 =A0 =A0 break;
>> + =A0 =A0 default:
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Trying to transmit unsupported pac=
ket type "
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"(0x%.2X)", bt_cb(skb)-=
>pkt_type);
>> + =A0 =A0 =A0 =A0 =A0 =A0 err =3D -EOPNOTSUPP;
>> + =A0 =A0 =A0 =A0 =A0 =A0 break;
>> + =A0 =A0 };
>> +
>> + =A0 =A0 return err;
>> +}
>> +
>> +/**
>> + * destruct_from_hci() - Destruct HCI interface.
>> + * @hdev: =A0 =A0HCI device being destructed.
>> + */
>> +static void destruct_from_hci(struct hci_dev *hdev)
>> +{
>> + =A0 =A0 CG2900_INFO("destruct_from_hci");
>> +
>> + =A0 =A0 if (!hci_info)
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> +
>> + =A0 =A0 /* When being reset, register a new hdev when hdev is deregist=
ered */
>> + =A0 =A0 if (hci_info->reset_state =3D=3D RESET_ACTIVATED) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (hci_info->hdev)
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 hci_free_dev(hci_info->hdev);
>> + =A0 =A0 =A0 =A0 =A0 =A0 SET_RESET_STATE(RESET_UNREGISTERED);
>> + =A0 =A0 }
>> +}
>
> Please name thse cg2900_destruct or btcg2900_destruct. And not from_hci.
> Follow how the other Bluetooth drivers do the naming.
>
> And the destruct callback is for freeing memory. I am also not sure how
> reset and unregister/re-register HCI is a good idea.
>

Regarding naming: no problem, we'll change that. We will see how we
solve the reset. It's a bit tricky to get it working correctly, but
we'll see what we can do. We have to be able in some way to handle if
another stack, such as GPS or FM, suddenly reset the chip.

>> +/**
>> + * notify_from_hci() - Notification from the HCI interface.
>> + * @hdev: =A0 =A0HCI device notifying.
>> + * @evt: =A0 =A0 Notification event.
>> + */
>> +static void notify_from_hci(struct hci_dev *hdev, unsigned int evt)
>> +{
>> + =A0 =A0 CG2900_INFO("notify_from_hci - evt =3D 0x%.2X", evt);
>> +}
>
> If you don't use it, then just leave it out.
>

OK

>> +/**
>> + * ioctl_from_hci() - Handle IOCTL call to the HCI interface.
>> + * @hdev: HCI device.
>> + * @cmd: =A0IOCTL command.
>> + * @arg: =A0IOCTL argument.
>> + *
>> + * Returns:
>> + * =A0 -EINVAL if NULL is supplied for hdev.
>> + * =A0 -EPERM otherwise since current driver supports no IOCTL.
>> + */
>> +static int ioctl_from_hci(struct hci_dev *hdev, unsigned int cmd,
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned long arg)
>> +{
>> + =A0 =A0 CG2900_INFO("ioctl_from_hci - cmd 0x%X", cmd);
>> + =A0 =A0 CG2900_DBG("DIR: %d, TYPE: %d, NR: %d, SIZE: %d",
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(=
cmd),
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_IOC_SIZE(cmd));
>> +
>> + =A0 =A0 if (!hdev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("NULL supplied for hdev");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 return -EPERM;
>> +}
>
> Since you are not using anything with the ioctl, just leave it out. The
> Bluetooth subsystem will do the right thing.
>

OK

>> +/**
>> + * register_to_bluez() - Initialize module.
>> + *
>> + * Alloc, init, and register HCI device to BlueZ.
>> + *
>> + * Returns:
>> + * =A0 0 if there is no error.
>> + * =A0 -ENOMEM if allocation fails.
>> + * =A0 Error codes from hci_register_dev.
>> + */
>> +static int register_to_bluez(void)
>> +{
>> + =A0 =A0 int err;
>> +
>> + =A0 =A0 hci_info->hdev =3D hci_alloc_dev();
>> + =A0 =A0 if (!hci_info->hdev) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Could not allocate mem for HCI dri=
ver");
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 hci_info->hdev->bus =3D HCI_CG2900;
>> + =A0 =A0 hci_info->hdev->driver_data =3D hci_info;
>> + =A0 =A0 hci_info->hdev->owner =3D THIS_MODULE;
>> + =A0 =A0 hci_info->hdev->open =3D open_from_hci;
>> + =A0 =A0 hci_info->hdev->close =3D close_from_hci;
>> + =A0 =A0 hci_info->hdev->flush =3D flush_from_hci;
>> + =A0 =A0 hci_info->hdev->send =3D send_from_hci;
>> + =A0 =A0 hci_info->hdev->destruct =3D destruct_from_hci;
>> + =A0 =A0 hci_info->hdev->notify =3D notify_from_hci;
>> + =A0 =A0 hci_info->hdev->ioctl =3D ioctl_from_hci;
>> +
>> + =A0 =A0 err =3D hci_register_dev(hci_info->hdev);
>> + =A0 =A0 if (err) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Can not register HCI device (%d)",=
 err);
>> + =A0 =A0 =A0 =A0 =A0 =A0 hci_free_dev(hci_info->hdev);
>> + =A0 =A0 }
>> +
>> + =A0 =A0 SET_ENABLE_STATE(ENABLE_IDLE);
>> + =A0 =A0 SET_RESET_STATE(RESET_IDLE);
>> +
>> + =A0 =A0 return err;
>> +}
>
> So whenever the module is loaded it registers the HCI device. That is
> not really useful here. This driver needs to be able to be compiled into
> the kernel (or as module) and run on hardware that doesn't have this
> chip built in.
>

OK. We will think this through and solve it in a better way.

>> +/**
>> + * hci_init() - Initialize module.
>> + *
>> + * Allocate and initialize private data. Register to BlueZ.
>> + *
>> + * Returns:
>> + * =A0 0 if there is no error.
>> + * =A0 -ENOMEM if allocation fails.
>> + * =A0 Error codes from register_to_bluez.
>> + */
>> +static int __init hci_init(void)
>> +{
>> + =A0 =A0 int err;
>> + =A0 =A0 CG2900_INFO("hci_init");
>> +
>> + =A0 =A0 /* Initialize private data. */
>> + =A0 =A0 hci_info =3D kzalloc(sizeof(*hci_info), GFP_KERNEL);
>> + =A0 =A0 if (!hci_info) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Could not alloc hci_info struct.")=
;
>> + =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 /* Init and register hdev */
>> + =A0 =A0 err =3D register_to_bluez();
>> + =A0 =A0 if (err) {
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("HCI Device registration error (%d)=
", err);
>> + =A0 =A0 =A0 =A0 =A0 =A0 kfree(hci_info);
>> + =A0 =A0 =A0 =A0 =A0 =A0 hci_info =3D NULL;
>> + =A0 =A0 =A0 =A0 =A0 =A0 return err;
>> + =A0 =A0 }
>> +
>> + =A0 =A0 return 0;
>> +}
>> +
>> +/**
>> + * hci_exit() - Remove module.
>> + *
>> + * Remove HCI device from CG2900 driver.
>> + */
>> +static void __exit hci_exit(void)
>> +{
>> + =A0 =A0 int err =3D 0;
>> +
>> + =A0 =A0 CG2900_INFO("hci_exit");
>> +
>> + =A0 =A0 if (!hci_info)
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> +
>> + =A0 =A0 if (!hci_info->hdev)
>> + =A0 =A0 =A0 =A0 =A0 =A0 goto finished;
>> +
>> + =A0 =A0 err =3D hci_unregister_dev(hci_info->hdev);
>> + =A0 =A0 if (err)
>> + =A0 =A0 =A0 =A0 =A0 =A0 CG2900_ERR("Can not unregister HCI device (%d)=
", err);
>> + =A0 =A0 hci_free_dev(hci_info->hdev);
>> +
>> +finished:
>> + =A0 =A0 kfree(hci_info);
>> + =A0 =A0 hci_info =3D NULL;
>> +}
>> +
>> +module_init(hci_init);
>> +module_exit(hci_exit);
>
> Please use more clear names like cg2900_init or similar.
>

OK

>> +MODULE_AUTHOR("Par-Gunnar Hjalmdahl ST-Ericsson");
>> +MODULE_AUTHOR("Henrik Possung ST-Ericsson");
>> +MODULE_AUTHOR("Josef Kindberg ST-Ericsson");
>> +MODULE_LICENSE("GPL v2");
>> +MODULE_DESCRIPTION("Linux Bluetooth HCI H:4 Driver for ST-Ericsson
>> controller");
>
> Regards
>
> Marcel
>
>
>

^ permalink raw reply

* Pull request git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream
From: Jose Antonio Santos Cadenas @ 2010-10-11 12:25 UTC (permalink / raw)
  To: linux-bluetooth

The following changes since commit 646f0c7e6b557c5413825ce7b04bee52bf0129e8:

  Move remote name and version requests to hciops (2010-10-10 22:44:25 +0100)

are available in the git repository at:
  git://gitorious.org/bluez-mcap-hdp/mcap-hdp.git for_upstream

José Antonio Santos Cadenas (6):
      Remove mdl_conn from struct hdp_channel
      Remove app paramter from hdp_establish_mcl, it is not needed
      Imcoming connection in control channel should be ERTM
      Fix multiple emission of main channel property signal.
      Return MCAP_MDL_BUSY when health channel can't be created
      Implement callback for responding echo petitions

Santiago Carot-Nemesio (6):
      Add a new function to create channels
      Process request of of echo channels creation
      Correctly notify the deletion of the reliable data channel
      Add extra checks for avoid notifiying incoming echo channels
      Delete all channels DBus interface when the instance is removed
      Check first reliable configuration during channel creation

 health/hdp.c       |  249 +++++++++++++++++++++++++++++++++++----------------
 health/hdp_types.h |    3 +-
 health/hdp_util.c  |    3 -
 health/hdp_util.h  |    1 -
 health/mcap.c      |    1 +
 5 files changed, 174 insertions(+), 83 deletions(-)

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox