summaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/btwilink.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2015-10-04 17:34:02 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2015-10-05 03:30:25 -0400
commite9ca8bf157f2b45f8f670517c96da313083ee9b2 (patch)
tree7aaa31766e0af85588a84f0d06d65d5b77375f7b /drivers/bluetooth/btwilink.c
parent73d0d3c8671190ea982a8e79a7c79fbfe88f8f47 (diff)
Bluetooth: Move handling of HCI_RUNNING flag into core
Setting and clearing of HCI_RUNNING flag in each and every driver is just duplicating the same code all over the place. So instead of having the driver do it in their hdev->open and hdev->close callbacks, set it globally in the core transport handling. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'drivers/bluetooth/btwilink.c')
-rw-r--r--drivers/bluetooth/btwilink.c10
1 files changed, 0 insertions, 10 deletions
diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
index 4db99a44f671..57eb935aedc7 100644
--- a/drivers/bluetooth/btwilink.c
+++ b/drivers/bluetooth/btwilink.c
@@ -155,9 +155,6 @@ static int ti_st_open(struct hci_dev *hdev)
155 155
156 BT_DBG("%s %p", hdev->name, hdev); 156 BT_DBG("%s %p", hdev->name, hdev);
157 157
158 if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
159 return -EBUSY;
160
161 /* provide contexts for callbacks from ST */ 158 /* provide contexts for callbacks from ST */
162 hst = hci_get_drvdata(hdev); 159 hst = hci_get_drvdata(hdev);
163 160
@@ -181,7 +178,6 @@ static int ti_st_open(struct hci_dev *hdev)
181 goto done; 178 goto done;
182 179
183 if (err != -EINPROGRESS) { 180 if (err != -EINPROGRESS) {
184 clear_bit(HCI_RUNNING, &hdev->flags);
185 BT_ERR("st_register failed %d", err); 181 BT_ERR("st_register failed %d", err);
186 return err; 182 return err;
187 } 183 }
@@ -195,7 +191,6 @@ static int ti_st_open(struct hci_dev *hdev)
195 (&hst->wait_reg_completion, 191 (&hst->wait_reg_completion,
196 msecs_to_jiffies(BT_REGISTER_TIMEOUT)); 192 msecs_to_jiffies(BT_REGISTER_TIMEOUT));
197 if (!timeleft) { 193 if (!timeleft) {
198 clear_bit(HCI_RUNNING, &hdev->flags);
199 BT_ERR("Timeout(%d sec),didn't get reg " 194 BT_ERR("Timeout(%d sec),didn't get reg "
200 "completion signal from ST", 195 "completion signal from ST",
201 BT_REGISTER_TIMEOUT / 1000); 196 BT_REGISTER_TIMEOUT / 1000);
@@ -205,7 +200,6 @@ static int ti_st_open(struct hci_dev *hdev)
205 /* Is ST registration callback 200 /* Is ST registration callback
206 * called with ERROR status? */ 201 * called with ERROR status? */
207 if (hst->reg_status != 0) { 202 if (hst->reg_status != 0) {
208 clear_bit(HCI_RUNNING, &hdev->flags);
209 BT_ERR("ST registration completed with invalid " 203 BT_ERR("ST registration completed with invalid "
210 "status %d", hst->reg_status); 204 "status %d", hst->reg_status);
211 return -EAGAIN; 205 return -EAGAIN;
@@ -215,7 +209,6 @@ done:
215 hst->st_write = ti_st_proto[i].write; 209 hst->st_write = ti_st_proto[i].write;
216 if (!hst->st_write) { 210 if (!hst->st_write) {
217 BT_ERR("undefined ST write function"); 211 BT_ERR("undefined ST write function");
218 clear_bit(HCI_RUNNING, &hdev->flags);
219 for (i = 0; i < MAX_BT_CHNL_IDS; i++) { 212 for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
220 /* Undo registration with ST */ 213 /* Undo registration with ST */
221 err = st_unregister(&ti_st_proto[i]); 214 err = st_unregister(&ti_st_proto[i]);
@@ -236,9 +229,6 @@ static int ti_st_close(struct hci_dev *hdev)
236 int err, i; 229 int err, i;
237 struct ti_st *hst = hci_get_drvdata(hdev); 230 struct ti_st *hst = hci_get_drvdata(hdev);
238 231
239 if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
240 return 0;
241
242 for (i = MAX_BT_CHNL_IDS-1; i >= 0; i--) { 232 for (i = MAX_BT_CHNL_IDS-1; i >= 0; i--) {
243 err = st_unregister(&ti_st_proto[i]); 233 err = st_unregister(&ti_st_proto[i]);
244 if (err) 234 if (err)