All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mgmtops: Handle Start Discovery Complete in case of failure
@ 2012-04-09  7:07 Hemant Gupta
  2012-04-10  9:13 ` Johan Hedberg
  0 siblings, 1 reply; 7+ messages in thread
From: Hemant Gupta @ 2012-04-09  7:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Hemant Gupta

This patch adds handling of start discovery complete event in cases
when discovery fails to get started.
---
 plugins/mgmtops.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 612368f..d8518af 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -1258,6 +1258,36 @@ static void read_local_oob_data_complete(int sk, uint16_t index, void *buf,
 		oob_read_local_data_complete(adapter, rp->hash, rp->randomizer);
 }
 
+static void start_discovery_complete(int sk, uint16_t index, uint8_t status,
+				     void *buf, size_t len)
+{
+	uint8_t *type = buf;
+	struct btd_adapter *adapter;
+
+	if (len != sizeof(*type)) {
+		error("start_discovery_complete event size mismatch "
+		      "(%zu != %zu)", len, sizeof(*type));
+		return;
+	}
+
+	if (index > max_index) {
+		error("Unexpected index %u in start_discovery_complete",
+		      index);
+		return;
+	}
+
+	if (!status)
+		return;
+
+	DBG("hci%u type%d status%d", index, *type, status);
+
+	adapter = manager_find_adapter_by_id(index);
+
+	if (adapter)
+		/* Start discovery failed, inform upper layers. */
+		adapter_set_discovering(adapter, FALSE);
+}
+
 static void mgmt_read_rssi_complete(int sk, uint16_t index, void *buf, size_t len)
 {
 	struct mgmt_rp_read_rssi *rp = buf;
@@ -1546,7 +1576,7 @@ static void mgmt_cmd_complete(int sk, uint16_t index, void *buf, size_t len)
 		DBG("set_fast_connectable complete");
 		break;
 	case MGMT_OP_START_DISCOVERY:
-		DBG("start_discovery complete");
+		start_discovery_complete(sk, index, ev->status, ev->data, len);
 		break;
 	case MGMT_OP_STOP_DISCOVERY:
 		DBG("stop_discovery complete");
-- 
1.7.0.4


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

* Re: [PATCH] mgmtops: Handle Start Discovery Complete in case of failure
  2012-04-09  7:07 [PATCH] mgmtops: Handle Start Discovery Complete in case of failure Hemant Gupta
@ 2012-04-10  9:13 ` Johan Hedberg
  2012-04-10  9:58   ` Hemant Gupta
  0 siblings, 1 reply; 7+ messages in thread
From: Johan Hedberg @ 2012-04-10  9:13 UTC (permalink / raw)
  To: Hemant Gupta; +Cc: linux-bluetooth

Hi Hemant,

On Mon, Apr 09, 2012, Hemant Gupta wrote:
> +	if (len != sizeof(*type)) {
> +		error("start_discovery_complete event size mismatch "
> +		      "(%zu != %zu)", len, sizeof(*type));

The above line should be indented only with tabs. You're using tabs +
spaces.

> +	if (index > max_index) {
> +		error("Unexpected index %u in start_discovery_complete",
> +		      index);
> +		return;
> +	}
> +
> +	if (!status)
> +		return;
> +
> +	DBG("hci%u type%d status%d", index, *type, status);

Could you move this DBG statement above the index < max_index and add
spaces after "type" and "status" (hci%u is the only exception since
that's how adapters are named). Also, the format specifiers should be %u
since both type and status are unsigned.

> +	adapter = manager_find_adapter_by_id(index);
> +
> +	if (adapter)

Remove the empty line between the adapter assignment and the
if-statement (this applies to any function call and a test for its
result; there should be no empty line between them).

Johan

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

* Re: [PATCH] mgmtops: Handle Start Discovery Complete in case of failure
  2012-04-10  9:13 ` Johan Hedberg
@ 2012-04-10  9:58   ` Hemant Gupta
  2012-04-10 10:04     ` Johan Hedberg
  0 siblings, 1 reply; 7+ messages in thread
From: Hemant Gupta @ 2012-04-10  9:58 UTC (permalink / raw)
  To: Hemant Gupta, linux-bluetooth

Hi Johan,

On Tue, Apr 10, 2012 at 2:43 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Hemant,
>
> On Mon, Apr 09, 2012, Hemant Gupta wrote:
>> +     if (len != sizeof(*type)) {
>> +             error("start_discovery_complete event size mismatch "
>> +                   "(%zu != %zu)", len, sizeof(*type));
>
Sorry, but I thought we need to allign to the opening brace. Will
update it in next patch.

> The above line should be indented only with tabs. You're using tabs +
> spaces.
>
>> +     if (index > max_index) {
>> +             error("Unexpected index %u in start_discovery_complete",
>> +                   index);
>> +             return;
>> +     }
>> +
>> +     if (!status)
>> +             return;
>> +
>> +     DBG("hci%u type%d status%d", index, *type, status);
>
> Could you move this DBG statement above the index < max_index and add
> spaces after "type" and "status" (hci%u is the only exception since
> that's how adapters are named). Also, the format specifiers should be %u
> since both type and status are unsigned.
>
Thanks, will update this in next patch.

>> +     adapter = manager_find_adapter_by_id(index);
>> +
>> +     if (adapter)
>
> Remove the empty line between the adapter assignment and the
> if-statement (this applies to any function call and a test for its
> result; there should be no empty line between them).
>
Thanks will update this in next patch.
> Johan
> --
> 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



-- 
Best Regards
Hemant Gupta
ST-Ericsson India

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

* Re: [PATCH] mgmtops: Handle Start Discovery Complete in case of failure
  2012-04-10  9:58   ` Hemant Gupta
@ 2012-04-10 10:04     ` Johan Hedberg
  0 siblings, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2012-04-10 10:04 UTC (permalink / raw)
  To: Hemant Gupta; +Cc: Hemant Gupta, linux-bluetooth

Hi Hemant,

On Tue, Apr 10, 2012, Hemant Gupta wrote:
> Sorry, but I thought we need to allign to the opening brace.

That's for the kernel. We haven't changed the expected coding style for
user space.

Johan

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

* Re: [PATCH] mgmtops: Handle Start Discovery Complete in case of failure
  2012-04-09  7:05 ` Marcel Holtmann
@ 2012-04-09  7:08   ` Hemant Gupta
  0 siblings, 0 replies; 7+ messages in thread
From: Hemant Gupta @ 2012-04-09  7:08 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Hemant Gupta, linux-bluetooth

Hi Marcel,

On Mon, Apr 9, 2012 at 12:35 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Hemant,
>
>> This patch adds handling of start discovery complete event in cases
>> when discovery fails to get started.
>>
>> Change-Id: I214c8deb10fd97a529faeec50d789478aea2f402
>
> please do not include the Android specific change id stuff in the
> upstream patches.
>
Thanks for pointing out, missed it somehow. I have re-sent a new patch.
> Regards
>
> Marcel
>
>
> --
> 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



-- 
Best Regards
Hemant Gupta
ST-Ericsson India

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

* Re: [PATCH] mgmtops: Handle Start Discovery Complete in case of failure
  2012-04-09  5:47 Hemant Gupta
@ 2012-04-09  7:05 ` Marcel Holtmann
  2012-04-09  7:08   ` Hemant Gupta
  0 siblings, 1 reply; 7+ messages in thread
From: Marcel Holtmann @ 2012-04-09  7:05 UTC (permalink / raw)
  To: Hemant Gupta; +Cc: linux-bluetooth

Hi Hemant,

> This patch adds handling of start discovery complete event in cases
> when discovery fails to get started.
> 
> Change-Id: I214c8deb10fd97a529faeec50d789478aea2f402

please do not include the Android specific change id stuff in the
upstream patches.

Regards

Marcel



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

* [PATCH] mgmtops: Handle Start Discovery Complete in case of failure
@ 2012-04-09  5:47 Hemant Gupta
  2012-04-09  7:05 ` Marcel Holtmann
  0 siblings, 1 reply; 7+ messages in thread
From: Hemant Gupta @ 2012-04-09  5:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Hemant Gupta

This patch adds handling of start discovery complete event in cases
when discovery fails to get started.

Change-Id: I214c8deb10fd97a529faeec50d789478aea2f402
---
 plugins/mgmtops.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 612368f..d8518af 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -1258,6 +1258,36 @@ static void read_local_oob_data_complete(int sk, uint16_t index, void *buf,
 		oob_read_local_data_complete(adapter, rp->hash, rp->randomizer);
 }
 
+static void start_discovery_complete(int sk, uint16_t index, uint8_t status,
+				     void *buf, size_t len)
+{
+	uint8_t *type = buf;
+	struct btd_adapter *adapter;
+
+	if (len != sizeof(*type)) {
+		error("start_discovery_complete event size mismatch "
+		      "(%zu != %zu)", len, sizeof(*type));
+		return;
+	}
+
+	if (index > max_index) {
+		error("Unexpected index %u in start_discovery_complete",
+		      index);
+		return;
+	}
+
+	if (!status)
+		return;
+
+	DBG("hci%u type%d status%d", index, *type, status);
+
+	adapter = manager_find_adapter_by_id(index);
+
+	if (adapter)
+		/* Start discovery failed, inform upper layers. */
+		adapter_set_discovering(adapter, FALSE);
+}
+
 static void mgmt_read_rssi_complete(int sk, uint16_t index, void *buf, size_t len)
 {
 	struct mgmt_rp_read_rssi *rp = buf;
@@ -1546,7 +1576,7 @@ static void mgmt_cmd_complete(int sk, uint16_t index, void *buf, size_t len)
 		DBG("set_fast_connectable complete");
 		break;
 	case MGMT_OP_START_DISCOVERY:
-		DBG("start_discovery complete");
+		start_discovery_complete(sk, index, ev->status, ev->data, len);
 		break;
 	case MGMT_OP_STOP_DISCOVERY:
 		DBG("stop_discovery complete");
-- 
1.7.0.4


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

end of thread, other threads:[~2012-04-10 10:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-09  7:07 [PATCH] mgmtops: Handle Start Discovery Complete in case of failure Hemant Gupta
2012-04-10  9:13 ` Johan Hedberg
2012-04-10  9:58   ` Hemant Gupta
2012-04-10 10:04     ` Johan Hedberg
  -- strict thread matches above, loose matches on Subject: below --
2012-04-09  5:47 Hemant Gupta
2012-04-09  7:05 ` Marcel Holtmann
2012-04-09  7:08   ` Hemant Gupta

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.