aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-07-14 14:13:47 -0400
committerMarcel Holtmann <marcel@holtmann.org>2008-07-14 14:13:47 -0400
commitf383f2750af19fe6f820edf40d8729f9741c5b37 (patch)
tree95163bddb967074d7e11b456b5b4aadb89257fba
parente4e8e37c42bdaaefcb84eeaef0dc1bc3f696f8f6 (diff)
[Bluetooth] Some cleanups for HCI event handling
Some minor cosmetic cleanups to the HCI event handling to make the code easier to read and understand. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/bluetooth/hci_event.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 9af181a61650..bf3fbf9817b4 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -198,12 +198,14 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
198 198
199 BT_DBG("%s status 0x%x", hdev->name, status); 199 BT_DBG("%s status 0x%x", hdev->name, status);
200 200
201 if (status)
202 return;
203
201 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME); 204 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME);
202 if (!sent) 205 if (!sent)
203 return; 206 return;
204 207
205 if (!status) 208 memcpy(hdev->dev_name, sent, 248);
206 memcpy(hdev->dev_name, sent, 248);
207} 209}
208 210
209static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb) 211static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
@@ -313,12 +315,14 @@ static void hci_cc_write_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb)
313 315
314 BT_DBG("%s status 0x%x", hdev->name, status); 316 BT_DBG("%s status 0x%x", hdev->name, status);
315 317
318 if (status)
319 return;
320
316 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV); 321 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV);
317 if (!sent) 322 if (!sent)
318 return; 323 return;
319 324
320 if (!status) 325 memcpy(hdev->dev_class, sent, 3);
321 memcpy(hdev->dev_class, sent, 3);
322} 326}
323 327
324static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb) 328static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb)
@@ -333,7 +337,7 @@ static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb)
333 337
334 setting = __le16_to_cpu(rp->voice_setting); 338 setting = __le16_to_cpu(rp->voice_setting);
335 339
336 if (hdev->voice_setting == setting ) 340 if (hdev->voice_setting == setting)
337 return; 341 return;
338 342
339 hdev->voice_setting = setting; 343 hdev->voice_setting = setting;
@@ -350,28 +354,31 @@ static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb)
350static void hci_cc_write_voice_setting(struct hci_dev *hdev, struct sk_buff *skb) 354static void hci_cc_write_voice_setting(struct hci_dev *hdev, struct sk_buff *skb)
351{ 355{
352 __u8 status = *((__u8 *) skb->data); 356 __u8 status = *((__u8 *) skb->data);
357 __u16 setting;
353 void *sent; 358 void *sent;
354 359
355 BT_DBG("%s status 0x%x", hdev->name, status); 360 BT_DBG("%s status 0x%x", hdev->name, status);
356 361
362 if (status)
363 return;
364
357 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_VOICE_SETTING); 365 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_VOICE_SETTING);
358 if (!sent) 366 if (!sent)
359 return; 367 return;
360 368
361 if (!status) { 369 setting = get_unaligned_le16(sent);
362 __u16 setting = get_unaligned_le16(sent);
363 370
364 if (hdev->voice_setting != setting) { 371 if (hdev->voice_setting == setting)
365 hdev->voice_setting = setting; 372 return;
366 373
367 BT_DBG("%s voice setting 0x%04x", hdev->name, setting); 374 hdev->voice_setting = setting;
368 375
369 if (hdev->notify) { 376 BT_DBG("%s voice setting 0x%04x", hdev->name, setting);
370 tasklet_disable(&hdev->tx_task); 377
371 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); 378 if (hdev->notify) {
372 tasklet_enable(&hdev->tx_task); 379 tasklet_disable(&hdev->tx_task);
373 } 380 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
374 } 381 tasklet_enable(&hdev->tx_task);
375 } 382 }
376} 383}
377 384