All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Fix mgmt response when adapter goes down or is removed
@ 2011-11-03 10:58 johan.hedberg
  2011-11-03 12:32 ` Andrei Emeltchenko
  2011-11-03 12:40 ` [PATCH v2] " johan.hedberg
  0 siblings, 2 replies; 5+ messages in thread
From: johan.hedberg @ 2011-11-03 10:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

When an adapter gets powered off or is removed any pending commands
should receive a ENETDOWN or ENODEV status response.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/mgmt.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index cbc8a6d..26b58ad 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -262,7 +262,7 @@ static void mgmt_pending_foreach(u16 opcode, int index,
 
 		cmd = list_entry(p, struct pending_cmd, list);
 
-		if (cmd->opcode != opcode)
+		if (opcode > 0 && cmd->opcode != opcode)
 			continue;
 
 		if (index >= 0 && cmd->index != index)
@@ -1949,6 +1949,14 @@ done:
 	return err;
 }
 
+static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
+{
+	uint8_t *status = data;
+
+	cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
+	mgmt_pending_remove(cmd);
+}
+
 int mgmt_index_added(u16 index)
 {
 	return mgmt_event(MGMT_EV_INDEX_ADDED, index, NULL, 0, NULL);
@@ -1956,6 +1964,10 @@ int mgmt_index_added(u16 index)
 
 int mgmt_index_removed(u16 index)
 {
+	uint8_t status = ENODEV;
+
+	mgmt_pending_foreach(0, index, cmd_status_rsp, &status);
+
 	return mgmt_event(MGMT_EV_INDEX_REMOVED, index, NULL, 0, NULL);
 }
 
@@ -1992,6 +2004,11 @@ int mgmt_powered(u16 index, u8 powered)
 
 	mgmt_pending_foreach(MGMT_OP_SET_POWERED, index, mode_rsp, &match);
 
+	if (!powered) {
+		uint8_t status = ENETDOWN;
+		mgmt_pending_foreach(0, index, cmd_status_rsp, &status);
+	}
+
 	ev.val = powered;
 
 	ret = mgmt_event(MGMT_EV_POWERED, index, &ev, sizeof(ev), match.sk);
-- 
1.7.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: Fix mgmt response when adapter goes down or is removed
  2011-11-03 10:58 [PATCH] Bluetooth: Fix mgmt response when adapter goes down or is removed johan.hedberg
@ 2011-11-03 12:32 ` Andrei Emeltchenko
  2011-11-03 12:35   ` Johan Hedberg
  2011-11-03 12:40 ` [PATCH v2] " johan.hedberg
  1 sibling, 1 reply; 5+ messages in thread
From: Andrei Emeltchenko @ 2011-11-03 12:32 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

On Thu, Nov 03, 2011 at 12:58:51PM +0200, johan.hedberg@gmail.com wrote:
> From: Johan Hedberg <johan.hedberg@intel.com>
> 
> When an adapter gets powered off or is removed any pending commands
> should receive a ENETDOWN or ENODEV status response.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
>  net/bluetooth/mgmt.c |   19 ++++++++++++++++++-
>  1 files changed, 18 insertions(+), 1 deletions(-)
> 
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index cbc8a6d..26b58ad 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -262,7 +262,7 @@ static void mgmt_pending_foreach(u16 opcode, int index,
>  
>  		cmd = list_entry(p, struct pending_cmd, list);
>  
> -		if (cmd->opcode != opcode)
> +		if (opcode > 0 && cmd->opcode != opcode)
>  			continue;
>  
>  		if (index >= 0 && cmd->index != index)
> @@ -1949,6 +1949,14 @@ done:
>  	return err;
>  }
>  
> +static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
> +{
> +	uint8_t *status = data;
> +
> +	cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
> +	mgmt_pending_remove(cmd);
> +}
> +
>  int mgmt_index_added(u16 index)
>  {
>  	return mgmt_event(MGMT_EV_INDEX_ADDED, index, NULL, 0, NULL);
> @@ -1956,6 +1964,10 @@ int mgmt_index_added(u16 index)
>  
>  int mgmt_index_removed(u16 index)
>  {
> +	uint8_t status = ENODEV;

Does it make sense to mix type naming here and below? (u8, u16, uint8_t, uint16_t)

Best regards 
Andrei Emeltchenko 


> +
> +	mgmt_pending_foreach(0, index, cmd_status_rsp, &status);
> +
>  	return mgmt_event(MGMT_EV_INDEX_REMOVED, index, NULL, 0, NULL);
>  }
>  
> @@ -1992,6 +2004,11 @@ int mgmt_powered(u16 index, u8 powered)
>  
>  	mgmt_pending_foreach(MGMT_OP_SET_POWERED, index, mode_rsp, &match);
>  
> +	if (!powered) {
> +		uint8_t status = ENETDOWN;
> +		mgmt_pending_foreach(0, index, cmd_status_rsp, &status);
> +	}
> +
>  	ev.val = powered;
>  
>  	ret = mgmt_event(MGMT_EV_POWERED, index, &ev, sizeof(ev), match.sk);
> -- 
> 1.7.7.1
> 
> --
> 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  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: Fix mgmt response when adapter goes down or is removed
  2011-11-03 12:32 ` Andrei Emeltchenko
@ 2011-11-03 12:35   ` Johan Hedberg
  0 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2011-11-03 12:35 UTC (permalink / raw)
  To: Andrei Emeltchenko, linux-bluetooth

Hi Andrei,

On Thu, Nov 03, 2011, Andrei Emeltchenko wrote:
> > @@ -1956,6 +1964,10 @@ int mgmt_index_added(u16 index)
> >  
> >  int mgmt_index_removed(u16 index)
> >  {
> > +	uint8_t status = ENODEV;
> 
> Does it make sense to mix type naming here and below? (u8, u16, uint8_t, uint16_t)

No, it doesn't make sense. It should be u8, u16, etc. This is just my
strong user-space background shining through. Will send a v2 in a
minute.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] Bluetooth: Fix mgmt response when adapter goes down or is removed
  2011-11-03 10:58 [PATCH] Bluetooth: Fix mgmt response when adapter goes down or is removed johan.hedberg
  2011-11-03 12:32 ` Andrei Emeltchenko
@ 2011-11-03 12:40 ` johan.hedberg
  2011-11-03 14:32   ` Gustavo Padovan
  1 sibling, 1 reply; 5+ messages in thread
From: johan.hedberg @ 2011-11-03 12:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

When an adapter gets powered off or is removed any pending commands
should receive a ENETDOWN or ENODEV status response.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
v2: Fix uint8_t -> u8

 net/bluetooth/mgmt.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index cbc8a6d..747366a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -262,7 +262,7 @@ static void mgmt_pending_foreach(u16 opcode, int index,
 
 		cmd = list_entry(p, struct pending_cmd, list);
 
-		if (cmd->opcode != opcode)
+		if (opcode > 0 && cmd->opcode != opcode)
 			continue;
 
 		if (index >= 0 && cmd->index != index)
@@ -1949,6 +1949,14 @@ done:
 	return err;
 }
 
+static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
+{
+	u8 *status = data;
+
+	cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
+	mgmt_pending_remove(cmd);
+}
+
 int mgmt_index_added(u16 index)
 {
 	return mgmt_event(MGMT_EV_INDEX_ADDED, index, NULL, 0, NULL);
@@ -1956,6 +1964,10 @@ int mgmt_index_added(u16 index)
 
 int mgmt_index_removed(u16 index)
 {
+	u8 status = ENODEV;
+
+	mgmt_pending_foreach(0, index, cmd_status_rsp, &status);
+
 	return mgmt_event(MGMT_EV_INDEX_REMOVED, index, NULL, 0, NULL);
 }
 
@@ -1992,6 +2004,11 @@ int mgmt_powered(u16 index, u8 powered)
 
 	mgmt_pending_foreach(MGMT_OP_SET_POWERED, index, mode_rsp, &match);
 
+	if (!powered) {
+		u8 status = ENETDOWN;
+		mgmt_pending_foreach(0, index, cmd_status_rsp, &status);
+	}
+
 	ev.val = powered;
 
 	ret = mgmt_event(MGMT_EV_POWERED, index, &ev, sizeof(ev), match.sk);
-- 
1.7.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] Bluetooth: Fix mgmt response when adapter goes down or is removed
  2011-11-03 12:40 ` [PATCH v2] " johan.hedberg
@ 2011-11-03 14:32   ` Gustavo Padovan
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo Padovan @ 2011-11-03 14:32 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

* johan.hedberg@gmail.com <johan.hedberg@gmail.com> [2011-11-03 14:40:33 +0200]:

> From: Johan Hedberg <johan.hedberg@intel.com>
> 
> When an adapter gets powered off or is removed any pending commands
> should receive a ENETDOWN or ENODEV status response.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> v2: Fix uint8_t -> u8
> 
>  net/bluetooth/mgmt.c |   19 ++++++++++++++++++-
>  1 files changed, 18 insertions(+), 1 deletions(-)

Applied, thanks.

	Gustavo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-03 14:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-03 10:58 [PATCH] Bluetooth: Fix mgmt response when adapter goes down or is removed johan.hedberg
2011-11-03 12:32 ` Andrei Emeltchenko
2011-11-03 12:35   ` Johan Hedberg
2011-11-03 12:40 ` [PATCH v2] " johan.hedberg
2011-11-03 14:32   ` Gustavo Padovan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.