From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: anderson.briglia@openbossa.org
Cc: linux-bluetooth@vger.kernel.org, Ville Tervo <ville.tervo@nokia.com>
Subject: Re: [RFCv2 3/4] Bluetooth: Use ERR_PTR to return error from hci_connect
Date: Thu, 17 Feb 2011 14:25:31 -0300 [thread overview]
Message-ID: <20110217172531.GJ10543@joana> (raw)
In-Reply-To: <4d5d2589.8f7edc0a.5af6.27dd@mx.google.com>
Hi Ville,
* anderson.briglia@openbossa.org <anderson.briglia@openbossa.org> [2011-02-17 10:39:55 -0300]:
> From: Ville Tervo <ville.tervo@nokia.com>
>
> 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@nokia.com>
> ---
> 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
next prev parent reply other threads:[~2011-02-17 17:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-17 13:39 [RFCv2 3/4] Bluetooth: Use ERR_PTR to return error from hci_connect anderson.briglia
2011-02-17 17:25 ` Gustavo F. Padovan [this message]
2011-02-17 18:04 ` Anderson Lizardo
2011-02-17 17:59 ` Anderson Lizardo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110217172531.GJ10543@joana \
--to=padovan@profusion.mobi \
--cc=anderson.briglia@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=ville.tervo@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox