Re: [RFCv2 3/4] Bluetooth: Use ERR_PTR to return error from hci_connect

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

 



Hi Ville,

* anderson.briglia@xxxxxxxxxxxxx <anderson.briglia@xxxxxxxxxxxxx> [2011-02-17 10:39:55 -0300]:

> From: Ville Tervo <ville.tervo@xxxxxxxxx>
> 
> Use ERR_PRT mechanism to return error from hci_connect. This patch also

Typo here, ERR_PTR.

> includes a change to return error if LE link exists already to remote host.
> 
> Signed-off-by: Ville Tervo <ville.tervo@xxxxxxxxx>
> ---
>  net/bluetooth/hci_conn.c   |   12 +++++++-----
>  net/bluetooth/l2cap_core.c |   10 ++++------
>  net/bluetooth/sco.c        |    6 +++---
>  3 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index ee7dcdd..e06b856 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -305,7 +305,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
>  
>  	conn = kzalloc(sizeof(struct hci_conn), GFP_ATOMIC);
>  	if (!conn)
> -		return NULL;
> +		return ERR_PTR(-ENOMEM);

That's not really need. Seems that return NULL here means ENOMEM.

>  
>  	bacpy(&conn->dst, dst);
>  	conn->hdev  = hdev;
> @@ -459,8 +459,10 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
>  		le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
>  		if (!le)
>  			le = hci_conn_add(hdev, LE_LINK, dst);
> -		if (!le)
> -			return NULL;
> +		else
> +			return ERR_PTR(-EBUSY);
> +		if (IS_ERR(le))
> +			return le;

I prefer this instead:

                le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
                if (le)
                        return ERR_PTR(-EBUSY);

                le = hci_conn_add(hdev, LE_LINK, dst);
                if (!le)
                        return ERR_PTR(-ENOMEM);

Regards,

-- 
Gustavo F. Padovan
http://profusion.mobi
--
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