Re: [RFCv2 05/20] Bluetooth: AMP: Use HCI callback to Read Loc AMP Assoc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 24, 2012 at 05:55:54PM -0300, Gustavo Padovan wrote:
...

> > +static void hci_cc_read_local_amp_assoc(struct hci_dev *hdev,
> > +					struct sk_buff *skb)
> > +{
> > +	struct hci_rp_read_local_amp_assoc *rp = (void *) skb->data;
> > +	struct amp_assoc *assoc = &hdev->loc_assoc;
> > +	size_t rem_len, frag_len;
> > +
> > +	BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
> > +
> > +	if (rp->status)
> > +		goto process_cb;
> > +
> > +	frag_len = skb->len - sizeof(*rp);
> > +	rem_len = __le16_to_cpu(rp->rem_len);
> > +
> > +	if (rem_len > frag_len) {
> > +		BT_DBG("frag_len %d rem_len %d", frag_len, rem_len);
> > +
> > +		memcpy(assoc->data + assoc->offset, rp->frag, frag_len);
> > +		assoc->offset += frag_len;
> > +
> > +		/* Read other fragments */
> > +		amp_read_loc_assoc_frag(hdev, rp->phy_handle);
> > +
> > +		return;
> > +	}
> > +
> > +	memcpy(assoc->data + assoc->offset, rp->frag, rem_len);
> > +	assoc->len = assoc->offset + rem_len;
> > +	assoc->offset = 0;
> > +
> > +process_cb:
> > +	/* Run callback when all fragments received */
> > +	hci_process_cb(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, rp->status);
> 
> So, I have a question here, why are we going with this callback system here?
> This code and A2MP code runs inside the same module, so why do we need
> callbacks? 

About code running in the same module please refer to management interface
calbacks like mgmt_pending_foreach, etc

> I wonder if switch all of this to directly calls to the A2MP code,
> this simplifies things a lot.

A2MP code is running above different HCI device. The problem here is that 
if we have several AMP managers and we execute some HCI command to AMP
controller then we wouldn't know which AMP manager has initiated
connection. (Some commands though provide phy_handler and this might be
used).

If we __always__ have only one AMP Manager that would work as we can have
global pointer. Then we can always call to A2MP context which I think
shall be run in a workqueue. We can have problems here if we remove and
create AMP manager...

Best regards 
Andrei Emeltchenko 


--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux