Return-Path: Subject: Re: [PATCH v4 03/14] Bluetooth: Check pending command in start_discovery() Mime-Version: 1.0 (Apple Message framework v1244.3) Content-Type: text/plain; charset=us-ascii From: Andre Guedes In-Reply-To: <1316521610.1937.72.camel@aeonflux> Date: Fri, 23 Sep 2011 16:13:19 -0300 Cc: linux-bluetooth@vger.kernel.org Message-Id: <569C5CF2-08CB-4A09-941F-9E9AC2E8C29C@openbossa.org> References: <1316468136-12472-1-git-send-email-andre.guedes@openbossa.org> <1316468136-12472-4-git-send-email-andre.guedes@openbossa.org> <1316521610.1937.72.camel@aeonflux> To: Marcel Holtmann Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi Marcel, On Sep 20, 2011, at 9:26 AM, Marcel Holtmann wrote: > Hi Andre, > >> If discovery procedure is already running then EINPROGRESS command >> status should be returned. >> >> Signed-off-by: Andre Guedes >> --- >> net/bluetooth/mgmt.c | 6 ++++++ >> 1 files changed, 6 insertions(+), 0 deletions(-) >> >> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c >> index cc0c204..d8333e0 100644 >> --- a/net/bluetooth/mgmt.c >> +++ b/net/bluetooth/mgmt.c >> @@ -1622,6 +1622,12 @@ static int start_discovery(struct sock *sk, u16 index) >> >> hci_dev_lock_bh(hdev); >> >> + if (mgmt_pending_find(MGMT_OP_START_DISCOVERY, index)) { >> + err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY, >> + EINPROGRESS); >> + goto failed; >> + } >> + > > the idea is correct, but instead of using mgmt_pending_find we should > have an internal flags field to track our current states. That is way > more efficient then looking for pending commands. See my reply about having an mgmt internal flag on patch 02/14. Andre